VTK  9.3.1
vtkCommunity2DLayoutStrategy.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
22 #ifndef vtkCommunity2DLayoutStrategy_h
23 #define vtkCommunity2DLayoutStrategy_h
24 
25 #include "vtkGraphLayoutStrategy.h"
26 #include "vtkInfovisLayoutModule.h" // For export macro
27 
28 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkFastSplatter;
32 class vtkImageData;
33 class vtkFloatArray;
34 
35 class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
36 {
37 public:
39 
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
44 
49  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
50  vtkGetMacro(RandomSeed, int);
52 
54 
62  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
63  vtkGetMacro(MaxNumberOfIterations, int);
65 
67 
74  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
75  vtkGetMacro(IterationsPerLayout, int);
77 
79 
85  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
86  vtkGetMacro(InitialTemperature, float);
88 
90 
98  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
99  vtkGetMacro(CoolDownRate, double);
101 
103 
107  vtkSetMacro(RestDistance, float);
108  vtkGetMacro(RestDistance, float);
110 
115  void Initialize() override;
116 
124  void Layout() override;
125 
130  int IsLayoutComplete() override { return this->LayoutComplete; }
131 
133 
136  vtkGetStringMacro(CommunityArrayName);
137  vtkSetStringMacro(CommunityArrayName);
139 
141 
147  vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
148  vtkGetMacro(CommunityStrength, float);
150 
151 protected:
153  ~vtkCommunity2DLayoutStrategy() override;
154 
155  int MaxNumberOfIterations; // Maximum number of iterations.
157  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
158 
159 private:
160  // An edge consists of two vertices joined together.
161  // This struct acts as a "pointer" to those two vertices.
162  struct vtkLayoutEdge_t
163  {
164  vtkIdType from;
165  vtkIdType to;
166  float weight;
167  };
168  using vtkLayoutEdge = struct vtkLayoutEdge_t;
169 
170  // This class 'has a' vtkFastSplatter for the density grid
173  vtkSmartPointer<vtkFloatArray> RepulsionArray;
174  vtkSmartPointer<vtkFloatArray> AttractionArray;
175 
176  vtkLayoutEdge* EdgeArray;
177 
178  int RandomSeed;
179  int IterationsPerLayout;
180  int TotalIterations;
181  int LayoutComplete;
182  float Temp;
183  float RestDistance;
184  float CommunityStrength;
185 
189  char* CommunityArrayName;
190 
191  // Private helper methods
192  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
193  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
194  void ResolveCoincidentVertices();
195 
197  void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
198 };
199 
200 VTK_ABI_NAMESPACE_END
201 #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
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph...
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 community array on it's input and strengthens edges wi...
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. ...