54 void initialize(
float aspect_ratio = 0.0,
float edge_length = 0.0,
55 unsigned int max_valence = 0,
float normal_deviation = 0.0,
56 float hausdorff_error = 0.0);
62 void simplify(
unsigned int n_vertices);
99 : prio_(prio), pos_(pos) {
102 bool less(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) {
return prio_[v0] < prio_[v1]; }
104 bool greater(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) {
return prio_[v0] > prio_[v1]; }
106 int get_heap_position(SurfaceMesh::Vertex v) {
return pos_[v]; }
108 void set_heap_position(SurfaceMesh::Vertex v,
int pos) { pos_[v] = pos; }
111 SurfaceMesh::VertexProperty<float> prio_;
112 SurfaceMesh::VertexProperty<int> pos_;
119 Quadric(
double a,
double b,
double c,
double d,
120 double e,
double f,
double g,
123 : a_(a), b_(b), c_(c), d_(d),
129 explicit Quadric(
double a = 0.0,
double b = 0.0,
double c = 0.0,
double d = 0.0)
130 : a_(a * a), b_(a * b), c_(a * c), d_(a * d),
131 e_(b * b), f_(b * c), g_(b * d),
132 h_(c * c), i_(c * d),
136 Quadric(
const vec3 &n,
const vec3 &p) {
137 *
this = Quadric(n[0], n[1], n[2], -
dot(n, p));
141 void clear() { a_ = b_ = c_ = d_ = e_ = f_ = g_ = h_ = i_ = j_ = 0.0; }
144 Quadric &operator+=(
const Quadric &q) {
159 Quadric &operator*=(
double s) {
174 double operator()(
const vec3 &p)
const {
175 const double x(p[0]), y(p[1]), z(p[2]);
176 return a_ * x * x + 2.0 * b_ * x * y + 2.0 * c_ * x * z + 2.0 * d_ * x
177 + e_ * y * y + 2.0 * f_ * y * z + 2.0 * g_ * y
178 + h_ * z * z + 2.0 * i_ * z
184 double a_, b_, c_, d_,
196 NormalCone() =
default;
199 explicit NormalCone(
const vec3 &normal,
float angle = 0.0)
200 : center_normal_(normal), angle_(angle) {
204 const vec3 ¢er_normal()
const {
return center_normal_; }
207 float angle()
const {
return angle_; }
210 NormalCone &merge(
const vec3 &n) {
return merge(NormalCone(n)); }
213 NormalCone &merge(
const NormalCone &nc) {
214 const float dp =
dot(center_normal_, nc.center_normal_);
218 angle_ = std::max(angle_, nc.angle_);
222 else if (dp < -0.99999) {
223 angle_ =
static_cast<float>(2 * M_PI);
226 float center_angle = std::acos(dp);
227 float min_angle = std::min(-angle_, center_angle - nc.angle_);
228 float max_angle = std::max(angle_, center_angle + nc.angle_);
229 angle_ = 0.5f * (max_angle - min_angle);
232 float axis_angle = 0.5f * (min_angle + max_angle);
233 center_normal_ = ((center_normal_ * std::sin(center_angle - axis_angle) +
234 nc.center_normal_ * std::sin(axis_angle)) /
235 std::sin(center_angle));
246 typedef Heap<SurfaceMesh::Vertex, HeapInterface> PriorityQueue;
248 typedef std::vector<vec3> Points;
252 void enqueue_vertex(SurfaceMesh::Vertex v);
255 bool is_collapse_legal(
const CollapseData &cd);
258 float priority(
const CollapseData &cd);
261 void postprocess_collapse(
const CollapseData &cd);
264 float aspect_ratio(SurfaceMesh::Face f)
const;
267 float distance(SurfaceMesh::Face f,
const vec3 &p)
const;
274 SurfaceMesh::VertexProperty<float> vpriority_;
275 SurfaceMesh::VertexProperty<SurfaceMesh::Halfedge> vtarget_;
276 SurfaceMesh::VertexProperty<int> heap_pos_;
277 SurfaceMesh::VertexProperty<Quadric> vquadric_;
278 SurfaceMesh::FaceProperty<NormalCone> normal_cone_;
279 SurfaceMesh::FaceProperty<Points> face_points_;
281 SurfaceMesh::VertexProperty<vec3> vpoint_;
282 SurfaceMesh::FaceProperty<vec3> fnormal_;
283 SurfaceMesh::VertexProperty<bool> vselected_;
284 SurfaceMesh::VertexProperty<bool> vfeature_;
285 SurfaceMesh::EdgeProperty<bool> efeature_;
287 PriorityQueue *queue_;
291 float normal_deviation_;
292 float hausdorff_error_;
295 unsigned int max_valence_;
void initialize(float aspect_ratio=0.0, float edge_length=0.0, unsigned int max_valence=0, float normal_deviation=0.0, float hausdorff_error=0.0)
Initialize with given parameters.
Definition surface_mesh_simplification.cpp:42