# Mesh.slice\_plane method for open mesh

**URL:** <https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516>\
**Category:** compas\
**Created:** [September 3, 2021, 1:36pm UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516 "2021-09-03T13:36:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nizartaha](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@nizartaha](https://forum.compas-framework.org/u/nizartaha)\
**Post date:** [September 3, 2021, 1:36pm UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516/1 "2021-09-03T13:36:50Z")

</div>

@tomvanmele  
how do i delete the unloaded faces that gets created after slicing a mesh to two parts with a plane?

i read that its mentioned here but i cant figure out how to delete them in the code ( not manually) ['TypeError' while using remesh from compas\_cgal](https://forum.compas-framework.org/t/typeerror-while-using-remesh-from-compas-cgal/414)

I tried to look if there is an obvious line where they are created under `def mesh_slice_plane(mesh, plane):` under `def positive(self):` or `def negative(self):` but there is none , even in the mesh data structure , there are no attribute for such faces.  
and if i print out `len(mesh.faces_on_boundary())` it returns 0.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/compas_framework1/original/1X/6509b7ce767dc46a2638c6bf8ee617486a6aae12.png)

\*side note: I tried to slice the mesh with `boolean_intersection` from compas\_cgal with a box that contains some part of the open mesh ,but i figure out that `boolean_intersection` works only for closed meshes.

---

<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:** [September 6, 2021, 12:00pm UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516/2 "2021-09-06T12:00:45Z")

</div>

hi,

what do you mean by “unloaded faces that get created after slicing a mesh”?  
the concept of unloaded faces is specific to RV2 form diagrams.  
normal meshes don’t have them, and they are not a by-product of the slicing operation…

some code and a sample file would be helpful 🙂

---

<div class="post-metadata">

**Author:** ![nizartaha](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@nizartaha](https://forum.compas-framework.org/u/nizartaha)\
**Post date:** [September 6, 2021, 3:33pm UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516/3 "2021-09-06T15:33:14Z")

</div>

Hi Tom,  
i see. i get some extra faces as a result of the slice, not sure why it happens. here is a link for a ply mesh and the code below.

> **[open mesh slice sample.py and 1 more file](https://wetransfer.com/downloads/6ed870b60ef03c9bd3d6be95ae75ed8020210906152742/086caf)**
>
> 2 files sent via WeTransfer, the simplest way to send your files around the world

```auto
import os

from compas.datastructures import Mesh
from compas.geometry import Plane
from compas_rhino.artists import MeshArtist
# from compas_cgal.meshing import remesh

# file path
HERE = os.path.dirname( __file__ )
mesh_json_file_path = os.path.join(HERE, 'mesh_part.json')
mesh_file_path = os.path.join(HERE, 'rock_mesh.ply')

mesh = Mesh.from_ply(mesh_file_path)

# parts size
part_size_x = 700
part_size_y = 800

# create planes
bbox = mesh.bounding_box()
bbox_bottom_right_pt_Try = [bbox[0][0], bbox[0][1]+part_size_y, bbox[0][2]]
bbox_bottom_right_pt_Trx = [bbox[0][0]+part_size_x, bbox[0][1], bbox[0][2]]

plane_cut_along_y = Plane(bbox_bottom_right_pt_Try, (0, 1, 0))
plane_cut_along_x = Plane(bbox_bottom_right_pt_Trx, (1, 0, 0))

# # remesh if necessary, when executed outside rhino
# B = mesh.to_vertices_and_faces()
# V, F = remesh(B, 40, 10)
# mesh = Mesh.from_vertices_and_faces(V, F)

result = mesh.slice_plane(plane_cut_along_y)
mesh_part_01 = result[1] # or result[0]

result = mesh_part_01.slice_plane(plane_cut_along_x)
mesh_part_02 = result[1] # or result[0]

# to json
mesh_part_02.to_json(mesh_json_file_path)

# visualize in rhino
# when executed outside rhino
# JSON_MESH = Mesh.from_json(mesh_json_file_path)
# artist = MeshArtist(JSON_MESH, layer="mesh")

# inside rhino
artist = MeshArtist(mesh_part_02, layer="mesh")
artist.clear_layer()
artist.draw_edges()
artist.draw_faces()
artist.redraw()

```

---

<div class="post-metadata">

**Author:** ![nizartaha](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@nizartaha](https://forum.compas-framework.org/u/nizartaha)\
**Post date:** [September 15, 2021, 4:20pm UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516/4 "2021-09-15T16:20:49Z")

</div>

Hi,  
I believe this is created when the negative and positive parts are created 🙂 . this line of code in each method makes sure to close the mesh and create these extra faces.  
`mesh.add_face(mesh.vertices_on_boundary())`  
In my case above, i think it would be nice if the user have the choice to close the mesh or keep it open. Thank you

---

<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:** [September 28, 2021, 7:08am UTC](https://forum.compas-framework.org/t/mesh-slice-plane-method-for-open-mesh/516/5 "2021-09-28T07:08:09Z")

</div>

hi nizar,

sorry for not following up. i will address this shortly using the PR you submitted…

best,  
tom
