VTK  9.1.0
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
39#include "vtkInfovisLayoutModule.h" // For export macro
40
41#include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
42
43class vtkFastSplatter;
44class vtkImageData;
45class vtkFloatArray;
46
47class VTKINFOVISLAYOUT_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy
48{
49public:
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
163protected:
166
167 int MaxNumberOfIterations; // Maximum number of iterations.
169 float CoolDownRate; // Cool-down rate. Note: Higher # = Slower rate.
170
171private:
172 // An edge consists of two vertices joined together.
173 // This struct acts as a "pointer" to those two vertices.
174 struct vtkLayoutEdge_t
175 {
176 vtkIdType from;
177 vtkIdType to;
178 float weight;
179 };
180 using vtkLayoutEdge = struct vtkLayoutEdge_t;
181
182 // This class 'has a' vtkFastSplatter for the density grid
185 vtkSmartPointer<vtkFloatArray> RepulsionArray;
186 vtkSmartPointer<vtkFloatArray> AttractionArray;
187
188 vtkLayoutEdge* EdgeArray;
189
190 int RandomSeed;
191 int IterationsPerLayout;
192 int TotalIterations;
193 int LayoutComplete;
194 float Temp;
195 float RestDistance;
196 float CommunityStrength;
197
201 char* CommunityArrayName;
202
203 // Private helper methods
204 void GenerateCircularSplat(vtkImageData* splat, int x, int y);
205 void GenerateGaussianSplat(vtkImageData* splat, int x, int y);
206 void ResolveCoincidentVertices();
207
209 void operator=(const vtkCommunity2DLayoutStrategy&) = delete;
210};
211
212#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.
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
static vtkCommunity2DLayoutStrategy * New()
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
abstract superclass for all graph layout strategies
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
@ weight
Definition: vtkX3D.h:538
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
#define VTK_INT_MAX
Definition: vtkType.h:155
#define VTK_FLOAT_MAX
Definition: vtkType.h:163