def ds_from_filelist(filelist): meshes = [] mesheslist = [] for file in filelist: meshes.append(MeshFactory.mesh_from_file(file)) mesheslist.append(meshes) return (DatasetCollection(datasets=mesheslist))
def ds_from_dir(dir_path, center_scale=False): c = [join(dir_path, x) for x in listdir(dir_path)] files = [ f for f in c if isfile(f) and splitext(f)[1] in DatasetFactory.__ftypes ] if not files: msg = 'No appropriate files were found in ' + dir_path raise OSError(msg) meshes = [] mesheslist = [] for file in files: meshes.append(MeshFactory.mesh_from_file(file, center_scale)) mesheslist.append(meshes) return (DatasetCollection(datasets=mesheslist))
from auto3dgm.mesh.meshfactory import MeshFactory #Another test for the off files: #Setup: There is a valid off file tooth.off a=MeshFactory.mesh_from_file("tooth.off") """ <class 'vtkCommonDataModelPython.vtkPolyData'> """ a.vertices """ array([[ 23.1074, 12.3061, 44.2893], [ 23.1281, 12.3142, 44.2809], [ 23.1233, 12.296 , 44.2963], ..., [ 22.2795, 14.2197, 47.1709], [ 22.2679, 14.236 , 47.1686], [ 22.232 , 14.2798, 47.163 ]]) """ # This fails currently, but is not a show stopper a.faces """ array([], shape=(0, 3), dtype=float64) """
from auto3dgm.mesh.meshfactory import MeshFactory filestring='../fixtures/int_vertex_super_simple.ply' m = MeshFactory.mesh_from_file(filestring) print(m) print(m.vertices) print(m.faces) """ Print output should look like this: <class 'vtkCommonDataModelPython.vtkPolyData'> <auto3dgm.mesh.mesh.Mesh object at 0x10f8c85f8> [[0. 1. 2.] [1. 2. 3.] [2. 3. 4.] [3. 4. 5.] [4. 5. 6.] [5. 6. 7.]] [[0 1 2] [0 2 3] [4 5 6]] """
def ds_from_meshdata(vertices, faces, deep=True): for i in range(0, len(vertices)): meshes.append( MeshFactory.mesh_from_data(vertices[i], faces[i], deep)) mesheslist.append(meshes) return (DatasetCollection(datasets=mesheslist))
def print_polyfaces(polydata): cell_n = polydata.GetNumberOfCells() point_n = polydata.GetCell(1).GetNumberOfPoints() faces_new = zeros((cell_n, point_n), dtype=int) for i in range(cell_n): print('cell/polygon ' + str(i)) for j in range(point_n): print(polydata.GetCell(i).GetPointId(j)) vertices = array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [2, 2, 1]], dtype=int) faces = array([[0, 1, 2], [1, 2, 3], [1, 3, 4], [2, 3, 0]], dtype=int) mesh = MeshFactory.mesh_from_data(vertices, faces, False) print(mesh) print(mesh.vertices) print(mesh.faces) """ Print output should look like this: <auto3dgm.mesh.mesh.Mesh object at 0x1048962b0> [[0. 0. 0.] [1. 0. 0.] [1. 1. 0.] [0. 1. 0.] [2. 2. 1.]] [[0 1 2] [1 2 3]
array([[ 1.38777878e-16, 1.00000000e+00, 2.49800181e-16], [ -1.11022302e-16, -3.60822483e-16, 1.00000000e+00], [ 1.00000000e+00, -1.38777878e-17, 1.66533454e-16]])) ''' print(AA[1]) ''' Out[40]: array([[ 4.49640325e-15, 1.00000000e+00, -3.87190280e-15], [ -3.94129174e-15, 3.94129174e-15, 1.00000000e+00], [ 1.00000000e+00, -4.38538095e-15, 4.21884749e-15]]) ''' # So the alignment works as expected. However, when we integrate the mesh class: mesh1=MeshFactory.mesh_from_data(A) mesh2=MeshFactory.mesh_from_data(B) BB=Correspondence.best_pairwise_PCA_alignment(mesh1, mesh2,0) print(BB) ''' Out[45]: (array([3, 1, 2, 0]), array([[ 0.18660992, -0.95001991, -0.25027765], [ 0.02395067, -0.25027765, 0.96787781], [ 0.9821421 , 0.18660992, 0.02395067]])) ''' AA=Correspondence.locgpd(mesh1,mesh2,0,0,5,0) print(AA[1])
from auto3dgm.mesh.meshfactory import MeshFactory from auto3dgm.mesh.subsample import Subsample from numpy import array vertices = array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [2, 2, 1]]) seed = vertices[[1, 4]] mesh = MeshFactory.mesh_from_data(vertices) submesh_noseed = Subsample.far_point_subsample(mesh, 4) print(submesh_noseed) print(submesh_noseed.vertices) print(submesh_noseed.faces) submesh_seed = Subsample.far_point_subsample(mesh, 4, seed) print(submesh_seed) print(submesh_seed.vertices) print(submesh_seed.faces) """ Print results for first set will be random, but second set will be stable Print results should look something like this: <auto3dgm.mesh.mesh.Mesh object at 0x117cd5518> [[0 0 0] [2 2 1] [1 1 0] [1 0 0]] [] <auto3dgm.mesh.mesh.Mesh object at 0x10f5e31d0> [[1 0 0]