TTK
Loading...
Searching...
No Matches
Triangulation.cpp
Go to the documentation of this file.
1#include <Triangulation.h>
2
3using namespace std;
4using namespace ttk;
5
6Triangulation::Triangulation() : abstractTriangulation_{nullptr} {
7 debugLevel_ = 0; // overrides the global debug level.
8 gridDimensions_ = {-1, -1, -1};
10}
11
13 : AbstractTriangulation(rhs), abstractTriangulation_{nullptr},
14 explicitTriangulation_{rhs.explicitTriangulation_},
15 implicitTriangulation_{rhs.implicitTriangulation_},
16 periodicImplicitTriangulation_{rhs.periodicImplicitTriangulation_},
17 compactTriangulation_{rhs.compactTriangulation_} {
18
21
22 switch(rhs.getType()) {
23 case Type::EXPLICIT:
25 break;
26 case Type::COMPACT:
28 break;
29 case Type::IMPLICIT:
31 break;
34 break;
35 case Type::PERIODIC:
37 break;
40 break;
41 }
42}
43
46 std::move(*static_cast<AbstractTriangulation *>(&rhs))),
47 abstractTriangulation_{nullptr}, explicitTriangulation_{std::move(
48 rhs.explicitTriangulation_)},
49 implicitTriangulation_{std::move(rhs.implicitTriangulation_)},
50 periodicImplicitTriangulation_{
51 std::move(rhs.periodicImplicitTriangulation_)},
52 compactTriangulation_{std::move(rhs.compactTriangulation_)} {
53
54 gridDimensions_ = rhs.gridDimensions_;
55 hasPeriodicBoundaries_ = rhs.hasPeriodicBoundaries_;
56
57 switch(rhs.getType()) {
58 case Type::EXPLICIT:
59 this->abstractTriangulation_ = &this->explicitTriangulation_;
60 break;
61 case Type::COMPACT:
62 this->abstractTriangulation_ = &this->compactTriangulation_;
63 break;
64 case Type::IMPLICIT:
65 this->abstractTriangulation_ = &this->implicitTriangulation_;
66 break;
67 case Type::HYBRID_IMPLICIT:
68 this->abstractTriangulation_ = &this->implicitPreconditionsTriangulation_;
69 break;
70 case Type::PERIODIC:
71 this->abstractTriangulation_ = &this->periodicImplicitTriangulation_;
72 break;
73 case Type::HYBRID_PERIODIC:
74 this->abstractTriangulation_ = &this->periodicPreconditionsTriangulation_;
75 break;
76 }
77 rhs.abstractTriangulation_ = nullptr;
78}
79
116
118 if(this != &rhs) {
119 gridDimensions_ = rhs.gridDimensions_;
120 abstractTriangulation_ = nullptr;
121 explicitTriangulation_ = std::move(rhs.explicitTriangulation_);
122 implicitTriangulation_ = std::move(rhs.implicitTriangulation_);
123 periodicImplicitTriangulation_
124 = std::move(rhs.periodicImplicitTriangulation_);
125 compactTriangulation_ = std::move(rhs.compactTriangulation_);
126 hasPeriodicBoundaries_ = rhs.hasPeriodicBoundaries_;
127
128 switch(rhs.getType()) {
129 case Type::EXPLICIT:
130 this->abstractTriangulation_ = &this->explicitTriangulation_;
131 break;
132 case Type::COMPACT:
133 this->abstractTriangulation_ = &this->compactTriangulation_;
134 break;
135 case Type::IMPLICIT:
136 this->abstractTriangulation_ = &this->implicitTriangulation_;
137 break;
138 case Type::HYBRID_IMPLICIT:
139 this->abstractTriangulation_
140 = &this->implicitPreconditionsTriangulation_;
141 break;
142 case Type::PERIODIC:
143 this->abstractTriangulation_ = &this->periodicImplicitTriangulation_;
144 break;
145 case Type::HYBRID_PERIODIC:
146 this->abstractTriangulation_
147 = &this->periodicPreconditionsTriangulation_;
148 break;
149 }
150 }
151 AbstractTriangulation::operator=(std::move(rhs));
152
153 return *this;
154}
155
157
158void Triangulation::switchGrid(const bool usePeriodic,
159 const bool usePreconditions) {
160 if(abstractTriangulation_ != nullptr
165 return;
166 }
167
168 if(abstractTriangulation_ != nullptr) {
169 // clear preconditions when switching triangulation type
171 && (usePeriodic || !usePreconditions)) {
174 && (!usePeriodic || !usePreconditions)) {
176 }
177 }
178
179 if(!usePeriodic && !usePreconditions) {
182 } else if(!usePeriodic && usePreconditions) {
185 } else if(usePeriodic && !usePreconditions) {
188 } else if(usePeriodic && usePreconditions) {
191 }
192}
193
195
196 if(strategy == STRATEGY::DEFAULT) {
197
198#ifndef TTK_IMPLICIT_PRECONDITIONS_THRESHOLD
199#define TTK_IMPLICIT_PRECONDITIONS_THRESHOLD 256 * 256 * 256
200#endif // TTK_IMPLICIT_PRECONDITIONS_THRESHOLD
201
202 const uint64_t threshold{TTK_IMPLICIT_PRECONDITIONS_THRESHOLD};
203 const uint64_t nVerts
205
206 // disable preconditioning above TTK_IMPLICIT_PRECONDITIONS_THRESHOLD
207 const auto doPreconditioning = nVerts <= threshold;
208
209 if(!doPreconditioning) {
210
211 // ensure that the warning message is printed at creation time
212 int prevDebugLevel{-1};
213 if(this->debugLevel_ < 2) {
214 prevDebugLevel = this->debugLevel_;
215 this->debugLevel_ = 2;
216 }
217 this->printWrn("Large grid detected (> " + std::to_string(threshold)
218 + " vertices)");
219 this->printWrn("Defaulting to the fully implicit triangulation");
220 if(prevDebugLevel != -1) {
221 this->debugLevel_ = prevDebugLevel;
222 }
223 }
224 return doPreconditioning;
225 } else if(strategy == STRATEGY::WITH_PRECONDITIONS) {
226 return true;
227 }
228 return false;
229}
#define TTK_IMPLICIT_PRECONDITIONS_THRESHOLD
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
AbstractTriangulation & operator=(const AbstractTriangulation &)=default
std::array< SimplexId, 3 > gridDimensions_
int debugLevel_
Definition Debug.h:379
int printWrn(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:159
Triangulation is a class that provides time and memory efficient traversal methods on triangulations ...
ImplicitNoPreconditions implicitTriangulation_
CompactTriangulation compactTriangulation_
ExplicitTriangulation explicitTriangulation_
PeriodicNoPreconditions periodicImplicitTriangulation_
Triangulation::Type getType() const
~Triangulation() override
void switchGrid(const bool usePeriodic, const bool usePreconditions)
Switch regular grid triangulation type.
AbstractTriangulation * abstractTriangulation_
bool processImplicitStrategy(const STRATEGY strategy=STRATEGY::DEFAULT) const
Should we precondition the implicit/periodic triangulations?
PeriodicWithPreconditions periodicPreconditionsTriangulation_
ImplicitWithPreconditions implicitPreconditionsTriangulation_
Triangulation & operator=(const Triangulation &)
The Topology ToolKit.