zippy84 / vtkbool

A new boolean operations filter for VTK
Apache License 2.0
166 stars 39 forks source link

SetOperMode is inconsistent with the final results #76

Closed zhan1589 closed 6 months ago

zhan1589 commented 7 months ago

Thanks a lot for your work. Our team were able to compile vtkbool with vtk and Java wrapping. We are trying to perform some operation between a vessel segmentation and a simple geometry, e.g., a sphere. However, we found that SetOperModeToUnion can result in "difference" operation while SetOperModeToDifference can lead to "union" operation. The picture Below is an example of the result from a sphere and a vessel with SetOperModeToDifference. Is there something we should look into? Thank you for your help. example_image

zippy84 commented 7 months ago

Check the orientation of your triangles/polygons with ParaViews Normal Glyphs. You can also share the meshes with me.

zhan1589 commented 7 months ago

Thank you for your reply! Please find the attached vtk files of the vessel isosurface, the simple geometry (a sphere), and the resulting vtkPolyData obtained using the "difference" operator but ends up adding them together... I have applied vtkPolyDataNormals to these polydata before the boolean operation. Could you please tell us how should we check the normals and correct them? Thank you for your help! vtkfiles.zip

zippy84 commented 7 months ago

As I thought, the orientations of one input is wrong. In your case it's the vessel mesh:

grafik

Just use vtkPolyDataNormals with FlipNormalsOn.

zhan1589 commented 7 months ago

Thanks a lot! That fixed it! It seems that the boolean operation filter requires normals to be pointing outwards for the input polydata. I just want to ask if you are aware of some vtk filter that can make the normals pointing outwards or tell whether the normals are pointing outwards (such that I can decide when to flip the normals)? Thansk.

zhan1589 commented 7 months ago

It seems that vktPolyDataNormals can compute this with SetAutoOrientNormals(). Please see https://vtk.org/doc/nightly/html/classvtkPolyDataNormals.html#a586e27a0e8bfdcb12992228242416173 for more details.