VTK  9.3.1
vtkConstrained2DLayoutStrategy.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
26 #ifndef vtkConstrained2DLayoutStrategy_h
27 #define vtkConstrained2DLayoutStrategy_h
28 
29 #include "vtkGraphLayoutStrategy.h"
30 #include "vtkInfovisLayoutModule.h" // For export macro
31 
32 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkFastSplatter;
36 class vtkImageData;
37 class vtkFloatArray;
38 
39 class VTKINFOVISLAYOUT_EXPORT vtkConstrained2DLayoutStrategy : public vtkGraphLayoutStrategy
40 {
41 public:
43 
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
53  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
54  vtkGetMacro(RandomSeed, int);
56 
58 
66  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
67  vtkGetMacro(MaxNumberOfIterations, int);
69 
71 
78  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
79  vtkGetMacro(IterationsPerLayout, int);
81 
83 
89  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
90  vtkGetMacro(InitialTemperature, float);
92 
94 
102  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
103  vtkGetMacro(CoolDownRate, double);
105 
107 
111  vtkSetMacro(RestDistance, float);
112  vtkGetMacro(RestDistance, float);
114 
119  void Initialize() override;
120 
128  void Layout() override;
129 
134  int IsLayoutComplete() override { return this->LayoutComplete; }
135 
137 
141  vtkSetStringMacro(InputArrayName);
142  vtkGetStringMacro(InputArrayName);
144 
145 protected:
147  ~vtkConstrained2DLayoutStrategy() override;
148 
149  int MaxNumberOfIterations; // Maximum number of iterations.
151  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
152 
153 private:
154  // An edge consists of two vertices joined together.
155  // This struct acts as a "pointer" to those two vertices.
156  struct vtkLayoutEdge_t
157  {
158  vtkIdType from;
159  vtkIdType to;
160  float weight;
161  };
162  using vtkLayoutEdge = struct vtkLayoutEdge_t;
163 
164  // This class 'has a' vtkFastSplatter for the density grid
167  vtkSmartPointer<vtkFloatArray> RepulsionArray;
168  vtkSmartPointer<vtkFloatArray> AttractionArray;
169 
170  vtkLayoutEdge* EdgeArray;
171 
172  int RandomSeed;
173  int IterationsPerLayout;
174  int TotalIterations;
175  int LayoutComplete;
176  float Temp;
177  float RestDistance;
178 
179  char* InputArrayName;
180 
181  // Private helper methods
182  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
183  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
184  void ResolveCoincidentVertices();
185 
187  void operator=(const vtkConstrained2DLayoutStrategy&) = delete;
188 };
189 
190 VTK_ABI_NAMESPACE_END
191 #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
#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
a simple fast 2D graph layout that looks for a 'constraint' array (vtkDoubleArray).
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. ...