Пример #1
0
# Test parameters
nb_step = 10
diffusion_step = 10
saved_flow = trimeshpy.data.output_test_flow
saved_fib = trimeshpy.data.output_test_fib

# Test functions
start = time.time()
#points = tri_mesh_flow.laplacian_smooth(nb_step, diffusion_step, l2_dist_weighted=False, area_weighted=False, backward_step=False, flow_file=saved_flow)
#points = tri_mesh_flow.curvature_normal_smooth(nb_step, diffusion_step, area_weighted=True, backward_step=True, flow_file=saved_flow)
#points = tri_mesh_flow.positive_curvature_normal_smooth(nb_step, diffusion_step, area_weighted=True, backward_step=True, flow_file=saved_flow)
points = tri_mesh_flow.mass_stiffness_smooth(nb_step, diffusion_step, flow_file=saved_flow)
#points = tri_mesh_flow.positive_mass_stiffness_smooth(nb_step, diffusion_step, flow_file=saved_flow)
#points = tri_mesh_flow.volume_mass_stiffness_smooth(nb_step, diffusion_step, flow_file=saved_flow)
stop = time.time()
print (stop - start)

lines = np.memmap(saved_flow, dtype=np.float64, mode='r', shape=(nb_step, vertices.shape[0], vertices.shape[1]))
tri_mesh_flow.set_vertices_flow(np.array(lines))
tri_mesh_flow.display(display_name="Trimeshpy: Flow resulting surface")
tri_mesh_flow.display_vertices_flow(display_name="Trimeshpy: Flow visualization")

"""
### save fibers in .fib normal
#line_to_save = streamline.compress_streamlines(np.swapaxes(lines, 0, 1))
line_to_save = np.swapaxes(lines, 0, 1)
lines_polydata = lines_to_vtk_polydata(line_to_save, None, np.float32)
save_polydata(lines_polydata, saved_fib, True)
"""
brain_file_name = "../data/brain_mesh/100307_smooth_lh.vtk"


# Init Sphere
s_mesh = TriMesh_Vtk(sphere_file_name, 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()

# Umbrella sphere
sphere_tmf.laplacian_smooth(100, 1, l2_dist_weighted=False, area_weighted=False, backward_step=False, flow_file=saved_flow)
sphere_tmf.set_vertices_flow_from_memmap(saved_flow, 100, 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(100, 1, l2_dist_weighted=True, area_weighted=False, backward_step=False, flow_file=saved_flow)
sphere_tmf.set_vertices_flow_from_memmap(saved_flow, 100, s_vshape0)
sphere_tmf.display()
sphere_tmf.display_vertices_flow()

# L2 weighted implicit step
sphere_tmf.set_vertices_flow(s_mesh.get_vertices())
sphere_tmf.laplacian_smooth(100, 1, l2_dist_weighted=True, area_weighted=False, backward_step=True, flow_file=saved_flow)
sphere_tmf.set_vertices_flow_from_memmap(saved_flow, 100, s_vshape0)
sphere_tmf.display()
sphere_tmf.display_vertices_flow()
Пример #3
0
# 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,
                            l2_dist_weighted=True,
                            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 implicit step