TTK
Loading...
Searching...
No Matches
ttkMergeTreeTemporalReduction.h
Go to the documentation of this file.
1
35
36#pragma once
37
38// VTK Module
39#include <ttkMergeTreeTemporalReductionModule.h>
40
41// VTK Includes
42#include <ttkAlgorithm.h>
43#include <vtkMultiBlockDataSet.h>
44#include <vtkSmartPointer.h>
45#include <vtkUnstructuredGrid.h>
46
47// TTK Base Includes
49
50class TTKMERGETREETEMPORALREDUCTION_EXPORT ttkMergeTreeTemporalReduction
51 : public ttkAlgorithm // we inherit from the generic ttkAlgorithm class
52 ,
53 protected ttk::MergeTreeTemporalReduction // and we inherit from the
54 // base class
55{
56private:
57 // Execution options
58 std::string TimeVariableName{""};
59
60 // Input Options
61 bool DoResampleToImage = false;
62
63 // ----------------------
64 // Data for visualization
65 // ----------------------
66 // Trees
67 std::vector<vtkUnstructuredGrid *> treesNodes;
68 std::vector<vtkUnstructuredGrid *> treesArcs;
69 std::vector<vtkDataSet *> treesSegmentation;
70 // Output
71 std::vector<std::vector<int>> treesNodeCorrMesh;
72 std::vector<double> emptyTreeDistances;
73 std::vector<ttk::ftm::MergeTree<double>> keyFrames;
74 std::vector<int> removed;
75
76 void setDataVisualization(int numInputs) {
77 // Trees
78 treesNodes = std::vector<vtkUnstructuredGrid *>(numInputs);
79 treesArcs = std::vector<vtkUnstructuredGrid *>(numInputs);
80 treesSegmentation = std::vector<vtkDataSet *>(numInputs);
81 }
82
83 void resetDataVisualization() {
84 setDataVisualization(0);
85 treesNodeCorrMesh = std::vector<std::vector<int>>();
86 emptyTreeDistances = std::vector<double>();
87 keyFrames = std::vector<ttk::ftm::MergeTree<double>>();
88 removed = std::vector<int>();
89 }
90
91 bool isDataVisualizationFilled() {
92 return treesNodeCorrMesh.size() != 0 and keyFrames.size() != 0
93 and emptyTreeDistances.size() != 0 and removed.size() != 0;
94 }
95
96public:
101 // Input Options
102 void SetEpsilon1UseFarthestSaddle(bool epsilon1UseFarthestSaddle) {
103 epsilon1UseFarthestSaddle_ = epsilon1UseFarthestSaddle;
104 Modified();
105 resetDataVisualization();
106 }
110
111 void SetEpsilonTree1(double epsilonTree1) {
112 epsilonTree1_ = epsilonTree1;
113 Modified();
114 resetDataVisualization();
115 }
117 return epsilonTree1_;
118 }
119
120 void SetEpsilon2Tree1(double epsilon2Tree1) {
121 epsilon2Tree1_ = epsilon2Tree1;
122 Modified();
123 resetDataVisualization();
124 }
126 return epsilon2Tree1_;
127 }
128
129 void SetEpsilon3Tree1(double epsilon3Tree1) {
130 epsilon3Tree1_ = epsilon3Tree1;
131 Modified();
132 resetDataVisualization();
133 }
135 return epsilon3Tree1_;
136 }
137
138 void SetPersistenceThreshold(double persistenceThreshold) {
139 persistenceThreshold_ = persistenceThreshold;
140 Modified();
141 resetDataVisualization();
142 }
145 }
146
147 void SetUseMinMaxPair(bool useMinMaxPair) {
148 useMinMaxPair_ = useMinMaxPair;
149 Modified();
150 resetDataVisualization();
151 }
153 return useMinMaxPair_;
154 }
155
156 void SetDeleteMultiPersPairs(bool doDelete) {
157 deleteMultiPersPairs_ = doDelete;
158 Modified();
159 resetDataVisualization();
160 }
164
165 // Execution Options
166 void SetAssignmentSolver(int assignmentSolver) {
167 assignmentSolverID_ = assignmentSolver;
168 Modified();
169 resetDataVisualization();
170 }
172 return assignmentSolverID_;
173 }
174
175 void SetRemovalPercentage(double removePerc) {
176 removalPercentage_ = removePerc;
177 Modified();
178 resetDataVisualization();
179 }
181 return removalPercentage_;
182 }
183
184 void SetUseL2Distance(double useL2) {
185 useL2Distance_ = useL2;
186 Modified();
187 resetDataVisualization();
188 }
190 return useL2Distance_;
191 }
192
193 void SetUseCustomTimeVariable(bool useCustomTime) {
194 useCustomTimeVariable_ = useCustomTime;
195 Modified();
196 resetDataVisualization();
197 }
201
203 int idx, int port, int connection, int fieldAssociation, const char *name) {
204 SetInputArrayToProcess(idx, port, connection, fieldAssociation, name);
205 TimeVariableName = std::string(name);
206 Modified();
207 resetDataVisualization();
208 }
209 vtkGetMacro(TimeVariableName, std::string);
210
217
218protected:
225
230 int FillInputPortInformation(int port, vtkInformation *info) override;
231
236 int FillOutputPortInformation(int port, vtkInformation *info) override;
237
242 int RequestData(vtkInformation *request,
243 vtkInformationVector **inputVector,
244 vtkInformationVector *outputVector) override;
245
246 template <class dataType>
247 int run(vtkInformationVector *outputVector,
248 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
249
250 template <class dataType>
251 int runCompute(
252 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
253
254 template <class dataType>
255 int runOutput(vtkInformationVector *outputVector,
256 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
257};
Baseclass of all VTK filters that wrap ttk modules.
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
TTK VTK-filter that wraps the ttk::MergeTreeTemporalReduction module.
static ttkMergeTreeTemporalReduction * New()
void SetEpsilon1UseFarthestSaddle(bool epsilon1UseFarthestSaddle)
void SetPersistenceThreshold(double persistenceThreshold)
void SetAssignmentSolver(int assignmentSolver)
~ttkMergeTreeTemporalReduction() override
void SetTimeVariableName(int idx, int port, int connection, int fieldAssociation, const char *name)
void SetUseCustomTimeVariable(bool useCustomTime)