VTK  9.1.0
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 -------------------------------------------------------------------------*/
42 #ifndef vtkConstrained2DLayoutStrategy_h
43 #define vtkConstrained2DLayoutStrategy_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 vtkImageData;
52 class vtkFloatArray;
53 
54 class VTKINFOVISLAYOUT_EXPORT vtkConstrained2DLayoutStrategy : public vtkGraphLayoutStrategy
55 {
56 public:
58 
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
63 
68  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
69  vtkGetMacro(RandomSeed, int);
71 
73 
81  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
82  vtkGetMacro(MaxNumberOfIterations, int);
84 
86 
93  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
94  vtkGetMacro(IterationsPerLayout, int);
96 
98 
104  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
105  vtkGetMacro(InitialTemperature, float);
107 
109 
117  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
118  vtkGetMacro(CoolDownRate, double);
120 
122 
126  vtkSetMacro(RestDistance, float);
127  vtkGetMacro(RestDistance, float);
129 
134  void Initialize() override;
135 
143  void Layout() override;
144 
149  int IsLayoutComplete() override { return this->LayoutComplete; }
150 
152 
156  vtkSetStringMacro(InputArrayName);
157  vtkGetStringMacro(InputArrayName);
159 
160 protected:
163 
164  int MaxNumberOfIterations; // Maximum number of iterations.
166  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
167 
168 private:
169  // An edge consists of two vertices joined together.
170  // This struct acts as a "pointer" to those two vertices.
171  struct vtkLayoutEdge_t
172  {
173  vtkIdType from;
174  vtkIdType to;
175  float weight;
176  };
177  using vtkLayoutEdge = struct vtkLayoutEdge_t;
178 
179  // This class 'has a' vtkFastSplatter for the density grid
182  vtkSmartPointer<vtkFloatArray> RepulsionArray;
183  vtkSmartPointer<vtkFloatArray> AttractionArray;
184 
185  vtkLayoutEdge* EdgeArray;
186 
187  int RandomSeed;
188  int IterationsPerLayout;
189  int TotalIterations;
190  int LayoutComplete;
191  float Temp;
192  float RestDistance;
193 
194  char* InputArrayName;
195 
196  // Private helper methods
197  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
198  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
199  void ResolveCoincidentVertices();
200 
202  void operator=(const vtkConstrained2DLayoutStrategy&) = delete;
203 };
204 
205 #endif
vtkConstrained2DLayoutStrategy::vtkConstrained2DLayoutStrategy
vtkConstrained2DLayoutStrategy()
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkConstrained2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkConstrained2DLayoutStrategy.h:165
vtkIdType
int vtkIdType
Definition: vtkType.h:332
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:145
vtkConstrained2DLayoutStrategy::~vtkConstrained2DLayoutStrategy
~vtkConstrained2DLayoutStrategy() override
vtkGraphLayoutStrategy
abstract superclass for all graph layout strategies
Definition: vtkGraphLayoutStrategy.h:105
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:149
vtkX3D::weight
@ weight
Definition: vtkX3D.h:538
vtkConstrained2DLayoutStrategy
a simple fast 2D graph layout that looks for a 'constraint' array (vtkDoubleArray).
Definition: vtkConstrained2DLayoutStrategy.h:55
vtkSmartPointer< vtkFastSplatter >
vtkConstrained2DLayoutStrategy::New
static vtkConstrained2DLayoutStrategy * New()
vtkConstrained2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkConstrained2DLayoutStrategy.h:166
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkSmartPointer.h
vtkFastSplatter
A splatter optimized for splatting single kernels.
Definition: vtkFastSplatter.h:71
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:164
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165