# vtkLoopSubdivisionFilter doesn't work properly

**URL:** https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893
**Category:** Support
**Created:** [July 6, 2022, 4:59pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893 "2022-07-06T16:59:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![esmitt](https://discourse.vtk.org/user_avatar/discourse.vtk.org/esmitt/32/5465_2.png) [@esmitt](https://discourse.vtk.org/u/esmitt)
#### Post date: [July 6, 2022, 4:59pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/1 "2022-07-06T16:59:49Z")

</div>

Hello! this is my first post due that I am having a problem:  
I am using this example: [https://kitware.github.io/vtk-examples/site/Cxx/Meshes/Subdivision/](https://kitware.github.io/vtk-examples/site/Cxx/Meshes/Subdivision/)  
replacing my OBJ file (a simple one based on triangles, vertex, vertex’s normal and faces).  
However, the output is as follows:  
[Ys4Pw.jpg (1307×678) (imgur.com)](https://i.stack.imgur.com/Ys4Pw.jpg)

Any idea? Thanks!

---

<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: [July 6, 2022, 5:17pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/2 "2022-07-06T17:17:47Z")

</div>

Is the mesh watertight (manifold)? e.g., no duplicate points or edges, cracks, t-junctions, etc. Some of this can be cleaned up with vtkStaticCleanPolyData / vtkCleanPolyData.

---

<div class="post-metadata">

### Author: ![esmitt](https://discourse.vtk.org/user_avatar/discourse.vtk.org/esmitt/32/5465_2.png) [@esmitt](https://discourse.vtk.org/u/esmitt)
#### Post date: [July 6, 2022, 8:49pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/3 "2022-07-06T20:49:14Z")

</div>

Thanks for the answer Will.  
I realized that using vtkOBJReader + vtkTriangleFilter, all the triangles are set as separate structures! Then, the image corresponds to a filter applied to each triangle (in a correct way). Thus, my problem is another!

Actually, I set everything to use a polydata P with the following:  
GetNumberOfPieces: 1  
GetNumberOfPolys: 286598  
GetNumberOfPoints: 859794

And, using vtkLoopSubdivisionFilter over P is the image that I attached.  
Any clue is welcome

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/bf64c686953126e97504d0dd38596faa050d9260.jpeg)

Again, thanks a lot Will

---

<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: [July 7, 2022, 11:46am UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/4 "2022-07-07T11:46:11Z")

</div>

Can you provide sample data? Assuming the data is triangles (as required by the filter), I am suspicious that the mesh is disconnected in some way.

Another suggestion: use ParaView for quick debugging situations like this. Filters like feature edges can be very helpful in spotting issues.

---

<div class="post-metadata">

### Author: ![esmitt](https://discourse.vtk.org/user_avatar/discourse.vtk.org/esmitt/32/5465_2.png) [@esmitt](https://discourse.vtk.org/u/esmitt)
#### Post date: [July 7, 2022, 5:55pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/5 "2022-07-07T17:55:49Z")

</div>

Sure!  
Here is a sample OBJ [WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free](https://we.tl/t-QGlGhkr95O) (it expires in 1 week).  
Again, thanks.

---

<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: [July 7, 2022, 6:46pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/6 "2022-07-07T18:46:02Z")

</div>

The triangles are disconnected from each other. Use vtkCleanPolyData or vtkStaticCleanPolyData. This removes duplicate points with the effect of “joining” the mesh polygons.

Also the mesh has non-triangles in it. Finally, there are a few non-manifold edges. Both of which make the subdivision filters unhappy ☹

With a little work the mesh could be cleaned up…

---

<div class="post-metadata">

### Author: ![esmitt](https://discourse.vtk.org/user_avatar/discourse.vtk.org/esmitt/32/5465_2.png) [@esmitt](https://discourse.vtk.org/u/esmitt)
#### Post date: [July 7, 2022, 11:52pm UTC](https://discourse.vtk.org/t/vtkloopsubdivisionfilter-doesnt-work-properly/8893/7 "2022-07-07T23:52:34Z")

</div>

I used the vtkStaticCleanPolyData + vtkTriangleFilter with PassLinesOff and PassVertsOff + playing with vtkSmoothPolyDataFilter + vtkPolyDataNormals and I obtained the image.  
Isn’t fully subdivided as I expected… but at least is not the mess that I had before ☠

I know that removing the non-manifold points/edges is the way to input in vtk\<…\>SubdivisionFilter but well…is a job for the future me 😬

Will, thanks for the support.

![image](https://discourse.vtk.org/uploads/default/original/2X/f/f6ee1f92c419c9a829b1eaa1c8aec59c0911dcba.jpeg)
