TTK
Loading...
Searching...
No Matches
Quadrangulation.h
Go to the documentation of this file.
2
3#include <array>
4#include <iostream>
5
6namespace ttk {
7
8 class Quadrangulation : virtual public Debug {
9 public:
11 ~Quadrangulation() override = default;
12
16
17 inline void setInputCells(const SimplexId cellNumber,
18 void *const quadCells) {
19 this->nCells_ = cellNumber;
20 this->cells_ = static_cast<const Quad *>(quadCells);
21 }
22
23 inline void setInputPoints(const SimplexId pointNumber,
24 void *const pointCoords) {
25 this->nVerts_ = pointNumber;
26 this->vertCoords_ = static_cast<const Point *>(pointCoords);
27 }
28
29 inline int isVertexExtraordinary(const SimplexId v) {
30 const size_t ordinary_valence{4};
31 return this->vertexNeighbors_[v].size() != ordinary_valence;
32 }
33
34 inline void
35 getVertexPoint(const SimplexId v, float &x, float &y, float &z) const {
36 const auto &c{this->vertCoords_[v]};
37 x = c[0];
38 y = c[1];
39 z = c[2];
40 }
41
42 inline void
43 getCellVertex(const SimplexId c, const int l, SimplexId &v) const {
44 v = this->cells_[c][l];
45 }
46
48 return this->vertexNeighbors_[v].size();
49 }
50 inline void
51 getVertexNeighbor(const SimplexId v, const int l, SimplexId &n) const {
52 n = this->vertexNeighbors_[v][l];
53 }
54
55 inline SimplexId getVertexStarNumber(const SimplexId v) const {
56 return this->vertexStars_[v].size();
57 }
58 inline SimplexId getVertexStar(const SimplexId v, const int l) const {
59 return this->vertexStars_[v][l];
60 }
61 inline void
62 getVertexStar(const SimplexId v, const int l, SimplexId &vs) const {
63 vs = this->vertexStars_[v][l];
64 }
65
66 inline SimplexId getEdgeStarNumber(const SimplexId e) const {
67 return this->edgeStars_[e].size();
68 }
69 inline SimplexId getEdgeStar(const SimplexId e, const int l) const {
70 return this->edgeStars_[e][l];
71 }
72
73 inline SimplexId getCellEdge(const SimplexId c, const int l) {
74 return this->quadEdges_[c][l];
75 }
76
77 const std::array<SimplexId, 2> &getEdge(const SimplexId e) const {
78 return this->edges_[e];
79 }
80
82 return 4;
83 }
84 inline int getDimensionality() const {
85 return 2;
86 }
87 inline const SimplexId &getNumberOfVertices() const {
88 return this->nVerts_;
89 }
90 inline const SimplexId &getNumberOfCells() const {
91 return this->nCells_;
92 }
93 inline SimplexId getNumberOfEdges() const {
94 return this->edges_.size();
95 }
96
98 float &density,
99 float &deformity) const {
100 auto minDist{std::numeric_limits<float>::max()};
101 auto maxDist{std::numeric_limits<float>::lowest()};
102 const auto &pi{this->vertCoords_[v]};
103 for(const auto j : this->vertexNeighbors_[v]) {
104 const auto &pj{this->vertCoords_[j]};
105 const auto dist{Geometry::distance(pi.data(), pj.data())};
106 minDist = std::min(minDist, dist);
107 maxDist = std::max(maxDist, dist);
108 }
109 density = std::exp(-minDist);
110 deformity = std::exp(-minDist / maxDist);
111 }
112
113 void computeStatistics(std::vector<SimplexId> &vertsValence,
114 std::vector<float> &vertsDensity,
115 std::vector<float> &vertsDifformity,
116 std::vector<float> &quadArea,
117 std::vector<float> &quadDiagsRatio,
118 std::vector<float> &quadEdgesRatio,
119 std::vector<float> &quadAnglesRatio) const;
120
124 using Quad = std::array<ttk::LongSimplexId, 4>;
129
130 private:
131 CellArray buildQuadOffsets();
132
133 const Point *vertCoords_{};
134 const Quad *cells_{};
135 SimplexId nVerts_{};
136 SimplexId nCells_{};
137 FlatJaggedArray vertexNeighbors_{};
138 FlatJaggedArray vertexStars_{};
139 std::vector<std::array<SimplexId, 2>> edges_{};
140 FlatJaggedArray edgeStars_{};
141 std::vector<std::array<SimplexId, 4>> quadEdges_{};
142 std::vector<LongSimplexId> quadOffsets_{};
143 };
144
145} // namespace ttk
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition: BaseClass.h:47
CellArray generic array of cells
Minimalist debugging class.
Definition: Debug.h:88
SimplexId size(SimplexId id) const
Get the size of a particular sub-vector.
SimplexId getEdgeStar(const SimplexId e, const int l) const
~Quadrangulation() override=default
int isVertexExtraordinary(const SimplexId v)
void getVertexStar(const SimplexId v, const int l, SimplexId &vs) const
SimplexId getCellVertexNumber(const SimplexId ttkNotUsed(c)) const
SimplexId getVertexStar(const SimplexId v, const int l) const
const std::array< SimplexId, 2 > & getEdge(const SimplexId e) const
void getVertexPoint(const SimplexId v, float &x, float &y, float &z) const
std::array< ttk::LongSimplexId, 4 > Quad
Ad-hoc quad data structure (4 vertex ids)
SimplexId getEdgeStarNumber(const SimplexId e) const
int getDimensionality() const
SimplexId getNumberOfEdges() const
const SimplexId & getNumberOfVertices() const
void computeDensityAndDeformity(const SimplexId v, float &density, float &deformity) const
void computeStatistics(std::vector< SimplexId > &vertsValence, std::vector< float > &vertsDensity, std::vector< float > &vertsDifformity, std::vector< float > &quadArea, std::vector< float > &quadDiagsRatio, std::vector< float > &quadEdgesRatio, std::vector< float > &quadAnglesRatio) const
SimplexId getVertexNeighborNumber(const SimplexId v) const
void getCellVertex(const SimplexId c, const int l, SimplexId &v) const
const SimplexId & getNumberOfCells() const
void setInputCells(const SimplexId cellNumber, void *const quadCells)
SimplexId getVertexStarNumber(const SimplexId v) const
void setInputPoints(const SimplexId pointNumber, void *const pointCoords)
SimplexId getCellEdge(const SimplexId c, const int l)
void getVertexNeighbor(const SimplexId v, const int l, SimplexId &n) const
T distance(const T *p0, const T *p1, const int &dimension=3)
Definition: Geometry.cpp:344
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition: DataTypes.h:22