TTK
Loading...
Searching...
No Matches
DeprecatedSegmentation.cpp
Go to the documentation of this file.
1/*
2 * file: Segmentation.cpp
3 * description: Segmentation processing package.
4 * author: Gueunet Charles
5 * date: September 2016
6 */
7
9
10#include <algorithm>
11
12using namespace std;
13using namespace ttk;
14using namespace cf;
15
16// -------
17// Segment
18// -------
19
20Segment::Segment(const bool order) : ascendingOrder_(order) {
21}
22
24 return ascendingOrder_;
25}
26
27void Segment::sort(const Scalars *s) {
28 // sort with removal of disabled
29
30 auto ascendingSort
31 = [&](const vertex &a, const vertex &b) { return s->isLower(a.id, b.id); };
32
33 auto descendingSort
34 = [&](const vertex &a, const vertex &b) { return s->isHigher(a.id, b.id); };
35
36 if(ascendingOrder_) {
37 std::sort(vertices_.begin(), vertices_.end(), ascendingSort);
38 } else {
39 std::sort(vertices_.begin(), vertices_.end(), descendingSort);
40 }
41}
42
44 vertices_.emplace_back(vertex{v, nullSuperArc});
45}
46
48 vertices_.clear();
49 vertices_.shrink_to_fit();
50}
51
53 return vertices_[idx].id;
54}
55
56const SimplexId &Segment::operator[](size_t idx) const {
57 return vertices_[idx].id;
58}
59
61 if(ascendingOrder_) {
62 return sorted_iterator(vertices_.begin());
63 }
64
65 return sorted_iterator(vertices_.rbegin());
66}
67
69 if(ascendingOrder_) {
70 return sorted_iterator(vertices_.end());
71 }
72
73 return sorted_iterator(vertices_.rend());
74}
75
76// --------
77// Segments
78// --------
79
81 return segments_.size();
82}
83
85 segments_.clear();
86 segments_.shrink_to_fit();
87}
88
90 return segments_[idx];
91}
92
93const Segment &Segments::operator[](size_t idx) const {
94 return segments_[idx];
95}
96
97// ---------
98// ArcRegion
99// ---------
100
102 segmentsIn_.emplace_front(Region{s, s, bool()});
103}
104
106 const segmentIterator &end) {
107 segmentsIn_.emplace_front(Region{begin, end, bool()});
108}
109
111 SimplexId totalSegmSize = 0;
112 vector<sorted_iterator> heads, ends;
113 for(const auto &region : segmentsIn_) {
114 totalSegmSize += distance(region.segmentBegin, region.segmentEnd);
115 heads.emplace_back(region.sbegin());
116 heads.emplace_back(region.send());
117 }
118
119 segmentation_.clear();
120 segmentation_.reserve(
121 totalSegmSize); // max size, including discarded vertices
122
123 const auto &nbSegments = heads.size();
124 bool added = true;
125
126 while(added) {
127 added = false;
128 for(unsigned i = 0; i < nbSegments; i++) {
129 if(i >= ends.size()) {
130 break;
131 }
132 auto &&head = heads[i];
133 auto &&end = ends[i];
134 // find next potential vertex
135 while(head != end && head->ctArc != thisArc)
136 ++head;
137
138 if(!added || true) {
139 } // isLower than actual
140 throw "Not finished yet";
141 }
142 }
143}
void addSegment(const segmentIterator &begin, const segmentIterator &end)
void createSegmentation(const idSuperArc &thisArc)
ArcRegion(const segmentIterator &s)
Segment(const bool order=true)
void sort(const Scalars *s)
SimplexId & operator[](size_t idx)
void emplace_back(const SimplexId &v)
Segment & operator[](size_t idx)
idSuperArc idSegment
for the segmentation, we have an array of segment containing area of the mesh
std::vector< vertex >::iterator segmentIterator
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
T end(std::pair< T, T > &p)
Definition ripserpy.cpp:472
T begin(std::pair< T, T > &p)
Definition ripserpy.cpp:468
bool isHigher(const SimplexId &a, const SimplexId &b) const
bool isLower(const SimplexId &a, const SimplexId &b) const