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