# The result of Boolean operation returns non-manifold surfaces

**URL:** https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018
**Category:** Support
**Created:** [August 19, 2020, 10:32am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018 "2020-08-19T10:32:41Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [August 19, 2020, 10:32am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/1 "2020-08-19T10:32:41Z")

</div>

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.

 ![Screenshot_2020-08-19-12-29-19-1](https://discourse.vtk.org/uploads/default/original/2X/e/e32c72c2b29ccff55485639797dd9d165ff7fa55.png) ![Screenshot_2020-08-19-12-29-59-1](https://discourse.vtk.org/uploads/default/original/2X/a/a401598095a5fd1bc5e7536f03c1e4630b9588d5.jpeg)

Thank you very much for your help

---

<div class="post-metadata">

### Author: ![geoffw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://discourse.vtk.org/u/geoffw)
#### Post date: [August 28, 2020, 2:16am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/2 "2020-08-28T02:16:49Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [August 28, 2020, 6:46am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/3 "2020-08-28T06:46:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [August 30, 2020, 10:15pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/4 "2020-08-30T22:15:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![geoffw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://discourse.vtk.org/u/geoffw)
#### Post date: [September 1, 2020, 12:22am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/5 "2020-09-01T00:22:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [September 23, 2020, 10:22am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/6 "2020-09-23T10:22:01Z")

</div>

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

> **[cylinder with polydata.rar](https://wetransfer.com/downloads/df06af5cc7f6c6c3e9063eb2f523d4d320200923100937/2a7f0483d2e5154cf1fefaf9d0532e6620200923101006/81fedf)**
>
> 1 file sent via WeTransfer, the simplest way to send your files around the world

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [September 25, 2020, 9:10pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/7 "2020-09-25T21:10:46Z")

</div>

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:

 ![jawbone](https://discourse.vtk.org/uploads/default/original/2X/7/7dc02086d930d41865dd05fcfdfc9037de121009.jpeg)

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

 ![jawbone2](https://discourse.vtk.org/uploads/default/original/2X/6/61ae6baee9f76515f1cc6d0fe8c1720e95349526.png)

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [September 28, 2020, 12:34pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/8 "2020-09-28T12:34:30Z")

</div>

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

```

}

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [November 7, 2020, 9:17pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/9 "2020-11-07T21:17:33Z")

</div>

@zandarina Could you please reupload your meshes?

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [November 11, 2020, 7:55am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/10 "2020-11-11T07:55:03Z")

</div>

Sure,

> **[cylinder with polydata.rar](https://wetransfer.com/downloads/e9bba307f6d9eb0ff92e8d39817ae44420201111075059/4eb785)**
>
> 1 file sent via WeTransfer, the simplest way to send your files around the world

Thanks !!

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [December 14, 2020, 8:23am UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/11 "2020-12-14T08:23:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [March 31, 2021, 1:08pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/12 "2021-03-31T13:08:14Z")

</div>

> [@geoffw](#):
>
> 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 @geoffw I am considering to buy one boolean library. I wonder if Polygonica is easy to adapt with vtk?. Thank you

---

<div class="post-metadata">

### Author: ![geoffw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://discourse.vtk.org/u/geoffw)
#### Post date: [July 28, 2021, 2:56pm UTC](https://discourse.vtk.org/t/the-result-of-boolean-operation-returns-non-manifold-surfaces/4018/13 "2021-07-28T14:56:19Z")

</div>

@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.
