Пример #1
0
def flow_trajectories(vertices, triangles, flow_file, steps=10, timestep=5):
    """
    Compute the positive mass stiffness surface flow of a surface mesh.

    Parameters:
    - - - - -
    vertices: float array
        list of vertices in mesh
    triangles: int array
        list of faces in mesh
    flow_file: string
        file (memory map) in which to save flow lines
    steps: int
        number of diffusion steps
    timestep: int
        diffusion time
    """

    # initialize flow object
    tri_mesh_flow = TriMeshFlow_Vtk(triangles, vertices)
    # compute final flow surface
    points = tri_mesh_flow.positive_mass_stiffness_smooth(steps,
                                                          timestep,
                                                          flow_file=flow_file)
    # get flow trajectory for each mesh vertex
    flow_lines = tri_mesh_flow.get_vertices_flow()

    return flow_lines
Пример #2
0
                    help='Output base name.',
                    required=True,
                    type=str)

args = parser.parse_args()

# Load surface file
surface = nb.load(args.surface)
vertices = surface.darrays[0].data
triangles = surface.darrays[1].data

# Get diffusion step parameters
nb_step = args.diffusion_steps
nb_size = args.diffusion_size

tri_mesh_flow = TriMeshFlow_Vtk(triangles, vertices)

saved_flow = trimeshpy.data.output_test_flow
saved_fib = trimeshpy.data.output_test_fib

out_base = args.output_base
dat_file = ''.join([out_base, '.lines.dat'])
points = tri_mesh_flow.positive_mass_stiffness_smooth(nb_step,
                                                      nb_size,
                                                      flow_file=dat_file)

lines = np.memmap(dat_file,
                  dtype=np.float64,
                  mode='r',
                  shape=(nb_step, vertices.shape[0], vertices.shape[1]))
Пример #3
0
# by Etienne St-Onge

import trimeshpy
from trimeshpy.trimesh_vtk import TriMesh_Vtk
from trimeshpy.trimeshflow_vtk import TriMeshFlow_Vtk

# Init Sphere
s_mesh = TriMesh_Vtk(trimeshpy.data.sphere, None)
s_vshape0 = s_mesh.get_nb_vertices()

# Display sphere
sphere_tmf = TriMeshFlow_Vtk(s_mesh.get_triangles(), s_mesh.get_vertices())
sphere_tmf.display()
NB_STEP_SPHERE = 100

# Umbrella sphere
sphere_tmf.laplacian_smooth(NB_STEP_SPHERE,
                            1,
                            l2_dist_weighted=False,
                            area_weighted=False,
                            backward_step=False,
                            flow_file=trimeshpy.data.output_test_flow)
sphere_tmf.set_vertices_flow_from_memmap(trimeshpy.data.output_test_flow,
                                         NB_STEP_SPHERE, s_vshape0)
sphere_tmf.display()
sphere_tmf.display_vertices_flow()

# L2 weighted
sphere_tmf.set_vertices_flow(s_mesh.get_vertices())
sphere_tmf.laplacian_smooth(NB_STEP_SPHERE,
                            1,