VTK
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 "vtkInfovisLayoutModule.h" // For export macro
41 #include "vtkGraphLayoutStrategy.h"
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 
177  // A vertex contains a position and a displacement.
178  typedef struct
179  {
180  double x[3];
181  double d[3];
182  } vtkLayoutVertex;
183 
184  // An edge consists of two vertices joined together.
185  // This struct acts as a "pointer" to those two vertices.
186  typedef struct
187  {
188  int t;
189  int u;
190  } vtkLayoutEdge;
191 
192  int RandomSeed;
193  int IterationsPerLayout;
194  int TotalIterations;
195  int LayoutComplete;
196  double Temp;
197  double optDist;
198  vtkLayoutVertex *v;
199  vtkLayoutEdge *e;
200 
202  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
203 };
204 
205 #endif
206 
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:169
#define VTK_INT_MAX
Definition: vtkType.h:159
abstract superclass for all graph layout strategies
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
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. ...