def test_vtk_icp(): source_file = os.path.join(data_dir(), 'wave1.off') target_file = os.path.join(data_dir(), 'wave2.off') output_file = os.path.join(tempfile.gettempdir(), 'wave.off') source_mesh = Mesh(source_file) target_mesh = Mesh(target_file) vtk_icp = VTKICP(source_mesh, target_mesh) points = vtk_icp.transform(source_mesh.points) new_mesh = Mesh(points, source_mesh.indices) new_mesh.write(output_file)
def test_vtk_icp(): source_file = os.path.join(data_dir(), 'wave1.off') target_file = os.path.join(data_dir(), 'wave2.off') output_file = os.path.join(tempfile.gettempdir(), 'wave.off') source_mesh = Mesh(source_file) target_mesh = Mesh(target_file) vtk_icp = VTKICP(source_mesh, target_mesh) points = vtk_icp.transform(source_mesh.points) new_mesh = Mesh(points, source_mesh.indices) new_mesh.write(output_file)
def test_triangle_mesh_icp(): source_file = os.path.join(data_dir(), 'wave1.off') target_file = os.path.join(data_dir(), 'wave2.off') output_file = os.path.join(tempfile.gettempdir(), 'wave.off') source_mesh = Mesh(source_file) target_mesh = Mesh(target_file) triangle_mesh_icp = TriangleMeshICP(source_mesh, target_mesh, rigid=True) points = triangle_mesh_icp.transform(source_mesh.points) new_mesh = Mesh(points, source_mesh.indices) new_mesh.write(output_file)
indices.append([i0, i2, i3]) indices.append([i0, i1, i2]) return Mesh(points, indices) if __name__ == '__main__': output_dir = os.path.join(os.path.dirname(__file__), '..', 'data') wave_file1 = os.path.join(output_dir, 'wave1.off') wave_file2 = os.path.join(output_dir, 'wave2.off') wave1 = generate_wave(0.1) wave2 = generate_wave(0.2) angle = numpy.pi / 6 rotation = numpy.zeros((3,3)) rotation[0, 0] = numpy.cos(angle) rotation[1, 1] = rotation[0, 0] rotation[0, 1] = -numpy.sin(angle) rotation[1, 0] = -rotation[0, 1] rotation[2, 2] = 1 new_points = [] for p in wave2.points: new_points.append(numpy.dot(rotation, p) + numpy.array([1, 0, 3])) wave2 = Mesh(new_points, wave2.indices) wave1.write(wave_file1) wave2.write(wave_file2)
indices.append([i0, i2, i3]) indices.append([i0, i1, i2]) return Mesh(points, indices) if __name__ == '__main__': output_dir = os.path.join(os.path.dirname(__file__), '..', 'data') wave_file1 = os.path.join(output_dir, 'wave1.off') wave_file2 = os.path.join(output_dir, 'wave2.off') wave1 = generate_wave(0.1) wave2 = generate_wave(0.2) angle = numpy.pi / 6 rotation = numpy.zeros((3, 3)) rotation[0, 0] = numpy.cos(angle) rotation[1, 1] = rotation[0, 0] rotation[0, 1] = -numpy.sin(angle) rotation[1, 0] = -rotation[0, 1] rotation[2, 2] = 1 new_points = [] for p in wave2.points: new_points.append(numpy.dot(rotation, p) + numpy.array([1, 0, 3])) wave2 = Mesh(new_points, wave2.indices) wave1.write(wave_file1) wave2.write(wave_file2)