VTK  9.3.0
vtkCachingInterpolatedVelocityField.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
32 #ifndef vtkCachingInterpolatedVelocityField_h
33 #define vtkCachingInterpolatedVelocityField_h
34 
35 #include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_2_0
36 #include "vtkFiltersFlowPathsModule.h" // For export macro
37 #include "vtkFunctionSet.h"
38 #include "vtkSmartPointer.h" // this is allowed
39 
40 #include <vector> // we need them
41 
42 VTK_ABI_NAMESPACE_BEGIN
43 class vtkDataSet;
44 class vtkDataArray;
45 class vtkPointData;
46 class vtkGenericCell;
48 
49 //---------------------------------------------------------------------------
50 class IVFDataSetInfo;
51 //---------------------------------------------------------------------------
52 class IVFCacheList : public std::vector<IVFDataSetInfo>
53 {
54 };
55 //---------------------------------------------------------------------------
56 
59  "and set the desired strategy.") VTKFILTERSFLOWPATHS_EXPORT vtkCachingInterpolatedVelocityField
60  : public vtkFunctionSet
61 {
62 public:
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
71 
72  using Superclass::FunctionValues;
74 
78  int FunctionValues(double* x, double* f) override;
79  virtual int InsideTest(double* x);
81 
85  virtual void SetDataSet(
86  int I, vtkDataSet* dataset, bool staticdataset, vtkAbstractCellLocator* locator);
87 
89 
94  vtkGetStringMacro(VectorsSelection);
95  void SelectVectors(const char* fieldName) { this->SetVectorsSelection(fieldName); }
97 
103  void SetLastCellInfo(vtkIdType c, int datasetindex);
104 
110 
112 
117  int GetLastWeights(double* w);
118  int GetLastLocalCoordinates(double pcoords[3]);
120 
122 
125  vtkGetMacro(CellCacheHit, int);
126  vtkGetMacro(DataSetCacheHit, int);
127  vtkGetMacro(CacheMiss, int);
129 
130 protected:
133 
140  IVFDataSetInfo* Cache;
143 
144  std::vector<double> Weights;
145 
146  vtkSetStringMacro(VectorsSelection);
147 
148  // private versions which work on the passed dataset/cache
149  // these do the real computation
150  int FunctionValues(IVFDataSetInfo* cache, double* x, double* f);
151  int InsideTest(IVFDataSetInfo* cache, double* x);
152 
155 
162  void FastCompute(IVFDataSetInfo* cache, double f[3]);
163  bool InterpolatePoint(vtkPointData* outPD, vtkIdType outIndex);
168 
169 private:
171  void operator=(const vtkCachingInterpolatedVelocityField&) = delete;
172 };
173 
174 //---------------------------------------------------------------------------
175 
177 // IVFDataSetInfo
179 #ifndef DOXYGEN_SHOULD_SKIP_THIS
180 //
181 
182 //
183 class IVFDataSetInfo
184 {
185 public:
189  double PCoords[3];
190  float* VelocityFloat;
191  double* VelocityDouble;
192  double Tolerance;
193  bool StaticDataSet;
194  IVFDataSetInfo();
195  IVFDataSetInfo(const IVFDataSetInfo& ivfci);
196  IVFDataSetInfo& operator=(const IVFDataSetInfo& ivfci);
197  void SetDataSet(
198  vtkDataSet* data, char* velocity, bool staticdataset, vtkAbstractCellLocator* locator);
199  //
200  static const double TOLERANCE_SCALE;
201 };
202 
203 //
204 
205 //
206 
207 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
208 
209 VTK_ABI_NAMESPACE_END
210 #endif
211 
212 // VTK-HeaderTest-Exclude: vtkCachingInterpolatedVelocityField.h
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)
If all weights have been computed (parametric coords etc all valid) then we can quickly interpolate a...
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...
vtkGenericCell * GetLastCell()
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])
Returns the interpolation weights/pcoords cached from last evaluation if the cached cell is valid (re...
virtual int InsideTest(double *x)
Evaluate the velocity field, f={u,v,w}, at {x, y, z}.
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)
If all weights have been computed (parametric coords etc all valid) then we can quickly interpolate a...
void SelectVectors(const char *fieldName)
If you want to work with an arbitrary vector array, then set its name here.
An abstract class for obtaining the interpolated velocity values at a point.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
Abstract interface for sets of functions.
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate point attribute data
Definition: vtkPointData.h:39
A helper class for interpolating between times during particle tracing.
@ vector
Definition: vtkX3D.h:237
@ data
Definition: vtkX3D.h:315
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition: vtkType.h:315