# Triangular leaky surfaces from \`compas.geometry.boolean\_union\_mesh\_mesh\`

**URL:** https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685
**Category:** compas
**Created:** [March 12, 2023, 9:07am UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685 "2023-03-12T09:07:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)
#### Post date: [March 12, 2023, 9:07am UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685/1 "2023-03-12T09:07:33Z")

</div>

I was playing with `compas.geometry.boolean_union_mesh_mesh`, and found imperfect boolean union outcomes. There are triangular voids in non-intersection parts of the geometry.

Presumably, it is a bug in the intersection calculation code, and we look forward to further improvement. 🙂

Examples:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/compas_framework1/original/1X/10db40ebb57833ea212a7eb404f6793eb7a9c09b.jpeg)

```auto
from compas.geometry import Cylinder, Circle, Plane, boolean_union_mesh_mesh
from compas.datastructures import Mesh
from compas.artists import Artist

# Geometries for boolean
cylinder_mesh = Mesh.from_shape(Cylinder(Circle(Plane([0, 0, 0], [0, 0, 1]), 5), 3))
cylinder_mesh_2 = Mesh.from_shape(Cylinder(Circle(Plane([0, 0, 0], [1, 0, 0]), 7), 9 * 0.1))

# Boolean operations
vertices_and_faces = boolean_union_mesh_mesh(cylinder_mesh.to_vertices_and_faces(), cylinder_mesh_2.to_vertices_and_faces())
mesh = Mesh.from_vertices_and_faces(*vertices_and_faces)

# Update the model using the artist
artist = Artist(mesh)
outTemp = artist.draw()

```

```auto
from compas.geometry import Cylinder, Circle, Plane, Sphere, boolean_union_mesh_mesh
from compas.datastructures import Mesh
from compas.artists import Artist

# Geometries for boolean
cylinder_mesh = Mesh.from_shape(Cylinder(Circle(Plane([0, 0, 0], [0, 0, 1]), 5), 3))
sphere_mesh = Mesh.from_shape(Sphere([0, 0, 0], 3))

# Boolean operations for boolean
vertices_and_faces = boolean_union_mesh_mesh(cylinder_mesh.to_vertices_and_faces(), sphere_mesh.to_vertices_and_faces())
mesh = Mesh.from_vertices_and_faces(*vertices_and_faces)

# Update the model using the artist
artist = Artist(mesh)
outTemp = artist.draw()

```

```auto
from compas.geometry import Sphere, Box, Frame, boolean_union_mesh_mesh
from compas.datastructures import Mesh
from compas.artists import Artist

# Geometries for boolean
box_mesh = Mesh.from_shape(Box(Frame.worldXY(), 10, 3, 3))
sphere_mesh = Mesh.from_shape(Sphere([0, 0, 0], 3))

# Boolean operations for boolean
vertices_and_faces = boolean_union_mesh_mesh(box_mesh.to_vertices_and_faces(), sphere_mesh.to_vertices_and_faces())
mesh = Mesh.from_vertices_and_faces(*vertices_and_faces)

# Update the model using the artist 
artist = Artist(mesh)
outTemp = artist.draw()

```

```auto
from compas.geometry import Box, Frame, boolean_union_mesh_mesh
from compas.datastructures import Mesh
from compas.artists import Artist

# Geometries for boolean
box_mesh = Mesh.from_shape(Box(Frame.worldXY(), 10, 3, 3))
box_mesh_2 = Mesh.from_shape(Box(Frame.worldXY(), 3, 3, 10))

# Boolean operations for boolean
vertices_and_faces = boolean_union_mesh_mesh(box_mesh.to_vertices_and_faces(), box_mesh_2.to_vertices_and_faces())
mesh = Mesh.from_vertices_and_faces(*vertices_and_faces)

# Update the model using the artist
artist = Artist(mesh)
outTemp = artist.draw()

```

---

<div class="post-metadata">

### Author: ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)
#### Post date: [March 12, 2023, 6:09pm UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685/2 "2023-03-12T18:09:00Z")

</div>

are you running this in Rhino?

---

<div class="post-metadata">

### Author: ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)
#### Post date: [March 12, 2023, 6:24pm UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685/3 "2023-03-12T18:24:00Z")

</div>

Yes! I am using Rhino 7 for that!

---

<div class="post-metadata">

### Author: ![tomvanmele](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/tomvanmele/32/13_2.png) [@tomvanmele](https://forum.compas-framework.org/u/tomvanmele)
#### Post date: [March 12, 2023, 8:19pm UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685/4 "2023-03-12T20:19:33Z")

</div>

not sure about the implementations in Rhino, but the base implementation (using CGAL) requires the meshes to be triangulated to be able to apply boolean operations.

the mesh representations of shapes are not automatically triangulated.

just set `triangulated=True` in `from_shape`.

```python
from compas.geometry import Cylinder, Circle, Plane, boolean_union_mesh_mesh
from compas.datastructures import Mesh

from compas_view2.app import App

cylinder_1 = Mesh.from_shape(
    Cylinder(Circle(Plane([0, 0, 0], [0, 0, 1]), 5), 3),
    u=64,
    triangulated=True,
)
cylinder_2 = Mesh.from_shape(
    Cylinder(Circle(Plane([0, 0, 0], [1, 0, 0]), 7), 9 * 0.1),
    u=64,
    triangulated=True,
)

vertices_and_faces = boolean_union_mesh_mesh(
    cylinder_1.to_vertices_and_faces(),
    cylinder_2.to_vertices_and_faces(),
)
mesh = Mesh.from_vertices_and_faces(*vertices_and_faces)

viewer = App()
viewer.add(mesh)
viewer.show()

```

 ![Screenshot 2023-03-12 at 21.16.49](https://us1.discourse-cdn.com/flex015/uploads/compas_framework1/original/1X/d65750fde3bf41bb61983693d584eb3f9d1ced8e.jpeg)

---

<div class="post-metadata">

### Author: ![Zac\_Zhuo\_Zhang](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.compas-framework.org/zac_zhuo_zhang/32/433_2.png) [@Zac\_Zhuo\_Zhang](https://forum.compas-framework.org/u/Zac_Zhuo_Zhang)
#### Post date: [March 13, 2023, 10:37am UTC](https://forum.compas-framework.org/t/triangular-leaky-surfaces-from-compas-geometry-boolean-union-mesh-mesh/685/5 "2023-03-13T10:37:40Z")

</div>

Thanks a lot for the reply! The problem is now solved by adding `triangulated=True` in `from_shape`. 🙂
