Esempio n. 1
0
import rhinoscriptsyntax as rs

from compas.datastructures.mesh import Mesh
import compas_rhino as rhino

from compas_pattern.topology.pattern_operators import conway_ambo

from compas_pattern.cad.rhino.utilities import draw_mesh

mesh = rs.GetObject('mesh', filter=32)
mesh = rhino.mesh_from_guid(Mesh, mesh)

mesh = conway_ambo(mesh)

rs.EnableRedraw(False)
draw_mesh(mesh)
rs.EnableRedraw(True)
Esempio n. 2
0
# 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

target = RhinoMesh(guid_target)
border = RhinoCurve(guid_border)

# make a map of vertex coorindates
# with 1 float precision

gkey_key = {
                continue

            x, y, z = centroid_points(positions[index])
            vertex[0] = x
            vertex[1] = y
            vertex[2] = z

        if callback:
            callback(k, callback_args)
    
    return vertices



guid = rs.GetObject('get mesh')
mesh = rhino.mesh_from_guid(PseudoQuadMesh, guid)

vertices = []
key_to_index = {}
for i, vkey in enumerate(mesh.vertices()):
    vertices.append(mesh.vertex_coordinates(vkey))
    key_to_index[vkey] = i
faces = [[key_to_index[vkey] for vkey in mesh.face_vertices(fkey)] for fkey in fkeys]

fixed_vertices = [key_to_index[vkey] for vkey in mesh.vertices_on_boundary()]



new_vertices = planarize_faces(vertices, faces, fixed = fixed_vertices, kmax=100)

Esempio n. 4
0
import compas_rhino

from compas_rhino.conduits import LinesConduit
from compas_rhino.geometry import RhinoSurface

__author__ = ['Tom Van Mele', 'Matthias Rippmann']
__copyright__ = 'Copyright 2017, BRG - ETH Zurich',
__license__ = 'MIT'
__email__ = '*****@*****.**'

# make a mesh datastructure from a Rhino mesh object
# and select a target surface

guid = compas_rhino.select_mesh()
mesh = compas_rhino.mesh_from_guid(Mesh, guid)

guid = compas_rhino.select_surface()
surf = RhinoSurface(guid)

# extract the input for the smoothing algorithm from the mesh
# and identify the boundary as fixed

vertices = mesh.get_vertices_attributes('xyz')
faces = [mesh.face_vertices(fkey) for fkey in mesh.faces()]
adjacency = [mesh.vertex_faces(key, ordered=True) for key in mesh.vertices()]
fixed = set(mesh.vertices_on_boundary())

# make a conduit for visualization
# and a callback for updating the conduit
# and for pulling the free vertices back to the surface
        x, y, z = xyz[0]
        attr = mesh.vertex[vkey]
        attr['x'] = x
        attr['y'] = y
        attr['z'] = z


default_settings = {
    'dx': 15,
    'dy': 0,
    'density': 1,
    'pattern': 'seed',
    'smoothing iterations': 20,
    'smoothing damping': .5
}

primal_guid = rs.GetObject('primal mesh', filter=32)
primal = rhino.mesh_from_guid(Mesh, primal_guid)

curve_constraints = rs.GetObjects('curve constraits', filter=4)
if curve_constraints is None:
    curve_constraints = []
point_constraints = rs.GetObjects('point constraints', filter=1)
if point_constraints is None:
    point_constraints = []

rs.DeleteObjects(primal_guid)

editing_primal_dual(primal, default_settings, curve_constraints,
                    point_constraints)