VTK  9.3.1
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
21 #ifndef vtkForceDirectedLayoutStrategy_h
22 #define vtkForceDirectedLayoutStrategy_h
23 
24 #include "vtkGraphLayoutStrategy.h"
25 #include "vtkInfovisLayoutModule.h" // For export macro
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
29 {
30 public:
32 
34  void PrintSelf(ostream& os, vtkIndent indent) override;
35 
37 
42  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
43  vtkGetMacro(RandomSeed, int);
45 
47 
52  vtkSetVector6Macro(GraphBounds, double);
53  vtkGetVectorMacro(GraphBounds, double, 6);
55 
57 
62  vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
63  vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
64  vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
66 
68 
74  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
75  vtkGetMacro(MaxNumberOfIterations, int);
77 
79 
85  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
86  vtkGetMacro(IterationsPerLayout, int);
88 
90 
95  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
96  vtkGetMacro(CoolDownRate, double);
98 
100 
105  vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
106  vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
107  vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
109 
111 
114  vtkSetMacro(RandomInitialPoints, vtkTypeBool);
115  vtkGetMacro(RandomInitialPoints, vtkTypeBool);
116  vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
118 
120 
124  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
125  vtkGetMacro(InitialTemperature, float);
127 
132  void Initialize() override;
133 
141  void Layout() override;
142 
147  int IsLayoutComplete() override { return this->LayoutComplete; }
148 
149 protected:
151  ~vtkForceDirectedLayoutStrategy() override;
152 
153  double GraphBounds[6];
154  vtkTypeBool AutomaticBoundsComputation; // Boolean controls automatic bounds calc.
155  int MaxNumberOfIterations; // Maximum number of iterations.
156  double CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
158  vtkTypeBool ThreeDimensionalLayout; // Boolean for a third dimension.
159  vtkTypeBool RandomInitialPoints; // Boolean for having random points
160 private:
161  // A vertex contains a position and a displacement.
162  struct vtkLayoutVertex_t
163  {
164  double x[3];
165  double d[3];
166  };
167  using vtkLayoutVertex = struct vtkLayoutVertex_t;
168 
169  // An edge consists of two vertices joined together.
170  // This struct acts as a "pointer" to those two vertices.
171  struct vtkLayoutEdge_t
172  {
173  int t;
174  int u;
175  };
176  using vtkLayoutEdge = struct vtkLayoutEdge_t;
177 
178  int RandomSeed;
179  int IterationsPerLayout;
180  int TotalIterations;
181  int LayoutComplete;
182  double Temp;
183  double optDist;
184  vtkLayoutVertex* v;
185  vtkLayoutEdge* e;
186 
188  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
189 };
190 
191 VTK_ABI_NAMESPACE_END
192 #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.
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph...
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
#define VTK_INT_MAX
Definition: vtkType.h:144
abstract superclass for all graph layout strategies
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_FLOAT_MAX
Definition: vtkType.h:152
a simple class to control print indentation
Definition: vtkIndent.h:28
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. ...