Easy3D 2.5.3
surface_mesh_triangulation.h
1/********************************************************************
2 * Copyright (C) 2020-2021 by Liangliang Nan <liangliang.nan@gmail.com>
3 * Copyright (C) 2011-2020 the Polygon Mesh Processing Library developers.
4 *
5 * The code in this file is adapted from the PMP (Polygon Mesh Processing
6 * Library) with modifications.
7 * https://github.com/pmp-library/pmp-library
8 * The original code was distributed under a MIT-style license, see
9 * https://github.com/pmp-library/pmp-library/blob/master/LICENSE.txt
10 ********************************************************************/
11
12#ifndef EASY3D_ALGO_SURFACE_MESH_TRIANGULATION_H
13#define EASY3D_ALGO_SURFACE_MESH_TRIANGULATION_H
14
15
16#include <easy3d/core/surface_mesh.h>
17
18#include <vector>
19#include <cfloat>
20
21
22namespace easy3d {
23
32 public:
34
38 enum Objective { MIN_AREA, MAX_ANGLE};
39
41 void triangulate(Objective obj = MIN_AREA);
42
44 void triangulate(SurfaceMesh::Face f, Objective obj = MIN_AREA);
45
46 private:
47
48 // compute the weight of the triangle (i,j,k).
49 float compute_weight(int i, int j, int k) const;
50
51 // does edge (a,b) exist?
52 bool is_edge(SurfaceMesh::Vertex a, SurfaceMesh::Vertex b) const;
53
54 // add edges from vertex i to j
55 bool insert_edge(int i, int j);
56
57 private:
58 Objective objective_;
59
60 // mesh and properties
61 SurfaceMesh *mesh_;
63 std::vector<SurfaceMesh::Halfedge> halfedges_;
64 std::vector<SurfaceMesh::Vertex> vertices_;
65
66 // data for computing optimal triangulation
67 std::vector<std::vector<float> > weight_;
68 std::vector<std::vector<int> > index_;
69 };
70
71} // namespace easy3d
72
73
74#endif // EASY3D_ALGO_SURFACE_MESH_TRIANGULATION_H
Definition: surface_mesh.h:185
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
Triangulate a polygonal mesh into a pure triangle mesh.
Definition: surface_mesh_triangulation.h:31
void triangulate(Objective obj=MIN_AREA)
triangulate all faces
Definition: surface_mesh_triangulation.cpp:25
Objective
triangulation objective: find the triangulation that minimizes the sum of squared triangle areas,...
Definition: surface_mesh_triangulation.h:38
Definition: collider.cpp:182
Definition: surface_mesh.h:134
Definition: surface_mesh.h:104