-
Notifications
You must be signed in to change notification settings - Fork 0
/
MeshWalkHandler.h
125 lines (99 loc) · 4.72 KB
/
MeshWalkHandler.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
#ifndef MESHWALKHANDLER_H
#define MESHWALKHANDLER_H
#include <array>
#include <vector>
#include "Mesh.h"
#include "SubdivisionStrategy.h"
class MeshWalkHandler
{
public:
enum OddsType {Edge, Face};
class Walk {
public:
Walk(std::array<K::Point_3, 16> odds,
std::vector<K::Point_3> evens,
int n_odds,
int n_evens,
MeshType mesh_type,
OddsType odds_type,
SubdivisionType subdivision_type):
odds(odds),
evens(evens),
n_odds(n_odds),
n_evens(n_evens),
mesh_type(mesh_type),
odds_type(odds_type),
subdivision_type(subdivision_type)
{}
int n_odds;
int n_evens;
MeshType mesh_type;
OddsType odds_type;
SubdivisionType subdivision_type;
K::Point_3 atOdds(int index) {
if (index < n_odds) {
return odds.at(index);
}
throw std::exception("Invalid odd vertex index: " + index);
}
K::Point_3 atEvens(int index) {
if (index < n_evens) {
return evens.at(index);
}
throw std::exception("Invalid even vertex index: " + index);
}
std::array<K::Point_3, 16> getOdds();
std::vector<K::Point_3> getEvens() {
return evens;
}
protected:
std::array<K::Point_3, 16> odds;
std::vector<K::Point_3> evens;
};
class LoopLikeWalk : public Walk {
public:
LoopLikeWalk(std::array<K::Point_3, 16> odds, std::vector<K::Point_3> evens):
Walk(odds, evens, 4, evens.size(), Triangular, Edge, Approximating) {}
};
class ButterflyLikeWalk : public Walk {
public:
ButterflyLikeWalk(std::array<K::Point_3, 16> odds):
Walk(odds, std::vector<K::Point_3>(), 8, 0, Triangular, Edge, Interpolating) {}
};
class CatmullClarkLikeWalk : public Walk {
public:
CatmullClarkLikeWalk(std::array<K::Point_3, 16> odds, std::vector<K::Point_3> evens, OddsType odds_type):
Walk(odds, evens, odds_type == Face ? 4 : 6, evens.size(), Quadrilateral, odds_type, Approximating) {}
};
class KobbeltLikeWalk : public Walk {
public:
KobbeltLikeWalk(std::array<K::Point_3, 16> odds, OddsType odds_type):
Walk(odds, std::vector<K::Point_3>(), odds_type == Face ? 16 : 4, 0, Quadrilateral, odds_type, Interpolating) {}
};
static MeshWalkHandler& getInstance() {
static MeshWalkHandler instance;
return instance;
}
MeshWalkHandler(MeshWalkHandler const&) = delete;
void operator=(MeshWalkHandler const&) = delete;
Walk walk(Polyhedron::Halfedge_iterator halfedge, int neighbour_level, SubdivisionType subdivision_type, OddsType odds_type, MeshType mesh_type);
LoopLikeWalk loopLikeWalk(Polyhedron::Halfedge_iterator halfedge);
ButterflyLikeWalk butterflyLikeWalk(Polyhedron::Halfedge_iterator halfedge);
CatmullClarkLikeWalk catmullClarkLikeWalk(Polyhedron::Halfedge_iterator halfedge, OddsType odds_type);
KobbeltLikeWalk kobbeltLikeWalk(Polyhedron::Halfedge_iterator halfedge, OddsType odds_type);
private:
MeshWalkHandler() {}
int triOddVerticesOneNeighbour(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge);
int triOddVerticesTwoNeighbour(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge);
inline Polyhedron::Halfedge_iterator secondNeighbourTriHelper(std::array<K::Point_3, 16>& vertices, int index, Polyhedron::Halfedge_iterator halfedge);
int quadOddVerticesOneNeighbour(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge, OddsType odds_type);
int quadOddVerticesTwoNeighbour(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge, OddsType odds_type);
inline int quadFaceOddTwo(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge);
inline Polyhedron::Halfedge_iterator quadFaceOddTwoCornerHelper(Polyhedron::Halfedge_iterator halfedge, std::array<K::Point_3, 16>& vertices, std::pair<int, int> indicies);
inline Polyhedron::Halfedge_iterator quadFaceOddTwoSideHelper(Polyhedron::Halfedge_iterator halfedge, std::array<K::Point_3, 16>& vertices, std::pair<int, int> indicies);
inline int quadEdgeOddTwo(std::array<K::Point_3, 16>& vertices, Polyhedron::Halfedge_iterator halfedge);
inline Polyhedron::Halfedge_iterator quadEdgeOddTwoStraightHelper(Polyhedron::Halfedge_iterator halfedge);
std::vector<K::Point_3> triEvenVertices(Polyhedron::Halfedge_iterator halfedge);
std::vector<K::Point_3> quadEvenVertices(Polyhedron::Halfedge_iterator halfedge);
};
#endif // MESHWALKHANDLER_H