VTK
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 -------------------------------------------------------------------------*/
35 #ifndef vtkCommunity2DLayoutStrategy_h
36 #define vtkCommunity2DLayoutStrategy_h
37 
38 #include "vtkInfovisLayoutModule.h" // For export macro
39 #include "vtkGraphLayoutStrategy.h"
40 
41 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
42 
43 class vtkFastSplatter;
44 class vtkImageData;
45 class vtkFloatArray;
46 
47 class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
48 {
49 public:
51 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
61  vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
62  vtkGetMacro(RandomSeed, int);
64 
66 
74  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
75  vtkGetMacro(MaxNumberOfIterations, int);
77 
79 
86  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
87  vtkGetMacro(IterationsPerLayout, int);
89 
91 
97  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
98  vtkGetMacro(InitialTemperature, float);
100 
102 
110  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
111  vtkGetMacro(CoolDownRate, double);
113 
114 
116 
120  vtkSetMacro(RestDistance, float);
121  vtkGetMacro(RestDistance, float);
123 
128  void Initialize() override;
129 
137  void Layout() override;
138 
143  int IsLayoutComplete() override {return this->LayoutComplete;}
144 
146 
149  vtkGetStringMacro(CommunityArrayName);
150  vtkSetStringMacro(CommunityArrayName);
152 
154 
160  vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
161  vtkGetMacro(CommunityStrength, float);
163 
164 protected:
166  ~vtkCommunity2DLayoutStrategy() override;
167 
168  int MaxNumberOfIterations; //Maximum number of iterations.
170  float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
171 
172 private:
173 
174  // An edge consists of two vertices joined together.
175  // This struct acts as a "pointer" to those two vertices.
176  typedef struct
177  {
178  vtkIdType from;
179  vtkIdType to;
180  float weight;
181  } vtkLayoutEdge;
182 
183  // This class 'has a' vtkFastSplatter for the density grid
186  vtkSmartPointer<vtkFloatArray> RepulsionArray;
187  vtkSmartPointer<vtkFloatArray> AttractionArray;
188 
189  vtkLayoutEdge *EdgeArray;
190 
191  int RandomSeed;
192  int IterationsPerLayout;
193  int TotalIterations;
194  int LayoutComplete;
195  float Temp;
196  float RestDistance;
197  float CommunityStrength;
198 
202  char* CommunityArrayName;
203 
204  // Private helper methods
205  void GenerateCircularSplat(vtkImageData *splat, int x, int y);
206  void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
207  void ResolveCoincidentVertices();
208 
210  void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
211 };
212 
213 #endif
214 
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
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...
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 community array on it&#39;s input and strengthens edges wi...
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. ...