VTK
vtkClustering2DLayoutStrategy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkClustering2DLayoutStrategy.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 __vtkClustering2DLayoutStrategy_h
36 #define __vtkClustering2DLayoutStrategy_h
37 
38 #include "vtkGraphLayoutStrategy.h"
39 
40 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars.
41 
42 class vtkFastSplatter;
43 class vtkImageData;
44 class vtkIntArray;
45 class vtkFloatArray;
46 
48 {
49 public:
51 
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
56 
59  vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER);
60  vtkGetMacro(RandomSeed, int);
62 
64 
69  vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER);
70  vtkGetMacro(MaxNumberOfIterations, int);
72 
74 
78  vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER);
79  vtkGetMacro(IterationsPerLayout, int);
81 
83 
86  vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
87  vtkGetMacro(InitialTemperature, float);
89 
91 
95  vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
96  vtkGetMacro(CoolDownRate, double);
98 
100 
102  vtkSetMacro(RestDistance, float);
103  vtkGetMacro(RestDistance, float);
105 
108  virtual void Initialize();
109 
114  virtual void Layout();
115 
118  virtual int IsLayoutComplete() {return this->LayoutComplete;}
119 
120 protected:
123 
124  int MaxNumberOfIterations; //Maximum number of iterations.
126  float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate.
127 
128 private:
129 
130  //BTX
131 
132  // An edge consists of two vertices joined together.
133  // This struct acts as a "pointer" to those two vertices.
134  typedef struct
135  {
136  vtkIdType from;
137  vtkIdType to;
138  float weight;
139  int dead_edge; // I'm making this an int so that the edge array is
140  // word boundary aligned... but I'm not sure what
141  // really happens in these days of magical compilers
142  } vtkLayoutEdge;
143 
144  // This class 'has a' vtkFastSplatter for the density grid
147  vtkSmartPointer<vtkFloatArray> RepulsionArray;
148  vtkSmartPointer<vtkFloatArray> AttractionArray;
149  vtkSmartPointer<vtkIntArray> EdgeCountArray;
150  //ETX
151 
152  vtkLayoutEdge *EdgeArray;
153 
154  int RandomSeed;
155  int IterationsPerLayout;
156  int TotalIterations;
157  int LayoutComplete;
158  float Temp;
159  float RestDistance;
160  float CuttingThreshold;
161 
162  // Private helper methods
163  void GenerateCircularSplat(vtkImageData *splat, int x, int y);
164  void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
165  void ResolveCoincidentVertices();
166 
168  void operator=(const vtkClustering2DLayoutStrategy&); // Not implemented.
169 };
170 
171 #endif
172