Пример #1
0
mesh_quads_to_triangles(mesh)

# identify the fixed vertices
# by matching the coordinates of the selected points
# up to a precision

keys = mesh_identify_vertices(mesh, points, '1f')
fixed = set(keys)

# create a conduit for visualisation
# define a callback
# for updating the conduit
# and for pulling the mesh back to the original during remeshing
# and for keeping the boundary on the boundary curve

conduit = MeshConduit(mesh, refreshrate=2)


def callback(mesh, k, args):
    boundary = set(mesh.vertices_on_boundary())

    for key, attr in mesh.vertices(data=True):
        if key in fixed:
            continue

        if key in boundary:
            x, y, z = border.closest_point(mesh.vertex_coordinates(key))
            attr['x'] = x
            attr['y'] = y
            attr['z'] = z
        else:
Пример #2
0
    for key in mesh.vertices():
        if key in bound:
            pt = mesh.vertex_coordinates(key)
            pt_geo = geometric_key(pt, precision)
            # check if pt has same coordinates as any fixed point
            if pt_geo in pts_fixed_geo:
                mesh.set_vertex_attribute(key, 'fixed', True)
                fixed.append(key)
            else:
                # assign guid of closest curve to vertex
                mesh.set_vertex_attribute(
                    key, 'crv',
                    rs.PointClosestObject(pt, guid_crvs)[0])
        else:
            # assign surface guid to vertex
            mesh.set_vertex_attribute(key, 'srf', srf)

    # initialize conduit
    conduit = MeshConduit(mesh)

    # run smoothing with conduit
    with conduit.enabled():
        mesh_smooth_area(mesh,
                         fixed=fixed,
                         kmax=200,
                         damping=0.5,
                         callback=callback)

    artist = MeshArtist(mesh, layer='relaxed_mesh_on_surface')
    artist.draw()