VTK  9.2.6
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  struct vtkLayoutEdge_t
178  {
179  vtkIdType from;
180  vtkIdType to;
181  float weight;
182  };
183  using vtkLayoutEdge = struct vtkLayoutEdge_t;
184 
185  // This class 'has a' vtkFastSplatter for the density grid
188  vtkSmartPointer<vtkFloatArray> RepulsionArray;
189  vtkSmartPointer<vtkFloatArray> AttractionArray;
190 
191  vtkLayoutEdge* EdgeArray;
192 
193  int RandomSeed;
194  int IterationsPerLayout;
195  int TotalIterations;
196  int LayoutComplete;
197  float Temp;
198  float RestDistance;
199  float CommunityStrength;
200 
204  char* CommunityArrayName;
205 
206  // Private helper methods
207  void GenerateCircularSplat(vtkImageData* splat, int x, int y);
208  void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
209  void ResolveCoincidentVertices();
210 
212  void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
213 };
214 
215 #endif
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:165
#define VTK_INT_MAX
Definition: vtkType.h:155
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
int vtkIdType
Definition: vtkType.h:332
int IsLayoutComplete() override
I'm an iterative layout so this method lets the caller know if I'm done laying out the graph...
abstract superclass for all graph layout strategies
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
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:53
a simple fast 2D graph layout that looks for a community array on it'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. ...