VTK  9.1.0
vtkSimple2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSimple2DLayoutStrategy.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 -------------------------------------------------------------------------*/
90 #ifndef vtkSimple2DLayoutStrategy_h
91 #define vtkSimple2DLayoutStrategy_h
92 
93 #include "vtkGraphLayoutStrategy.h"
94 #include "vtkInfovisLayoutModule.h" // For export macro
95 
96 class vtkFloatArray;
97 
98 class VTKINFOVISLAYOUT_EXPORT vtkSimple2DLayoutStrategy : public vtkGraphLayoutStrategy
99 {
100 public:
102 
104  void PrintSelf(ostream& os, vtkIndent indent) override;
105 
107 
112  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
113  vtkGetMacro(RandomSeed, int);
115 
117 
125  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
126  vtkGetMacro(MaxNumberOfIterations, int);
128 
130 
137  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
138  vtkGetMacro(IterationsPerLayout, int);
140 
142 
148  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
149  vtkGetMacro(InitialTemperature, float);
151 
153 
161  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
162  vtkGetMacro(CoolDownRate, double);
164 
166 
173  vtkSetMacro(Jitter, bool);
174  vtkGetMacro(Jitter, bool);
176 
178 
182  vtkSetMacro(RestDistance, float);
183  vtkGetMacro(RestDistance, float);
185 
190  void Initialize() override;
191 
199  void Layout() override;
200 
205  int IsLayoutComplete() override { return this->LayoutComplete; }
206 
207 protected:
210 
211  int MaxNumberOfIterations; // Maximum number of iterations.
213  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
214 
215 private:
216  // An edge consists of two vertices joined together.
217  // This struct acts as a "pointer" to those two vertices.
218  struct vtkLayoutEdge_t
219  {
220  vtkIdType from;
221  vtkIdType to;
222  float weight;
223  };
224  using vtkLayoutEdge = struct vtkLayoutEdge_t;
225 
226  // These are for storage of repulsion and attraction
227  vtkFloatArray* RepulsionArray;
228  vtkFloatArray* AttractionArray;
229  vtkLayoutEdge* EdgeArray;
230 
231  int RandomSeed;
232  int IterationsPerLayout;
233  int TotalIterations;
234  int LayoutComplete;
235  float Temp;
236  float RestDistance;
237  bool Jitter;
238 
240  void operator=(const vtkSimple2DLayoutStrategy&) = delete;
241 };
242 
243 #endif
vtkSimple2DLayoutStrategy::vtkSimple2DLayoutStrategy
vtkSimple2DLayoutStrategy()
vtkSimple2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkSimple2DLayoutStrategy.h:212
vtkSimple2DLayoutStrategy::Layout
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkSimple2DLayoutStrategy::~vtkSimple2DLayoutStrategy
~vtkSimple2DLayoutStrategy() override
vtkSimple2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkSimple2DLayoutStrategy.h:213
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:145
vtkGraphLayoutStrategy
abstract superclass for all graph layout strategies
Definition: vtkGraphLayoutStrategy.h:105
vtkX3D::weight
@ weight
Definition: vtkX3D.h:538
vtkSimple2DLayoutStrategy
a simple 2D graph layout
Definition: vtkSimple2DLayoutStrategy.h:99
vtkSimple2DLayoutStrategy::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkGraphLayoutStrategy.h
vtkSimple2DLayoutStrategy::Initialize
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
vtkSimple2DLayoutStrategy::MaxNumberOfIterations
int MaxNumberOfIterations
Definition: vtkSimple2DLayoutStrategy.h:211
vtkSimple2DLayoutStrategy::IsLayoutComplete
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph.
Definition: vtkSimple2DLayoutStrategy.h:205
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkSimple2DLayoutStrategy::New
static vtkSimple2DLayoutStrategy * New()