VTK  9.4.20250102
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
26#include "vtkInfovisLayoutModule.h" // For export macro
27
28#include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
29
30VTK_ABI_NAMESPACE_BEGIN
31class vtkFastSplatter;
32class vtkImageData;
33class vtkFloatArray;
34
35class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
36{
37public:
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
151protected:
154
155 int MaxNumberOfIterations; // Maximum number of iterations.
157 float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
158
159private:
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
200VTK_ABI_NAMESPACE_END
201#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:108
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