VTK  9.4.20250114
vtkForceDirectedLayoutStrategy.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
80#ifndef vtkForceDirectedLayoutStrategy_h
81#define vtkForceDirectedLayoutStrategy_h
82
84#include "vtkInfovisLayoutModule.h" // For export macro
85
86VTK_ABI_NAMESPACE_BEGIN
87class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
88{
89public:
91
93 void PrintSelf(ostream& os, vtkIndent indent) override;
94
96
101 vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
102 vtkGetMacro(RandomSeed, int);
104
106
111 vtkSetVector6Macro(GraphBounds, double);
112 vtkGetVectorMacro(GraphBounds, double, 6);
114
116
121 vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
122 vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
123 vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
125
127
133 vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
134 vtkGetMacro(MaxNumberOfIterations, int);
136
138
144 vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
145 vtkGetMacro(IterationsPerLayout, int);
147
149
154 vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
155 vtkGetMacro(CoolDownRate, double);
157
159
164 vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
165 vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
166 vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
168
170
173 vtkSetMacro(RandomInitialPoints, vtkTypeBool);
174 vtkGetMacro(RandomInitialPoints, vtkTypeBool);
175 vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
177
179
183 vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
184 vtkGetMacro(InitialTemperature, float);
186
191 void Initialize() override;
192
200 void Layout() override;
201
206 int IsLayoutComplete() override { return this->LayoutComplete; }
207
208protected:
211
212 double GraphBounds[6];
213 vtkTypeBool AutomaticBoundsComputation; // Boolean controls automatic bounds calc.
214 int MaxNumberOfIterations; // Maximum number of iterations.
215 double CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
217 vtkTypeBool ThreeDimensionalLayout; // Boolean for a third dimension.
218 vtkTypeBool RandomInitialPoints; // Boolean for having random points
219private:
220 // A vertex contains a position and a displacement.
221 struct vtkLayoutVertex_t
222 {
223 double x[3];
224 double d[3];
225 };
226 using vtkLayoutVertex = struct vtkLayoutVertex_t;
227
228 // An edge consists of two vertices joined together.
229 // This struct acts as a "pointer" to those two vertices.
230 struct vtkLayoutEdge_t
231 {
232 int t;
233 int u;
234 };
235 using vtkLayoutEdge = struct vtkLayoutEdge_t;
236
237 int RandomSeed;
238 int IterationsPerLayout;
239 int TotalIterations;
240 int LayoutComplete;
241 double Temp;
242 double optDist;
243 vtkLayoutVertex* v;
244 vtkLayoutEdge* e;
245
247 void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
248};
249
250VTK_ABI_NAMESPACE_END
251#endif
a force directed graph layout algorithm
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
~vtkForceDirectedLayoutStrategy() override
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph.
static vtkForceDirectedLayoutStrategy * New()
abstract superclass for all graph layout strategies
a simple class to control print indentation
Definition vtkIndent.h:108
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_FLOAT_MAX
Definition vtkType.h:152