vtkClipClosedSurface bad results


Here is a quite simple scene that produces bad result after a vtkClipClosedSurface filter.
The scene consists of several PolyData nested inside a vtkMultiBlockDataSet.
The filter is applied by the mean of vtkThreadedCompositeDataPipeline.

Screenshots show before and after clipping.
You can see there are missing triangles on the “cap” of the cylinder and near it.
VTM attached.

export.zip (104.5 KB)

From the screenshots, it looks like the outer wall (brown) and inner wall (blue) of the cylinder are separate polydata. If that’s the case, then vtkClipClosedSurface will not work on this dataset.

All objects are separated PolyData, and are valid closed shell.
The brown cylinder is an empty one, and the blue cylinder is filling it.
There is no reason vtkClipClosedSurface fail …

Can you show the brown cylinder by itself, both before and after clipping?


Thanks, that helps a lot. Can you tell me which one of the .vtp files it is? I might have time to look at it tonight.

export_44.vtp :wink:

I ran the cylinder through vtkFeatureEdges to see if it had any boundary edges, meaning edges that belong to only one polygon. All of the sharp edges are, in fact, boundary edges:

What this means is that the polygons are not connected across those edges. The algorithm used by vtkClipClosedSurface requires connectivity of all polygons, not just spatial adjacency.

In this case, you can fix the problem by passing the cylinder through vtkCleanPolyData before passing it through vtkClipClosedSurface. One caveat to doing this is that the normals associated with the points will be lost, but if the normals are needed they can be re-generated with vtkPolyDataNormals.

Thanks a lot David for you research !

All my geometry is obtained by a tessellator, and is thus triangulated.
Before passing it to VTK, all coincident vertices are merged, but not the edges / faces.
Consequently, there is indeed no connectivity (other than pure geometric proximity) between edges / faces.

I’ll try the “cleansing” approach.

Results are ok after vtkCleanPolyData, thanks again.