TTK
Loading...
Searching...
No Matches
MultiresTopology.cpp
Go to the documentation of this file.
1#include <MultiresTopology.h>
2
4 const SimplexId vertexId,
5 const std::vector<std::pair<polarity, polarity>> &vlp,
6 DynamicTree &link,
7 std::vector<polarity> &toPropagateMin,
8 std::vector<polarity> &toPropagateMax,
9 std::vector<std::vector<SimplexId>> &saddleCCMin,
10 std::vector<std::vector<SimplexId>> &saddleCCMax) const {
11
12 const auto nbCC = link.getNbCC();
13
14 SimplexId downValence = 0, upValence = 0;
15 saddleCCMin[vertexId].clear();
16 saddleCCMax[vertexId].clear();
17
18 if(nbCC > 2) {
19 std::vector<size_t> CCIds;
20 CCIds.reserve(nbCC);
21 link.retrieveNbCC(CCIds);
22 for(size_t i = 0; i < CCIds.size(); i++) {
23 const SimplexId neighbor = CCIds[i];
24 const polarity isUpper = vlp[neighbor].first;
25 if(isUpper) {
26 saddleCCMax[vertexId].emplace_back(neighbor);
27 upValence++;
28 } else {
29 saddleCCMin[vertexId].emplace_back(neighbor);
30 downValence++;
31 }
32 }
33
34 if(downValence > 1) {
35 toPropagateMin[vertexId] = 255;
36 } else {
37 saddleCCMin[vertexId].clear();
38 toPropagateMin[vertexId] = 0;
39 }
40 if(upValence > 1) {
41 toPropagateMax[vertexId] = 255;
42 } else {
43 saddleCCMax[vertexId].clear();
44 toPropagateMax[vertexId] = 0;
45 }
46
47 } else { // not a saddle
48 toPropagateMax[vertexId] = 0;
49 toPropagateMin[vertexId] = 0;
50 }
51}
52
54 const SimplexId vertexId, VLBoundaryType &vlbt) const {
55
56 const auto bid = multiresTriangulation_.getVertexBoundaryIndex(vertexId);
57 const auto nneigh = multiresTriangulation_.getVertexNeighborNumber(vertexId);
58 vlbt[bid].reserve(nneigh);
59
60 for(SimplexId i = 0; i < nneigh; i++) {
61 SimplexId n0 = 0;
62 multiresTriangulation_.getVertexNeighbor(vertexId, i, n0);
63 for(SimplexId j = i + 1; j < nneigh; j++) {
64 SimplexId n1 = 0;
65 multiresTriangulation_.getVertexNeighbor(vertexId, j, n1);
66 if(multiresTriangulation_.areVerticesNeighbors(n0, n1)) {
67 vlbt[bid].emplace_back(i, j);
68 }
69 }
70 }
71}
72
74 const SimplexId vertexId,
75 std::vector<triplet> &triplets,
76 const std::vector<std::vector<SimplexId>> &vertexReps) const {
77
78 const auto &reps = vertexReps[vertexId];
79 const SimplexId m = reps[0];
80#ifndef TTK_ENABLE_KAMIKAZE
81 const auto &repsm = vertexReps[m];
82 if(m == -1 || repsm.empty() || repsm[0] != m) {
83 this->printErr("HERE PROBLEM");
84 }
85#endif // TTK_ENABLE_KAMIKAZE
86 for(size_t i = 1; i < reps.size(); i++) {
87 const SimplexId n = reps[i];
88#ifndef TTK_ENABLE_KAMIKAZE
89 const auto &repsn = vertexReps[n];
90 if(n == -1 || repsn.empty() || repsn[0] != n) {
91 this->printErr("HERE2 PROBLEM");
92 }
93#endif // TTK_ENABLE_KAMIKAZE
94 triplets.emplace_back(vertexId, m, n);
95 }
96}
97
99 const std::vector<std::pair<polarity, polarity>> &vlp,
100 DynamicTree &link) const {
101
102 const auto nbCC = link.getNbCC();
103
104 int const dimensionality = multiresTriangulation_.getDimensionality();
105 SimplexId downValence = 0, upValence = 0;
106
107 std::vector<size_t> CCIds;
108 CCIds.reserve(nbCC);
109 link.retrieveNbCC(CCIds);
110 for(size_t i = 0; i < CCIds.size(); i++) {
111 const SimplexId neighbor = CCIds[i];
112 const polarity isUpper = vlp[neighbor].first;
113 if(isUpper) {
114 upValence++;
115 } else {
116 downValence++;
117 }
118 }
119
120 if(downValence == -1 && upValence == -1) {
121 return -1;
122 } else if(downValence == 0 && upValence == 1) {
123 return static_cast<char>(CriticalType::Local_minimum);
124 } else if(downValence == 1 && upValence == 0) {
125 return static_cast<char>(CriticalType::Local_maximum);
126 } else if(downValence == 1 && upValence == 1) {
127 // regular point
128 return static_cast<char>(CriticalType::Regular);
129 } else {
130 // saddles
131 if(dimensionality == 2) {
132 if((downValence == 2 && upValence == 1)
133 || (downValence == 1 && upValence == 2)
134 || (downValence == 2 && upValence == 2)) {
135 // regular saddle
136 return static_cast<char>(CriticalType::Saddle1);
137 } else {
138 // monkey saddle, saddle + extremum
139 return static_cast<char>(CriticalType::Degenerate);
140 // NOTE: you may have multi-saddles on the boundary in that
141 // configuration
142 // to make this computation 100% correct, one would need to
143 // disambiguate boundary from interior vertices
144 }
145 } else if(dimensionality == 3) {
146 if(downValence == 2 && upValence == 1) {
147 return static_cast<char>(CriticalType::Saddle1);
148 } else if(downValence == 1 && upValence == 2) {
149 return static_cast<char>(CriticalType::Saddle2);
150 } else {
151 // monkey saddle, saddle + extremum
152 return static_cast<char>(CriticalType::Degenerate);
153 // NOTE: we may have a similar effect in 3D (TODO)
154 }
155 }
156 }
157
158 // -2: regular points
159 return static_cast<char>(CriticalType::Regular);
160}
161
163 std::stringstream res;
164 res << "Resolution level "
165 << multiresTriangulation_.DL_to_RL(decimationLevel_);
166 if(decimationLevel_ == 0) {
167 res << " (final)";
168 }
169 return res.str();
170}
171
173 std::vector<std::pair<polarity, polarity>> &vlp) const {
174
175 for(size_t i = 0; i < vlp.size(); i++) {
176 if(vlp[i].second) {
177 vlp[i].first = ~vlp[i].first;
178 vlp[i].second = 0;
179 }
180 }
181}
Implements the Dynamic Tree data-structure (or ST-Tree)
Definition DynamicTree.h:66
size_t getNbCC() const
void retrieveNbCC(std::vector< size_t > &nbccIds) const
std::string resolutionInfoString()
void buildVertexLinkByBoundary(const SimplexId vertexId, VLBoundaryType &vlbt) const
char getCriticalTypeFromLink(const std::vector< std::pair< polarity, polarity > > &vlp, DynamicTree &link) const
void getValencesFromLink(const SimplexId vertexId, const std::vector< std::pair< polarity, polarity > > &vlp, DynamicTree &link, std::vector< polarity > &toPropagateMin, std::vector< polarity > &toPropagateMax, std::vector< std::vector< SimplexId > > &saddleCCMin, std::vector< std::vector< SimplexId > > &saddleCCMax) const
std::array< std::vector< std::pair< SimplexId, SimplexId > >, nLink_ > VLBoundaryType
void getTripletsFromSaddles(const SimplexId vertexId, std::vector< triplet > &triplets, const std::vector< std::vector< SimplexId > > &vertexReps) const
void updateLinkPolarityPonctual(std::vector< std::pair< polarity, polarity > > &vlp) const
unsigned char polarity
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22