def test_exact_geodesic(self): vs = np.array([0], dtype=self.f1.dtype) vt = np.arange(self.v1.shape[0]) vt = vt.astype(self.f1.dtype) # TODO as type should be here d = igl.exact_geodesic(self.v1, self.f1, vs, vt) self.assertEqual(d.dtype, self.v1.dtype)
def _get_geo_dist(vertices, faces, lib, source: int): """ Computing exact geodesic distances between source and all other vertices of the mesh Parameters: source: int - index of the source vertex Returns: geo_dist: np.ndarray - geodesic distances """ assert lib in ('gdist', 'igl') targets = np.arange(source, len(vertices), dtype=np.int32) source = np.array([source], dtype=np.int32) if lib == 'gdist': distances = gdist.compute_gdist(vertices, faces, source_indices=source, target_indices=targets) else: distances = igl.exact_geodesic(vertices, faces, vs=source, vt=targets) return distances
def compute_geodesic_to_every_vertex(self, mesh, vertices_start): v, f = mesh.to_vertices_and_faces() v = np.array(v) f = np.array(f) vertices_target = np.arange(len(v)) # all vertices are targets vstart = np.array(vertices_start) distances = igl.exact_geodesic(v, f, vstart, vertices_target) return distances
def compute_geodesic_from_start_to_target_vkeys(self, mesh, start_v_keys_list, target_v_keys_list): v, f = mesh.to_vertices_and_faces() v = np.array(v) f = np.array(f) vertices_start = np.array(start_v_keys_list) vertices_target = np.array(target_v_keys_list) distances = igl.exact_geodesic(v, f, vertices_start, vertices_target) return distances
def compute_geodesic_from_start_to_target_vkeys(mesh, start_v_keys_list, target_v_keys_list): """ compute distances from one edges to another edge and get longest way and shortest way """ v, f = mesh.to_vertices_and_faces() v = np.array(v) f = np.array(f) vertices_start = np.array(start_v_keys_list) vertices_target = np.array(target_v_keys_list) distances = igl.exact_geodesic(v, f, vertices_start, vertices_target) return distances
def compute_geodesic_to_every_vertex(mesh, vertices_start): """ compute distances from sevelral vertices to all vertices of the mesh vertices are described with keys """ v, f = mesh.to_vertices_and_faces() v = np.array(v) f = np.array(f) vertices_target = np.arange(len(v)) # all vertices are targets vstart = np.array(vertices_start) distances = igl.exact_geodesic(v, f, vstart, vertices_target) return distances
def get_igl_EXACT_geodesic_distances(mesh, vertices_start): """ Calculate geodesic distances using libigl. Parameters ---------- mesh: :class: 'compas.datastructures.Mesh' vertices_start: list, int """ utils.check_package_is_installed('igl') import igl v, f = mesh.to_vertices_and_faces() v = np.array(v) f = np.array(f) vertices_target = np.arange(len(v)) # all vertices are targets vstart = np.array(vertices_start) distances = igl.exact_geodesic(v, f, vstart, vertices_target) return distances
def run(self): if not self.copyData(): return if self.geo.getNumFaces() == 0 or self.geo.getNumVertexes() == 0: return start_index = self.get_property("Start Point") if start_index >= self.geo.getNumVertexes(): return mesh = self.geo.getTriangulateMesh() v = mesh.points() f = mesh.face_vertex_indices() vs = np.array([start_index]) vt = np.arange(v.shape[0]) d = igl.exact_geodesic(v, f, vs, vt) if self.get_property("Normalize"): d /= np.max(d) self.geo.setVertexAttribData(self.get_property("Attribute Name"), d, attribType='float', defaultValue=0.0)
def test_read_triangle_mesh_type_issue(self): v, f = igl.read_triangle_mesh(self.test_path + "face.obj") vs = np.array([0], dtype = f.dtype) vt = np.arange(v.shape[0], dtype = f.dtype) d = igl.exact_geodesic(v, f, vs, vt)