clipping a polydata using the implicit of another polydata via vtkClipPolyData leads to a big hole on the cut side.

vtkSmartPointer<vtkPolyData> clipMesh (const vtkSmartPointer<vtkPolyData> &mesh1, const vtkSmartPointer<vtkPolyData> &mesh2) {

	vtkNew<vtkImplicitPolyDataDistance> implicit_distance_2;

	vtkNew<vtkClipPolyData> clip;

	return clip->GetOutput();

I dont understand why the mesh returned has a no surface on the clipped side.
Please let me know how I can improve this function to have a water tight mesh.

use vtkClipClosedSurface instead.

vtkClipClosedSurface does not work with implicit functions as far as I have checked, they work with planes. If they do, please let me know how.

Indeed, then I think you need to work with a volumic dataset. Something like this would be costly but should work:

  • Delaunay3D
  • Clip with implicit Function
  • ExtractSurface

Yes, I know the 3D method, but it would both be costly and inaccurate due to sampling or tolerance. The above method is too close to a fast and accurate result except that it is not closed. Since we are clipping at a point, we should be able to recover those points on the clipped side.

By the way, can you provide a code snippet for how exactly you propose to do this ?

vtkImplicitPolyDataDistance is in the group of filters that have been added to VTK to implement Boolean operations on meshes. All these filters are broken in the sense that they randomly give incorrect output for completely valid inputs.

Intersection of polygonal meshes is an extremely complicated problem (practically unsolvable for arbitrarily complex meshes). If you don’t want to solve the problem in the image domain (convert to binary images, combine, and remesh) then the only robust implementation with non-restrictive license that I know of is vtkbool. Fortunately, it is VTK-based, so you can conveniently use it from VTK.

I hope that vtkbool will become part of VTK core or will be made available as a VTK remote module. Until then, if you don’t want to build it yourself then it is available 3D Slicer (with GUI or Python scripting) and in Paraview.

1 Like

Thanks, I am aware of vtkbool and the complexities of mesh booleans. My question was specific to the code snippet I shared.

vtkImplicitPolyDataDistance is one of the more robust filters in the set. It isn’t doing any complex geometric cutting operations, so it shouldn’t fail as often as, say, the vtkIntersectionPolyDataFilter, which is performing the complex geometry cutting.

Invoke clip->GenerateClippedOutputOn() to produce a second output containing the clipped portion of the dataset.

I agree on your robustness remark on vtkImplicitPolyDataDistance.

We would need the clipped surface from the cutting mesh (can be done by reversing the order in the above function). In this case, the surfaces would be disjoint and the boundaries clipped would not come out perfect. Stitching would be non-trivial.

Perhaps vtkImprintFilter would work better for your needs.