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 -------------------------------------------------------------------------*/
46 #ifndef vtkForceDirectedLayoutStrategy_h
47 #define vtkForceDirectedLayoutStrategy_h
48 
49 #include "vtkGraphLayoutStrategy.h"
50 #include "vtkInfovisLayoutModule.h" // For export macro
51 
52 class VTKINFOVISLAYOUT_EXPORT vtkForceDirectedLayoutStrategy : public vtkGraphLayoutStrategy
53 {
54 public:
56 
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
66  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
67  vtkGetMacro(RandomSeed, int);
69 
71 
76  vtkSetVector6Macro(GraphBounds, double);
77  vtkGetVectorMacro(GraphBounds, double, 6);
79 
81 
86  vtkSetMacro(AutomaticBoundsComputation, vtkTypeBool);
87  vtkGetMacro(AutomaticBoundsComputation, vtkTypeBool);
88  vtkBooleanMacro(AutomaticBoundsComputation, vtkTypeBool);
90 
92 
98  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
99  vtkGetMacro(MaxNumberOfIterations, int);
101 
103 
109  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
110  vtkGetMacro(IterationsPerLayout, int);
112 
114 
119  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
120  vtkGetMacro(CoolDownRate, double);
122 
124 
129  vtkSetMacro(ThreeDimensionalLayout, vtkTypeBool);
130  vtkGetMacro(ThreeDimensionalLayout, vtkTypeBool);
131  vtkBooleanMacro(ThreeDimensionalLayout, vtkTypeBool);
133 
135 
138  vtkSetMacro(RandomInitialPoints, vtkTypeBool);
139  vtkGetMacro(RandomInitialPoints, vtkTypeBool);
140  vtkBooleanMacro(RandomInitialPoints, vtkTypeBool);
142 
144 
148  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
149  vtkGetMacro(InitialTemperature, float);
151 
156  void Initialize() override;
157 
165  void Layout() override;
166 
171  int IsLayoutComplete() override { return this->LayoutComplete; }
172 
173 protected:
176 
177  double GraphBounds[6];
178  vtkTypeBool AutomaticBoundsComputation; // Boolean controls automatic bounds calc.
179  int MaxNumberOfIterations; // Maximum number of iterations.
180  double CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
182  vtkTypeBool ThreeDimensionalLayout; // Boolean for a third dimension.
183  vtkTypeBool RandomInitialPoints; // Boolean for having random points
184 private:
185  // A vertex contains a position and a displacement.
186  struct vtkLayoutVertex_t
187  {
188  double x[3];
189  double d[3];
190  };
191  using vtkLayoutVertex = struct vtkLayoutVertex_t;
192 
193  // An edge consists of two vertices joined together.
194  // This struct acts as a "pointer" to those two vertices.
195  struct vtkLayoutEdge_t
196  {
197  int t;
198  int u;
199  };
200  using vtkLayoutEdge = struct vtkLayoutEdge_t;
201 
202  int RandomSeed;
203  int IterationsPerLayout;
204  int TotalIterations;
205  int LayoutComplete;
206  double Temp;
207  double optDist;
208  vtkLayoutVertex* v;
209  vtkLayoutEdge* e;
210 
212  void operator=(const vtkForceDirectedLayoutStrategy&) = delete;
213 };
214 
215 #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:49
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