VTK  9.3.1
vtkClustering2DLayoutStrategy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
20 #ifndef vtkClustering2DLayoutStrategy_h
21 #define vtkClustering2DLayoutStrategy_h
22 
23 #include "vtkGraphLayoutStrategy.h"
24 #include "vtkInfovisLayoutModule.h" // For export macro
25 
26 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkFastSplatter;
30 class vtkImageData;
31 class vtkIntArray;
32 class vtkFloatArray;
33 
34 class VTKINFOVISLAYOUT_EXPORT vtkClustering2DLayoutStrategy : public vtkGraphLayoutStrategy
35 {
36 public:
38 
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
43 
48  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
49  vtkGetMacro(RandomSeed, int);
51 
53 
61  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
62  vtkGetMacro(MaxNumberOfIterations, int);
64 
66 
73  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
74  vtkGetMacro(IterationsPerLayout, int);
76 
78 
84  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
85  vtkGetMacro(InitialTemperature, float);
87 
89 
97  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
98  vtkGetMacro(CoolDownRate, double);
100 
102 
106  vtkSetMacro(RestDistance, float);
107  vtkGetMacro(RestDistance, float);
109 
114  void Initialize() override;
115 
123  void Layout() override;
124 
129  int IsLayoutComplete() override { return this->LayoutComplete; }
130 
131 protected:
133  ~vtkClustering2DLayoutStrategy() override;
134 
135  int MaxNumberOfIterations; // Maximum number of iterations.
137  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
138 
139 private:
140  // An edge consists of two vertices joined together.
141  // This struct acts as a "pointer" to those two vertices.
142  struct vtkLayoutEdge_t
143  {
144  vtkIdType from;
145  vtkIdType to;
146  float weight;
147  int dead_edge; // I'm making this an int so that the edge array is
148  // word boundary aligned... but I'm not sure what
149  // really happens in these days of magical compilers
150  };
151  using vtkLayoutEdge = struct vtkLayoutEdge_t;
152 
153  // This class 'has a' vtkFastSplatter for the density grid
156  vtkSmartPointer<vtkFloatArray> RepulsionArray;
157  vtkSmartPointer<vtkFloatArray> AttractionArray;
158  vtkSmartPointer<vtkIntArray> EdgeCountArray;
159 
160  vtkLayoutEdge* EdgeArray;
161 
162  int RandomSeed;
163  int IterationsPerLayout;
164  int TotalIterations;
165  int LayoutComplete;
166  float Temp;
167  float RestDistance;
168  float CuttingThreshold;
169 
170  // Private helper methods
171  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
172  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
173  void ResolveCoincidentVertices();
174 
176  void operator=(const vtkClustering2DLayoutStrategy&) = delete;
177 };
178 
179 VTK_ABI_NAMESPACE_END
180 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
#define VTK_INT_MAX
Definition: vtkType.h:144
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
int vtkIdType
Definition: vtkType.h:315
abstract superclass for all graph layout strategies
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
#define VTK_FLOAT_MAX
Definition: vtkType.h:152
A splatter optimized for splatting single kernels.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Initialize()
This method allows the layout strategy to do initialization of data structures or whatever else it mi...
virtual void Layout()=0
This is the layout method where the graph that was set in SetGraph() is laid out. ...
a simple fast 2D graph layout