I’m using (C++) vtkIntersectionPolyDataFilter to perfrom boolean operations (union, intersection, difference) on geometric bodies such as spheres and cylinders. For instance, if 2 bodies do not touch or overlap in any manner, when I execute the code I see the following error messages / warnings (regardless of the boolean operation) and NO objects are rendered on screen:
2022-06-06 16:25:36.780 ( 0.334s) [ 3FD38A00] vtkPointLocator.cxx:845 ERR| vtkPointLocator (0x1147620): No points to subdivide 2022-06-06 16:25:36.781 ( 0.334s) [ 3FD38A00] vtkIntersectionPolyData:2410 WARN| No Intersection between objects 2022-06-06 16:25:36.781 ( 0.335s) [ 3FD38A00]vtkDistancePolyDataFilt:81 ERR| vtkDistancePolyDataFilter (0x1041fd0): No points/cells to operate on 2022-06-06 16:25:36.781 ( 0.335s) [ 3FD38A00]vtkDistancePolyDataFilt:81 ERR| vtkDistancePolyDataFilter (0x1041fd0): No points/cells to operate on
Now, the error messages are certainly informative to me as a developer, but they will probably confuse my users and have them asking “What went wrong?” when they mess up.
I would like to handle messages like those shown above in a more robust way in my code, but I can’t figure out how to do that from vtkBooleanOperationPolyDataFilter’s paucity of error codes. The fact that this filter inherits quite a lot from other filters is also a factor and seems to add complexity to the issue.
I’m not against subclassing vtkBooleanOperationPolyDataFilter and inserting my own codes and / or messages, but I’m not sure how to proceed considering that some of the messages are so deep into the inheritance chain.
Certainly, this is not the first time this issue has surfaced. Can anyone offer a solution? Did the vtk developers even consider a situation such as this?
Ah, I keep forgetting that it’s a Python wrapper around vtkCommand. You can search for vtkTest::ErrorObserver in the repo to see how it is done there; the class is part of VTK::TestingCore, so not really intended for generic use.
However, when I set it up according to the example on the vtkIntersectionPolyDataFilter object, it didn’t work. And, it didn’t work on any other object / filter that I tried the vtkObserver on. So, I’m lost of this one. Is it suppose to catch errors / warnings from inherited classses?
The try / catch doesn’t catch the errors and warnings that are generated by vtkBooleanOperationPolyDataFilter.
I believe that the filters aren’t throwing exceptions. They don’t like the data they are given. Are unsuccessful in working with the data. Print out the warnings and errors. What they should do is give me a return value that I can work with.
I agree about fixing the filter regarding the printed error messages.
I’ll take a stab at the factory approach, but I don’t have experience with it. For me, the code for the F3D factory was a little vague. I just don’t understand the principles needed for implementation. There was not enough code supporting it to understand what is needed to make it work. And, looking at (digging through) another major application to figure this out was not how I envisioned learning how to do this.
I see from the documentation that the vtkObjectFactory is an aid in writing a subclass. All of the examples mentioned at https://vtk.org/doc/nightly/html/classvtkObjectFactory.html
use the vtkObjectFactory. h header file, but do not directly use vtkObjectFactory. So, this is a bit confusing and leaves me wondering how to use the factory class.
But, the bigger issue is that I don’t know how to write the subclass at this point because the filters that vtkBooleanOperationPolyDataFilter use may or may not return any useful information from which I can create the code I need.
In essence, writing a subclass is basically fixing the problem that the developers created by not having the function make the right checks to begin with. At this point I don’t know enough about what these other routines return or make available for one to work with. This will take some digging on my part with the biggest concern is that I don’t know when the pipeline is making things available and what those things might be.