VTK
vtkCachingInterpolatedVelocityField.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCachingInterpolatedVelocityField.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
44 #ifndef vtkCachingInterpolatedVelocityField_h
45 #define vtkCachingInterpolatedVelocityField_h
46 
47 #include "vtkFiltersFlowPathsModule.h" // For export macro
48 #include "vtkFunctionSet.h"
49 #include "vtkSmartPointer.h" // this is allowed
50 
51 #include <vector> // we need them
52 
53 class vtkDataSet;
54 class vtkDataArray;
55 class vtkPointData;
56 class vtkGenericCell;
58 
59 //---------------------------------------------------------------------------
60 class IVFDataSetInfo;
61 //---------------------------------------------------------------------------
62 class IVFCacheList : public std::vector< IVFDataSetInfo > {};
63 //---------------------------------------------------------------------------
64 
65 class VTKFILTERSFLOWPATHS_EXPORT vtkCachingInterpolatedVelocityField : public vtkFunctionSet
66 {
67 public:
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
76 
78 
82  int FunctionValues(double* x, double* f) override;
83  virtual int InsideTest(double* x);
85 
89  virtual void SetDataSet(int I, vtkDataSet* dataset, bool staticdataset, vtkAbstractCellLocator *locator);
90 
92 
97  vtkGetStringMacro(VectorsSelection);
98  void SelectVectors(const char *fieldName)
99  {this->SetVectorsSelection(fieldName);}
101 
107  void SetLastCellInfo(vtkIdType c, int datasetindex);
108 
114 
116 
121  int GetLastWeights(double* w);
122  int GetLastLocalCoordinates(double pcoords[3]);
124 
126 
129  vtkGetMacro(CellCacheHit, int);
130  vtkGetMacro(DataSetCacheHit, int);
131  vtkGetMacro(CacheMiss, int);
133 
134 protected:
137 
144  IVFDataSetInfo *Cache;
147 
148  std::vector<double> Weights;
149 
150  vtkSetStringMacro(VectorsSelection);
151 
152  // private versions which work on the passed dataset/cache
153  // these do the real computation
154  int FunctionValues(IVFDataSetInfo *cache, double *x, double *f);
155  int InsideTest(IVFDataSetInfo *cache, double* x);
156 
159 
166  void FastCompute(IVFDataSetInfo *cache, double f[3]);
167  bool InterpolatePoint(vtkPointData *outPD, vtkIdType outIndex);
169  vtkPointData *outPD, vtkIdType outIndex);
172 
173 private:
175  void operator=(const vtkCachingInterpolatedVelocityField&) = delete;
176 };
177 
178 //---------------------------------------------------------------------------
179 
181 // IVFDataSetInfo
183 #ifndef DOXYGEN_SHOULD_SKIP_THIS
184 //
185 
186 //
187 class IVFDataSetInfo
188 {
189 public:
193  double PCoords[3];
194  float *VelocityFloat;
195  double *VelocityDouble;
196  double Tolerance;
197  bool StaticDataSet;
198  IVFDataSetInfo();
199  IVFDataSetInfo(const IVFDataSetInfo &ivfci);
200  IVFDataSetInfo &operator=(const IVFDataSetInfo &ivfci);
201  void SetDataSet(vtkDataSet *data, char *velocity, bool staticdataset, vtkAbstractCellLocator *locator);
202  //
203  static const double TOLERANCE_SCALE;
204 };
205 
206 //
207 
208 //
209 
210 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
211 
212 #endif
vtkCachingInterpolatedVelocityField::SetDataSet
virtual void SetDataSet(int I, vtkDataSet *dataset, bool staticdataset, vtkAbstractCellLocator *locator)
Add a dataset used by the interpolation function evaluation.
vtkCachingInterpolatedVelocityField::CacheList
IVFCacheList CacheList
Definition: vtkCachingInterpolatedVelocityField.h:145
vtkX3D::vector
@ vector
Definition: vtkX3D.h:237
vtkFunctionSet
Abstract interface for sets of functions.
Definition: vtkFunctionSet.h:36
vtkCachingInterpolatedVelocityField::InsideTest
int InsideTest(IVFDataSetInfo *cache, double *x)
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:38
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkCachingInterpolatedVelocityField::SelectVectors
void SelectVectors(const char *fieldName)
Definition: vtkCachingInterpolatedVelocityField.h:98
vtkCachingInterpolatedVelocityField::InterpolatePoint
bool InterpolatePoint(vtkCachingInterpolatedVelocityField *inCIVF, vtkPointData *outPD, vtkIdType outIndex)
vtkSmartPointer< vtkDataSet >
vtkCachingInterpolatedVelocityField::~vtkCachingInterpolatedVelocityField
~vtkCachingInterpolatedVelocityField() override
vtkCachingInterpolatedVelocityField::InsideTest
virtual int InsideTest(double *x)
vtkFunctionSet.h
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkCachingInterpolatedVelocityField::Weights
std::vector< double > Weights
Definition: vtkCachingInterpolatedVelocityField.h:148
vtkCachingInterpolatedVelocityField::FastCompute
void FastCompute(IVFDataSetInfo *cache, double f[3])
If all weights have been computed (parametric coords etc all valid) then we can quickly interpolate a...
vtkCachingInterpolatedVelocityField::vtkCachingInterpolatedVelocityField
vtkCachingInterpolatedVelocityField()
vtkCachingInterpolatedVelocityField::New
static vtkCachingInterpolatedVelocityField * New()
Construct a vtkCachingInterpolatedVelocityField with no initial data set.
vtkCachingInterpolatedVelocityField::ClearLastCellInfo
void ClearLastCellInfo()
Set LastCellId to -1 and Cache to nullptr so that the next search does not start from the previous ce...
vtkCachingInterpolatedVelocityField::LastCellId
int LastCellId
Definition: vtkCachingInterpolatedVelocityField.h:143
vtkCachingInterpolatedVelocityField
Interface for obtaining interpolated velocity values.
Definition: vtkCachingInterpolatedVelocityField.h:66
vtkCachingInterpolatedVelocityField::Cache
IVFDataSetInfo * Cache
Definition: vtkCachingInterpolatedVelocityField.h:144
vtkCachingInterpolatedVelocityField::FunctionValues
int FunctionValues(IVFDataSetInfo *cache, double *x, double *f)
vtkCachingInterpolatedVelocityField::GetLastWeights
int GetLastWeights(double *w)
Returns the interpolation weights/pcoords cached from last evaluation if the cached cell is valid (re...
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkSmartPointer.h
vtkCachingInterpolatedVelocityField::VectorsSelection
char * VectorsSelection
Definition: vtkCachingInterpolatedVelocityField.h:146
IVFCacheList
Definition: vtkCachingInterpolatedVelocityField.h:62
vtkCachingInterpolatedVelocityField::FunctionValues
int FunctionValues(double *x, double *f) override
Evaluate the velocity field, f={u,v,w}, at {x, y, z}.
vtkCachingInterpolatedVelocityField::CacheMiss
int CacheMiss
Definition: vtkCachingInterpolatedVelocityField.h:141
vtkCachingInterpolatedVelocityField::DataSetCacheHit
int DataSetCacheHit
Definition: vtkCachingInterpolatedVelocityField.h:140
vtkCachingInterpolatedVelocityField::GetLastLocalCoordinates
int GetLastLocalCoordinates(double pcoords[3])
vtkCachingInterpolatedVelocityField::SetLastCellInfo
void SetLastCellInfo(vtkIdType c, int datasetindex)
Set LastCellId to c and LastCacheIndex datasetindex, cached from last evaluation.
vtkCachingInterpolatedVelocityField::CellCacheHit
int CellCacheHit
Definition: vtkCachingInterpolatedVelocityField.h:139
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:49
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
vtkCachingInterpolatedVelocityField::LastCacheIndex
int LastCacheIndex
Definition: vtkCachingInterpolatedVelocityField.h:142
vtkCachingInterpolatedVelocityField::TempCell
vtkGenericCell * TempCell
Definition: vtkCachingInterpolatedVelocityField.h:138
vtkTemporalInterpolatedVelocityField
A helper class for interpolating between times during particle tracing.
Definition: vtkTemporalInterpolatedVelocityField.h:69
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:40
vtkCachingInterpolatedVelocityField::GetLastCell
vtkGenericCell * GetLastCell()
vtkCachingInterpolatedVelocityField::InterpolatePoint
bool InterpolatePoint(vtkPointData *outPD, vtkIdType outIndex)
vtkCachingInterpolatedVelocityField::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.