Hello, thank you very much. I am very surprised about the quad issue as the code transforms both polydatas into triangular faces with the triangle filter and the clean filter afterwards. Should I also apply the triangle filter to the result?. I will look at this issue carefully as I might do something weird in the polydata that switches to quads.
Thank you very much !!
vtkSmartPointer<vtkPolyData> booleanSubstractionTwoPolyDatas(vtkSmartPointer<vtkPolyData> splint, vtkSmartPointer<vtkPolyData> polydataToSubstractToSplint) {
vtkSmartPointer<vtkTriangleFilter> tri1 =
vtkSmartPointer<vtkTriangleFilter>::New();
tri1->SetInputData(splint);
vtkSmartPointer<vtkCleanPolyData> clean1 =
vtkSmartPointer<vtkCleanPolyData>::New();
clean1->SetInputConnection(tri1->GetOutputPort());
clean1->Update();
auto input1 = clean1->GetOutput();
vtkSmartPointer<vtkTriangleFilter> tri2 =
vtkSmartPointer<vtkTriangleFilter>::New();
tri2->SetInputData(polydataToSubstractToSplint);
tri2->Update();
vtkSmartPointer<vtkCleanPolyData> clean2 =
vtkSmartPointer<vtkCleanPolyData>::New();
clean2->SetInputConnection(tri2->GetOutputPort());
clean2->Update();
auto input2 = clean2->GetOutput();
vtkPolyDataBooleanFilter *bf2 = vtkPolyDataBooleanFilter::New();
bf2->SetInputData(0, input1);
bf2->SetInputData(1, input2);
bf2->SetOperModeToDifference();
try {
bf2->Update();
}
catch (const std::exception& e) {
cout << "Error of the boolean library: " << e.what() << "\n";
return vtkSmartPointer<vtkPolyData>::New();
}
return bf2->GetOutput();
}