def main(): args = parse_args() mesh = pymesh.load_mesh(args.input_mesh) slices = pymesh.slice_mesh(mesh, np.array(args.axis), args.N) slices = pymesh.merge_meshes(slices) pymesh.save_mesh(args.output_slices, slices, *slices.get_attribute_names())
def test_diag_box(self): mesh = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) N = 5 slices = slice_mesh(mesh, [1, 1, 1], N) self.assertEqual(N, len(slices)) slices = merge_meshes(slices) self.assert_bbox_is_embedded(slices.bbox, mesh.bbox)
def test_diag_box(self): mesh = generate_box_mesh( np.array([0, 0, 0]), np.array([1, 1, 1])); N = 5; slices = slice_mesh(mesh, [1, 1, 1], N); self.assertEqual(N, len(slices)); slices = merge_meshes(slices); self.assert_bbox_is_embedded(slices.bbox, mesh.bbox);
def mesh_contours_pymesh(mesh, levels=None, density=100): vertices, faces = mesh.to_vertices_and_faces() m = pymesh.form_mesh(vertices, faces) return pymesh.slice_mesh(m, [0, 0, 1], 50)
def slice(the_mesh, step=1.0, epsilon=0.001): n = math.ceil((the_mesh.bbox[1][2] - the_mesh.bbox[0][2]) / step) print("slicing into %d slices" % (n)) return [[Contour(component) for component in pymesh.separate_mesh(slice)] for slice in pymesh.slice_mesh(the_mesh, numpy.array([0, 0, 1]), n) ]