I would like to do boolean operation repeatedly on the output of the boolean filter itself like below.
auto boolFilter = vtkSmartPointer<vtkPolyDataBooleanFilter>::New();
boolFilter->SetInputData( 0, input1 );
boolFilter->SetInputData( 1, transformFilter->GetOutput() ); //input2
for (int i = 0; i < numSteps; ++i)
//translation->Translate(0.1, 0.0, 0.0);
boolFilter->Update(); //program crashes here
// The total animation time is 12 seconds
std::this_thread::sleep_for(std::chrono::milliseconds(12000 / numSteps));
my program crashes in the loop where boolFilter->Update() is called. Am I doing the steps correctly in the for loop?
Thanks in advance.
Usually nothing special is needed if you create a circle in the processing pipeline. If you have doubts, you can always create a full copy of the data object (using
DeepCopy) and see if it makes a difference.
The problem may be that you use
vtkPolyDataBooleanFilter. This is one of the very few filters in VTK that actually does not work (randomly gives incorrect result or crashes, for completely valid inputs). You may be able to use plane cut or other filters that work well. If you really need Boolean operations on meshes then you can use vtkbool package, which generally works very well, even for very complex meshes (and it is actively maintained, so if you run into issues then there is someone to ask help from).
Thank you @lassoan for the reply. Yes, I created full copy of the data object and try to use that object as an input to the boolean filter in the loop with no luck. I tried with vtkLoopBooleanPolyDataFilter as well but I see “vtkPointLocator (0x5607c90efb50): No points to subdivide” and “no intersection between the objects” warnings for every iteration.
Thanks for suggesting the vtkbool package.It looks promising for boolean operations on my meshes. will check that.
I’ve just noticed that you already used vtkPolyDataBooleanFilter, which is implemented in vtkbool. The filter has some known issues, several of them are addressed in latest master version of the repository.
I would not recommend using VTK’s built-in vtkBooleanOperationPolyDataFilter, vtkIntersectionPolyDataFilter, and vtkLoopBooleanPolyDataFilter as they fail much more often than vtkbool.
I see. Thank you @lassoan for the valuable information.