VTK
dox/Infovis/vtkConstrained2DLayoutStrategy.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkConstrained2DLayoutStrategy.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 __vtkConstrained2DLayoutStrategy_h
00042 #define __vtkConstrained2DLayoutStrategy_h
00043 
00044 #include "vtkGraphLayoutStrategy.h"
00045 
00046 #include "vtkSmartPointer.h"    // Required for smart pointer internal ivars.
00047 
00048 class vtkFastSplatter;
00049 class vtkImageData;
00050 class vtkFloatArray;
00051 
00052 class VTK_INFOVIS_EXPORT vtkConstrained2DLayoutStrategy : public vtkGraphLayoutStrategy 
00053 {
00054 public:
00055   static vtkConstrained2DLayoutStrategy *New();
00056 
00057   vtkTypeMacro(vtkConstrained2DLayoutStrategy, vtkGraphLayoutStrategy);
00058   void PrintSelf(ostream& os, vtkIndent indent);
00059 
00061 
00064   vtkSetClampMacro(RandomSeed, int, 0, VTK_LARGE_INTEGER);
00065   vtkGetMacro(RandomSeed, int);
00067 
00069 
00074   vtkSetClampMacro(MaxNumberOfIterations, int, 0, VTK_LARGE_INTEGER);
00075   vtkGetMacro(MaxNumberOfIterations, int);
00077   
00079 
00083   vtkSetClampMacro(IterationsPerLayout, int, 0, VTK_LARGE_INTEGER);
00084   vtkGetMacro(IterationsPerLayout, int);
00086 
00088 
00091   vtkSetClampMacro(InitialTemperature, float, 0.0, VTK_FLOAT_MAX);
00092   vtkGetMacro(InitialTemperature, float);
00094   
00096 
00100   vtkSetClampMacro(CoolDownRate, double, 0.01, VTK_DOUBLE_MAX);
00101   vtkGetMacro(CoolDownRate, double);
00103   
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   
00127 
00129   vtkSetStringMacro(InputArrayName);
00130   vtkGetStringMacro(InputArrayName);
00132 
00133 protected:
00134   vtkConstrained2DLayoutStrategy();
00135   ~vtkConstrained2DLayoutStrategy();
00136 
00137   int    MaxNumberOfIterations;  //Maximum number of iterations.
00138   float  InitialTemperature;
00139   float  CoolDownRate;  //Cool-down rate.  Note:  Higher # = Slower rate.
00140 
00141 private:
00142 
00143   //BTX
00144 
00145   // An edge consists of two vertices joined together.
00146   // This struct acts as a "pointer" to those two vertices.
00147   typedef struct 
00148   {
00149     vtkIdType from;
00150     vtkIdType to;
00151     float weight;
00152   } vtkLayoutEdge;
00153   
00154   // This class 'has a' vtkFastSplatter for the density grid
00155   vtkSmartPointer<vtkFastSplatter>        DensityGrid;
00156   vtkSmartPointer<vtkImageData>           SplatImage;
00157   vtkSmartPointer<vtkFloatArray>          RepulsionArray;
00158   vtkSmartPointer<vtkFloatArray>          AttractionArray;
00159   //ETX
00160   
00161   vtkLayoutEdge *EdgeArray;
00162 
00163   int RandomSeed;
00164   int IterationsPerLayout;
00165   int TotalIterations;
00166   int LayoutComplete;
00167   float Temp;
00168   float RestDistance;
00169   
00170   char* InputArrayName;
00171   
00172   // Private helper methods
00173   void GenerateCircularSplat(vtkImageData *splat, int x, int y);
00174   void GenerateGaussianSplat(vtkImageData *splat, int x, int y);
00175   void ResolveCoincidentVertices();
00176 
00177   vtkConstrained2DLayoutStrategy(const vtkConstrained2DLayoutStrategy&);  // Not implemented.
00178   void operator=(const vtkConstrained2DLayoutStrategy&);  // Not implemented.
00179 };
00180 
00181 #endif
00182