TTK
Loading...
Searching...
No Matches
ttkPersistenceDiagramClustering.h
Go to the documentation of this file.
1
32
33#pragma once
34
35// VTK includes
36#include <vtkMultiBlockDataSetAlgorithm.h>
37#include <vtkNew.h>
38
39// VTK Module
40#include <ttkPersistenceDiagramClusteringModule.h>
41
42// TTK includes
44#include <ttkAlgorithm.h>
45#include <ttkMacros.h>
46
47class vtkUnstructuredGrid;
48
49class TTKPERSISTENCEDIAGRAMCLUSTERING_EXPORT ttkPersistenceDiagramClustering
50 : public ttkAlgorithm,
52
53public:
55
57
58 enum class DISPLAY {
60 STARS = 1,
62 };
63
64 enum class METHOD {
67 };
68
69 vtkSetMacro(WassersteinMetric, int);
70 vtkGetMacro(WassersteinMetric, int);
71
72 vtkSetMacro(UseProgressive, bool);
73 vtkGetMacro(UseProgressive, bool);
74
75 vtkSetMacro(TimeLimit, double);
76 vtkGetMacro(TimeLimit, double);
77
78 void SetAlpha(const double alpha) {
79 this->Alpha = std::min(std::abs(alpha), 1.0);
80 Modified();
81 }
82 void SetAntiAlpha(const double antiAlpha) {
83 SetAlpha(1.0 - antiAlpha);
84 }
85 vtkGetMacro(Alpha, double);
86
87 vtkSetMacro(DeltaLim, double);
88 vtkGetMacro(DeltaLim, double);
89
90 vtkSetMacro(Lambda, double);
91 vtkGetMacro(Lambda, double);
92
93 vtkSetMacro(NumberOfClusters, int);
94 vtkGetMacro(NumberOfClusters, int);
95
96 vtkSetMacro(UseAccelerated, bool);
97 vtkGetMacro(UseAccelerated, bool);
98
99 vtkSetMacro(UseKmeansppInit, bool);
100 vtkGetMacro(UseKmeansppInit, bool);
101
102 vtkSetMacro(ForceUseOfAlgorithm, bool);
103 vtkGetMacro(ForceUseOfAlgorithm, bool);
104
105 vtkSetMacro(Deterministic, bool);
106 vtkGetMacro(Deterministic, bool);
107
108 vtkSetMacro(PairTypeClustering, int);
109 vtkGetMacro(PairTypeClustering, int);
110
111 void SetSpacing(double spacing) {
112 this->Spacing = spacing;
113 Modified();
114 if(!intermediateDiagrams_.empty()) {
115 // skip clustering computation only if done at least once before
116 this->needUpdate_ = false;
117 }
118 }
119 vtkGetMacro(Spacing, double);
120
121 void SetDisplayMethod(int displayMethod) {
122 this->DisplayMethod = static_cast<DISPLAY>(displayMethod);
123 Modified();
124 if(!intermediateDiagrams_.empty()) {
125 // skip clustering computation only if done at least once before
126 this->needUpdate_ = false;
127 }
128 }
129 vtkGetEnumMacro(DisplayMethod, DISPLAY);
130
131 vtkSetMacro(UseAdditionalPrecision, bool);
132 vtkGetMacro(UseAdditionalPrecision, bool);
133
134 vtkSetMacro(DistanceWritingOptions, int);
135 vtkGetMacro(DistanceWritingOptions, int);
136
137 vtkSetMacro(UseInterruptible, bool);
138 vtkGetMacro(UseInterruptible, bool);
139
141 vtkGetEnumMacro(Method, METHOD);
142
143 vtkSetMacro(NonMatchingWeight, double);
144 vtkGetMacro(NonMatchingWeight, double);
145
146protected:
148
149 int FillInputPortInformation(int port, vtkInformation *info) override;
150 int FillOutputPortInformation(int port, vtkInformation *info) override;
151 void Modified() override;
152
154 vtkMultiBlockDataSet *output,
155 const std::vector<vtkUnstructuredGrid *> &diagsVTU,
156 const std::vector<ttk::DiagramType> &diags,
157 const std::vector<std::vector<std::vector<ttk::MatchingType>>>
158 &matchingsPerCluster,
159 const std::vector<int> &inv_clustering,
160 const DISPLAY dm,
161 const double spacing,
162 const double max_persistence) const;
163 void outputCentroids(
164 vtkMultiBlockDataSet *output,
165 const std::vector<ttk::DiagramType> &final_centroids,
166 const std::vector<std::vector<std::vector<ttk::MatchingType>>>
167 &matchingsPerCluster,
168 vtkUnstructuredGrid *const someInputDiag,
169 const DISPLAY dm,
170 const double spacing,
171 const double max_persistence) const;
172 void outputMatchings(
173 vtkMultiBlockDataSet *output,
174 const size_t nClusters,
175 const std::vector<ttk::DiagramType> &diags,
176 const std::vector<std::vector<std::vector<ttk::MatchingType>>>
177 &matchingsPerCluster,
178 const std::vector<ttk::DiagramType> &centroids,
179 const std::vector<int> &inv_clustering,
181 const double spacing,
182 const double max_persistence) const;
183
184 int RequestData(vtkInformation *request,
185 vtkInformationVector **inputVector,
186 vtkInformationVector *outputVector) override;
187
188private:
189 std::vector<ttk::DiagramType> intermediateDiagrams_{};
190 std::vector<std::vector<std::vector<ttk::MatchingType>>> all_matchings_{};
191 std::vector<ttk::DiagramType> final_centroids_{};
192 std::vector<int> inv_clustering_{};
193
194 double Spacing{1.0};
195 double max_dimension_total_{};
196
197 DISPLAY DisplayMethod{DISPLAY::COMPACT};
198 METHOD Method{METHOD::PROGRESSIVE};
199 bool needUpdate_{true};
200};
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
void outputCentroids(vtkMultiBlockDataSet *output, const std::vector< ttk::DiagramType > &final_centroids, const std::vector< std::vector< std::vector< ttk::MatchingType > > > &matchingsPerCluster, vtkUnstructuredGrid *const someInputDiag, const DISPLAY dm, const double spacing, const double max_persistence) const
void outputClusteredDiagrams(vtkMultiBlockDataSet *output, const std::vector< vtkUnstructuredGrid * > &diagsVTU, const std::vector< ttk::DiagramType > &diags, const std::vector< std::vector< std::vector< ttk::MatchingType > > > &matchingsPerCluster, const std::vector< int > &inv_clustering, const DISPLAY dm, const double spacing, const double max_persistence) const
void outputMatchings(vtkMultiBlockDataSet *output, const size_t nClusters, const std::vector< ttk::DiagramType > &diags, const std::vector< std::vector< std::vector< ttk::MatchingType > > > &matchingsPerCluster, const std::vector< ttk::DiagramType > &centroids, const std::vector< int > &inv_clustering, const ttkPersistenceDiagramClustering::DISPLAY dm, const double spacing, const double max_persistence) const
static ttkPersistenceDiagramClustering * New()
TTK processing package for the computation of Wasserstein barycenters and K-Means clusterings of a se...
#define ttkSetEnumMacro(name, enumType)
Definition ttkMacros.h:38