TTK
Loading...
Searching...
No Matches
ttkMergeTreePrincipalGeodesicsDecoding.h
Go to the documentation of this file.
1
38
39#pragma once
40
41// VTK Module
42#include <ttkMergeTreePrincipalGeodesicsDecodingModule.h>
43
44// VTK Includes
45#include <ttkAlgorithm.h>
46#include <vtkMultiBlockDataSet.h>
47#include <vtkTable.h>
48#include <vtkUnstructuredGrid.h>
49
50// TTK Base Includes
53
54class TTKMERGETREEPRINCIPALGEODESICSDECODING_EXPORT
56 : public ttkAlgorithm // we inherit from the generic ttkAlgorithm class
57 ,
58 protected ttk::MergeTreePrincipalGeodesicsDecoding // and we inherit from
59 // the base class
60{
61private:
67 // Output options
68 bool OutputInputTrees = false;
69 bool OutputInputTreesSegmentation = false;
70 bool OutputBarycenter = true;
71 bool ReconstructInputTrees = true;
72 bool ConstructGeodesicsTrees = false;
73 bool ConstructEllipses = false;
74 bool ConstructRectangle = false;
75 unsigned int RectangleMultiplier = 1;
76 bool ConstructSurface = false;
77 bool ProcessSecondInput = false;
78
79 // ----------------------
80 // Data for visualization
81 // ----------------------
82 // Trees
83 std::vector<ttk::ftm::MergeTree<double>> baryMTree, inputMTrees;
84 std::vector<vtkUnstructuredGrid *> baryTreeNodes, inputTreesNodes;
85 std::vector<vtkUnstructuredGrid *> baryTreeArcs, inputTreesArcs;
86 std::vector<vtkDataSet *> baryTreeSegmentation, inputTreesSegmentation;
87 // Output
88 bool processFirstInput;
89 std::vector<ttk::ftm::MergeTree<double>> reconstructedTrees;
90 std::vector<double> reconstructionErrors;
91 std::vector<
92 std::vector<std::tuple<ttk::ftm::idNode, ttk::ftm::idNode, double>>>
93 recInputMatchings, recBaryMatchings;
94 std::vector<std::vector<ttk::ftm::MergeTree<double>>> geodesicsTrees;
95 std::vector<ttk::ftm::MergeTree<double>> geodesicsEllipses,
96 geodesicsRectangle, geodesicsSurface;
97 vtkFieldData *inputFieldData;
98 // Verify input changed
99 vtkMTimeType tableCoefficientsMTime, tableVectorsMTime, tableCorrelationMTime,
100 blockInputTreesMTime;
101
102 void setDataVisualization(int numTrees) {
103 // Trees
104 baryMTree.resize(1);
105 baryTreeNodes.resize(1);
106 baryTreeArcs.resize(1);
107 baryTreeSegmentation.resize(1);
108
109 inputMTrees.resize(numTrees);
110 inputTreesNodes.resize(numTrees);
111 inputTreesArcs.resize(numTrees);
112 inputTreesSegmentation.resize(numTrees);
113 }
114
115 bool isDataVisualizationFilled() {
116 return (ReconstructInputTrees == (reconstructedTrees.size() != 0))
117 and (ConstructGeodesicsTrees == (geodesicsTrees.size() != 0))
118 and (ConstructEllipses == (geodesicsEllipses.size() != 0))
119 and (ConstructRectangle == (geodesicsRectangle.size() != 0))
120 and (ConstructSurface == (geodesicsSurface.size() != 0))
121 and (not OutputInputTrees) and geodesicsDistances_.size() != 0;
122 }
123
124 void resetDataVisualization() {
125 setDataVisualization(0);
126 reconstructedTrees.clear();
127 geodesicsTrees.clear();
128 geodesicsEllipses.clear();
129 geodesicsRectangle.clear();
130 geodesicsSurface.clear();
131 geodesicsDistances_.clear();
132 }
133
134public:
139 // Input options
141 k_ = k;
142 Modified();
143 resetDataVisualization();
144 }
145
147 return k_;
148 }
149
150 // Output options
151 vtkSetMacro(OutputInputTrees, bool);
152 vtkGetMacro(OutputInputTrees, bool);
153
154 vtkSetMacro(OutputInputTreesSegmentation, bool);
155 vtkGetMacro(OutputInputTreesSegmentation, bool);
156
157 vtkSetMacro(OutputBarycenter, bool);
158 vtkGetMacro(OutputBarycenter, bool);
159
160 vtkSetMacro(ReconstructInputTrees, bool);
161 vtkGetMacro(ReconstructInputTrees, bool);
162
164 computeReconstructionError_ = b;
165 Modified();
166 resetDataVisualization();
167 }
168 vtkGetMacro(computeReconstructionError_, bool);
169
171 transferInputTreesInformation_ = b;
172 Modified();
173 resetDataVisualization();
174 }
175 vtkGetMacro(transferInputTreesInformation_, bool);
176
178 transferBarycenterInformation_ = b;
179 Modified();
180 resetDataVisualization();
181 }
182 vtkGetMacro(transferBarycenterInformation_, bool);
183
184 vtkSetMacro(ConstructGeodesicsTrees, bool);
185 vtkGetMacro(ConstructGeodesicsTrees, bool);
186
187 vtkSetMacro(ConstructEllipses, bool);
188 vtkGetMacro(ConstructEllipses, bool);
189
190 vtkSetMacro(ConstructRectangle, bool);
191 vtkGetMacro(ConstructRectangle, bool);
192
193 void SetRectangleMultiplier(unsigned int mult) {
194 RectangleMultiplier = mult;
195 Modified();
196 geodesicsRectangle.clear();
197 }
198 vtkGetMacro(RectangleMultiplier, unsigned int);
199
200 vtkSetMacro(ConstructSurface, bool);
201 vtkGetMacro(ConstructSurface, bool);
202
204 ProcessSecondInput = b;
205 Modified();
206 resetDataVisualization();
207 }
208 vtkGetMacro(ProcessSecondInput, bool);
209
216
217protected:
223
228 int FillInputPortInformation(int port, vtkInformation *info) override;
229
234 int FillOutputPortInformation(int port, vtkInformation *info) override;
235
240 int RequestData(vtkInformation *request,
241 vtkInformationVector **inputVector,
242 vtkInformationVector *outputVector) override;
243
244 template <class dataType>
245 int run(vtkInformationVector *outputVector,
246 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputBary,
247 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
248
249 template <class dataType>
251 vtkInformationVector *outputVector,
252 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputBary,
253 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
254
255 template <class dataType>
256 int runOutput(vtkInformationVector *outputVector,
257 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputBary,
258 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
259};
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::MergeTreePrincipalGeodesicsDecoding module.
int runOutput(vtkInformationVector *outputVector, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputBary, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)
static ttkMergeTreePrincipalGeodesicsDecoding * New()
int runCompute(vtkInformationVector *outputVector, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputBary, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)