VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkCommunity2DLayoutStrategy.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 -------------------------------------------------------------------------*/ 00037 #ifndef __vtkCommunity2DLayoutStrategy_h 00038 #define __vtkCommunity2DLayoutStrategy_h 00039 00040 #include "vtkGraphLayoutStrategy.h" 00041 00042 #include "vtkSmartPointer.h" // Required for smart pointer internal ivars. 00043 00044 class vtkFastSplatter; 00045 class vtkImageData; 00046 class vtkFloatArray; 00047 00048 class VTK_INFOVIS_EXPORT vtkCommunity2DLayoutStrategy : public vtkGraphLayoutStrategy 00049 { 00050 public: 00051 static vtkCommunity2DLayoutStrategy *New(); 00052 00053 vtkTypeMacro(vtkCommunity2DLayoutStrategy, vtkGraphLayoutStrategy); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00057 00060 vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER); 00061 vtkGetMacro(RandomSeed, int); 00063 00065 00070 vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER); 00071 vtkGetMacro(MaxNumberOfIterations, int); 00073 00075 00079 vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER); 00080 vtkGetMacro(IterationsPerLayout, int); 00082 00084 00087 vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX); 00088 vtkGetMacro(InitialTemperature, float); 00090 00092 00096 vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX); 00097 vtkGetMacro(CoolDownRate, double); 00099 00100 00102 00104 vtkSetMacro(RestDistance, float); 00105 vtkGetMacro(RestDistance, float); 00107 00110 virtual void Initialize(); 00111 00116 virtual void Layout(); 00117 00120 virtual int IsLayoutComplete() {return this->LayoutComplete;} 00121 00123 00124 vtkGetStringMacro(CommunityArrayName); 00125 vtkSetStringMacro(CommunityArrayName); 00127 00129 00133 vtkSetClampMacro(CommunityStrength, float, 0.1, 1.0); 00134 vtkGetMacro(CommunityStrength, float); 00136 00137 protected: 00138 vtkCommunity2DLayoutStrategy(); 00139 ~vtkCommunity2DLayoutStrategy(); 00140 00141 int MaxNumberOfIterations; //Maximum number of iterations. 00142 float InitialTemperature; 00143 float CoolDownRate; //Cool-down rate. Note: Higher # = Slower rate. 00144 00145 private: 00146 00147 //BTX 00148 00149 // An edge consists of two vertices joined together. 00150 // This struct acts as a "pointer" to those two vertices. 00151 typedef struct 00152 { 00153 vtkIdType from; 00154 vtkIdType to; 00155 float weight; 00156 } vtkLayoutEdge; 00157 00158 // This class 'has a' vtkFastSplatter for the density grid 00159 vtkSmartPointer<vtkFastSplatter> DensityGrid; 00160 vtkSmartPointer<vtkImageData> SplatImage; 00161 vtkSmartPointer<vtkFloatArray> RepulsionArray; 00162 vtkSmartPointer<vtkFloatArray> AttractionArray; 00163 //ETX 00164 00165 vtkLayoutEdge *EdgeArray; 00166 00167 int RandomSeed; 00168 int IterationsPerLayout; 00169 int TotalIterations; 00170 int LayoutComplete; 00171 float Temp; 00172 float RestDistance; 00173 float CommunityStrength; 00174 00176 char* CommunityArrayName; 00177 00178 // Private helper methods 00179 void GenerateCircularSplat(vtkImageData *splat, int x, int y); 00180 void GenerateGaussianSplat(vtkImageData *splat, int x, int y); 00181 void ResolveCoincidentVertices(); 00182 00183 vtkCommunity2DLayoutStrategy(const vtkCommunity2DLayoutStrategy&); // Not implemented. 00184 void operator=(const vtkCommunity2DLayoutStrategy&); // Not implemented. 00185 }; 00186 00187 #endif 00188