TTK
Loading...
Searching...
No Matches
FTMSuperArc.h
Go to the documentation of this file.
1
2//
12
13#pragma once
14
15#include <list>
16#include <vector>
17
18#include <Debug.h>
19
20#include "FTMDataTypes.h"
21#include "FTMSegmentation.h"
22#include "FTMStructures.h"
23
24namespace ttk {
25 namespace ftm {
26 class SuperArc {
27 private:
28 // Extrema
29 idNode downNodeId_, upNodeId_;
30 // Stat of this arc (visible, hidden, merged) if merged...
31 ComponentState state_;
32
33 // Keep th last vertex seen by this arc
34 // After the build a a merge tree, a close step is
35 // done, using this field to close each root arc
36 SimplexId lastVisited_;
37
38 // Segmentation related
39 ArcRegion region_;
40 SimplexId verticesSeen_;
41 idSuperArc normalizedId_;
42
43 public:
44 // -----------------
45 // CONSTRUCT
46 // -----------------
47
48 // This arc will needs to receive both ends before being printed
50 : downNodeId_(nullNodes), upNodeId_(nullNodes),
51 state_(ComponentState::Visible), lastVisited_(nullVertex),
52 verticesSeen_(0), normalizedId_(nullSuperArc) {
53 }
54
56 idNode u,
58 : downNodeId_(d), upNodeId_(u), state_(state), lastVisited_(nullVertex),
59 verticesSeen_(0), normalizedId_(nullSuperArc) {
60 }
61
62 // ------------------
63 // ACCESSOR
64 // --------------------
65
66 // node
67
68 inline idNode getUpNodeId() const {
69 return upNodeId_;
70 }
71
72 inline idNode getDownNodeId() const {
73 return downNodeId_;
74 }
75
76 inline void setUpNodeId(idNode upId) {
77 upNodeId_ = upId;
78 }
79
80 inline void setDownNodeId(idNode downId) {
81 downNodeId_ = downId;
82 }
83
84 // last vertex seen, nb vertex seen & ids
85
86 inline SimplexId getLastVisited() const {
87 return lastVisited_;
88 }
89
90 inline void setLastVisited(SimplexId vertId) {
91 lastVisited_ = vertId;
92 ++verticesSeen_;
93 }
94
95 inline void atomicIncVisited(const SimplexId nb = 1) {
96#ifdef TTK_ENABLE_OPENMP
97#pragma omp atomic update
98#endif
99 verticesSeen_ += nb;
100 }
101
102 inline void decrNbSeen() {
103 --verticesSeen_;
104 }
105
106 inline SimplexId getNbVertSeen() const {
107 return verticesSeen_;
108 }
109
111 return normalizedId_;
112 }
113
114 inline void setNormalizeIds(const idSuperArc id) {
115 normalizedId_ = id;
116 }
117
118 // state
119
120 inline bool isHidden() const {
121 return state_ == ComponentState::Hidden;
122 }
123
124 inline bool isMerged() const {
125 return state_ == ComponentState::Merged;
126 }
127
128 inline bool isVisible() const {
129 return state_ == ComponentState::Visible;
130 }
131
132 // ------------
133 // Segmentation
134 // ------------
135
136 // Function using ArcRegion
137
138 inline void concat(const segm_it &begin, const segm_it &end) {
139 region_.concat(begin, end);
140 }
141
142 inline void concat(const ArcRegion &r) {
143 region_.concat(r);
144 }
145
146 inline void concat(const SuperArc &s) {
147 region_.concat(s.region_);
148 }
149
150 inline void concat(std::tuple<segm_it, segm_it> its) {
151 region_.concat(std::get<0>(its), std::get<1>(its));
152 }
153
154 // prerequisite for the following segmentation functions
155 inline void createSegmentation(const Scalars *s) {
156 region_.createSegmentation(s);
157 }
158
159 // Direct read access to the list of region
160 const std::list<Region> &getRegions() const {
161 return region_.getRegions();
162 }
163
164 std::list<Region> &getRegions() {
165 return region_.getRegions();
166 }
167
168 const ArcRegion &getRegion() const {
169 return region_;
170 }
171
172 size_t regionSize() const {
173 return region_.count();
174 }
175
177 region_.clear();
178 }
179
180 // access segmentation (after createSegmentation)
181 // vector-like
182
183 inline size_t size() const {
184 return region_.size();
185 }
186
187 std::vector<SimplexId>::iterator begin() {
188 return region_.begin();
189 }
190
191 std::vector<SimplexId>::iterator end() {
192 return region_.end();
193 }
194
196 return region_[v];
197 }
198
200 return region_[v];
201 }
202
203 // Access Segmentation legacy
204
206 return region_.size();
207 }
208
210 return region_[id];
211 }
212
213 // process segmentation
214
215 // keep the front segmentation, return the back
216 std::tuple<SimplexId, ArcRegion> splitFront(SimplexId v,
217 const Scalars *s) {
218 return region_.splitFront(v, s);
219 }
220
221 // Keep the back, return the front
222 std::tuple<SimplexId, ArcRegion> splitBack(SimplexId v,
223 const Scalars *s) {
224 return region_.splitBack(v, s);
225 }
226
228 const Scalars *s,
229 const std::vector<idCorresp> &vert2treeOther
230 = std::vector<idCorresp>()) const {
231 return region_.findBelow(v, s, vert2treeOther);
232 }
233
234 bool merge(const SuperArc &s) {
235 return region_.merge(s.region_);
236 }
237
238 std::string printReg() const {
239 return region_.print();
240 }
241 };
242
243 } // namespace ftm
244} // namespace ttk
std::string print() const
bool merge(const ArcRegion &r)
decltype(segmentation_) ::iterator end()
std::tuple< SimplexId, ArcRegion > splitFront(SimplexId v, const Scalars *s)
SimplexId findBelow(SimplexId v, const Scalars *s, const std::vector< idCorresp > &vert2treeOther=std::vector< idCorresp >()) const
SimplexId size() const
void createSegmentation(const Scalars *s)
void concat(const segm_it &begin, const segm_it &end)
decltype(segmentation_) ::iterator begin()
std::tuple< SimplexId, ArcRegion > splitBack(SimplexId v, const Scalars *s)
const decltype(segmentsIn_) & getRegions() const
SimplexId count() const
SimplexId getNumberOfRegularNodes() const
void setNormalizeIds(const idSuperArc id)
SimplexId getLastVisited() const
Definition FTMSuperArc.h:86
SuperArc(idNode d, idNode u, const ComponentState &state=ComponentState::Visible)
Definition FTMSuperArc.h:55
void concat(const SuperArc &s)
std::list< Region > & getRegions()
std::vector< SimplexId >::iterator begin()
void atomicIncVisited(const SimplexId nb=1)
Definition FTMSuperArc.h:95
idNode getUpNodeId() const
Definition FTMSuperArc.h:68
void concat(const segm_it &begin, const segm_it &end)
std::tuple< SimplexId, ArcRegion > splitFront(SimplexId v, const Scalars *s)
bool merge(const SuperArc &s)
bool isHidden() const
size_t size() const
SimplexId getNbVertSeen() const
std::tuple< SimplexId, ArcRegion > splitBack(SimplexId v, const Scalars *s)
SimplexId & operator[](SimplexId v)
void setUpNodeId(idNode upId)
Definition FTMSuperArc.h:76
SimplexId findBelow(SimplexId v, const Scalars *s, const std::vector< idCorresp > &vert2treeOther=std::vector< idCorresp >()) const
void concat(const ArcRegion &r)
bool isMerged() const
const std::list< Region > & getRegions() const
SimplexId operator[](SimplexId v) const
void createSegmentation(const Scalars *s)
std::string printReg() const
size_t regionSize() const
void setLastVisited(SimplexId vertId)
Definition FTMSuperArc.h:90
const ArcRegion & getRegion() const
idNode getDownNodeId() const
Definition FTMSuperArc.h:72
SimplexId getRegularNodeId(SimplexId id) const
void concat(std::tuple< segm_it, segm_it > its)
std::vector< SimplexId >::iterator end()
bool isVisible() const
void setDownNodeId(idNode downId)
Definition FTMSuperArc.h:80
idSuperArc getNormalizedId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
std::vector< SimplexId >::iterator segm_it
unsigned int idNode
Node index in vect_nodes_.
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22