示例#1
0
from __future__ import print_function

import compas_rhino

from compas.datastructures import Mesh
from compas.geometry import smooth_area

from compas_rhino.helpers import mesh_from_guid
from compas_rhino.geometry import RhinoSurface
from compas_rhino.artists import MeshArtist


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

guid = compas_rhino.select_mesh()
mesh = 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())

示例#2
0
文件: mesh.py 项目: itaycsguy/compas
 def from_selection(cls):
     guid = compas_rhino.select_mesh()
     return cls(guid)
示例#3
0
            attr['y'] = y
            attr['z'] = z

    conduit.redraw(k)


# 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)
__copyright__ = 'Copyright 2017, BRG - ETH Zurich',
__license__   = 'MIT'
__email__     = '*****@*****.**'


def callback(mesh, k, args):
    conduit, surf, fixed = args

    # pull the not fixed points back to the target surface
    surf.pull_mesh(mesh, fixed=fixed)

    # update the conduit
    conduit.redraw(k)


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

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

fixed = mesh.vertices_on_boundary()

conduit = MeshConduit(mesh, color=(255, 255, 255), refreshrate=2)

with conduit.enabled():
    smooth_mesh_area(mesh,
                     fixed,
                     kmax=100,
                     callback=callback,
                     callback_args=(conduit, surf, fixed))