Esempio n. 1
0
    vertices[key][2] -= dz
    fixed.append(key)

# make a conduit for visualisation

edges = list(mesh.edges())
lines = [[vertices[u], vertices[v]] for u, v in edges]

conduit = LinesConduit(lines, refreshrate=5)

# run the smoothing algorithm
# update the mesh
# and display the results

with conduit.enabled():
    smooth_area(vertices,
                faces,
                adjacency,
                fixed=fixed,
                kmax=100,
                callback=callback)

for key, attr in mesh.vertices(True):
    attr['x'] = vertices[key][0]
    attr['y'] = vertices[key][1]
    attr['z'] = vertices[key][2]

artist = MeshArtist(mesh)
artist.draw_faces(join_faces=True)
artist.redraw()
Esempio n. 2
0
    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 = [key for key in mesh.vertices() if mesh.vertex_degree(key) == 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,
        })

    smooth_area(vertices, faces, adjacency, fixed=fixed, kmax=100)

    for key, attr in mesh.vertices(True):
        attr['x'] = vertices[key][0]
        attr['y'] = vertices[key][1]
        attr['z'] = vertices[key][2]

    plotter = MeshPlotter(mesh)

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

    plotter.show()