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:
66
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 int DiagramPairTypes = 0;
80
81 // ----------------------
82 // Data for visualization
83 // ----------------------
84 // Trees
85 std::vector<ttk::ftm::MergeTree<double>> baryMTree, inputMTrees;
86 std::vector<vtkUnstructuredGrid *> baryTreeNodes, inputTreesNodes;
87 std::vector<vtkUnstructuredGrid *> baryTreeArcs, inputTreesArcs;
88 std::vector<vtkDataSet *> baryTreeSegmentation, inputTreesSegmentation;
89 // Output
90 bool processFirstInput;
91 std::vector<ttk::ftm::MergeTree<double>> reconstructedTrees;
92 std::vector<double> reconstructionErrors;
93 std::vector<
94 std::vector<std::tuple<ttk::ftm::idNode, ttk::ftm::idNode, double>>>
95 recInputMatchings, recBaryMatchings;
96 std::vector<std::vector<ttk::ftm::MergeTree<double>>> geodesicsTrees;
97 std::vector<ttk::ftm::MergeTree<double>> geodesicsEllipses,
98 geodesicsRectangle, geodesicsSurface;
99 vtkFieldData *inputFieldData;
100 // Verify input changed
101 vtkMTimeType tableCoefficientsMTime, tableVectorsMTime, tableCorrelationMTime,
102 blockInputTreesMTime;
103
104 void setDataVisualization(int numTrees) {
105 // Trees
106 baryMTree.resize(1);
107 baryTreeNodes.resize(1);
108 baryTreeArcs.resize(1);
109 baryTreeSegmentation.resize(1);
110
111 inputMTrees.resize(numTrees);
112 inputTreesNodes.resize(numTrees);
113 inputTreesArcs.resize(numTrees);
114 inputTreesSegmentation.resize(numTrees);
115 }
116
117 bool isDataVisualizationFilled() {
118 return (ReconstructInputTrees == (reconstructedTrees.size() != 0))
119 and (ConstructGeodesicsTrees == (geodesicsTrees.size() != 0))
120 and (ConstructEllipses == (geodesicsEllipses.size() != 0))
121 and (ConstructRectangle == (geodesicsRectangle.size() != 0))
122 and (ConstructSurface == (geodesicsSurface.size() != 0))
123 and (not OutputInputTrees) and geodesicsDistances_.size() != 0;
124 }
125
126 void resetDataVisualization() {
127 setDataVisualization(0);
128 reconstructedTrees.clear();
129 geodesicsTrees.clear();
130 geodesicsEllipses.clear();
131 geodesicsRectangle.clear();
132 geodesicsSurface.clear();
133 geodesicsDistances_.clear();
134 }
135
136public:
141 // Input options
143 k_ = k;
144 Modified();
145 resetDataVisualization();
146 }
147
149 return k_;
150 }
151
152 // Output options
153 vtkSetMacro(OutputInputTrees, bool);
154 vtkGetMacro(OutputInputTrees, bool);
155
156 vtkSetMacro(OutputInputTreesSegmentation, bool);
157 vtkGetMacro(OutputInputTreesSegmentation, bool);
158
159 vtkSetMacro(OutputBarycenter, bool);
160 vtkGetMacro(OutputBarycenter, bool);
161
162 vtkSetMacro(ReconstructInputTrees, bool);
163 vtkGetMacro(ReconstructInputTrees, bool);
164
167 Modified();
168 resetDataVisualization();
169 }
170 vtkGetMacro(computeReconstructionError_, bool);
171
174 Modified();
175 resetDataVisualization();
176 }
178
181 Modified();
182 resetDataVisualization();
183 }
185
186 vtkSetMacro(ConstructGeodesicsTrees, bool);
187 vtkGetMacro(ConstructGeodesicsTrees, bool);
188
189 vtkSetMacro(ConstructEllipses, bool);
190 vtkGetMacro(ConstructEllipses, bool);
191
192 vtkSetMacro(ConstructRectangle, bool);
193 vtkGetMacro(ConstructRectangle, bool);
194
195 void SetRectangleMultiplier(unsigned int mult) {
196 RectangleMultiplier = mult;
197 Modified();
198 geodesicsRectangle.clear();
199 }
200 vtkGetMacro(RectangleMultiplier, unsigned int);
201
202 vtkSetMacro(ConstructSurface, bool);
203 vtkGetMacro(ConstructSurface, bool);
204
206 ProcessSecondInput = b;
207 Modified();
208 resetDataVisualization();
209 }
210 vtkGetMacro(ProcessSecondInput, bool);
211
218
219protected:
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>> &inputBary,
249 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
250
251 template <class dataType>
253 vtkInformationVector *outputVector,
254 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputBary,
255 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
256
257 template <class dataType>
258 int runOutput(vtkInformationVector *outputVector,
259 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputBary,
260 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> &inputTrees);
261};
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 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)
int run(vtkInformationVector *outputVector, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputBary, std::vector< vtkSmartPointer< vtkMultiBlockDataSet > > &inputTrees)