VTK
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 "vtkInfovisLayoutModule.h" // For export macro
43 #include "vtkGraphLayoutStrategy.h"
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 
118 
120 
124  vtkSetMacro(RestDistance, float);
125  vtkGetMacro(RestDistance, float);
127 
132  void Initialize() override;
133 
141  void Layout() override;
142 
147  int IsLayoutComplete() override {return this->LayoutComplete;}
148 
150 
154  vtkSetStringMacro(InputArrayName);
155  vtkGetStringMacro(InputArrayName);
157 
158 protected:
160  ~vtkConstrained2DLayoutStrategy() override;
161 
162  int MaxNumberOfIterations; //Maximum number of iterations.
164  float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
165 
166 private:
167 
168  // An edge consists of two vertices joined together.
169  // This struct acts as a "pointer" to those two vertices.
170  typedef struct
171  {
172  vtkIdType from;
173  vtkIdType to;
174  float weight;
175  } vtkLayoutEdge;
176 
177  // This class 'has a' vtkFastSplatter for the density grid
180  vtkSmartPointer<vtkFloatArray> RepulsionArray;
181  vtkSmartPointer<vtkFloatArray> AttractionArray;
182 
183  vtkLayoutEdge *EdgeArray;
184 
185  int RandomSeed;
186  int IterationsPerLayout;
187  int TotalIterations;
188  int LayoutComplete;
189  float Temp;
190  float RestDistance;
191 
192  char* InputArrayName;
193 
194  // Private helper methods
195  void GenerateCircularSplat(vtkImageData *splat, int x, int y);
196  void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
197  void ResolveCoincidentVertices();
198 
200  void operator=(const vtkConstrained2DLayoutStrategy&) = delete;
201 };
202 
203 #endif
204 
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:169
#define VTK_INT_MAX
Definition: vtkType.h:159
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
int vtkIdType
Definition: vtkType.h:347
abstract superclass for all graph layout strategies
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
A splatter optimized for splatting single kernels.
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
a simple fast 2D graph layout that looks for a &#39;constraint&#39; array (vtkDoubleArray).
int IsLayoutComplete() override
I&#39;m an iterative layout so this method lets the caller know if I&#39;m done laying out the graph...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Initialize()
This method allows the layout strategy to do initialization of data structures or whatever else it mi...
virtual void Layout()=0
This is the layout method where the graph that was set in SetGraph() is laid out. ...