示例#1
0
 def smooth(self, fixed, kmax=10):
     mesh_smooth_area(self, fixed=fixed, kmax=kmax)
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()
示例#3
0
             [[2.3511410091698921, -3.2360679774997898, 0.0],
              [3.5267115137548384, -4.8541019662496847, 2.0]],
             [[2.3511410091698921, -3.2360679774997898, 0.0],
              [3.5267115137548384, -4.8541019662496847, -2.0]],
             [[3.8042260651806146, 1.2360679774997889, 0.0],
              [5.7063390977709219, 1.8541019662496834, 2.0]],
             [[3.8042260651806146, 1.2360679774997889, 0.0],
              [5.7063390977709219, 1.8541019662496834, -2.0]],
             [[0.0, 4.0, 0.0], [-3.8042260651806141, 1.2360679774997898, 0.0]],
             [[-3.8042260651806141, 1.2360679774997898, 0.0],
              [-2.351141009169893, -3.2360679774997894, 0.0]],
             [[-2.351141009169893, -3.2360679774997894, 0.0],
              [2.3511410091698921, -3.2360679774997898, 0.0]],
             [[2.3511410091698921, -3.2360679774997898, 0.0],
              [3.8042260651806146, 1.2360679774997889, 0.0]],
             [[3.8042260651806146, 1.2360679774997889, 0.0], [0.0, 4.0, 0.0]]]
    #lines = [[[0.0, 4.0, 0.0], [0.0, 6.0, 2.0]], [[0.0, 4.0, 0.0], [0.0, 6.0, -2.0]], [[-3.8042260651806141, 1.2360679774997898, 0.0], [-5.706339097770921, 1.8541019662496847, 2.0]], [[-3.8042260651806141, 1.2360679774997898, 0.0], [-5.706339097770921, 1.8541019662496847, -2.0]], [[-2.351141009169893, -3.2360679774997894, 0.0], [-3.5267115137548393, -4.8541019662496838, 2.0]], [[-2.351141009169893, -3.2360679774997894, 0.0], [-3.5267115137548393, -4.8541019662496838, -2.0]], [[2.3511410091698921, -3.2360679774997898, 0.0], [3.5267115137548384, -4.8541019662496847, 2.0]], [[2.3511410091698921, -3.2360679774997898, 0.0], [3.5267115137548384, -4.8541019662496847, -2.0]], [[3.8042260651806146, 1.2360679774997889, 0.0], [5.7063390977709219, 1.8541019662496834, 2.0]], [[3.8042260651806146, 1.2360679774997889, 0.0], [5.7063390977709219, 1.8541019662496834, -2.0]], [[0.0, 4.0, 0.0], [-3.8042260651806141, 1.2360679774997898, 0.0]], [[-3.8042260651806141, 1.2360679774997898, 0.0], [-2.351141009169893, -3.2360679774997894, 0.0]], [[-2.351141009169893, -3.2360679774997894, 0.0], [2.3511410091698921, -3.2360679774997898, 0.0]], [[2.3511410091698921, -3.2360679774997898, 0.0], [3.8042260651806146, 1.2360679774997889, 0.0]], [[3.8042260651806146, 1.2360679774997889, 0.0], [0.0, 4.0, 0.0]], [[-2.351141009169893, -3.2360679774997894, 0.0], [0.0, 0.0, 3.0]], [[-2.351141009169893, -3.2360679774997894, 0.0], [0.0, 0.0, -3.0]], [[2.3511410091698921, -3.2360679774997902, 0.0], [0.0, 0.0, 3.0]], [[3.8042260651806146, 1.2360679774997887, 0.0], [0.0, 0.0, 3.0]], [[8.8817841970012523e-16, 3.9999999999999996, 0.0], [0.0, 0.0, 3.0]], [[-3.8042260651806137, 1.2360679774997911, 0.0], [0.0, 0.0, 3.0]], [[2.3511410091698921, -3.2360679774997902, 0.0], [0.0, 0.0, -3.0]], [[3.8042260651806146, 1.2360679774997887, 0.0], [0.0, 0.0, -3.0]], [[8.8817841970012523e-16, 3.9999999999999996, 0.0], [0.0, 0.0, -3.0]], [[-3.8042260651806137, 1.2360679774997911, 0.0], [0.0, 0.0, -3.0]], [[0.0, 0.0, -3.0], [0.0, 0.0, -5.0]], [[0.0, 0.0, 5.0], [0.0, 0.0, 3.0]]]

    mesh = trimesh_skeleton(Kagome, lines, radius=2)
    mesh = trimesh_subdivide_loop(mesh, k=3)
    mesh = mesh_conway_ambo(mesh)
    fixed = [vkey for bdry in mesh.vertices_on_boundaries() for vkey in bdry]
    mesh_smooth_area(mesh, fixed=fixed, kmax=50, damping=0.5)
    viewer = App()
    #for fkey in mesh.singularities():
    #	viewer.add(Point(*mesh.face_centroid(fkey)))
    vertices, faces = mesh.to_vertices_and_faces()
    mesh = Mesh.from_vertices_and_faces(vertices, faces)
    viewer.add(mesh, show_edges=True)
    viewer.run()
import compas

from compas.datastructures import Mesh
from compas.datastructures import mesh_smooth_area
from compas_plotters import MeshPlotter

mesh = Mesh.from_obj(compas.get('faces.obj'))
fixed = [key for key in mesh.vertices() if mesh.vertex_degree(key) == 2]

mesh_smooth_area(mesh, fixed=fixed)

plotter = MeshPlotter(mesh)

plotter.draw_vertices(facecolor={key: '#ff0000' for key in fixed})
plotter.draw_faces()
plotter.draw_edges()

plotter.show()
示例#5
0
    import compas

    from compas.datastructures import Mesh
    from compas.datastructures import mesh_smooth_area

    from compas.plotters import MeshPlotter

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    fixed = list(mesh.vertices_where({'vertex_degree': 2}))

    lines = []
    for u, v in mesh.edges():
        lines.append({
            'start': mesh.vertex_coordinates(u, 'xy'),
            'end': mesh.vertex_coordinates(v, 'xy'),
            'color': '#cccccc',
            'width': 1.0,
        })

    mesh_smooth_area(mesh, fixed=fixed, kmax=100)

    plotter = MeshPlotter(mesh, figsize=(10, 7))

    plotter.draw_lines(lines)
    plotter.draw_vertices(facecolor={key: '#ff0000' for key in fixed})
    plotter.draw_edges()

    plotter.show()