# Boolean Operations

**URL:** https://discourse.paraview.org/t/boolean-operations/1498
**Category:** ParaView Support
**Tags:** python
**Created:** [March 20, 2019, 8:33pm UTC](https://discourse.paraview.org/t/boolean-operations/1498 "2019-03-20T20:33:58Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Ortley](https://discourse.paraview.org/user_avatar/discourse.paraview.org/david_ortley/32/2630_2.png) [@David\_Ortley](https://discourse.paraview.org/u/David_Ortley)
#### Post date: [March 20, 2019, 8:33pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/1 "2019-03-20T20:33:58Z")

</div>

I’m looking for a way to do boolean operations between two STLs in Paraview. Unions, Differences, etc…

This is unfortunately for a compute environment that doesn’t have Meshlab, Blender, etc…, but it DOES have Paraview.

I’ve looked around and it seems that there’s not a way to do this directly, but maybe it can be done with a script? Does anybody have experience with this?

Thanks.

-David O.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 26, 2019, 10:26am UTC](https://discourse.paraview.org/t/boolean-operations/1498/2 "2019-03-26T10:26:48Z")

</div>

There is a VTK filter called PolyData Boolean Operations, but it is not available in ParaView yet.

Feel free to open an issue, are to contribute yourself !

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 26, 2019, 12:50pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/3 "2019-03-26T12:50:02Z")

</div>

[BooleanOperation.xml](https://discourse.paraview.org/uploads/default/original/2X/c/c85fbc583a5f618e5ecaea16b470a1549a219c89.xml) (3.1 KB) is an XML plugin you can load from the Tools -\> Manage Plugins… menu item. In the plugin manager dialog, click “Load New…” and navigate to where you saved this XML plugin. Click OK. After you have loaded it, you will have a **Boolean Operation** filter available in the Filters menu. Click on a polydata source and apply this filter. In the dialog that appears, you can pick a second polydata source.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 26, 2019, 1:05pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/4 "2019-03-26T13:05:38Z")

</div>

Thanks @cory.quammen

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [March 27, 2019, 7:26pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/5 "2019-03-27T19:26:31Z")

</div>

@cory.quammen,  
I would like to run this Plugin to detect interference (Intersection) between parts.  
I start with a MultiBlockDataSet of unstructured grids. I run Merge Blocks on this and get an Unstructured Grid. Then I tried a Programmable Filter to run the vtkGeometryFilter on the unstructured grid and output a Polygonal mesh for use with the BooleanOperation. However, the Programmable filter output is a polygonal mesh of quads rather than hexs, and the BooleanOperation fails due to “No points/cells to operate on”.

Is there a way to convert an unstructured grid of hex elements to a Polygonal mesh of hex elements in order to use your plugin?

Thanks for any hints - I am probably not setting something in the vtkGeometryFilter, but I have no clue.

Dennis  
P.S. 5 work days til retirement, but I hope to knock this out before I leave!

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 28, 2019, 12:54am UTC](https://discourse.paraview.org/t/boolean-operations/1498/6 "2019-03-28T00:54:17Z")

</div>

@DennisConklin The **Boolean Operation** filter operates only on two input polydata consisting of only triangles. To compute with an intersection occurs between two blocks consisting of hex meshes you would first need to extract those blocks ( **Extract Block** ), **Merge Blocks** into an unstructured grid, **Extract Surface** to get the quad mesh, and then finally apply **Triangulate** to produce a polydata consisting of triangles.

This checks only if two blocks intersect, however, so you would need to do the same operation pairwise for each set of potentially overlapping blocks. You could do some preliminary checks like require that bounding boxes overlap before doing the more computationally intensive mesh intersection test to speed things up.

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [March 29, 2019, 12:03pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/7 "2019-03-29T12:03:31Z")

</div>

@cory.quammen Everytime I try this I get a segmentation error crash. I can’t believe that my datasets are big enough to actually run out of memory, so I’m thinking something else is going on. Any other restrictions that you can think of for this procedure??

Thanks

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 29, 2019, 2:08pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/8 "2019-03-29T14:08:59Z")

</div>

Procedurally, that’s all you should have to do. Can you provide any more info about the crash (stack trace, etc.)?

The boolean operations algorithm isn’t bulletproof, unfortunately, so you may be hitting a bug in it.

---

<div class="post-metadata">

### Author: ![RR84](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rr84/32/3155_2.png) [@RR84](https://discourse.paraview.org/u/RR84)
#### Post date: [March 4, 2020, 3:42pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/9 "2020-03-04T15:42:24Z")

</div>

> [@David\_Ortley](#):
>
> I’m looking for a way to do boolean operations between two STLs in Paraview

You can use this lib: [GitHub - zippy84/vtkbool: A new boolean operations filter for VTK](https://github.com/zippy84/vtkbool)

---

<div class="post-metadata">

### Author: ![kayarre](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kayarre/32/1994_2.png) [@kayarre](https://discourse.paraview.org/u/kayarre)
#### Post date: [December 16, 2021, 3:32pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/10 "2021-12-16T15:32:35Z")

</div>

@cory.quammen Thank you so much for providing the plugin. Is there a reason its not included in Paraview? is there a separate repo that provides a collection of things like this that aren’t standard? e.g. “dev”, ot “canary” filters or ones that aren’t currently robust for mainstream use?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [December 16, 2021, 6:53pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/11 "2021-12-16T18:53:30Z")

</div>

@kayarre It’s not included in ParaView because the boolean operations filter isn’t terribly reliable. There is not a repository for such things that I know of, but it’s an interesting idea to have one.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 27, 2021, 3:26pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/12 "2021-12-27T15:26:02Z")

</div>

> [@kayarre](#):
>
> “dev”, ot “canary” filters or ones that aren’t currently robust for mainstream use?

Adding the xml shared @cory.quammen, as well as a plugin for vtkBool would be a simple first step for this.

---

<div class="post-metadata">

### Author: ![kayarre](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kayarre/32/1994_2.png) [@kayarre](https://discourse.paraview.org/u/kayarre)
#### Post date: [January 4, 2022, 4:26pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/13 "2022-01-04T16:26:00Z")

</div>

thank you @mwestphal, maybe I don’t understand but was thinking a git repository that could hold the xml and plugin for things like this?

Adding the xml locally worked for me in this scenario. I have not tried creating a plugin before.

I would be happy create a repo for things like this, but am curious if the Paraview community would also find it beneficial?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 4, 2022, 4:27pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/14 "2022-01-04T16:27:22Z")

</div>

> [@kayarre](#):
>
> a git repository that could hold the xml and plugin for things like this?

You could do that, but most likely not many people will find it.

You could add the pluging directly to the ParaView official source code for easier access.

> am curious if the Paraview community would also find it beneficial?

Definitely !

---

<div class="post-metadata">

### Author: ![kayarre](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kayarre/32/1994_2.png) [@kayarre](https://discourse.paraview.org/u/kayarre)
#### Post date: [January 4, 2022, 4:29pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/15 "2022-01-04T16:29:05Z")

</div>

@mwestphal I believe I understand now. I agree that sounds good, but if vtkbool is not very robust will it get accepted into source?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 4, 2022, 4:29pm UTC](https://discourse.paraview.org/t/boolean-operations/1498/16 "2022-01-04T16:29:35Z")

</div>

As an optional plugin depending on vtkBool, yes.
