TTK
Loading...
Searching...
No Matches
FTMTree_Template.h
Go to the documentation of this file.
1
15
16#pragma once
17
18#include "FTMTree.h"
19
20// for std::isnan
21#include <cmath>
22// for std::numeric_limits
23#include <limits>
24
25// -------
26// PROCESS
27// -------
28
29template <typename scalarType, class triangulationType>
30void ttk::ftm::FTMTree::build(const triangulationType *mesh) {
31 // -----
32 // INPUT
33 // -----
34
36
37#ifdef TTK_ENABLE_OPENMP
38 ParallelGuard const pg{threadNumber_};
39 omp_set_nested(1);
40#ifdef TTK_ENABLE_OMP_PRIORITY
41 if(omp_get_max_task_priority() < 5) {
42 this->printWrn("OpenMP max priority is lower than 5");
43 }
44#endif
45#endif
46
47 // ----
48 // INIT
49 // ----
50
52 initNbScalars(mesh);
53
54 // This section is aimed to prevent un-deterministic results if the data-set
55 // have NaN values in it.
56 // In this loop, we replace every NaN by a 0 value.
57 // Recall: Equals values are distinguished using Simulation of Simplicity in
58 // the FTM tree computation Note: Can we detect NaN using vtk ?
59 if(::std::numeric_limits<scalarType>::has_quiet_NaN) {
60#ifdef TTK_ENABLE_OPENMP
61#pragma omp parallel for
62#endif
63 for(SimplexId i = 0; i < scalars_->size; i++) {
64 if(::std::isnan((double)(((scalarType *)scalars_->values)[i]))) {
65 ((scalarType *)scalars_->values)[i] = 0;
66 }
67 }
68 }
69
70 // Alloc / reserve
71 Timer initTime;
72 switch(params_->treeType) {
73 case TreeType::Join:
75 break;
76 case TreeType::Split:
78 break;
82 break;
86 makeAlloc();
87 break;
88 default:
89 break;
90 }
91 printTime(initTime, "alloc", 3);
92
93 Timer startTime;
94
95 // init values
96 Timer setTimer;
97 switch(params_->treeType) {
98 case TreeType::Join:
100 break;
101 case TreeType::Split:
103 break;
107 break;
111 makeInit();
112 break;
113 default:
114 break;
115 }
116 printTime(setTimer, "init", 3);
117
118 // for fast comparison
119 // and regions / segmentation
120 Timer sortTime;
121 sortInput<scalarType>();
122 printTime(sortTime, "sort step", 3);
123
124 // -----
125 // BUILD
126 // -----
127
128 Timer buildTime;
129 FTMTree_CT::build(mesh, params_->treeType);
130 printTime(buildTime, "build tree", 3);
131
132 printTime(startTime, "Total ", 1);
133
134#ifdef PERF_TESTS
135 exit(0);
136#endif
137
138 // Build the list of regular vertices of the arc
139 if(params_->segm) {
140 switch(params_->treeType) {
141 case TreeType::Join:
144 break;
145 case TreeType::Split:
148 break;
154 break;
157 break;
158 default:
159 break;
160 }
161 }
162
163 // Normalization
164 if(params_->normalize) {
165 switch(params_->treeType) {
166 case TreeType::Join:
168 break;
169 case TreeType::Split:
171 break;
175 break;
177 normalizeIds();
178 break;
179 default:
180 break;
181 }
182 }
183
184 if(debugLevel_ > 4) {
185 switch(params_->treeType) {
186 case TreeType::Join:
187 jt_.printTree2();
188 break;
189 case TreeType::Split:
190 st_.printTree2();
191 break;
193 jt_.printTree2();
194 st_.printTree2();
195 break;
196 default:
197 printTree2();
198 }
199 }
200}
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
void build(const triangulationType *mesh, TreeType tt)
FTMTree_MT * getSplitTree()
Definition FTMTree_CT.h:51
int setDebugLevel(const int &d) override
Definition FTMTree_CT.h:79
FTMTree_MT * getJoinTree()
Definition FTMTree_CT.h:47
std::shared_ptr< Params > params_
Definition FTMTree_MT.h:86
void printParams() const
void initNbScalars(const triangulationType *triangulation)
Definition FTMTree_MT.h:119
void makeAlloc()
clear local data for new computation
Definition FTMTree_MT.h:154
int printTime(Timer &t, const std::string &s, const int debugLevel=2) const
void buildSegmentation()
use vert2tree to compute the segmentation of the fresh built merge tree.
std::shared_ptr< Scalars > scalars_
Definition FTMTree_MT.h:87
void build(const triangulationType *mesh)
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22