12#ifndef EASY3D_ALGO_SURFACE_MESH_GEODESIC_H
13#define EASY3D_ALGO_SURFACE_MESH_GEODESIC_H
15#include <easy3d/core/surface_mesh.h>
51 unsigned int compute(
const std::vector<SurfaceMesh::Vertex> &seed,
52 float max_dist = FLT_MAX,
53 unsigned int max_num = INT_MAX,
54 std::vector<SurfaceMesh::Vertex> *neighbors =
nullptr);
76 bool operator()(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1)
const {
77 return ((dist_[v0] == dist_[v1]) ? (v0 < v1)
78 : (dist_[v0] < dist_[v1]));
82 const SurfaceMesh::VertexProperty<float> &dist_;
86 typedef std::set<SurfaceMesh::Vertex, VertexCmp> PriorityQueue;
90 VirtualEdge(SurfaceMesh::Vertex v,
float l) : vertex(v),
length(l) {}
92 SurfaceMesh::Vertex vertex;
97 typedef std::map<SurfaceMesh::Halfedge, VirtualEdge> VirtualEdges;
100 void find_virtual_edges();
102 unsigned int init_front(
const std::vector<SurfaceMesh::Vertex> &seed,
103 std::vector<SurfaceMesh::Vertex> *neighbors);
105 unsigned int propagate_front(
float max_dist,
unsigned int max_num,
106 std::vector<SurfaceMesh::Vertex> *neighbors);
108 void heap_vertex(SurfaceMesh::Vertex v);
110 float distance(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1, SurfaceMesh::Vertex v2,
float r0 = FLT_MAX,
116 bool use_virtual_edges_;
117 VirtualEdges virtual_edges_;
119 PriorityQueue *front_;
121 SurfaceMesh::VertexProperty<float> distance_;
122 SurfaceMesh::VertexProperty<bool> processed_;
This class computes geodesic distance from a set of seed vertices.
Definition: surface_mesh_geodesic.h:31
float operator()(SurfaceMesh::Vertex v) const
Access the computed geodesic distance.
Definition: surface_mesh_geodesic.h:62
void distance_to_texture_coordinates()
Use the normalized distances as texture coordinates.
Definition: surface_mesh_geodesic.cpp:387
unsigned int compute(const std::vector< SurfaceMesh::Vertex > &seed, float max_dist=FLT_MAX, unsigned int max_num=INT_MAX, std::vector< SurfaceMesh::Vertex > *neighbors=nullptr)
Compute geodesic distances from specified seed points.
Definition: surface_mesh_geodesic.cpp:134
SurfaceMeshGeodesic(SurfaceMesh *mesh, bool use_virtual_edges=true)
Construct from mesh.
Definition: surface_mesh_geodesic.cpp:17
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
Definition: collider.cpp:182
T length(const Vec< N, T > &v)
Computes the length/magnitude of a vector.
Definition: vec.h:289
Definition: surface_mesh.h:104