コード例 #1
0
ファイル: mesh-remeshing.py プロジェクト: yijiangh/compas
# 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
# and a callback for updating the conduit

conduit = MeshConduit(mesh, refreshrate=2)


def callback(mesh, k, args):
    conduit.redraw(k)


# 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)

compas_rhino.mesh_draw(
    mesh, vertexcolor={key: '#ff0000'
                       for key in mesh.vertices_on_boundary()})
コード例 #2
0
import compas
import compas_rhino

from compas.datastructures import Mesh

__author__ = [
    'Tom Van Mele',
]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__ = 'MIT License'
__email__ = '*****@*****.**'

mesh = Mesh.from_ply(compas.get('stanford_armadillo.ply'))

compas_rhino.mesh_draw(mesh)
コード例 #3
0
def mesh_identify_vertices(mesh, points, precision=None):
    keys = []
    gkey_key = {
        geometric_key(mesh.vertex_coordinates(key), precision): key
        for key in mesh.vertices()
    }
    for xyz in points:
        gkey = geometric_key(xyz, precision)
        if gkey in gkey_key:
            key = gkey_key[gkey]
            keys.append(key)
    return keys


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas
    from compas.datastructures import Mesh
    from compas_rhino import mesh_draw
    from compas_rhino import mesh_select_vertex
    from compas_rhino import mesh_move_vertex

    mesh = Mesh.from_obj(compas.get_data('quadmesh_planar.obj'))

    mesh_draw(mesh, layer='test', clear_layer=True)
コード例 #4
0
            attr['x'] = x
            attr['y'] = y
            attr['z'] = z
        else:
            x, y, z = target.closest_point(mesh.vertex_coordinates(key))
            attr['x'] = x
            attr['y'] = y
            attr['z'] = z
    conduit.redraw(k)


# 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)


compas_rhino.mesh_draw(mesh, layer='remeshed', clear_layer=True)