VTK  9.0.1
vtkConstrained2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkConstrained2DLayoutStrategy.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 -------------------------------------------------------------------------*/
39 #ifndef vtkConstrained2DLayoutStrategy_h
40 #define vtkConstrained2DLayoutStrategy_h
41 
42 #include "vtkGraphLayoutStrategy.h"
43 #include "vtkInfovisLayoutModule.h" // For export macro
44 
45 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
46 
47 class vtkFastSplatter;
48 class vtkImageData;
49 class vtkFloatArray;
50 
51 class VTKINFOVISLAYOUT_EXPORT vtkConstrained2DLayoutStrategy : public vtkGraphLayoutStrategy
52 {
53 public:
55 
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
60 
65  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
66  vtkGetMacro(RandomSeed, int);
68 
70 
78  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
79  vtkGetMacro(MaxNumberOfIterations, int);
81 
83 
90  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
91  vtkGetMacro(IterationsPerLayout, int);
93 
95 
101  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
102  vtkGetMacro(InitialTemperature, float);
104 
106 
114  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
115  vtkGetMacro(CoolDownRate, double);
117 
119 
123  vtkSetMacro(RestDistance, float);
124  vtkGetMacro(RestDistance, float);
126 
131  void Initialize() override;
132 
140  void Layout() override;
141 
146  int IsLayoutComplete() override { return this->LayoutComplete; }
147 
149 
153  vtkSetStringMacro(InputArrayName);
154  vtkGetStringMacro(InputArrayName);
156 
157 protected:
160 
161  int MaxNumberOfIterations; // Maximum number of iterations.
163  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
164 
165 private:
166  // An edge consists of two vertices joined together.
167  // This struct acts as a "pointer" to those two vertices.
168  typedef struct
169  {
170  vtkIdType from;
171  vtkIdType to;
172  float weight;
173  } vtkLayoutEdge;
174 
175  // This class 'has a' vtkFastSplatter for the density grid
178  vtkSmartPointer<vtkFloatArray> RepulsionArray;
179  vtkSmartPointer<vtkFloatArray> AttractionArray;
180 
181  vtkLayoutEdge* EdgeArray;
182 
183  int RandomSeed;
184  int IterationsPerLayout;
185  int TotalIterations;
186  int LayoutComplete;
187  float Temp;
188  float RestDistance;
189 
190  char* InputArrayName;
191 
192  // Private helper methods
193  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
194  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
195  void ResolveCoincidentVertices();
196 
198  void operator=(const vtkConstrained2DLayoutStrategy&) = delete;
199 };
200 
201 #endif
vtkConstrained2DLayoutStrategy::vtkConstrained2DLayoutStrategy
vtkConstrained2DLayoutStrategy()
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkConstrained2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkConstrained2DLayoutStrategy.h:162
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkConstrained2DLayoutStrategy::Initialize
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
vtkConstrained2DLayoutStrategy::~vtkConstrained2DLayoutStrategy
~vtkConstrained2DLayoutStrategy() override
vtkGraphLayoutStrategy
abstract superclass for all graph layout strategies
Definition: vtkGraphLayoutStrategy.h:46
vtkConstrained2DLayoutStrategy::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: vtkConstrained2DLayoutStrategy.h:146
vtkX3D::weight
@ weight
Definition: vtkX3D.h:538
vtkConstrained2DLayoutStrategy
a simple fast 2D graph layout that looks for a 'constraint' array (vtkDoubleArray).
Definition: vtkConstrained2DLayoutStrategy.h:52
vtkSmartPointer< vtkFastSplatter >
vtkConstrained2DLayoutStrategy::New
static vtkConstrained2DLayoutStrategy * New()
vtkConstrained2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkConstrained2DLayoutStrategy.h:163
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkSmartPointer.h
vtkFastSplatter
A splatter optimized for splatting single kernels.
Definition: vtkFastSplatter.h:52
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkGraphLayoutStrategy.h
vtkConstrained2DLayoutStrategy::Layout
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
vtkConstrained2DLayoutStrategy::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkConstrained2DLayoutStrategy::MaxNumberOfIterations
int MaxNumberOfIterations
Definition: vtkConstrained2DLayoutStrategy.h:161
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165