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