VTK  9.3.0
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
19#ifndef vtkCommunity2DLayoutStrategy_h
20#define vtkCommunity2DLayoutStrategy_h
21
23#include "vtkInfovisLayoutModule.h" // For export macro
24
25#include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
26
27VTK_ABI_NAMESPACE_BEGIN
28class vtkFastSplatter;
29class vtkImageData;
30class vtkFloatArray;
31
32class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
33{
34public:
36
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
41
46 vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
47 vtkGetMacro(RandomSeed, int);
49
51
59 vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
60 vtkGetMacro(MaxNumberOfIterations, int);
62
64
71 vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
72 vtkGetMacro(IterationsPerLayout, int);
74
76
82 vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
83 vtkGetMacro(InitialTemperature, float);
85
87
95 vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
96 vtkGetMacro(CoolDownRate, double);
98
100
104 vtkSetMacro(RestDistance, float);
105 vtkGetMacro(RestDistance, float);
107
112 void Initialize() override;
113
121 void Layout() override;
122
127 int IsLayoutComplete() override { return this->LayoutComplete; }
128
130
133 vtkGetStringMacro(CommunityArrayName);
134 vtkSetStringMacro(CommunityArrayName);
136
138
144 vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
145 vtkGetMacro(CommunityStrength, float);
147
148protected:
151
152 int MaxNumberOfIterations; // Maximum number of iterations.
154 float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
155
156private:
157 // An edge consists of two vertices joined together.
158 // This struct acts as a "pointer" to those two vertices.
159 struct vtkLayoutEdge_t
160 {
161 vtkIdType from;
162 vtkIdType to;
163 float weight;
164 };
165 using vtkLayoutEdge = struct vtkLayoutEdge_t;
166
167 // This class 'has a' vtkFastSplatter for the density grid
170 vtkSmartPointer<vtkFloatArray> RepulsionArray;
171 vtkSmartPointer<vtkFloatArray> AttractionArray;
172
173 vtkLayoutEdge* EdgeArray;
174
175 int RandomSeed;
176 int IterationsPerLayout;
177 int TotalIterations;
178 int LayoutComplete;
179 float Temp;
180 float RestDistance;
181 float CommunityStrength;
182
186 char* CommunityArrayName;
187
188 // Private helper methods
189 void GenerateCircularSplat(vtkImageData* splat, int x, int y);
190 void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
191 void ResolveCoincidentVertices();
192
194 void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
195};
196
197VTK_ABI_NAMESPACE_END
198#endif
a simple fast 2D graph layout that looks for a community array on it's input and strengthens edges wi...
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph.
~vtkCommunity2DLayoutStrategy() override
static vtkCommunity2DLayoutStrategy * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A splatter optimized for splatting single kernels.
dynamic, self-adjusting array of float
abstract superclass for all graph layout strategies
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:315
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_FLOAT_MAX
Definition vtkType.h:152