if voxel_space[0] != 'L': new_vertice[:,0] = -new_vertice[:,0] if voxel_space[1] != 'P': new_vertice[:,1] = -new_vertice[:,1] if voxel_space[2] != 'S': new_vertice[:,2] = -new_vertice[:,2] mesh.set_vertices(new_vertice) if args.fx or args.fy or args.fz: flip = [-1 if args.fx else 1, -1 if args.fy else 1, -1 if args.fz else 1] print "flip:", flip f_triangles, f_vertices = mesh.flip_triangle_and_vertices(flip) mesh.set_vertices(f_vertices) mesh.set_triangles(f_triangles) # smooth if args.smooth is not None: new_vertice = mesh.laplacian_smooth(1, args.smooth, l2_dist_weighted=False, area_weighted=False, backward_step=True) mesh.set_vertices(new_vertice) if args.out_surface is not None: mesh.save(args.out_surface) # view if args.v: mesh.update_polydata() mesh.update_normals() mesh.display()
#file_name = "Raihaan/civet_obj_stl/stosurf_S1-A1_T1_white_surface_rsl_right_calibrated_81920.stl" #file_name = "brain_mesh/white_rsl_smooth_test.ply" #file_name = "surf_vtk/lhwhite_fsT.vtk" #file_name = "brain_mesh/rhwhiteRAS_LPS_smooth.vtk" #file_name = "brain_mesh/lh_white.vtk" #file_name = "s1a1/lh_white.vtk" #file_name = "brain_mesh/prefix_100307_white_surface.obj" #file_name = "brain_mesh/prefix_100307_mid_surface.obj" #file_name = "hcp/t1000_01/hcp_test_smooth_rh.vtk" mesh = TriMesh_Vtk(file_name, None) triangles = mesh.get_triangles() vertices = mesh.get_vertices() mesh.display() """ from scipy.spatial import Delaunay # Triangulate parameter space to determine the triangles #tri = mtri.Triangulation(u, v) tri = Delaunay(vertices) delaunay_triangles = np.vstack((tri.simplices[:,0:3], np.roll(tri.simplices,2,axis=1)[:,0:3])) mesh.set_triangles(tri.simplices[:,0:3]) mesh.display() """ """ #pre-smooth vertices = mesh.laplacian_smooth(2, 5.0, l2_dist_weighted=False, area_weighted=False, backward_step=True, flow_file=None)