VTK  9.0.1
vtkCommunity2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCommunity2DLayoutStrategy.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 -------------------------------------------------------------------------*/
38 #ifndef vtkCommunity2DLayoutStrategy_h
39 #define vtkCommunity2DLayoutStrategy_h
40 
41 #include "vtkGraphLayoutStrategy.h"
42 #include "vtkInfovisLayoutModule.h" // For export macro
43 
44 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
45 
46 class vtkFastSplatter;
47 class vtkImageData;
48 class vtkFloatArray;
49 
50 class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
51 {
52 public:
54 
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59 
64  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
65  vtkGetMacro(RandomSeed, int);
67 
69 
77  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
78  vtkGetMacro(MaxNumberOfIterations, int);
80 
82 
89  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
90  vtkGetMacro(IterationsPerLayout, int);
92 
94 
100  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
101  vtkGetMacro(InitialTemperature, float);
103 
105 
113  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
114  vtkGetMacro(CoolDownRate, double);
116 
118 
122  vtkSetMacro(RestDistance, float);
123  vtkGetMacro(RestDistance, float);
125 
130  void Initialize() override;
131 
139  void Layout() override;
140 
145  int IsLayoutComplete() override { return this->LayoutComplete; }
146 
148 
151  vtkGetStringMacro(CommunityArrayName);
152  vtkSetStringMacro(CommunityArrayName);
154 
156 
162  vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
163  vtkGetMacro(CommunityStrength, float);
165 
166 protected:
168  ~vtkCommunity2DLayoutStrategy() override;
169 
170  int MaxNumberOfIterations; // Maximum number of iterations.
172  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
173 
174 private:
175  // An edge consists of two vertices joined together.
176  // This struct acts as a "pointer" to those two vertices.
177  typedef struct
178  {
179  vtkIdType from;
180  vtkIdType to;
181  float weight;
182  } vtkLayoutEdge;
183 
184  // This class 'has a' vtkFastSplatter for the density grid
187  vtkSmartPointer<vtkFloatArray> RepulsionArray;
188  vtkSmartPointer<vtkFloatArray> AttractionArray;
189 
190  vtkLayoutEdge* EdgeArray;
191 
192  int RandomSeed;
193  int IterationsPerLayout;
194  int TotalIterations;
195  int LayoutComplete;
196  float Temp;
197  float RestDistance;
198  float CommunityStrength;
199 
203  char* CommunityArrayName;
204 
205  // Private helper methods
206  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
207  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
208  void ResolveCoincidentVertices();
209 
211  void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
212 };
213 
214 #endif
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< vtkFastSplatter >
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
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
vtkCommunity2DLayoutStrategy::MaxNumberOfIterations
int MaxNumberOfIterations
Definition: vtkCommunity2DLayoutStrategy.h:170
vtkCommunity2DLayoutStrategy
a simple fast 2D graph layout that looks for a community array on it's input and strengthens edges wi...
Definition: vtkCommunity2DLayoutStrategy.h:50
vtkCommunity2DLayoutStrategy::InitialTemperature
float InitialTemperature
Definition: vtkCommunity2DLayoutStrategy.h:171
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkCommunity2DLayoutStrategy::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: vtkCommunity2DLayoutStrategy.h:145
vtkCommunity2DLayoutStrategy::CoolDownRate
float CoolDownRate
Definition: vtkCommunity2DLayoutStrategy.h:172