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.
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.
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.
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.