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 -------------------------------------------------------------------------*/
37 #ifndef __vtkCommunity2DLayoutStrategy_h
38 #define __vtkCommunity2DLayoutStrategy_h
39 
40 #include "vtkGraphLayoutStrategy.h"
41 
42 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
43 
44 class vtkFastSplatter;
45 class vtkImageData;
46 class vtkFloatArray;
47 
49 {
50 public:
52 
54  void PrintSelf(ostream& os, vtkIndent indent);
55 
57 
60  vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER);
61  vtkGetMacro(RandomSeed, int);
63 
65 
70  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER);
71  vtkGetMacro(MaxNumberOfIterations, int);
73 
75 
79  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER);
80  vtkGetMacro(IterationsPerLayout, int);
82 
84 
87  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
88  vtkGetMacro(InitialTemperature, float);
90 
92 
96  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
97  vtkGetMacro(CoolDownRate, double);
99 
100 
102 
104  vtkSetMacro(RestDistance, float);
105  vtkGetMacro(RestDistance, float);
107 
110  virtual void Initialize();
111 
116  virtual void Layout();
117 
120  virtual int IsLayoutComplete() {return this->LayoutComplete;}
121 
123 
124  vtkGetStringMacro(CommunityArrayName);
125  vtkSetStringMacro(CommunityArrayName);
127 
129 
133  vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0);
134  vtkGetMacro(CommunityStrength, float);
136 
137 protected:
140 
141  int MaxNumberOfIterations; //Maximum number of iterations.
143  float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
144 
145 private:
146 
147  //BTX
148 
149  // An edge consists of two vertices joined together.
150  // This struct acts as a "pointer" to those two vertices.
151  typedef struct
152  {
153  vtkIdType from;
154  vtkIdType to;
155  float weight;
156  } vtkLayoutEdge;
157 
158  // This class 'has a' vtkFastSplatter for the density grid
161  vtkSmartPointer<vtkFloatArray> RepulsionArray;
162  vtkSmartPointer<vtkFloatArray> AttractionArray;
163  //ETX
164 
165  vtkLayoutEdge *EdgeArray;
166 
167  int RandomSeed;
168  int IterationsPerLayout;
169  int TotalIterations;
170  int LayoutComplete;
171  float Temp;
172  float RestDistance;
173  float CommunityStrength;
174 
176  char* CommunityArrayName;
177 
178  // Private helper methods
179  void GenerateCircularSplat(vtkImageData *splat, int x, int y);
180  void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
181  void ResolveCoincidentVertices();
182 
184  void operator=(const vtkCommunity2DLayoutStrategy&); // Not implemented.
185 };
186 
187 #endif
188