The result of Boolean operation returns non-manifold surfaces

Hello everybody,

I have a question. I am using vtkBooleanOperationPolyDataFilter to make holes in a polydata using a cylinder. The result looks good. But when I go to blender, I get a warning that the result is not manifold. I can see that the areas, where the boolean has been applied, have some open faces. Is there any way to get a manifold result like the input surface?. The input surface is constructed using a distance map of an stl.

Thank you very much for your help

We have had the same problem and have had to abandon using the vtk Boolean ops. There are third-party implementation that might be better. We ended up using Parasolid and Polygonica for Boolean ops. Polygonica seemed to be the best of the 3 so far…

Hello, thank you for answering. I also tried the romer library but i got the same problem although the results were much better. I will try one of the libraries you suggest. Are they easy to integrate with a vtk project ?. Are they freeware? I cheched their website and I think you must pay to use them. If this is the case it is an open source alternative?

Thank you very much

Please send me your meshes. I’m sure I can help you with it. Or I can say, what’s wrong with it.

Unfortunately I don’t think they are freeware. I hope Ronald can help you.

Thank you very much for your answers. I will consider it.

I also attached the polydatas that we used to perform the boolean operations where the result is non-manifold in case @Ron84 wants to have a look. Really thank you !!. We detected non-manifold results with blender. In vtk, it is not visible at all, but in blender, those areas can be detected marking them in red when you verify the polydata. We moved the faces a bit to see that the polydata was really open in those areas. Otherwise it is not visible.

Thanks for anwering

My boolean filter works fine with your meshes. The problem is: cylinderWithPolyData_data_1.vtp is constructed with cells of type VTK_QUAD. The points of that cells are not in a plane. Therefore the calculated normals are wrong. And therefore the intersections are wrong. You have to apply a vtkTriangleFilter to that mesh. And voila, you will get this:

Btw: Your mesh has non-manifold edges at this locations:

1 Like

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();

}

@zandarina Could you please reupload your meshes?

Sure,

Thanks !!

1 Like

Hello @Ron84 I have tried with other polydatas and I got the same behaviour if I apply a connected component after applying the boolean operation I only get a small layer due to this open areas. And I corrected the orientation of the normals and used a triangle an a clean filter. I do not know why but the result it is not a connected component in points where it should be. I think it is the only weak point of the library because the rest is amazing. Thanks

Hello @geoffw I am considering to buy one boolean library. I wonder if Polygonica is easy to adapt with vtk?. Thank you

@zandarina, in the end you just need to pull out the point and cell information from vtk and provide it to polygonica in the right format. The Polygonica API is a little strange but it’s not too bad.