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 -------------------------------------------------------------------------*/
42 #ifndef vtkFast2DLayoutStrategy_h
43 #define vtkFast2DLayoutStrategy_h
44 
45 #include "vtkGraphLayoutStrategy.h"
46 #include "vtkInfovisLayoutModule.h" // For export macro
47 
48 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
49 
50 class vtkFastSplatter;
51 class vtkFloatArray;
52 class vtkGraphToPolyData;
53 class vtkImageData;
54 
55 class VTKINFOVISLAYOUT_EXPORT vtkFast2DLayoutStrategy : public vtkGraphLayoutStrategy
56 {
57 public:
58  static vtkFast2DLayoutStrategy* New();
59 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64 
69  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
70  vtkGetMacro(RandomSeed, int);
72 
74 
82  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
83  vtkGetMacro(MaxNumberOfIterations, int);
85 
87 
94  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
95  vtkGetMacro(IterationsPerLayout, int);
97 
99 
105  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
106  vtkGetMacro(InitialTemperature, float);
108 
110 
118  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
119  vtkGetMacro(CoolDownRate, double);
121 
123 
127  vtkSetMacro(RestDistance, float);
128  vtkGetMacro(RestDistance, float);
130 
135  void Initialize() override;
136 
144  void Layout() override;
145 
150  int IsLayoutComplete() override { return this->LayoutComplete; }
151 
152 protected:
154  ~vtkFast2DLayoutStrategy() override;
155 
156  int MaxNumberOfIterations; // Maximum number of iterations.
158  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
159 
160 private:
161  // An edge consists of two vertices joined together.
162  // This struct acts as a "pointer" to those two vertices.
163  typedef struct
164  {
165  vtkIdType from;
166  vtkIdType to;
167  float weight;
168  } vtkLayoutEdge;
169 
170  // This class 'has a' vtkFastSplatter for the density grid
174  vtkSmartPointer<vtkFloatArray> RepulsionArray;
175  vtkSmartPointer<vtkFloatArray> AttractionArray;
176 
177  vtkLayoutEdge* EdgeArray;
178 
179  int RandomSeed;
180  int IterationsPerLayout;
181  int TotalIterations;
182  int LayoutComplete;
183  float Temp;
184  float RestDistance;
185 
186  // Private helper methods
187  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
188  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
189  void ResolveCoincidentVertices();
190 
192  void operator=(const vtkFast2DLayoutStrategy&) = delete;
193 };
194 
195 #endif
vtkGraphToPolyData
convert a vtkGraph to vtkPolyData
Definition: vtkGraphToPolyData.h:41
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkGraphLayoutStrategy
abstract superclass for all graph layout strategies
Definition: vtkGraphLayoutStrategy.h:45
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:150
vtkGraphLayoutStrategy::Layout
virtual void Layout()=0
This is the layout method where the graph that was set in SetGraph() is laid out.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkGraphLayoutStrategy::Initialize
virtual void Initialize()
This method allows the layout strategy to do initialization of data structures or whatever else it mi...
Definition: vtkGraphLayoutStrategy.h:61
vtkSmartPointer.h
vtkFast2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkFast2DLayoutStrategy.h:157
vtkGraphLayoutStrategy::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkFastSplatter
A splatter optimized for splatting single kernels.
Definition: vtkFastSplatter.h:51
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkGraphLayoutStrategy.h
vtkFast2DLayoutStrategy
a simple fast 2D graph layout
Definition: vtkFast2DLayoutStrategy.h:55
vtkFast2DLayoutStrategy::MaxNumberOfIterations
int MaxNumberOfIterations
Definition: vtkFast2DLayoutStrategy.h:156
vtkFast2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkFast2DLayoutStrategy.h:158
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165