VTK  9.3.20240423
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
30#include "vtkInfovisLayoutModule.h" // For export macro
31
32#include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
33
34VTK_ABI_NAMESPACE_BEGIN
35class vtkFastSplatter;
36class vtkImageData;
37class vtkFloatArray;
38
39class VTKINFOVISLAYOUT_EXPORT vtkConstrained2DLayoutStrategy : public vtkGraphLayoutStrategy
40{
41public:
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
145protected:
148
149 int MaxNumberOfIterations; // Maximum number of iterations.
151 float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
152
153private:
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
190VTK_ABI_NAMESPACE_END
191#endif
a simple fast 2D graph layout that looks for a 'constraint' array (vtkDoubleArray).
~vtkConstrained2DLayoutStrategy() override
static vtkConstrained2DLayoutStrategy * New()
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.
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
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