-
Notifications
You must be signed in to change notification settings - Fork 1
/
h2polygontriangulater.h
111 lines (76 loc) · 3.67 KB
/
h2polygontriangulater.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
#ifndef H2POLYGONTRIANGULATER_H
#define H2POLYGONTRIANGULATER_H
#include "tools.h"
#include "h2polygon.h"
class H2GeodesicArc;
class TriangulationCut
{
friend class H2PolygonTriangulater;
friend class H2MeshConstructor;
private:
TriangulationCut() {}
TriangulationCut(uint vertexIndex1, uint vertexIndex2, uint leftTriangleIndex, uint rightTriangleIndex) :
vertexIndex1(vertexIndex1), vertexIndex2(vertexIndex2), leftTriangleIndex(leftTriangleIndex), rightTriangleIndex(rightTriangleIndex) {}
uint vertexIndex1, vertexIndex2;
uint leftTriangleIndex, rightTriangleIndex;
};
class TriangulationTriangle
{
friend class H2PolygonTriangulater;
public:
bool operator <(const TriangulationTriangle &other) const;
void getVertices(uint &i1, uint &i2, uint &i3) const;
private:
TriangulationTriangle() {}
TriangulationTriangle(uint vertexIndex1, uint vertexIndex2, uint vertexIndex3) :
vertexIndex1(vertexIndex1), vertexIndex2(vertexIndex2), vertexIndex3(vertexIndex3) {}
uint vertexIndex1, vertexIndex2, vertexIndex3;
};
class H2Triangle;
class H2PolygonTriangulater
{
friend class H2MeshConstructor;
public:
H2PolygonTriangulater(const H2Polygon * const polygon);
H2PolygonTriangulater() = delete;
H2PolygonTriangulater & operator=(H2PolygonTriangulater) = delete;
std::vector<H2Triangle> getTriangles() const;
std::vector<TriangulationTriangle> getTriangulationTriangles() const;
std::vector<TriangulationCut> getCuts() const;
std::vector<H2GeodesicArc> getH2Cuts() const;
std::vector<uint> nbCutsFromVertex() const;
void verticesIndices(std::vector< std::vector<uint> > &triangleIndices, std::vector< std::vector<uint> > &indicesInTriangles) const;
private:
H2PolygonTriangulater(const H2PolygonTriangulater &);
void triangulate();
std::vector<double> subpolygonAngles(const std::vector<uint> &indices) const;
void findCutInSubpolygon1(const std::vector<uint> &indices, uint &outputIndex1, uint &outputIndex2) const;
void findCutInSubpolygon2(const std::vector<uint> &indices, uint &outputIndex1, uint &outputIndex2) const;
void findCutInSubpolygon3(const std::vector<uint> &indices, uint &outputIndex1, uint &outputIndex2) const;
void triangulateSubpolygon(const std::vector<uint> &indices);
void splitIndicesList(const std::vector<uint> & indices, uint cut1, uint cut2,
std::vector<uint> &outputList1, std::vector<uint> &outputList2) const;
void sortTriangles();
void completeCutsAndSides();
void adjacentSidesIndices(uint cutIndex, uint &outputIndexLeft1, uint &outputIndexLeft2, uint &outputIndexRight1, uint &outputIndexRight2) const;
double minAngleOfCutInSubpolygon(const std::vector<uint> & indices, uint cut1, uint cut2) const;
double minTriangleAngle() const;
double minTriangleSide() const;
void createSteinerPoints();
bool sameSide(uint fullIndex1, uint fullIndex2) const;
void getCutsFromTriangle(uint triangleIndex, uint &cutIndex1, uint &cutIndex2, uint &cutIndex3) const;
bool isSideTriangle(uint triangleIndex) const;
bool attemptFlip();
bool testQuadrilateralForFlipAngles(const std::vector<uint> & quadrilateralIndices) const;
bool testQuadrilateralForFlipLengths(const std::vector<uint> & quadrilateralIndices) const;
const H2Polygon * const polygon;
bool orientation;
std::vector<TriangulationCut> cuts;
std::vector<TriangulationTriangle> triangles;
std::vector<uint> sideTrianglesIndices;
std::vector<uint> sideTrianglesBoundarySideIndices;
H2SteinerPolygon steinerPolygon;
H2Polygon fullPolygon;
uint maxNbFlips;
};
#endif // H2POLYGONTRIANGULATER_H