VTK
vtkFast2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFast2DLayoutStrategy.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 -------------------------------------------------------------------------*/
41 #ifndef __vtkFast2DLayoutStrategy_h
42 #define __vtkFast2DLayoutStrategy_h
43 
44 #include "vtkGraphLayoutStrategy.h"
45 
46 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
47 
48 class vtkFastSplatter;
49 class vtkFloatArray;
50 class vtkGraphToPolyData;
51 class vtkImageData;
52 
54 {
55 public:
56  static vtkFast2DLayoutStrategy *New();
57 
59  void PrintSelf(ostream& os, vtkIndent indent);
60 
62 
65  vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER);
66  vtkGetMacro(RandomSeed, int);
68 
70 
75  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER);
76  vtkGetMacro(MaxNumberOfIterations, int);
78 
80 
84  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER);
85  vtkGetMacro(IterationsPerLayout, int);
87 
89 
92  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
93  vtkGetMacro(InitialTemperature, float);
95 
97 
101  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
102  vtkGetMacro(CoolDownRate, double);
104 
106 
108  vtkSetMacro(RestDistance, float);
109  vtkGetMacro(RestDistance, float);
111 
114  virtual void Initialize();
115 
120  virtual void Layout();
121 
124  virtual int IsLayoutComplete() {return this->LayoutComplete;}
125 
126 protected:
129 
130  int MaxNumberOfIterations; //Maximum number of iterations.
132  float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
133 
134 private:
135 
136  //BTX
137 
138  // An edge consists of two vertices joined together.
139  // This struct acts as a "pointer" to those two vertices.
140  typedef struct
141  {
142  vtkIdType from;
143  vtkIdType to;
144  float weight;
145  } vtkLayoutEdge;
146 
147  // This class 'has a' vtkFastSplatter for the density grid
151  vtkSmartPointer<vtkFloatArray> RepulsionArray;
152  vtkSmartPointer<vtkFloatArray> AttractionArray;
153  //ETX
154 
155  vtkLayoutEdge *EdgeArray;
156 
157  int RandomSeed;
158  int IterationsPerLayout;
159  int TotalIterations;
160  int LayoutComplete;
161  float Temp;
162  float RestDistance;
163 
164  // Private helper methods
165  void GenerateCircularSplat(vtkImageData *splat, int x, int y);
166  void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
167  void ResolveCoincidentVertices();
168 
169  vtkFast2DLayoutStrategy(const vtkFast2DLayoutStrategy&); // Not implemented.
170  void operator=(const vtkFast2DLayoutStrategy&); // Not implemented.
171 };
172 
173 #endif
174