VTK
dox/Filters/FlowPaths/vtkCachingInterpolatedVelocityField.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCachingInterpolatedVelocityField.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 =========================================================================*/
00043 #ifndef __vtkTInterpolatedVelocityField_h
00044 #define __vtkTInterpolatedVelocityField_h
00045 
00046 #include "vtkFiltersFlowPathsModule.h" // For export macro
00047 #include "vtkFunctionSet.h"
00048 #include "vtkSmartPointer.h" // this is allowed
00049 //BTX
00050 #include <vector> // we need them
00051 //ETX
00052 
00053 class vtkDataSet;
00054 class vtkDataArray;
00055 class vtkPointData;
00056 class vtkGenericCell;
00057 class vtkAbstractCellLocator;
00058 //BTX
00059 //---------------------------------------------------------------------------
00060 class IVFDataSetInfo;
00061 //---------------------------------------------------------------------------
00062 class IVFCacheList : public std::vector< IVFDataSetInfo > {};
00063 //---------------------------------------------------------------------------
00064 //ETX
00065 class VTKFILTERSFLOWPATHS_EXPORT vtkCachingInterpolatedVelocityField : public vtkFunctionSet
00066 {
00067 public:
00068   vtkTypeMacro(vtkCachingInterpolatedVelocityField,vtkFunctionSet);
00069   virtual void PrintSelf(ostream& os, vtkIndent indent);
00070 
00073   static vtkCachingInterpolatedVelocityField *New();
00074 
00076 
00078   virtual int FunctionValues(double* x, double* f);
00079   virtual int InsideTest(double* x);
00081 
00083   virtual void SetDataSet(int I, vtkDataSet* dataset, bool staticdataset, vtkAbstractCellLocator *locator);
00084 
00086 
00089   vtkGetStringMacro(VectorsSelection);
00090   void SelectVectors(const char *fieldName)
00091     {this->SetVectorsSelection(fieldName);}
00093 
00095   void SetLastCellInfo(vtkIdType c, int datasetindex);
00096 
00099   void ClearLastCellInfo();
00100 
00102 
00105   int GetLastWeights(double* w);
00106   int GetLastLocalCoordinates(double pcoords[3]);
00108 
00110 
00111   vtkGetMacro(CellCacheHit, int);
00112   vtkGetMacro(DataSetCacheHit, int);
00113   vtkGetMacro(CacheMiss, int);
00115 
00116 protected:
00117   vtkCachingInterpolatedVelocityField();
00118  ~vtkCachingInterpolatedVelocityField();
00119 
00120   vtkGenericCell          *TempCell;
00121   int                      CellCacheHit;
00122   int                      DataSetCacheHit;
00123   int                      CacheMiss;
00124   int                      LastCacheIndex;
00125   int                      LastCellId;
00126   IVFDataSetInfo          *Cache;
00127   IVFCacheList          CacheList;
00128   char                    *VectorsSelection;
00129 //BTX
00130   std::vector<double>   Weights;
00131 //ETX
00132 
00133   vtkSetStringMacro(VectorsSelection);
00134 
00135   // private versions which work on the passed dataset/cache
00136   // these do the real computation
00137   int FunctionValues(IVFDataSetInfo *cache, double *x, double *f);
00138   int InsideTest(IVFDataSetInfo *cache, double* x);
00139 
00140 //BTX
00141   friend class vtkTemporalInterpolatedVelocityField;
00143 
00147   void FastCompute(IVFDataSetInfo *cache, double f[3]);
00148   bool InterpolatePoint(vtkPointData *outPD, vtkIdType outIndex);
00149   vtkGenericCell *GetLastCell();
00150 //ETX
00152 
00153 private:
00154   vtkCachingInterpolatedVelocityField(const vtkCachingInterpolatedVelocityField&);  // Not implemented.
00155   void operator=(const vtkCachingInterpolatedVelocityField&);  // Not implemented.
00156 };
00157 
00158 //---------------------------------------------------------------------------
00159 
00161 // IVFDataSetInfo
00163 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00164 //
00165 //BTX
00166 //
00167 class IVFDataSetInfo
00168 {
00169 public:
00170   vtkSmartPointer<vtkDataSet>             DataSet;
00171   vtkSmartPointer<vtkAbstractCellLocator> BSPTree;
00172   vtkSmartPointer<vtkGenericCell>         Cell;
00173   double                                  PCoords[3];
00174   float                                  *VelocityFloat;
00175   double                                 *VelocityDouble;
00176   double                                  Tolerance;
00177   bool                                    StaticDataSet;
00178   IVFDataSetInfo();
00179   IVFDataSetInfo(const IVFDataSetInfo &ivfci);
00180   IVFDataSetInfo &operator=(const IVFDataSetInfo &ivfci);
00181   void SetDataSet(vtkDataSet *data, char *velocity, bool staticdataset, vtkAbstractCellLocator *locator);
00182   //
00183   static const double TOLERANCE_SCALE;
00184 };
00185 
00186 //
00187 //ETX
00188 //
00189 
00190 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00191 
00192 #endif