12#ifndef TTK_ENABLE_KAMIKAZE
33 return vertices_.begin();
37 return vertices_.begin();
41 list<vector<SimplexId>> ®ularList,
43 auto vectComp = [&](
const vector<SimplexId> &a,
const vector<SimplexId> &b) {
48 for(
const auto &vectReg : regularList) {
49 totalSize += vectReg.size();
51 vertices_.reserve(totalSize);
53 regularList.sort(vectComp);
56 for(
auto it1 = regularList.cbegin(); it1 != regularList.cend(); ++it1) {
57 for(
auto it2 = it1->crbegin(); it2 != it1->crend(); ++it2) {
58 vertices_.emplace_back(*it2);
62 for(
auto it1 = regularList.cbegin(); it1 != regularList.cend(); ++it1) {
63 for(
auto it2 = it1->cbegin(); it2 != it1->cend(); ++it2) {
64 vertices_.emplace_back(*it2);
73 return vertices_.end();
77 return vertices_.end();
81 return vertices_[idx];
85 return vertices_[idx];
89 return vertices_.size();
96 std::sort(vertices_.begin(), vertices_.end(), comp);
110 return segments_[idx];
114 return segments_[idx];
118#ifndef TTK_ENABLE_KAMIKAZE
119 if(segments_.size()) {
120 cerr <<
"Call reserve on an already reserved Segments! " << endl;
124 segments_.reserve(sizes.size());
126 segments_.emplace_back(
size);
131 return segments_.size();
137 for(
idSegment i = 0; i < nbSegments; i++) {
138#ifdef TTK_ENABLE_OPENMP
139#pragma omp task firstprivate(i)
141 segments_[i].sort(s);
143#ifdef TTK_ENABLE_OPENMP
151#ifndef TTK_ENABLE_KAMIKAZE
168 for(
const auto ® : r.segmentsIn_) {
169 concat(reg.segmentBegin, reg.segmentEnd);
174#ifndef TTK_ENABLE_KAMIKAZE
175 if(segmentation_.size()) {
176 cout <<
"createSegmentation called on an already segmented region" << endl;
181 vector<segm_const_it> heads, ends;
182 for(
const auto ®ion : segmentsIn_) {
183 totalSegmSize += distance(region.segmentBegin, region.segmentEnd);
184 heads.emplace_back(region.segmentBegin);
185 ends.emplace_back(region.segmentEnd);
188 segmentation_.clear();
189 segmentation_.reserve(
198 for(
idSegment i = 0; i < nbSegments; i++) {
199 auto &headIt = heads[i];
200 const auto &endIt = ends[i];
202 if(headIt == endIt) {
204 heads.erase(heads.begin() + i);
205 ends.erase(ends.begin() + i);
211 if(added == -1 || s->
isLower(*headIt, minVert)) {
217 segmentation_.emplace_back(minVert);
222#ifndef TTK_ENABLE_KAMIKAZE
229 const vector<idCorresp> &vert2treeOther)
const {
234 const bool chkOther = vert2treeOther.size() > 0;
236 for(
const auto ® : segmentsIn_) {
241 const auto &oldBeg = reg.segmentBegin;
242 auto posV = lower_bound(oldBeg, reg.segmentEnd, v, comp);
245 if(posV != oldBeg && *posV != v) {
250 while(posV != oldBeg && vert2treeOther[*posV] == nullCorresp) {
253 if(posV == oldBeg && vert2treeOther[*posV] == nullCorresp) {
258 if(posV != reg.segmentEnd) {
262 }
else if(s->
isLower(*(reg.segmentEnd - 1), v)) {
264 if(splitVert == nullVertex
265 || s->
isHigher(*(reg.segmentEnd - 1), splitVert)) {
266 auto posV = reg.segmentEnd - 1;
268 const auto &oldBeg = reg.segmentBegin;
269 while(posV != oldBeg && vert2treeOther[*posV] == nullCorresp) {
272 if(((posV == oldBeg && vert2treeOther[*posV] != nullCorresp)
274 && (splitVert == nullVertex || s->
isHigher(*posV, splitVert))) {
288 const Region &other = r.segmentsIn_.front();
289 Region &self = segmentsIn_.front();
310 list<
decltype(segmentsIn_)::iterator> willErase;
312 for(
decltype(segmentsIn_)::iterator it = segmentsIn_.begin();
313 it != segmentsIn_.end(); ++it) {
319 const auto &oldBeg = reg.segmentBegin;
320 auto posV = lower_bound(oldBeg, reg.segmentEnd, v, comp);
323 if(posV != oldBeg && *posV != v) {
328 remainingRegion.
concat(oldBeg, posV);
331 if(posV == reg.segmentEnd) {
332 willErase.emplace_back(it);
335 reg.segmentBegin = posV;
338 }
else if(s->
isLower(*(reg.segmentEnd - 1), v)) {
340 remainingRegion.
concat(reg.segmentBegin, reg.segmentEnd);
341 willErase.emplace_back(it);
342 if(splitVert == nullVertex
343 || s->
isHigher(*(reg.segmentEnd - 1), splitVert)) {
344 splitVert = *(reg.segmentEnd - 1);
350 for(
auto &tmpIt : willErase) {
351 segmentsIn_.erase(tmpIt);
354 return make_tuple(splitVert, remainingRegion);
365 list<
decltype(segmentsIn_)::iterator> willErase;
367 for(
decltype(segmentsIn_)::iterator it = segmentsIn_.begin();
368 it != segmentsIn_.end(); ++it) {
374 const auto &oldEnd = reg.segmentEnd;
375 auto posV = lower_bound(reg.segmentBegin, oldEnd, v, comp);
379 remainingRegion.
concat(posV, oldEnd);
382 if(posV == reg.segmentBegin) {
383 willErase.emplace_back(it);
385 reg.segmentEnd = posV;
388 }
else if(s->
isHigher(*reg.segmentBegin, v)) {
390 remainingRegion.
concat(reg.segmentBegin, reg.segmentEnd);
391 willErase.emplace_back(it);
392 if(splitVert == nullVertex || s->
isLower(*reg.segmentBegin, splitVert)) {
394 splitVert = *reg.segmentBegin;
400 for(
auto &tmpIt : willErase) {
401 segmentsIn_.erase(tmpIt);
404 return make_tuple(splitVert, remainingRegion);
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
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)
segm_const_it begin() const
SimplexId operator[](const size_t &idx) const
void createFromList(const Scalars *s, std::list< std::vector< SimplexId > > ®ularsList, const bool reverse)
segm_const_it end() const
void sort(const Scalars *s)
void sortAll(const Scalars *s)
Segment & operator[](const size_t &idx)
void resize(const std::vector< SimplexId > &sizes)
idSuperArc idSegment
for the segmentation, we have an array of segment containing area of the mesh
std::vector< SimplexId >::iterator segm_it
std::vector< SimplexId >::const_iterator segm_const_it
int SimplexId
Identifier type for simplices of any dimension.
T end(std::pair< T, T > &p)
T begin(std::pair< T, T > &p)
bool isEqLower(const SimplexId a, const SimplexId b) const
bool isLower(const SimplexId a, const SimplexId b) const
bool isHigher(const SimplexId a, const SimplexId b) const
bool isEqHigher(const SimplexId a, const SimplexId b) const