VTK  9.7.1
vtkCellGridEvaluator.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
103 #ifndef vtkCellGridEvaluator_h
104 #define vtkCellGridEvaluator_h
105 
106 #include "vtkCellAttribute.h" // For Attribute ivar.
107 #include "vtkCellGridQuery.h"
108 #include "vtkNew.h" // For ivars.
109 #include "vtkStringToken.h" // For Allocations ivar.
110 #include "vtkTypeUInt32Array.h" // For ivars.
111 #include "vtkTypeUInt64Array.h" // For ivars.
112 
113 #include <array>
114 #include <unordered_map>
115 #include <vector>
116 
117 VTK_ABI_NAMESPACE_BEGIN
118 
120 class vtkPointSet;
121 
122 class VTKCOMMONDATAMODEL_EXPORT vtkCellGridEvaluator : public vtkCellGridQuery
123 {
124 public:
125  static vtkCellGridEvaluator* New();
127  void PrintSelf(ostream& os, vtkIndent indent) override;
128 
130  enum Phases
131  {
135  Interpolate
136  };
137 
139  struct VTKCOMMONDATAMODEL_EXPORT AllocationsByCellType
140  {
146  {
149  std::array<double, 3> ParametricCoords;
150  };
151 
155  std::vector<ClassifiedPoint> InputPoints;
157  vtkIdType Offset{ 0 };
158 
161  {
162  return static_cast<vtkIdType>(this->InputPoints.size());
163  }
164  };
165 
169  vtkSetObjectMacro(CellAttribute, vtkCellAttribute);
170  vtkGetObjectMacro(CellAttribute, vtkCellAttribute);
171 
174  vtkGetObjectMacro(InputPoints, vtkDataArray);
175 
177  vtkGetObjectMacro(ClassifierCellTypes, vtkTypeUInt32Array);
178 
180  vtkGetObjectMacro(ClassifierCellOffsets, vtkTypeUInt64Array);
181 
183  vtkGetObjectMacro(ClassifierPointIDs, vtkTypeUInt64Array);
184 
186  vtkGetObjectMacro(ClassifierCellIndices, vtkTypeUInt64Array);
187 
189  vtkGetObjectMacro(ClassifierPointParameters, vtkDataArray);
190 
192  vtkGetObjectMacro(InterpolatedValues, vtkDataArray);
193 
195  void ClassifyPoints(vtkDataArray* points);
196 
198  void InterpolatePoints(vtkDataArray* points);
199 
205  void InterpolateCellParameters(vtkTypeUInt32Array* cellTypes, vtkTypeUInt64Array* cellOffsets,
206  vtkTypeUInt64Array* cellIndices, vtkDataArray* pointParameters);
207 
209  vtkGetEnumMacro(PhasesToPerform, vtkCellGridEvaluator::Phases);
210 
212  bool Initialize() override;
214  void StartPass() override;
216  bool IsAnotherPassRequired() override;
218  bool Finalize() override;
219 
220  // Return a point locator that can be used to find input points quickly.
221  // vtkStaticPointLocator* GetLocator();
222  vtkGetObjectMacro(Locator, vtkStaticPointLocator);
223 
226  AllocationsByCellType& GetAllocationsForCellType(vtkStringToken cellType);
227 
228 protected:
230  ~vtkCellGridEvaluator() override;
231 
234  vtkSetObjectMacro(InputPoints, vtkDataArray);
235 
237  vtkSetObjectMacro(ClassifierCellTypes, vtkTypeUInt32Array);
238 
240  vtkSetObjectMacro(ClassifierCellOffsets, vtkTypeUInt64Array);
241 
243  vtkSetObjectMacro(ClassifierPointIDs, vtkTypeUInt64Array);
244 
246  vtkSetObjectMacro(ClassifierCellIndices, vtkTypeUInt64Array);
247 
249  vtkSetObjectMacro(ClassifierPointParameters, vtkDataArray);
250 
252  vtkSetObjectMacro(InterpolatedValues, vtkDataArray);
253 
254  void AllocateClassificationOutput();
255  void AllocatePositionOutput();
256  void AllocateInterpolationOutput();
257 
258  vtkCellGrid* CellGrid{ nullptr };
259  vtkCellAttribute* CellAttribute{ nullptr };
260  vtkDataArray* InputPoints{ nullptr };
261  vtkTypeUInt32Array* ClassifierCellTypes{ nullptr };
262  vtkTypeUInt64Array* ClassifierCellOffsets{ nullptr };
263  vtkTypeUInt64Array* ClassifierPointIDs{ nullptr };
264  vtkTypeUInt64Array* ClassifierCellIndices{ nullptr };
265  vtkDataArray* ClassifierPointParameters{ nullptr };
266  vtkDataArray* InterpolatedValues{ nullptr };
267 
269 
271  Phases PhasesToPerform{ Phases::None };
273  vtkIdType NumberOfOutputPoints{ 0 };
275  std::unordered_map<vtkStringToken, AllocationsByCellType> Allocations;
276 
277 private:
279  void operator=(const vtkCellGridEvaluator&) = delete;
280 };
281 
282 VTK_ABI_NAMESPACE_END
283 #endif // vtkCellGridEvaluator_h
vtkIdType GetNumberOfOutputPoints() const
Return the number of classified points for this cell type.
Perform an operation on cells in a vtkCellMetadata instance.
concrete class for storing a set of points
Definition: vtkPointSet.h:58
The result of classifying a single probe point: the index of the input point, the cell that contains ...
int vtkIdType
Definition: vtkType.h:363
Hold per-type input point assignment and an offset for output arrays.
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
a simple class to control print indentation
Definition: vtkIndent.h:28
A function defined over the physical domain of a vtkCellGrid.
!< For HCURL
Evaluate a field (vtkCellAttribute) at some points inside cells.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
std::unordered_map< vtkStringToken, AllocationsByCellType > Allocations
Internal state used during classification to compute the size of the output arrays.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Represent a string by its integer hash.
std::vector< ClassifiedPoint > InputPoints
Flat list of classified probe points, populated by ClassifyPoints.
quickly locate points in 3-space
vtkNew< vtkStaticPointLocator > Locator
Phases
Indicate which phases of the query to perform.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...