# ============================================================================== # Booleans # ============================================================================== # convert meshes to data VA, FA = a.to_vertices_and_faces() VB, FB = b.to_vertices_and_faces() # boolean operations VC, FC = igl.mesh_union(VA, FA, VB, FB) c_union = Mesh.from_vertices_and_faces(VC, FC) VC, FC = igl.mesh_intersection(VA, FA, VB, FB) c_intersection = Mesh.from_vertices_and_faces(VC, FC) VC, FC = igl.mesh_difference(VA, FA, VB, FB) c_diff = Mesh.from_vertices_and_faces(VC, FC) # ============================================================================== # Visualization # ============================================================================== # the original meshes artist = MeshArtist(a, layer="IGL::A") artist.clear_layer() artist.draw_mesh(color=[255, 0, 0])
b = Mesh.from_shape(b) mesh_quads_to_triangles(a) mesh_quads_to_triangles(b) # ============================================================================== # Booleans # ============================================================================== A = a.to_vertices_and_faces() B = b.to_vertices_and_faces() C = igl.mesh_union(A, B) c_union = Mesh.from_vertices_and_faces(*C) C = igl.mesh_intersection(A, B) c_intersection = Mesh.from_vertices_and_faces(*C) C = igl.mesh_difference(A, B) c_diff = Mesh.from_vertices_and_faces(*C) # ============================================================================== # Visualization # ============================================================================== c_union.transform(Translation([7.5, 0, 0])) c_intersection.transform(Translation([15, 0, 0])) c_diff.transform(Translation([22.5, 0, 0])) artist = MeshArtist(a, layer="IGL::A") artist.clear_layer()