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   bool InterpolatePoint(vtkCachingInterpolatedVelocityField *inCIVF,
00150                         vtkPointData *outPD, vtkIdType outIndex);
00151   vtkGenericCell *GetLastCell();
00152 //ETX
00154 
00155 private:
00156   vtkCachingInterpolatedVelocityField(const vtkCachingInterpolatedVelocityField&);  // Not implemented.
00157   void operator=(const vtkCachingInterpolatedVelocityField&);  // Not implemented.
00158 };
00159 
00160 //---------------------------------------------------------------------------
00161 
00163 // IVFDataSetInfo
00165 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00166 //
00167 //BTX
00168 //
00169 class IVFDataSetInfo
00170 {
00171 public:
00172   vtkSmartPointer<vtkDataSet>             DataSet;
00173   vtkSmartPointer<vtkAbstractCellLocator> BSPTree;
00174   vtkSmartPointer<vtkGenericCell>         Cell;
00175   double                                  PCoords[3];
00176   float                                  *VelocityFloat;
00177   double                                 *VelocityDouble;
00178   double                                  Tolerance;
00179   bool                                    StaticDataSet;
00180   IVFDataSetInfo();
00181   IVFDataSetInfo(const IVFDataSetInfo &ivfci);
00182   IVFDataSetInfo &operator=(const IVFDataSetInfo &ivfci);
00183   void SetDataSet(vtkDataSet *data, char *velocity, bool staticdataset, vtkAbstractCellLocator *locator);
00184   //
00185   static const double TOLERANCE_SCALE;
00186 };
00187 
00188 //
00189 //ETX
00190 //
00191 
00192 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00193 
00194 #endif