VTK  9.2.20230201
vtkAbstractInterpolatedVelocityField.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAbstractInterpolatedVelocityField.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 =========================================================================*/
77 #ifndef vtkAbstractInterpolatedVelocityField_h
78 #define vtkAbstractInterpolatedVelocityField_h
79 
80 #include "vtkFiltersFlowPathsModule.h" // For export macro
81 #include "vtkFunctionSet.h"
82 #include "vtkNew.h" // for vtkNew
83 #include "vtkSmartPointer.h" // for vtkSmartPointer
84 
85 #include <vector> // for weights
86 
87 VTK_ABI_NAMESPACE_BEGIN
92 class vtkDataObject;
93 class vtkDataSet;
94 class vtkDataArray;
95 class vtkIdList;
96 class vtkPointData;
97 class vtkGenericCell;
99 
100 class VTKFILTERSFLOWPATHS_EXPORT vtkAbstractInterpolatedVelocityField : public vtkFunctionSet
101 {
102 public:
104 
108  void PrintSelf(ostream& os, vtkIndent indent) override;
110 
111  // Keep track of how the interpolated velocity field is
112  // initialized. Currently, all datasets that compose the velocity field are
113  // initialized (meaning that supporting structures like locators are
114  // built).
116  {
117  NOT_INITIALIZED = 0,
118  INITIALIZE_ALL_DATASETS = 1,
119  SELF_INITIALIZE = 2
120  };
121 
123 
137  virtual void Initialize(vtkCompositeDataSet* compDS, int initStrategy = INITIALIZE_ALL_DATASETS);
138  vtkGetMacro(InitializationState, int);
140 
142 
148  vtkSetMacro(Caching, bool);
149  vtkGetMacro(Caching, bool);
151 
153 
157  vtkGetMacro(CacheHit, int);
158  vtkGetMacro(CacheMiss, int);
160 
161  vtkGetObjectMacro(LastDataSet, vtkDataSet);
162 
164 
167  vtkGetMacro(LastCellId, vtkIdType);
168  virtual void SetLastCellId(vtkIdType c) { this->LastCellId = c; }
170 
174  virtual void SetLastCellId(vtkIdType c, int dataindex) = 0;
175 
177 
181  vtkGetStringMacro(VectorsSelection);
182  vtkGetMacro(VectorsType, int);
184 
189  void SelectVectors(int fieldAssociation, const char* fieldName);
190 
192 
209  vtkSetMacro(NormalizeVector, bool);
210  vtkGetMacro(NormalizeVector, bool);
212 
214 
219  vtkSetMacro(ForceSurfaceTangentVector, bool);
220  vtkGetMacro(ForceSurfaceTangentVector, bool);
222 
224 
227  vtkSetMacro(SurfaceDataset, bool);
228  vtkGetMacro(SurfaceDataset, bool);
230 
238 
239  using Superclass::FunctionValues;
243  int FunctionValues(double* x, double* f) override = 0;
244 
248  void ClearLastCellId() { this->LastCellId = -1; }
249 
251 
255  int GetLastWeights(double* w);
256  int GetLastLocalCoordinates(double pcoords[3]);
258 
260 
267  vtkGetObjectMacro(FindCellStrategy, vtkFindCellStrategy);
269 
270 protected:
273 
274  static const double TOLERANCE_SCALE;
275  static const double SURFACE_TOLERANCE_SCALE;
276 
277  int CacheHit;
279  bool Caching;
285  std::vector<double> Weights;
286  double LastPCoords[3];
288  double LastClosestPoint[3];
294 
300 
301  // This is used to keep track of the find cell strategy and vector array
302  // associated with each dataset forming the velocity field. Note that the
303  // find cells strategy can be null, this means the find cell is invoked
304  // using the dataset's FindCell() method.
306  {
310 
312  : DataSet(dataSet)
313  , Strategy(strategy)
314  , Vectors(vectors)
315  {
316  }
317  };
319 
324  std::vector<vtkDataSetInformation> DataSetsInfo;
325  std::vector<vtkDataSetInformation>::iterator GetDataSetInfo(vtkDataSet* dataset);
327 
329 
332  vtkSetStringMacro(VectorsSelection);
334 
346  virtual int FunctionValues(vtkDataSet* ds, double* x, double* f);
347 
354  virtual bool FindAndUpdateCell(vtkDataSet* ds, vtkFindCellStrategy* strategy, double* x);
355 
358 
364  void FastCompute(vtkDataArray* vectors, double f[3]);
365  void FastCompute(vtkAbstractInterpolatedVelocityField* inIVF, vtkDataArray* vectors, double f[3]);
366  bool InterpolatePoint(vtkPointData* outPD, vtkIdType outIndex);
370  {
371  return (this->LastCellId != -1) ? this->CurrentCell.Get() : nullptr;
372  }
374 
376 
382  virtual int SelfInitialize() { return 0; }
386 
387 private:
389  void operator=(const vtkAbstractInterpolatedVelocityField&) = delete;
390 };
391 
392 VTK_ABI_NAMESPACE_END
393 #endif
An abstract class for obtaining the interpolated velocity values at a point.
int FunctionValues(double *x, double *f) override=0
Evaluate the velocity field f at point (x, y, z).
virtual int FunctionValues(vtkDataSet *ds, double *x, double *f)
Evaluate the velocity field f at point (x, y, z) in a specified dataset by invoking vtkDataSet::FindC...
virtual int SelfInitialize()
These methods pertain to initializing the vector field by subclasses (which may have special initiali...
int GetLastWeights(double *w)
Get the interpolation weights cached from last evaluation.
int GetLastLocalCoordinates(double pcoords[3])
Get the interpolation weights cached from last evaluation.
int InitializationState
Make sure the velocity field is initialized: record the initialization strategy.
size_t GetDataSetsInfoSize()
These methods pertain to initializing the vector field by subclasses (which may have special initiali...
virtual void Initialize(vtkCompositeDataSet *compDS, int initStrategy=INITIALIZE_ALL_DATASETS)
The Initialize() method is used to build and cache supporting structures (such as locators) which are...
void ClearLastCellId()
Set the last cell id to -1 to incur a global cell search for the next point.
virtual void SetFindCellStrategy(vtkFindCellStrategy *)
Set / get the strategy used to perform the FindCell() operation.
void FastCompute(vtkDataArray *vectors, double f[3])
If all weights have been computed (parametric coords etc all valid), a scalar/vector can be quickly i...
std::vector< vtkDataSetInformation > DataSetsInfo
Define a FindCell() strategy, keep track of the strategies (and other cached information) associated ...
std::vector< vtkDataSetInformation >::iterator GetDataSetInfo(vtkDataSet *dataset)
Define a FindCell() strategy, keep track of the strategies (and other cached information) associated ...
void AddToDataSetsInfo(vtkDataSet *, vtkFindCellStrategy *, vtkDataArray *vectors)
These methods pertain to initializing the vector field by subclasses (which may have special initiali...
vtkFindCellStrategy * FindCellStrategy
Define a FindCell() strategy, keep track of the strategies (and other cached information) associated ...
bool InterpolatePoint(vtkPointData *outPD, vtkIdType outIndex)
If all weights have been computed (parametric coords etc all valid), a scalar/vector can be quickly i...
bool InterpolatePoint(vtkAbstractInterpolatedVelocityField *inIVF, vtkPointData *outPD, vtkIdType outIndex)
If all weights have been computed (parametric coords etc all valid), a scalar/vector can be quickly i...
virtual void CopyParameters(vtkAbstractInterpolatedVelocityField *from)
Copy essential parameters between instances of this class.
virtual void SetLastCellId(vtkIdType c)
Get/Set the id of the cell cached from last evaluation.
vtkGenericCell * GetLastCell()
If all weights have been computed (parametric coords etc all valid), a scalar/vector can be quickly i...
virtual bool FindAndUpdateCell(vtkDataSet *ds, vtkFindCellStrategy *strategy, double *x)
Try to find the cell closest to provided x point in provided dataset, By first testing inclusion in i...
virtual void SetLastCellId(vtkIdType c, int dataindex)=0
Set the id of the most recently visited cell of a dataset.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for obtaining type information and printing the object state.
void FastCompute(vtkAbstractInterpolatedVelocityField *inIVF, vtkDataArray *vectors, double f[3])
If all weights have been computed (parametric coords etc all valid), a scalar/vector can be quickly i...
void SelectVectors(int fieldAssociation, const char *fieldName)
the association type (see vtkDataObject::FieldAssociations) and the name of the velocity data field
implement a specific vtkPointSet::FindCell() strategy based on using a cell locator
implement a specific vtkPointSet::FindCell() strategy based on the N closest points
implement a specific vtkPointSet::FindCell() strategy based on closest point
abstract superclass for composite (multi-block or AMR) datasets
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:166
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:174
helper class to manage the vtkPointSet::FindCell() METHOD
Abstract interface for sets of functions.
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:144
a simple class to control print indentation
Definition: vtkIndent.h:120
T * Get() const noexcept
Get a raw pointer to the contained object.
Definition: vtkNew.h:262
represent and manipulate point attribute data
Definition: vtkPointData.h:151
A helper class for interpolating between times during particle tracing.
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:40
vtkDataSetInformation(vtkDataSet *dataSet, vtkFindCellStrategy *strategy, vtkDataArray *vectors)
int vtkIdType
Definition: vtkType.h:327