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 -------------------------------------------------------------------------*/
34 #ifndef vtkForceDirectedLayoutStrategy_h
35 #define vtkForceDirectedLayoutStrategy_h
36 
37 #include "vtkInfovisLayoutModule.h" // For export macro
38 #include "vtkGraphLayoutStrategy.h"
39 
40 class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
41 {
42 public:
44 
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
49 
54  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
55  vtkGetMacro(RandomSeed, int);
57 
59 
64  vtkSetVector6Macro(GraphBounds,double);
65  vtkGetVectorMacro(GraphBounds,double,6);
67 
69 
74  vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
75  vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
76  vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
78 
80 
86  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
87  vtkGetMacro(MaxNumberOfIterations, int);
89 
91 
97  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
98  vtkGetMacro(IterationsPerLayout, int);
100 
102 
107  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
108  vtkGetMacro(CoolDownRate, double);
110 
112 
117  vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
118  vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
119  vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
121 
123 
126  vtkSetMacro(RandomInitialPoints, vtkTypeBool);
127  vtkGetMacro(RandomInitialPoints, vtkTypeBool);
128  vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
130 
132 
136  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
137  vtkGetMacro(InitialTemperature, float);
139 
144  void Initialize() override;
145 
153  void Layout() override;
154 
159  int IsLayoutComplete() override {return this->LayoutComplete;}
160 
161 protected:
163  ~vtkForceDirectedLayoutStrategy() override;
164 
165  double GraphBounds[6];
166  vtkTypeBool AutomaticBoundsComputation; //Boolean controls automatic bounds calc.
167  int MaxNumberOfIterations; //Maximum number of iterations.
168  double CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
170  vtkTypeBool ThreeDimensionalLayout; //Boolean for a third dimension.
171  vtkTypeBool RandomInitialPoints; //Boolean for having random points
172 private:
173 
174  // A vertex contains a position and a displacement.
175  typedef struct
176  {
177  double x[3];
178  double d[3];
179  } vtkLayoutVertex;
180 
181  // An edge consists of two vertices joined together.
182  // This struct acts as a "pointer" to those two vertices.
183  typedef struct
184  {
185  int t;
186  int u;
187  } vtkLayoutEdge;
188 
189  int RandomSeed;
190  int IterationsPerLayout;
191  int TotalIterations;
192  int LayoutComplete;
193  double Temp;
194  double optDist;
195  vtkLayoutVertex *v;
196  vtkLayoutEdge *e;
197 
199  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
200 };
201 
202 #endif
203 
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:167
#define VTK_INT_MAX
Definition: vtkType.h:157
abstract superclass for all graph layout strategies
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
a simple class to control print indentation
Definition: vtkIndent.h:33
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. ...