VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkClustering2DLayoutStrategy.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00035 #ifndef __vtkClustering2DLayoutStrategy_h 00036 #define __vtkClustering2DLayoutStrategy_h 00037 00038 #include "vtkGraphLayoutStrategy.h" 00039 00040 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars. 00041 00042 class vtkFastSplatter; 00043 class vtkImageData; 00044 class vtkIntArray; 00045 class vtkFloatArray; 00046 00047 class VTK_INFOVIS_EXPORT vtkClustering2DLayoutStrategy : public vtkGraphLayoutStrategy 00048 { 00049 public: 00050 static vtkClustering2DLayoutStrategy *New(); 00051 00052 vtkTypeMacro(vtkClustering2DLayoutStrategy, vtkGraphLayoutStrategy); 00053 void PrintSelf(ostream& os, vtkIndent indent); 00054 00056 00059 vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER); 00060 vtkGetMacro(RandomSeed, int); 00062 00064 00069 vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER); 00070 vtkGetMacro(MaxNumberOfIterations, int); 00072 00074 00078 vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER); 00079 vtkGetMacro(IterationsPerLayout, int); 00081 00083 00086 vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX); 00087 vtkGetMacro(InitialTemperature, float); 00089 00091 00095 vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX); 00096 vtkGetMacro(CoolDownRate, double); 00098 00100 00102 vtkSetMacro(RestDistance, float); 00103 vtkGetMacro(RestDistance, float); 00105 00108 virtual void Initialize(); 00109 00114 virtual void Layout(); 00115 00118 virtual int IsLayoutComplete() {return this->LayoutComplete;} 00119 00120 protected: 00121 vtkClustering2DLayoutStrategy(); 00122 ~vtkClustering2DLayoutStrategy(); 00123 00124 int MaxNumberOfIterations; //Maximum number of iterations. 00125 float InitialTemperature; 00126 float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate. 00127 00128 private: 00129 00130 //BTX 00131 00132 // An edge consists of two vertices joined together. 00133 // This struct acts as a "pointer" to those two vertices. 00134 typedef struct 00135 { 00136 vtkIdType from; 00137 vtkIdType to; 00138 float weight; 00139 int dead_edge; // I'm making this an int so that the edge array is 00140 // word boundary aligned... but I'm not sure what 00141 // really happens in these days of magical compilers 00142 } vtkLayoutEdge; 00143 00144 // This class 'has a' vtkFastSplatter for the density grid 00145 vtkSmartPointer<vtkFastSplatter> DensityGrid; 00146 vtkSmartPointer<vtkImageData> SplatImage; 00147 vtkSmartPointer<vtkFloatArray> RepulsionArray; 00148 vtkSmartPointer<vtkFloatArray> AttractionArray; 00149 vtkSmartPointer<vtkIntArray> EdgeCountArray; 00150 //ETX 00151 00152 vtkLayoutEdge *EdgeArray; 00153 00154 int RandomSeed; 00155 int IterationsPerLayout; 00156 int TotalIterations; 00157 int LayoutComplete; 00158 float Temp; 00159 float RestDistance; 00160 float CuttingThreshold; 00161 00162 // Private helper methods 00163 void GenerateCircularSplat(vtkImageData *splat, int x, int y); 00164 void GenerateGaussianSplat(vtkImageData *splat, int x, int y); 00165 void ResolveCoincidentVertices(); 00166 00167 vtkClustering2DLayoutStrategy(const vtkClustering2DLayoutStrategy&); // Not implemented. 00168 void operator=(const vtkClustering2DLayoutStrategy&); // Not implemented. 00169 }; 00170 00171 #endif 00172