TTK
Loading...
Searching...
No Matches
ttkMergeTreeTemporalReduction.h
Go to the documentation of this file.
1
31
42
43#pragma once
44
45// VTK Module
46#include <ttkMergeTreeTemporalReductionModule.h>
47
48// VTK Includes
49#include <ttkAlgorithm.h>
50#include <vtkMultiBlockDataSet.h>
51#include <vtkSmartPointer.h>
52#include <vtkUnstructuredGrid.h>
53
54// TTK Base Includes
56
57class TTKMERGETREETEMPORALREDUCTION_EXPORT ttkMergeTreeTemporalReduction
58 : public ttkAlgorithm // we inherit from the generic ttkAlgorithm class
59 ,
60 protected ttk::MergeTreeTemporalReduction // and we inherit from the
61 // base class
62{
63private:
64 // Execution options
65 std::string TimeVariableName{""};
66
67 // Input Options
68 bool DoResampleToImage = false;
69
70 // ----------------------
71 // Data for visualization
72 // ----------------------
73 // Trees
74 std::vector<vtkUnstructuredGrid *> treesNodes;
75 std::vector<vtkUnstructuredGrid *> treesArcs;
76 std::vector<vtkDataSet *> treesSegmentation;
77 // Output
78 std::vector<std::vector<int>> treesNodeCorrMesh;
79 std::vector<double> emptyTreeDistances;
80 std::vector<ttk::ftm::MergeTree<double>> keyFrames;
81 std::vector<int> removed;
82
83 void setDataVisualization(int numInputs) {
84 // Trees
85 treesNodes = std::vector<vtkUnstructuredGrid *>(numInputs);
86 treesArcs = std::vector<vtkUnstructuredGrid *>(numInputs);
87 treesSegmentation = std::vector<vtkDataSet *>(numInputs);
88 }
89
90 void resetDataVisualization() {
91 setDataVisualization(0);
92 treesNodeCorrMesh = std::vector<std::vector<int>>();
93 emptyTreeDistances = std::vector<double>();
94 keyFrames = std::vector<ttk::ftm::MergeTree<double>>();
95 removed = std::vector<int>();
96 }
97
98 bool isDataVisualizationFilled() {
99 return treesNodeCorrMesh.size() != 0 and keyFrames.size() != 0
100 and emptyTreeDistances.size() != 0 and removed.size() != 0;
101 }
102
103public:
108 // Input Options
109 void SetEpsilon1UseFarthestSaddle(bool epsilon1UseFarthestSaddle) {
110 epsilon1UseFarthestSaddle_ = epsilon1UseFarthestSaddle;
111 Modified();
112 resetDataVisualization();
113 }
117
118 void SetEpsilonTree1(double epsilonTree1) {
119 epsilonTree1_ = epsilonTree1;
120 Modified();
121 resetDataVisualization();
122 }
124 return epsilonTree1_;
125 }
126
127 void SetEpsilon2Tree1(double epsilon2Tree1) {
128 epsilon2Tree1_ = epsilon2Tree1;
129 Modified();
130 resetDataVisualization();
131 }
133 return epsilon2Tree1_;
134 }
135
136 void SetEpsilon3Tree1(double epsilon3Tree1) {
137 epsilon3Tree1_ = epsilon3Tree1;
138 Modified();
139 resetDataVisualization();
140 }
142 return epsilon3Tree1_;
143 }
144
145 void SetPersistenceThreshold(double persistenceThreshold) {
146 persistenceThreshold_ = persistenceThreshold;
147 Modified();
148 resetDataVisualization();
149 }
152 }
153
154 void SetUseMinMaxPair(bool useMinMaxPair) {
155 useMinMaxPair_ = useMinMaxPair;
156 Modified();
157 resetDataVisualization();
158 }
160 return useMinMaxPair_;
161 }
162
163 void SetDeleteMultiPersPairs(bool doDelete) {
164 deleteMultiPersPairs_ = doDelete;
165 Modified();
166 resetDataVisualization();
167 }
171
172 // Execution Options
173 void SetAssignmentSolver(int assignmentSolver) {
174 assignmentSolverID_ = assignmentSolver;
175 Modified();
176 resetDataVisualization();
177 }
179 return assignmentSolverID_;
180 }
181
182 void SetRemovalPercentage(double removePerc) {
183 removalPercentage_ = removePerc;
184 Modified();
185 resetDataVisualization();
186 }
188 return removalPercentage_;
189 }
190
191 void SetUseL2Distance(double useL2) {
192 useL2Distance_ = useL2;
193 Modified();
194 resetDataVisualization();
195 }
197 return useL2Distance_;
198 }
199
200 void SetUsePathMappings(double usePM) {
201 usePathMappings_ = usePM;
202 Modified();
203 resetDataVisualization();
204 }
206 return usePathMappings_;
207 }
208
209 void SetUseCustomTimeVariable(bool useCustomTime) {
210 useCustomTimeVariable_ = useCustomTime;
211 Modified();
212 resetDataVisualization();
213 }
217
219 int idx, int port, int connection, int fieldAssociation, const char *name) {
220 SetInputArrayToProcess(idx, port, connection, fieldAssociation, name);
221 TimeVariableName = std::string(name);
222 Modified();
223 resetDataVisualization();
224 }
225 vtkGetMacro(TimeVariableName, std::string);
226
233
234protected:
241
246 int FillInputPortInformation(int port, vtkInformation *info) override;
247
252 int FillOutputPortInformation(int port, vtkInformation *info) override;
253
258 int RequestData(vtkInformation *request,
259 vtkInformationVector **inputVector,
260 vtkInformationVector *outputVector) override;
261
262 template <class dataType>
263 int run(vtkInformationVector *outputVector,
264 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
265
266 template <class dataType>
267 int runCompute(
268 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
269
270 template <class dataType>
271 int runOutput(vtkInformationVector *outputVector,
272 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
273};
virtual int RequestData(vtkInformation *ttkNotUsed(request), vtkInformationVector **ttkNotUsed(inputVectors), vtkInformationVector *ttkNotUsed(outputVector))
int FillInputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
int FillOutputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
int run(vtkInformationVector *outputVector, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)
static ttkMergeTreeTemporalReduction * New()
void SetEpsilon1UseFarthestSaddle(bool epsilon1UseFarthestSaddle)
void SetPersistenceThreshold(double persistenceThreshold)
void SetAssignmentSolver(int assignmentSolver)
int runOutput(vtkInformationVector *outputVector, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)
~ttkMergeTreeTemporalReduction() override
void SetTimeVariableName(int idx, int port, int connection, int fieldAssociation, const char *name)
void SetUseCustomTimeVariable(bool useCustomTime)
int runCompute(std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)