VTK  9.0.3
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 //---------------------------------------------------------------------------
66 
67 class VTKFILTERSFLOWPATHS_EXPORT vtkCachingInterpolatedVelocityField : public vtkFunctionSet
68 {
69 public:
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
78 
79  using Superclass::FunctionValues;
81 
85  int FunctionValues(double* x, double* f) override;
86  virtual int InsideTest(double* x);
88 
92  virtual void SetDataSet(
93  int I, vtkDataSet* dataset, bool staticdataset, vtkAbstractCellLocator* locator);
94 
96 
101  vtkGetStringMacro(VectorsSelection);
102  void SelectVectors(const char* fieldName) { this->SetVectorsSelection(fieldName); }
104 
110  void SetLastCellInfo(vtkIdType c, int datasetindex);
111 
117 
119 
124  int GetLastWeights(double* w);
125  int GetLastLocalCoordinates(double pcoords[3]);
127 
129 
132  vtkGetMacro(CellCacheHit, int);
133  vtkGetMacro(DataSetCacheHit, int);
134  vtkGetMacro(CacheMiss, int);
136 
137 protected:
140 
147  IVFDataSetInfo* Cache;
150 
151  std::vector<double> Weights;
152 
153  vtkSetStringMacro(VectorsSelection);
154 
155  // private versions which work on the passed dataset/cache
156  // these do the real computation
157  int FunctionValues(IVFDataSetInfo* cache, double* x, double* f);
158  int InsideTest(IVFDataSetInfo* cache, double* x);
159 
162 
169  void FastCompute(IVFDataSetInfo* cache, double f[3]);
170  bool InterpolatePoint(vtkPointData* outPD, vtkIdType outIndex);
175 
176 private:
178  void operator=(const vtkCachingInterpolatedVelocityField&) = delete;
179 };
180 
181 //---------------------------------------------------------------------------
182 
184 // IVFDataSetInfo
186 #ifndef DOXYGEN_SHOULD_SKIP_THIS
187 //
188 
189 //
190 class IVFDataSetInfo
191 {
192 public:
196  double PCoords[3];
197  float* VelocityFloat;
198  double* VelocityDouble;
199  double Tolerance;
200  bool StaticDataSet;
201  IVFDataSetInfo();
202  IVFDataSetInfo(const IVFDataSetInfo& ivfci);
203  IVFDataSetInfo& operator=(const IVFDataSetInfo& ivfci);
204  void SetDataSet(
205  vtkDataSet* data, char* velocity, bool staticdataset, vtkAbstractCellLocator* locator);
206  //
207  static const double TOLERANCE_SCALE;
208 };
209 
210 //
211 
212 //
213 
214 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
215 
216 #endif
an abstract base class for locators which find cells
Interface for obtaining interpolated velocity values.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetLastWeights(double *w)
Returns the interpolation weights/pcoords cached from last evaluation if the cached cell is valid (re...
bool InterpolatePoint(vtkPointData *outPD, vtkIdType outIndex)
int InsideTest(IVFDataSetInfo *cache, double *x)
void SetLastCellInfo(vtkIdType c, int datasetindex)
Set LastCellId to c and LastCacheIndex datasetindex, cached from last evaluation.
int FunctionValues(IVFDataSetInfo *cache, double *x, double *f)
int FunctionValues(double *x, double *f) override
Evaluate the velocity field, f={u,v,w}, at {x, y, z}.
static vtkCachingInterpolatedVelocityField * New()
Construct a vtkCachingInterpolatedVelocityField with no initial data set.
void FastCompute(IVFDataSetInfo *cache, double f[3])
If all weights have been computed (parametric coords etc all valid) then we can quickly interpolate a...
void ClearLastCellInfo()
Set LastCellId to -1 and Cache to nullptr so that the next search does not start from the previous ce...
int GetLastLocalCoordinates(double pcoords[3])
virtual int InsideTest(double *x)
virtual void SetDataSet(int I, vtkDataSet *dataset, bool staticdataset, vtkAbstractCellLocator *locator)
Add a dataset used by the interpolation function evaluation.
bool InterpolatePoint(vtkCachingInterpolatedVelocityField *inCIVF, vtkPointData *outPD, vtkIdType outIndex)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
Abstract interface for sets of functions.
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:34
represent and manipulate point attribute data
Definition: vtkPointData.h:32
A helper class for interpolating between times during particle tracing.
@ vector
Definition: vtkX3D.h:243
@ data
Definition: vtkX3D.h:321
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
int vtkIdType
Definition: vtkType.h:338