VTK  9.2.6
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 
91 class vtkDataObject;
92 class vtkDataSet;
93 class vtkDataArray;
94 class vtkIdList;
95 class vtkPointData;
96 class vtkGenericCell;
98 
99 class VTKFILTERSFLOWPATHS_EXPORT vtkAbstractInterpolatedVelocityField : public vtkFunctionSet
100 {
101 public:
103 
107  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
110  // Keep track of how the interpolated velocity field is
111  // initialized. Currently, all datasets that compose the velocity field are
112  // initialized (meaning that supporting structures like locators are
113  // built).
115  {
116  NOT_INITIALIZED = 0,
117  INITIALIZE_ALL_DATASETS = 1,
118  SELF_INITIALIZE = 2
119  };
120 
122 
136  virtual void Initialize(vtkCompositeDataSet* compDS, int initStrategy = INITIALIZE_ALL_DATASETS);
137  vtkGetMacro(InitializationState, int);
139 
141 
147  vtkSetMacro(Caching, bool);
148  vtkGetMacro(Caching, bool);
150 
152 
156  vtkGetMacro(CacheHit, int);
157  vtkGetMacro(CacheMiss, int);
159 
160  vtkGetObjectMacro(LastDataSet, vtkDataSet);
161 
163 
166  vtkGetMacro(LastCellId, vtkIdType);
167  virtual void SetLastCellId(vtkIdType c) { this->LastCellId = c; }
169 
173  virtual void SetLastCellId(vtkIdType c, int dataindex) = 0;
174 
176 
180  vtkGetStringMacro(VectorsSelection);
181  vtkGetMacro(VectorsType, int);
183 
188  void SelectVectors(int fieldAssociation, const char* fieldName);
189 
191 
208  vtkSetMacro(NormalizeVector, bool);
209  vtkGetMacro(NormalizeVector, bool);
211 
213 
218  vtkSetMacro(ForceSurfaceTangentVector, bool);
219  vtkGetMacro(ForceSurfaceTangentVector, bool);
221 
223 
226  vtkSetMacro(SurfaceDataset, bool);
227  vtkGetMacro(SurfaceDataset, bool);
229 
237 
238  using Superclass::FunctionValues;
242  int FunctionValues(double* x, double* f) override = 0;
243 
247  void ClearLastCellId() { this->LastCellId = -1; }
248 
250 
254  int GetLastWeights(double* w);
255  int GetLastLocalCoordinates(double pcoords[3]);
257 
259 
266  vtkGetObjectMacro(FindCellStrategy, vtkFindCellStrategy);
268 
269 protected:
272 
273  static const double TOLERANCE_SCALE;
274  static const double SURFACE_TOLERANCE_SCALE;
275 
276  int CacheHit;
278  bool Caching;
284  std::vector<double> Weights;
285  double LastPCoords[3];
287  double LastClosestPoint[3];
293 
299 
300  // This is used to keep track of the find cell strategy and vector array
301  // associated with each dataset forming the velocity field. Note that the
302  // find cells strategy can be null, this means the find cell is invoked
303  // using the dataset's FindCell() method.
305  {
309 
311  : DataSet(dataSet)
312  , Strategy(strategy)
313  , Vectors(vectors)
314  {
315  }
316  };
318 
323  std::vector<vtkDataSetInformation> DataSetsInfo;
324  std::vector<vtkDataSetInformation>::iterator GetDataSetInfo(vtkDataSet* dataset);
326 
328 
331  vtkSetStringMacro(VectorsSelection);
333 
345  virtual int FunctionValues(vtkDataSet* ds, double* x, double* f);
346 
353  virtual bool FindAndUpdateCell(vtkDataSet* ds, vtkFindCellStrategy* strategy, double* x);
354 
357 
363  void FastCompute(vtkDataArray* vectors, double f[3]);
364  void FastCompute(vtkAbstractInterpolatedVelocityField* inIVF, vtkDataArray* vectors, double f[3]);
365  bool InterpolatePoint(vtkPointData* outPD, vtkIdType outIndex);
369  {
370  return (this->LastCellId != -1) ? this->CurrentCell.Get() : nullptr;
371  }
373 
375 
381  virtual int SelfInitialize() { return 0; }
385 
386 private:
388  void operator=(const vtkAbstractInterpolatedVelocityField&) = delete;
389 };
390 
391 #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:165
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
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:143
a simple class to control print indentation
Definition: vtkIndent.h:119
T * Get() const noexcept
Get a raw pointer to the contained object.
Definition: vtkNew.h:261
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:39
vtkDataSetInformation(vtkDataSet *dataSet, vtkFindCellStrategy *strategy, vtkDataArray *vectors)
int vtkIdType
Definition: vtkType.h:332