VTK
dox/Infovis/Layout/vtkFast2DLayoutStrategy.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkFast2DLayoutStrategy.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 -------------------------------------------------------------------------*/
00041 #ifndef __vtkFast2DLayoutStrategy_h
00042 #define __vtkFast2DLayoutStrategy_h
00043 
00044 #include "vtkInfovisLayoutModule.h" // For export macro
00045 #include "vtkGraphLayoutStrategy.h"
00046 
00047 #include "vtkSmartPointer.h"    // Required for smart pointer internal ivars.
00048 
00049 class vtkFastSplatter;
00050 class vtkFloatArray;
00051 class vtkGraphToPolyData;
00052 class vtkImageData;
00053 
00054 class VTKINFOVISLAYOUT_EXPORT vtkFast2DLayoutStrategy : public vtkGraphLayoutStrategy
00055 {
00056 public:
00057   static vtkFast2DLayoutStrategy *New();
00058 
00059   vtkTypeMacro(vtkFast2DLayoutStrategy, vtkGraphLayoutStrategy);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00063 
00066   vtkSetClampMacro(RandomSeed, int, 0, VTK_INT_MAX);
00067   vtkGetMacro(RandomSeed, int);
00069 
00071 
00076   vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_INT_MAX);
00077   vtkGetMacro(MaxNumberOfIterations, int);
00079 
00081 
00085   vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_INT_MAX);
00086   vtkGetMacro(IterationsPerLayout, int);
00088 
00090 
00093   vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
00094   vtkGetMacro(InitialTemperature, float);
00096 
00098 
00102   vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
00103   vtkGetMacro(CoolDownRate, double);
00105 
00107 
00109   vtkSetMacro(RestDistance, float);
00110   vtkGetMacro(RestDistance, float);
00112 
00115   virtual void Initialize();
00116 
00121   virtual void Layout();
00122 
00125   virtual int IsLayoutComplete() {return this->LayoutComplete;}
00126 
00127 protected:
00128   vtkFast2DLayoutStrategy();
00129   ~vtkFast2DLayoutStrategy();
00130 
00131   int    MaxNumberOfIterations;  //Maximum number of iterations.
00132   float  InitialTemperature;
00133   float  CoolDownRate;  //Cool-down rate.  Note:  Higher # = Slower rate.
00134 
00135 private:
00136 
00137   //BTX
00138 
00139   // An edge consists of two vertices joined together.
00140   // This struct acts as a "pointer" to those two vertices.
00141   typedef struct
00142   {
00143     vtkIdType from;
00144     vtkIdType to;
00145     float weight;
00146   } vtkLayoutEdge;
00147 
00148   // This class 'has a' vtkFastSplatter for the density grid
00149   vtkSmartPointer<vtkGraphToPolyData>     GraphToPoly;
00150   vtkSmartPointer<vtkFastSplatter>        DensityGrid;
00151   vtkSmartPointer<vtkImageData>           SplatImage;
00152   vtkSmartPointer<vtkFloatArray>          RepulsionArray;
00153   vtkSmartPointer<vtkFloatArray>          AttractionArray;
00154   //ETX
00155 
00156   vtkLayoutEdge *EdgeArray;
00157 
00158   int RandomSeed;
00159   int IterationsPerLayout;
00160   int TotalIterations;
00161   int LayoutComplete;
00162   float Temp;
00163   float RestDistance;
00164 
00165   // Private helper methods
00166   void GenerateCircularSplat(vtkImageData *splat, int x, int y);
00167   void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
00168   void ResolveCoincidentVertices();
00169 
00170   vtkFast2DLayoutStrategy(const vtkFast2DLayoutStrategy&);  // Not implemented.
00171   void operator=(const vtkFast2DLayoutStrategy&);  // Not implemented.
00172 };
00173 
00174 #endif
00175