Apologies up front for this being rather long and possibly somewhat difficult to understand.
I hope that someone can suggest a course of action for this.
I’ve been trying to model and render various geometric bodies with boolean operations using vtkBooleanOperationPolyDataFilter and have run into a problem with the normals not being right in the final object.
I have 2 objects, a sphere that is built using vtkSphereSource and a cube using a modification that I made to vtkCubeSource. When rendered individually, everything appears fine, but when I use vtkBooleanOperationPolyDataFilter and take a bite out of the cube with the sphere, a good number of the normals aren’t right as can be seen in the picture.
The black indicates where the normals aren’t correct. My opinion is that the system didn’t copy them over correctly from the original bodies. When one looks at just the mesh, it appears correct.
Because vtkBooleanOperationPolyDataFilter is based upon the work at
https://www.vtkjournal.org/browse/publication/797
and this article discusses the steps that are needed under the hood, I decided to look at the individual steps to see what was causing the problem. The following code is what generated the picture above.
Cube2.cxx (2.6 KB)
In the several steps (filters) that the journal paper discusses in building the vtkBooleanOperationPolyDataFilter, it appears that with the vtkIntersectionPolyDataFilter the normals aren’t being handled correctly. From the code listing one can see that I needed the step with vtkDistancePolyDataFilter in order to setup the mapper, but vtkIntersectionPolyDataFilter appears to be responsible for the heavy lifting for the triangle intersections, etc. and processing of the polydata.
It appears to me that vtkIntersectionPolyDataFilter isn’t re-calculating the normals, but I suspect that because there is so much inheritance going on that something up the chain is responsible for handling the normals in the new body. I not sure how to debug this to find the culprit.
I’m hoping that someone with more experience with these routines and the inheritance can shed some light on this. Its possible that one of the inherited routines is messing up (and I don’t know which) or I need to somehow further process what I have. But, I had expected vtkBooleanOperationPolyDataFilter to handle this correctly without an further manipulation needed on my part.
Am open to suggestions as to what to try next.
BK