-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcel-manifold.h
138 lines (95 loc) · 3.49 KB
/
dcel-manifold.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#pragma once
#include "dcel.h"
namespace dcel
{
class manifold
{
public:
manifold() = default;
~manifold();
using Pointer = std::shared_ptr<manifold>;
vertex_ptr add_vertex(glm::vec3 pos);
face_ptr add_face(const std::vector<vertex_ptr>& verts);
void pair_edges(face_ptr fb);
int print_build();
int build();
/* Generate edge indices from the manifold*/
std::vector<uint32_t> generate_edge_indices();
/* Rotate triangle onto z-plane */
void rotate_triangle_x_plane(glm::vec3& a, glm::vec3& b, glm::vec3& c);
/* Project point to plane */
glm::vec3 plane_projection(const glm::vec3& target, const glm::vec3& normal);
/* Determine the best-fit plane given a set points */
plane_ptr best_plane_from_points(const face_ptr& face);
/* Generate vertex indices from the manifold */
std::vector<uint32_t> generate_face_indices();
/* Generate vertices from the manifold*/
std::vector<vertex_attr> generate_vertices();
/* Contruct edge from vertex and face */
edge_ptr construct_edge(vertex_ptr vert, face_ptr face);
/* Calculate vertex normals from face */
void calculate_normals(face_ptr f);
/* Calculate tangent basis */
void calculate_tangent_basis();
/* Insert face */
std::size_t insert_face(const std::vector<std::size_t>& v);
/* Insert vertices */
std::size_t insert_vertex(glm::vec3 pos);
/* Get the list of interior vertices in insertion order */
std::vector<vertex_ptr> vertices_interior();
/* Get the list of boundary vertices in insertion order */
std::vector<vertex_ptr> vertices_boundary();
/* Get the list of edges in insertion order */
const std::vector<edge_ptr> edges();
/* Get the list of faces in insertion order */
const std::vector<face_ptr> faces();
/* Get the list of vertices in insertion order */
const std::vector<vertex_ptr> vertices();
/* Get the number of edges */
const std::size_t num_edges();
/* Get the number of faces */
const std::size_t num_faces();
/* Get the number of vertices */
const std::size_t num_vertices();
/* Get the number of interior vertices */
const std::size_t num_interior_vertices();
/* Check for coplanarity */
bool coplanar(size_t idx);
// Compute ABF++
void compute_abfpp();
// Compute LSCM
void compute_lscm();
/* Computer face angles */
void compute_face_angles(face_ptr face);
/* Compute interior angles */
float interior_angle(const glm::vec3& a, const glm::vec3& b);
/* Calculate the angle weights */
void initialize_angles_weights();
/* Gradient */
float gradient();
/* Triangle gradient */
float triangle_gradient(const face_ptr& f);
/* Planar gradient */
float planar_gradient(const vertex_ptr& v);
/* Length gradient */
float length_gradient(const vertex_ptr& v);
/* Length gradient */
float length_gradient(const vertex_ptr& v, const edge_ptr& edge);
/* Alpha gradient */
float alpha_gradient(const edge_ptr& e);
/* Find an existing edge with the provided points */
edge_ptr find_edge(std::size_t start, std::size_t end);
/* Print edges */
std::string print_edges(face_ptr face);
/* Print vertices*/
std::string print_vertices(face_ptr face);
/* Point in triangle test */
bool point_in_triangle(const glm::vec3 p, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c);
/* Check winding order */
bool is_ccw(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c);
private:
std::vector<vertex_ptr> _vertices;
std::vector<face_ptr> _faces;
std::multimap<std::size_t, edge_ptr> _edges;
};
}