@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
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.
*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.
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
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.
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()
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
hi nizar,
sorry for not following up. i will address this shortly using the PR you submitted…
best,
tom