def threaded_function(): trimesh_remesh(st[mesh_key], target=length, kmax=500, allow_boundary_split=True, allow_boundary_swap=True, callback=callback)
mesh = Mesh.from_vertices_and_faces(vertices, faces) key = mesh.insert_vertex(0) fixed = [key] plotter = MeshPlotter(mesh, figsize=(8, 5)) plotter.draw_edges(width=0.5) def callback(mesh, k, args): print(k) plotter.update_edges() plotter.update() trimesh_remesh(mesh, 0.5, kmax=200, allow_boundary_split=True, allow_boundary_swap=True, allow_boundary_collapse=True, fixed=fixed, callback=callback) mesh_smooth_area(mesh, fixed=mesh.vertices_on_boundary()) plotter.update_edges() plotter.update(pause=2.0) plotter.show()
# identify the fixed vertices # by matching the coordinates of the selected points # up to a precision keys = mesh_identify_vertices(mesh, points, '1f') fixed = set(keys) # create a conduit for visualisation conduit = MeshConduit(mesh, refreshrate=2) # run the remeshing algorithm # draw the result with conduit.enabled(): trimesh_remesh(mesh, target=length, kmax=kmax, tol=0.1, divergence=0.01, allow_boundary_split=True, allow_boundary_swap=True, allow_boundary_collapse=False, smooth=True, fixed=fixed, callback=callback) artist = MeshArtist(mesh, layer='remeshed') artist.draw_faces(join_faces=True)
boundary = rs.GetObject("Select Boundary Curve", 4) length = rs.GetReal("Select Edge Target Length", 2.0) points = rs.DivideCurve(boundary, rs.CurveLength(boundary) / length) # generate a delaunay triangulation # from the points on the boundary faces = delaunay_from_points(points, boundary=points) mesh = Mesh.from_vertices_and_faces(points, faces) # make a conduit for visualization conduit = MeshConduit(mesh, refreshrate=2) # run the remeshing algorithm # and draw the result with conduit.enabled(): trimesh_remesh( mesh, target=length, kmax=500, allow_boundary_split=True, allow_boundary_swap=True, callback=callback) artist = MeshArtist(mesh) artist.draw_faces(join_faces=True) artist.redraw()