def select_nodes(self): """Select nodes of the network. Returns ------- list A list of node identifiers. """ guids = compas_rhino.select_points() nodes = [self.artist.guid_node[guid] for guid in guids if guid in self.artist.guid_node] return nodes
def select_vertices(self): """Select vertices of the mesh. Returns ------- list A list of vertex identifiers. """ guids = compas_rhino.select_points() vertices = [self.artist.guid_vertex[guid] for guid in guids if guid in self.artist.guid_vertex] return vertices
def select_vertices(self, message="Select vertices."): """Select vertices of the volmesh. Returns ------- list A list of vertex identifiers. """ guids = compas_rhino.select_points(message=message) vertices = [ self.guid_vertex[guid] for guid in guids if guid in self.guid_vertex ] return vertices
def select_vertices_anchor(self): """Manually select anchor vertices in the Rhino model view. Returns ------- list The keys of the selected vertices. Examples -------- >>> """ guids = compas_rhino.select_points(message="Select anchor vertices.") if guids: keys = [self.guid_anchor[guid] for guid in guids if guid in self.guid_anchor] else: keys = [] return keys
def select_vertices(self): """Manually select vertices in the Rhino model view. Returns ------- list The keys of the selected vertices. Examples -------- >>> """ guids = compas_rhino.select_points() if guids: guid_vertex = {} guid_vertex.update(self.guid_free) guid_vertex.update(self.guid_anchor) keys = [guid_vertex[guid] for guid in guids if guid in guid_vertex] else: keys = [] return keys
from compas_rhino.geometry import RhinoCurve from compas_rhino.conduits import MeshConduit from compas_rhino.artists import MeshArtist # set the remeshing parameters length = 0.25 kmax = 300 # select the original mesh # select the border # select the fixed points guid_target = compas_rhino.select_mesh() guid_border = compas_rhino.select_polyline() guid_points = compas_rhino.select_points() # wrap the Rhino mesh object for convenience # wrap the Rhino curve object for convenience # get the point coordinates target = RhinoMesh(guid_target) border = RhinoCurve(guid_border) points = compas_rhino.get_point_coordinates(guid_points) # make a mesh datastructure from the Rhino mesh # triangulate the mesh mesh = mesh_from_guid(Mesh, guid_target) mesh_quads_to_triangles(mesh)
attr['y'] = y attr['z'] = z # update the conduit at the specified rate conduit.redraw(k) # get the target mesh # and its border guid_target = compas_rhino.select_mesh() guid_border = compas_rhino.select_polyline() # get fixed points points = compas_rhino.get_point_coordinates(compas_rhino.select_points()) # triangulate the input mesh rs.MeshQuadsToTriangles(guid_target) # make a remeshing mesh mesh = compas_rhino.mesh_from_guid(Mesh, guid_target) # update its attributes mesh.attributes['name'] = 'Remeshed' mesh.update_default_vertex_attributes({'is_fixed': False}) # make the target and border objects
from compas.datastructures import Mesh from compas.topology import delaunay_from_points from compas_rhino.helpers import MeshArtist __author__ = ['Tom Van Mele', 'Matthias Rippmann'] __copyright__ = 'Copyright 2017, BRG - ETH Zurich', __license__ = 'MIT' __email__ = '*****@*****.**' # select the points # select the boundary # select the hole(s) guids = compas_rhino.select_points("Select points.") points = compas_rhino.get_point_coordinates(guids) guid = compas_rhino.select_polyline("Select boundary.") boundary = compas_rhino.get_polyline_coordinates(guid) guids = compas_rhino.select_polylines("Select holes.") holes = [compas_rhino.get_polyline_coordinates(guid) for guid in guids] # make a delaunay triangulation # within the boundary # and around the holes faces = delaunay_from_points(points, boundary=boundary, holes=holes) mesh = Mesh.from_vertices_and_faces(points, faces)
def RunCommand(is_interactive): scene = get_scene() if not scene: return proxy = get_proxy() if not proxy: return delaunay = proxy.function('compas.geometry.delaunay_from_points_numpy') # Get input data. surf_guid = compas_rhino.select_surface("Select a surface to decompose.") if not surf_guid: return point_guids = compas_rhino.select_points( "Select points to include in the decomposition.") curve_guids = [] compas_rhino.rs.HideObjects([surf_guid] + point_guids + curve_guids) surface = RhinoSurface.from_guid(surf_guid) curves = [RhinoCurve.from_guid(guid) for guid in curve_guids] points = [RhinoPoint.from_guid(guid) for guid in point_guids] # Compute the feature discretisation length. box = compas_rhino.rs.BoundingBox([surf_guid]) diagonal = compas_rhino.rs.Distance(box[0], box[6]) D = 0.05 * diagonal # Get the target length for the final quad mesh. L = compas_rhino.rs.GetReal( "Define the target edge length of the pattern.", 1.0) # Generate the pattern pattern = Pattern.from_surface_and_features(D, L, surf_guid, curve_guids, point_guids, delaunay=delaunay) scene.clear() scene.add(pattern, name='pattern') scene.update() kmax = 10 # Constrain mesh components to the feature geometry. constraints = automated_smoothing_surface_constraints(pattern, surface) constraints.update( automated_smoothing_constraints(pattern, rhinopoints=points, rhinocurves=curves)) while True: option = compas_rhino.rs.GetString("Smoothen the pattern?", "No", ["Yes", "No"]) if not option: break if option != "Yes": break constrained_smoothing(pattern, kmax=kmax, damping=0.5, constraints=constraints, algorithm="area") scene.update() print('Pattern object successfully created. Input object has been hidden.')
def RunCommand(is_interactive): scene = get_scene() if not scene: return proxy = get_proxy() if not proxy: return srf_guid = compas_rhino.select_surface("Select a surface.") if not srf_guid: return crv_guids = [] pt_guids = compas_rhino.select_points( "Step 1/3 (Optional) - Select points for pole singularities.") or [] box = compas_rhino.rs.BoundingBox([srf_guid]) input_subdivision_spacing = 0.01 * compas_rhino.rs.Distance(box[0], box[6]) mesh_edge_length = compas_rhino.rs.GetReal( "Step 2/3 - Enter target length for edges.", 1.0) delaunay = proxy.function( "compas.geometry.triangulation.triangulation_numpy.delaunay_from_points_numpy" ) pattern = Pattern.from_surface_and_features(input_subdivision_spacing, mesh_edge_length, srf_guid, crv_guids, pt_guids, delaunay) scene.clear() scene.add(pattern, name='pattern') scene.update() kmax = 10 while True: option = compas_rhino.rs.GetString( "Step 3/3 (Optional) - Press Enter to run constrained Laplacian smoothing or ESC to skip.", strings=['Iterations']) if option is None: break if not option: constraints = automated_smoothing_surface_constraints( pattern, srf_guid) constraints.update( automated_smoothing_constraints(pattern, points=pt_guids, curves=crv_guids)) constrained_smoothing(pattern, kmax=kmax, damping=0.5, constraints=constraints, algorithm='area') objs = set(constraints.values()) inputs = [srf_guid] + crv_guids + pt_guids for obj in objs: if obj not in inputs: compas_rhino.rs.DeleteObject(obj) compas_rhino.rs.HideObjects(inputs) break if option == 'Iterations': new_kmax = compas_rhino.rs.GetInteger("Number of iterations:", kmax) if new_kmax or new_kmax is not None: kmax = new_kmax scene.update() print('Pattern object successfully created. Input object has been hidden.')
"""Delaunay triangulation from points""" import compas_rhino as rhino from compas.datastructures.mesh import Mesh from compas.datastructures.mesh.algorithms import delaunay_from_points __author__ = ['Tom Van Mele', 'Matthias Rippmann'] __copyright__ = 'Copyright 2017, BRG - ETH Zurich', __license__ = 'MIT' __email__ = '*****@*****.**' guids = rhino.select_points() vertices = rhino.get_point_coordinates(guids) faces = delaunay_from_points(vertices) mesh = Mesh.from_vertices_and_faces(vertices, faces) rhino.draw_mesh(mesh)