TTK
Loading...
Searching...
No Matches
DeprecatedNode.h
Go to the documentation of this file.
1
7//
15
16#pragma once
17
18#include <vector>
19
20#include <Debug.h>
21
22#include "DeprecatedDataTypes.h"
23#include "ExtendedUF.h"
24
25namespace ttk {
26 namespace cf {
27
28 class Node {
29 friend class MergeTree;
30
31 private:
32 // mesh vertex where this node is
33 SimplexId vertexId_;
34 // For leaves, linkedNode is the saddle ending the persistence pair
35 // For saddle, linked is the leaf starting the persistence pair in which
36 // they are
37 SimplexId linkedNode_;
38 // link with superArc above and below
39 std::vector<idSuperArc> vect_downSuperArcList_, vect_upSuperArcList_;
40 // Won't be displayed if hidden
41 bool hidden_;
42 // valence down / up
43 std::tuple<idSuperArc, idSuperArc> valence_;
44
45 public:
46 // -----------------
47 // CONSTRUCTOR
48 // -----------------
49 // {
50
51 Node(const SimplexId &id, const SimplexId &linked)
52 : vertexId_(id), linkedNode_(linked), hidden_(false), valence_(0, 0) {
53 }
54
55 // }
56 // -----------------
57 // ACCESSOR
58 // ------------------
59 // {
60
61 // Vertex id
62 // ........................{
63
64 inline SimplexId getVertexId() const {
65 return vertexId_;
66 }
67
68 inline void setVertexId(const SimplexId &vertexId) {
69 vertexId_ = vertexId;
70 }
71
72 // }
73 // Linked node
74 // ........................{
75
76 inline const SimplexId &getOrigin() const {
77 return linkedNode_;
78 }
79
80 inline const SimplexId &getTermination() const {
81 return linkedNode_;
82 }
83
84 inline void setOrigin(const SimplexId &linked) {
85 linkedNode_ = linked;
86 }
87
88 inline void setTermination(const SimplexId &linked) {
89 linkedNode_ = linked;
90 }
91
92 // }
93 // vector arcs
94 // ............................{
95
97 return vect_downSuperArcList_.size();
98 }
99
101 return vect_upSuperArcList_.size();
102 }
103
105 return vect_upSuperArcList_.size() + vect_downSuperArcList_.size();
106 }
107
108 inline idSuperArc getDownSuperArcId(const idSuperArc &neighborId) const {
109#ifndef TTK_ENABLE_KAMIKAZE
110 if(neighborId >= vect_downSuperArcList_.size()) {
111 std::cerr << "[Merge Tree:Node] get down on bad neighbor !";
112 std::cerr << std::endl;
113 return 0;
114 }
115#endif
116 return vect_downSuperArcList_[neighborId];
117 }
118
119 inline idSuperArc getUpSuperArcId(const idSuperArc &neighborId) const {
120#ifndef TTK_ENABLE_KAMIKAZE
121 if(neighborId >= vect_upSuperArcList_.size()) {
122 std::cerr << "[MergeTree:Node] No SuperArc to access "
123 << static_cast<unsigned>(neighborId);
124 std::cerr << std::endl;
125 }
126#endif
127 if(vect_upSuperArcList_.size() == 0) {
128 return nullSuperArc;
129 }
130 return vect_upSuperArcList_[neighborId];
131 }
132
133 inline void addDownSuperArcId(const idSuperArc &downSuperArcId) {
134 vect_downSuperArcList_.emplace_back(downSuperArcId);
135 }
136
137 inline void addUpSuperArcId(const idSuperArc &upSuperArcId) {
138 vect_upSuperArcList_.emplace_back(upSuperArcId);
139 }
140
142 const idSuperArc s = vect_downSuperArcList_.size();
143 vect_downSuperArcList_.clear();
144 return s;
145 }
146
148 const idSuperArc s = vect_upSuperArcList_.size();
149 vect_upSuperArcList_.clear();
150 return s;
151 }
152
153 // remove the i^th arc
154 inline void removeDownSuperArcPos(const idSuperArc &i) {
155 vect_downSuperArcList_[i] = vect_downSuperArcList_.back();
156 vect_downSuperArcList_.pop_back();
157
159 }
160
161 // Find and remove the arc
162 inline void removeDownSuperArc(const idSuperArc &idSa) {
163 for(idSuperArc i = 0; i < vect_downSuperArcList_.size(); ++i) {
164 if(vect_downSuperArcList_[i] == idSa) {
165 vect_downSuperArcList_[i] = vect_downSuperArcList_.back();
166 vect_downSuperArcList_.pop_back();
167
169 return;
170 }
171 }
172 }
173
174 // Find and remove the arc (better perf for young added arc)
175 inline void removeDownSuperArcFromLast(const idSuperArc &idSa) {
176 for(idSuperArc i = vect_downSuperArcList_.size() - 1;; --i) {
177 if(vect_downSuperArcList_[i] == idSa) {
178 vect_downSuperArcList_[i] = vect_downSuperArcList_.back();
179 vect_downSuperArcList_.pop_back();
180
182 return;
183 }
184 if(i == 0) {
185 return;
186 }
187 }
188 }
189
190 // Find and remove the arc
191 inline void removeUpSuperArc(const idSuperArc &idSa) {
192 for(idSuperArc i = 0; i < vect_upSuperArcList_.size(); ++i) {
193 if(vect_upSuperArcList_[i] == idSa) {
194 vect_upSuperArcList_[i] = vect_upSuperArcList_.back();
195 vect_upSuperArcList_.pop_back();
196
197 decUpValence();
198 return;
199 }
200 }
201 }
202
203 // Find and remove the arc (better perf for young added arc)
204 inline void removeUpSuperArcFromLast(const idSuperArc &idSa) {
205 for(idSuperArc i = vect_upSuperArcList_.size();; --i) {
206 if(vect_upSuperArcList_[i] == idSa) {
207 vect_upSuperArcList_[i] = vect_upSuperArcList_.back();
208 vect_upSuperArcList_.pop_back();
209
210 decUpValence();
211 return;
212 }
213 if(i == 0) {
214 return;
215 }
216 }
217 }
218
219 // }
220 // hidden node
221 // ...........................................{
222
223 inline bool isHidden() const {
224 return hidden_;
225 }
226
227 inline bool isVisible() const {
228 return !hidden_;
229 }
230
231 inline void hide() {
232 hidden_ = true;
233 }
234
235 inline void setHidden(const bool local_hidden) {
236 hidden_ = local_hidden;
237 }
238
239 // }
240 // Valence
241 // .......................................... {
242
243 inline idSuperArc getUpValence() const {
244 return std::get<1>(valence_);
245 }
246
247 inline idSuperArc getDownValence() const {
248 return std::get<0>(valence_);
249 }
250
251 inline idSuperArc getValence() const {
252 return std::get<0>(valence_) + std::get<1>(valence_);
253 }
254
255 inline void setUpValence(const idSuperArc &v) {
256 std::get<1>(valence_) = v;
257 }
258
259 inline void setDownValence(const idSuperArc &v) {
260 std::get<0>(valence_) = v;
261 }
262
263 inline void incUpValence() {
264 ++std::get<1>(valence_);
265 }
266
267 inline void incDownValence() {
268 ++std::get<0>(valence_);
269 }
270
271 inline void decUpValence() {
272 --std::get<1>(valence_);
273 }
274
275 inline void decDownValence() {
276 --std::get<0>(valence_);
277 }
278
279 // }
280
281 // }
282 };
283
284 } // namespace cf
285} // namespace ttk
SimplexId getVertexId() const
idSuperArc clearUpSuperArcs()
idSuperArc getNumberOfSuperArcs() const
const SimplexId & getOrigin() const
idSuperArc clearDownSuperArcs()
void removeDownSuperArcFromLast(const idSuperArc &idSa)
const SimplexId & getTermination() const
void removeDownSuperArc(const idSuperArc &idSa)
void addUpSuperArcId(const idSuperArc &upSuperArcId)
void addDownSuperArcId(const idSuperArc &downSuperArcId)
idSuperArc getDownSuperArcId(const idSuperArc &neighborId) const
void setVertexId(const SimplexId &vertexId)
Node(const SimplexId &id, const SimplexId &linked)
idSuperArc getDownValence() const
idSuperArc getNumberOfUpSuperArcs() const
void setTermination(const SimplexId &linked)
void removeUpSuperArcFromLast(const idSuperArc &idSa)
bool isHidden() const
void setOrigin(const SimplexId &linked)
void setUpValence(const idSuperArc &v)
void removeUpSuperArc(const idSuperArc &idSa)
bool isVisible() const
idSuperArc getUpSuperArcId(const idSuperArc &neighborId) const
void setDownValence(const idSuperArc &v)
void removeDownSuperArcPos(const idSuperArc &i)
idSuperArc getUpValence() const
idSuperArc getNumberOfDownSuperArcs() const
idSuperArc getValence() const
void setHidden(const bool local_hidden)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22