def save(self, file_name): self.update() vtk_u.save_polydata(self.__polydata__, file_name)
# 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) """
end_vertices = mesh.positive_mass_stiffness_smooth( nb_iter=args.nb_step, diffusion_step=step_size, flow_file=args.flow_file) end_mesh = TriMesh_Vtk(mesh.get_triangles(), end_vertices) print "saving surface tracking ..." flow = np.memmap(args.flow_file, dtype=np.float64, mode='r', shape=(args.nb_step, end_vertices.shape[0], end_vertices.shape[1])) if args.tracking is not None: lines = compress_streamlines(np.swapaxes(flow, 0, 1)) lines_polydata = lines_to_vtk_polydata(lines, None, np.float32) save_polydata(lines_polydata, args.tracking, True) # save if args.end_points is not None: # save only not masked points if args.mask is not None: np.save(args.end_points, end_vertices[mask]) else: np.save(args.end_points, end_vertices) if args.end_normal is not None: end_normal = end_mesh.vertices_normal(args.ed_not_normed, args.ed_not_weighted) # save only not masked points if args.mask is not None: