# vtkCutter: How to Separate Groups of Points in Multiple Contour Results in vtk.js

**URL:** https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088
**Category:** vtk.js
**Created:** [January 17, 2024, 4:06pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088 "2024-01-17T16:06:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Alireza](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alireza/32/6230_2.png) [@Alireza](https://discourse.vtk.org/u/Alireza)
#### Post date: [January 17, 2024, 4:06pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/1 "2024-01-17T16:06:09Z")

</div>

How to get the groups of points out of the vtkCutter when there is more than one contour as the result

For instance [in this example](https://kitware.github.io/vtk-js/examples/Cutter.html), If i manipulate the planes/origin and the result be more than one closed contour, I would like to get the two groups separately. But seems like the `cutter.getOutputData().getPoints().getData()` returns them all in one array?

 ![CleanShot 2024-01-17 at 11.02.39](https://discourse.vtk.org/uploads/default/original/2X/9/9a0010ae0bf7a3f8ccb936781d3057925caff758.jpeg)

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 17, 2024, 4:23pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/2 "2024-01-17T16:23:26Z")

</div>

You might want to look into vtkPolyDataConnectivityFilter.

---

<div class="post-metadata">

### Author: ![Alireza](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alireza/32/6230_2.png) [@Alireza](https://discourse.vtk.org/u/Alireza)
#### Post date: [January 17, 2024, 4:25pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/3 "2024-01-17T16:25:17Z")

</div>

Thanks, seems like it is not in vtk.js yet

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 17, 2024, 4:27pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/4 "2024-01-17T16:27:34Z")

</div>

Well depending on how ambitious you are, you might want to wasm it. And I suspect a tool like trame would work as well, although it’s hard to say without knowing your requirements.

---

<div class="post-metadata">

### Author: ![Alireza](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alireza/32/6230_2.png) [@Alireza](https://discourse.vtk.org/u/Alireza)
#### Post date: [January 17, 2024, 4:29pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/5 "2024-01-17T16:29:52Z")

</div>

The requirement is to detect and group them into separate arrays in order to render them with SVG polyline connecting points. Thanks I will look into the proposed solutions

---

<div class="post-metadata">

### Author: ![Alireza](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alireza/32/6230_2.png) [@Alireza](https://discourse.vtk.org/u/Alireza)
#### Post date: [February 1, 2024, 6:58pm UTC](https://discourse.vtk.org/t/vtkcutter-how-to-separate-groups-of-points-in-multiple-contour-results-in-vtk-js/13088/6 "2024-02-01T18:58:48Z")

</div>

> <https://github.com/Kitware/vtk-js/pull/3003>
>
> \### Context
> 
> \- Thanks to @floryst for providing me the \`contourLoopExtraction\`… code, I am just providing an example, as well as typing and submitting a pull request.
> 
> This PR introduces the \`vtkContourLoopExtraction\` filter, which is designed to extract closed loop contours from the output of the vtkPolyData. 
> 
> Unlike tools like \`vtkCutter\`, which lack sufficient clustering information about the cuts, \`vtkContourLoopExtraction\` efficiently traverses the points to identify loops.
> 
> \### Results
> 
> I've included an example that demonstrates this amazing feature. In this particular example, we obtain the output of the \`vtkCutter\` and then pass it to the \`vtkContourLoopExtraction\`. Finally, we generate separate polyData for each individual contour, with each contour having its own unique color.
> 
> 
> https://github.com/Kitware/vtk-js/assets/7490180/22124fb5-dd91-4bc9-a989-7981818083da
> 
> 
> 
> 
> \### Changes
> \- \[x\] Documentation and TypeScript definitions were updated to match those changes
> 
> \### PR and Code Checklist
> \- \[x\] \[semantic-release\](https://github.com/semantic-release/semantic-release) commit messages
> \- \[x\] Run \`npm run reformat\` to have correctly formatted code
> 
> \### Testing
> \<!--
> Please describe how this can be tested by reviewers. Be specific about anything not tested and the reasons why.
> Tests should complete without errors. See CONTRIBUTING.md
> \--\>
> \- \[x\] This change adds or fixes unit tests 
> \- \[x\] Tested environment:
> - \*\*vtk.js\*\*: Latest
> - \*\*OS\*\*: macOS
> - \*\*Browser\*\*: Chrome latest stable
> 
> \<!--
> Edit and uncomment the section below if relevant
> 
> \### Funding
> This contribution is funded by \[Example\](https://example.com).
> 
> --\>
