VTK
dox/Infovis/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 "vtkGraphLayoutStrategy.h"
00045 
00046 #include "vtkSmartPointer.h"    // Required for smart pointer internal ivars.
00047 
00048 class vtkFastSplatter;
00049 class vtkFloatArray;
00050 class vtkGraphToPolyData;
00051 class vtkImageData;
00052 
00053 class VTK_INFOVIS_EXPORT vtkFast2DLayoutStrategy : public vtkGraphLayoutStrategy 
00054 {
00055 public:
00056   static vtkFast2DLayoutStrategy *New();
00057 
00058   vtkTypeMacro(vtkFast2DLayoutStrategy, vtkGraphLayoutStrategy);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00062 
00065   vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER);
00066   vtkGetMacro(RandomSeed, int);
00068 
00070 
00075   vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER);
00076   vtkGetMacro(MaxNumberOfIterations, int);
00078   
00080 
00084   vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER);
00085   vtkGetMacro(IterationsPerLayout, int);
00087 
00089 
00092   vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
00093   vtkGetMacro(InitialTemperature, float);
00095   
00097 
00101   vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
00102   vtkGetMacro(CoolDownRate, double);
00104   
00106 
00108   vtkSetMacro(RestDistance, float);
00109   vtkGetMacro(RestDistance, float);
00111   
00114   virtual void Initialize();
00115   
00120   virtual void Layout();
00121   
00124   virtual int IsLayoutComplete() {return this->LayoutComplete;}
00125 
00126 protected:
00127   vtkFast2DLayoutStrategy();
00128   ~vtkFast2DLayoutStrategy();
00129 
00130   int    MaxNumberOfIterations;  //Maximum number of iterations.
00131   float  InitialTemperature;
00132   float  CoolDownRate;  //Cool-down rate.  Note:  Higher # = Slower rate.
00133 
00134 private:
00135 
00136   //BTX
00137 
00138   // An edge consists of two vertices joined together.
00139   // This struct acts as a "pointer" to those two vertices.
00140   typedef struct 
00141   {
00142     vtkIdType from;
00143     vtkIdType to;
00144     float weight;
00145   } vtkLayoutEdge;
00146   
00147   // This class 'has a' vtkFastSplatter for the density grid
00148   vtkSmartPointer<vtkGraphToPolyData>     GraphToPoly;
00149   vtkSmartPointer<vtkFastSplatter>        DensityGrid;
00150   vtkSmartPointer<vtkImageData>           SplatImage;
00151   vtkSmartPointer<vtkFloatArray>          RepulsionArray;
00152   vtkSmartPointer<vtkFloatArray>          AttractionArray;
00153   //ETX
00154   
00155   vtkLayoutEdge *EdgeArray;
00156 
00157   int RandomSeed;
00158   int IterationsPerLayout;
00159   int TotalIterations;
00160   int LayoutComplete;
00161   float Temp;
00162   float RestDistance;
00163   
00164   // Private helper methods
00165   void GenerateCircularSplat(vtkImageData *splat, int x, int y);
00166   void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
00167   void ResolveCoincidentVertices();
00168 
00169   vtkFast2DLayoutStrategy(const vtkFast2DLayoutStrategy&);  // Not implemented.
00170   void operator=(const vtkFast2DLayoutStrategy&);  // Not implemented.
00171 };
00172 
00173 #endif
00174