VTK
dox/Testing/Rendering/vtkTesting.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkTesting.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 =========================================================================*/
00064 #ifndef __vtkTesting_h
00065 #define __vtkTesting_h
00066 
00067 #include "vtkTestingRenderingModule.h" // For export macro
00068 #include "vtkObject.h"
00069 #include <vector> // STL Header used for argv
00070 #include <string> // STL Header used for argv
00071 
00072 class vtkAlgorithm;
00073 class vtkRenderWindow;
00074 class vtkImageData;
00075 class vtkDataArray;
00076 class vtkDataSet;
00077 class vtkRenderWindowInteractor;
00078 
00079 class VTKTESTINGRENDERING_EXPORT vtkTesting : public vtkObject
00080 {
00081 public:
00082   static vtkTesting *New();
00083   vtkTypeMacro(vtkTesting,vtkObject);
00084   void PrintSelf(ostream& os, vtkIndent indent);
00085 
00086 //BTX
00087   enum ReturnValue {
00088     FAILED = 0,
00089     PASSED = 1,
00090     NOT_RUN = 2,
00091     DO_INTERACTOR = 3
00092   };
00093 
00094   static int Test(int argc, char *argv[], vtkRenderWindow *rw, double thresh);
00095 
00097 
00115   static int InteractorEventLoop(int argc, char *argv[],
00116                                  vtkRenderWindowInteractor *iren,
00117                                  const char *stream = NULL);
00119 
00120 //ETX
00121 
00123 
00124   vtkSetClampMacro(FrontBuffer, int, 0, 1);
00125   vtkBooleanMacro(FrontBuffer, int);
00126   vtkGetMacro(FrontBuffer, int);
00128 
00130 
00132   virtual int RegressionTest(double thresh);
00133   virtual int RegressionTest(double thresh,ostream &os);
00135 
00137 
00139   virtual int RegressionTest(const std::string &pngFileName, double thresh);
00140   virtual int RegressionTest(const std::string &pngFileName,
00141                              double thresh, ostream& os);
00143 
00145 
00146   virtual int RegressionTest(vtkAlgorithm* imageSource, double thresh);
00147   virtual int RegressionTest(vtkAlgorithm* imageSource, double thresh,
00148                              ostream& os);
00150 
00155   int CompareAverageOfL2Norm(vtkDataSet *pdA, vtkDataSet *pdB, double tol);
00156 
00159   int CompareAverageOfL2Norm(vtkDataArray *daA, vtkDataArray *daB, double tol);
00160 
00162 
00164   virtual void SetRenderWindow(vtkRenderWindow* rw);
00165   vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
00167 
00169 
00170   vtkSetStringMacro(ValidImageFileName);
00171   const char *GetValidImageFileName();
00173 
00175 
00176   vtkGetMacro(ImageDifference, double);
00178 
00180 
00185   void AddArgument(const char *argv);
00186   void AddArguments(int argc,const char **argv);
00188 
00189   //BTX
00191 
00194   char *GetArgument(const char *arg);
00195   //ETX
00197 
00200   void CleanArguments();
00201 
00203 
00204   const char *GetDataRoot();
00205   vtkSetStringMacro(DataRoot);
00207 
00209 
00210   const char *GetTempDirectory();
00211   vtkSetStringMacro(TempDirectory);
00213 
00215   int IsValidImageSpecified();
00216 
00218   int IsInteractiveModeSpecified();
00219 
00221   int IsFlagSpecified(const char *flag);
00222 
00224 
00226   vtkSetMacro(BorderOffset, int);
00227   vtkGetMacro(BorderOffset, int);
00229 
00231 
00232   vtkSetMacro(Verbose, int);
00233   vtkGetMacro(Verbose, int);
00235 
00236 protected:
00237   vtkTesting();
00238   ~vtkTesting();
00239 
00240   static char* IncrementFileName(const char* fname, int count);
00241   static int LookForFile(const char* newFileName);
00242 
00243   int FrontBuffer;
00244   vtkRenderWindow* RenderWindow;
00245   char* ValidImageFileName;
00246   double ImageDifference;
00247   char *TempDirectory;
00248   int BorderOffset;
00249   int Verbose;
00250 
00251 //BTX
00252   std::vector<std::string> Args;
00253 //ETX
00254   char *DataRoot;
00255   double StartWallTime;
00256   double StartCPUTime;
00257 
00258 private:
00259   vtkTesting(const vtkTesting&);  // Not implemented.
00260   void operator=(const vtkTesting&);  // Not implemented.
00261 };
00262 
00263 #endif
00264 
00265