VTK  9.2.5
vtkForceDirectedLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkForceDirectedLayoutStrategy.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
96 #ifndef vtkForceDirectedLayoutStrategy_h
97 #define vtkForceDirectedLayoutStrategy_h
98 
99 #include "vtkGraphLayoutStrategy.h"
100 #include "vtkInfovisLayoutModule.h" // For export macro
101 
102 class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
103 {
104 public:
106 
108  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
111 
116  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
117  vtkGetMacro(RandomSeed, int);
119 
121 
126  vtkSetVector6Macro(GraphBounds, double);
127  vtkGetVectorMacro(GraphBounds, double, 6);
129 
131 
136  vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
137  vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
138  vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
140 
142 
148  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
149  vtkGetMacro(MaxNumberOfIterations, int);
151 
153 
159  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
160  vtkGetMacro(IterationsPerLayout, int);
162 
164 
169  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
170  vtkGetMacro(CoolDownRate, double);
172 
174 
179  vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
180  vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
181  vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
183 
185 
188  vtkSetMacro(RandomInitialPoints, vtkTypeBool);
189  vtkGetMacro(RandomInitialPoints, vtkTypeBool);
190  vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
192 
194 
198  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
199  vtkGetMacro(InitialTemperature, float);
201 
206  void Initialize() override;
207 
215  void Layout() override;
216 
221  int IsLayoutComplete() override { return this->LayoutComplete; }
222 
223 protected:
226 
227  double GraphBounds[6];
228  vtkTypeBool AutomaticBoundsComputation; // Boolean controls automatic bounds calc.
229  int MaxNumberOfIterations; // Maximum number of iterations.
230  double CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
232  vtkTypeBool ThreeDimensionalLayout; // Boolean for a third dimension.
233  vtkTypeBool RandomInitialPoints; // Boolean for having random points
234 private:
235  // A vertex contains a position and a displacement.
236  struct vtkLayoutVertex_t
237  {
238  double x[3];
239  double d[3];
240  };
241  using vtkLayoutVertex = struct vtkLayoutVertex_t;
242 
243  // An edge consists of two vertices joined together.
244  // This struct acts as a "pointer" to those two vertices.
245  struct vtkLayoutEdge_t
246  {
247  int t;
248  int u;
249  };
250  using vtkLayoutEdge = struct vtkLayoutEdge_t;
251 
252  int RandomSeed;
253  int IterationsPerLayout;
254  int TotalIterations;
255  int LayoutComplete;
256  double Temp;
257  double optDist;
258  vtkLayoutVertex* v;
259  vtkLayoutEdge* e;
260 
262  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
263 };
264 
265 #endif
a force directed graph layout algorithm
static vtkForceDirectedLayoutStrategy * New()
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.
abstract superclass for all graph layout strategies
a simple class to control print indentation
Definition: vtkIndent.h:119
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
#define VTK_INT_MAX
Definition: vtkType.h:155
#define VTK_FLOAT_MAX
Definition: vtkType.h:163