VTK  9.0.1
vtkFast2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFast2DLayoutStrategy.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 -------------------------------------------------------------------------*/
33 #ifndef vtkFast2DLayoutStrategy_h
34 #define vtkFast2DLayoutStrategy_h
35 
36 #include "vtkGraphLayoutStrategy.h"
37 #include "vtkInfovisLayoutModule.h" // For export macro
38 
39 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
40 
41 class vtkFastSplatter;
42 class vtkFloatArray;
43 class vtkGraphToPolyData;
44 class vtkImageData;
45 
46 class VTKINFOVISLAYOUT_EXPORT vtkFast2DLayoutStrategy : public vtkGraphLayoutStrategy
47 {
48 public:
50 
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
60  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
61  vtkGetMacro(RandomSeed, int);
63 
65 
73  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
74  vtkGetMacro(MaxNumberOfIterations, int);
76 
78 
85  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
86  vtkGetMacro(IterationsPerLayout, int);
88 
90 
96  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
97  vtkGetMacro(InitialTemperature, float);
99 
101 
109  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
110  vtkGetMacro(CoolDownRate, double);
112 
114 
118  vtkSetMacro(RestDistance, float);
119  vtkGetMacro(RestDistance, float);
121 
126  void Initialize() override;
127 
135  void Layout() override;
136 
141  int IsLayoutComplete() override { return this->LayoutComplete; }
142 
143 protected:
146 
147  int MaxNumberOfIterations; // Maximum number of iterations.
149  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
150 
151 private:
152  // An edge consists of two vertices joined together.
153  // This struct acts as a "pointer" to those two vertices.
154  typedef struct
155  {
156  vtkIdType from;
157  vtkIdType to;
158  float weight;
159  } vtkLayoutEdge;
160 
161  // This class 'has a' vtkFastSplatter for the density grid
165  vtkSmartPointer<vtkFloatArray> RepulsionArray;
166  vtkSmartPointer<vtkFloatArray> AttractionArray;
167 
168  vtkLayoutEdge* EdgeArray;
169 
170  int RandomSeed;
171  int IterationsPerLayout;
172  int TotalIterations;
173  int LayoutComplete;
174  float Temp;
175  float RestDistance;
176 
177  // Private helper methods
178  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
179  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
180  void ResolveCoincidentVertices();
181 
183  void operator=(const vtkFast2DLayoutStrategy&) = delete;
184 };
185 
186 #endif
vtkGraphToPolyData
convert a vtkGraph to vtkPolyData
Definition: vtkGraphToPolyData.h:42
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkFast2DLayoutStrategy::~vtkFast2DLayoutStrategy
~vtkFast2DLayoutStrategy() override
vtkFast2DLayoutStrategy::New
static vtkFast2DLayoutStrategy * New()
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
vtkGraphLayoutStrategy
abstract superclass for all graph layout strategies
Definition: vtkGraphLayoutStrategy.h:46
vtkFast2DLayoutStrategy::Layout
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
vtkX3D::weight
@ weight
Definition: vtkX3D.h:538
vtkSmartPointer< vtkGraphToPolyData >
vtkFast2DLayoutStrategy::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: vtkFast2DLayoutStrategy.h:141
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkFast2DLayoutStrategy::Initialize
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
vtkSmartPointer.h
vtkFast2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkFast2DLayoutStrategy.h:148
vtkFastSplatter
A splatter optimized for splatting single kernels.
Definition: vtkFastSplatter.h:52
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkFast2DLayoutStrategy::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGraphLayoutStrategy.h
vtkFast2DLayoutStrategy::vtkFast2DLayoutStrategy
vtkFast2DLayoutStrategy()
vtkFast2DLayoutStrategy
a simple fast 2D graph layout
Definition: vtkFast2DLayoutStrategy.h:47
vtkFast2DLayoutStrategy::MaxNumberOfIterations
int MaxNumberOfIterations
Definition: vtkFast2DLayoutStrategy.h:147
vtkFast2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkFast2DLayoutStrategy.h:149
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165