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 -------------------------------------------------------------------------*/
35 #ifndef vtkCommunity2DLayoutStrategy_h
36 #define vtkCommunity2DLayoutStrategy_h
37 
38 #include "vtkGraphLayoutStrategy.h"
39 #include "vtkInfovisLayoutModule.h" // For export macro
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 
115 
119  vtkSetMacro(RestDistance, float);
120  vtkGetMacro(RestDistance, float);
122 
127  void Initialize() override;
128 
136  void Layout() override;
137 
142  int IsLayoutComplete() override { return this->LayoutComplete; }
143 
145 
148  vtkGetStringMacro(CommunityArrayName);
149  vtkSetStringMacro(CommunityArrayName);
151 
153 
159  vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
160  vtkGetMacro(CommunityStrength, float);
162 
163 protected:
166 
167  int MaxNumberOfIterations; // Maximum number of iterations.
169  float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
170 
171 private:
172  // An edge consists of two vertices joined together.
173  // This struct acts as a "pointer" to those two vertices.
174  typedef struct
175  {
176  vtkIdType from;
177  vtkIdType to;
178  float weight;
179  } vtkLayoutEdge;
180 
181  // This class 'has a' vtkFastSplatter for the density grid
184  vtkSmartPointer<vtkFloatArray> RepulsionArray;
185  vtkSmartPointer<vtkFloatArray> AttractionArray;
186 
187  vtkLayoutEdge* EdgeArray;
188 
189  int RandomSeed;
190  int IterationsPerLayout;
191  int TotalIterations;
192  int LayoutComplete;
193  float Temp;
194  float RestDistance;
195  float CommunityStrength;
196 
200  char* CommunityArrayName;
201 
202  // Private helper methods
203  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
204  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
205  void ResolveCoincidentVertices();
206 
208  void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
209 };
210 
211 #endif
a simple fast 2D graph layout that looks for a community array on it's input and strengthens edges wi...
void Initialize() override
This strategy sets up some data structures for faster processing of each Layout() call.
static vtkCommunity2DLayoutStrategy * New()
void Layout() override
This is the layout method where the graph that was set in SetGraph() is laid out.
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph.
~vtkCommunity2DLayoutStrategy() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A splatter optimized for splatting single kernels.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
abstract superclass for all graph layout strategies
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
a simple class to control print indentation
Definition: vtkIndent.h:34
@ weight
Definition: vtkX3D.h:538
int vtkIdType
Definition: vtkType.h:338
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
#define VTK_INT_MAX
Definition: vtkType.h:155
#define VTK_FLOAT_MAX
Definition: vtkType.h:163