VTK  9.2.6
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 -------------------------------------------------------------------------*/
37 #ifndef vtkForceDirectedLayoutStrategy_h
38 #define vtkForceDirectedLayoutStrategy_h
39 
40 #include "vtkGraphLayoutStrategy.h"
41 #include "vtkInfovisLayoutModule.h" // For export macro
42 
43 class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
44 {
45 public:
47 
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52 
57  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
58  vtkGetMacro(RandomSeed, int);
60 
62 
67  vtkSetVector6Macro(GraphBounds, double);
68  vtkGetVectorMacro(GraphBounds, double, 6);
70 
72 
77  vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
78  vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
79  vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
81 
83 
89  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
90  vtkGetMacro(MaxNumberOfIterations, int);
92 
94 
100  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
101  vtkGetMacro(IterationsPerLayout, int);
103 
105 
110  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
111  vtkGetMacro(CoolDownRate, double);
113 
115 
120  vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
121  vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
122  vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
124 
126 
129  vtkSetMacro(RandomInitialPoints, vtkTypeBool);
130  vtkGetMacro(RandomInitialPoints, vtkTypeBool);
131  vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
133 
135 
139  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
140  vtkGetMacro(InitialTemperature, float);
142 
147  void Initialize() override;
148 
156  void Layout() override;
157 
162  int IsLayoutComplete() override { return this->LayoutComplete; }
163 
164 protected:
166  ~vtkForceDirectedLayoutStrategy() override;
167 
168  double GraphBounds[6];
169  vtkTypeBool AutomaticBoundsComputation; // Boolean controls automatic bounds calc.
170  int MaxNumberOfIterations; // Maximum number of iterations.
171  double CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
173  vtkTypeBool ThreeDimensionalLayout; // Boolean for a third dimension.
174  vtkTypeBool RandomInitialPoints; // Boolean for having random points
175 private:
176  // A vertex contains a position and a displacement.
177  struct vtkLayoutVertex_t
178  {
179  double x[3];
180  double d[3];
181  };
182  using vtkLayoutVertex = struct vtkLayoutVertex_t;
183 
184  // An edge consists of two vertices joined together.
185  // This struct acts as a "pointer" to those two vertices.
186  struct vtkLayoutEdge_t
187  {
188  int t;
189  int u;
190  };
191  using vtkLayoutEdge = struct vtkLayoutEdge_t;
192 
193  int RandomSeed;
194  int IterationsPerLayout;
195  int TotalIterations;
196  int LayoutComplete;
197  double Temp;
198  double optDist;
199  vtkLayoutVertex* v;
200  vtkLayoutEdge* e;
201 
203  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
204 };
205 
206 #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:165
#define VTK_INT_MAX
Definition: vtkType.h:155
abstract superclass for all graph layout strategies
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
a simple class to control print indentation
Definition: vtkIndent.h:39
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. ...