VTK  9.7.1
vtkCellGridSampleQuery.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
14 #ifndef vtkCellGridSampleQuery_h
15 #define vtkCellGridSampleQuery_h
16 
17 #include "vtkCellGrid.h" // For API
18 #include "vtkCellGridQuery.h"
19 #include "vtkFiltersCellGridModule.h" // For export macro
20 #include "vtkIdTypeArray.h" // For API
21 #include "vtkSmartPointer.h" // For API
22 #include "vtkStringToken.h" // For API
23 #include "vtkTable.h" // For API
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 
27 class vtkCellAttribute;
28 class vtkCellGrid;
29 class vtkDataArray;
30 class vtkIdTypeArray;
31 class vtkTable;
32 class vtkTypeUInt32Array;
33 
34 class VTKFILTERSCELLGRID_EXPORT vtkCellGridSampleQuery : public vtkCellGridQuery
35 {
36 public:
37  static vtkCellGridSampleQuery* New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
42 
47  vtkSetMacro(IncludeSourceCellInfo, bool);
48  vtkGetMacro(IncludeSourceCellInfo, bool);
49  vtkBooleanMacro(IncludeSourceCellInfo, bool);
51 
53 
63  vtkSetMacro(IncludeSourceCellSite, bool);
64  vtkGetMacro(IncludeSourceCellSite, bool);
65  vtkBooleanMacro(IncludeSourceCellSite, bool);
67 
69  using OutputAllocations = std::unordered_map<vtkStringToken, vtkIdType>;
70 
72  enum PassType : int
73  {
74  CountOutputs = 0,
75  GenerateOutputs = 1
76  };
77 
79  bool Initialize() override;
80  void StartPass() override;
81 
83  bool IsAnotherPassRequired() override { return this->Pass < PassType::GenerateOutputs; }
84 
86 
89  vtkSetSmartPointerMacro(Input, vtkCellGrid);
90  vtkGetSmartPointerMacro(Input, vtkCellGrid);
92 
94 
98  vtkSetSmartPointerMacro(Output, vtkTable);
99  vtkGetSmartPointerMacro(Output, vtkTable);
101 
104  void AddOutputSamples(vtkStringToken inputCellType, vtkIdType numberOfOutputs);
105 
108  vtkIdType GetSampleOffset(vtkStringToken inputCellType);
109 
114  vtkDataArray* GetOutputAttributeColumn(vtkCellAttribute* inputAttribute);
115 
123  vtkIdTypeArray* GetSourceCellIdColumn() { return this->SourceCellId; }
124 
133  vtkDataArray* GetSourceCellSiteColumn() { return this->SourceCellSite; }
134 
137  OutputAllocations& GetOutputAllocations() { return this->OutputOffsets; }
138  const OutputAllocations& GetOutputAllocations() const { return this->OutputOffsets; }
139 
141 
150  vtkSetMacro(MaximumParametricDimension, int);
151  vtkGetMacro(MaximumParametricDimension, int);
153 
154 protected:
155  vtkCellGridSampleQuery() = default;
156  ~vtkCellGridSampleQuery() override = default;
157 
158 private:
161 
162  bool IncludeSourceCellInfo{ false };
163  bool IncludeSourceCellSite{ false };
164  int MaximumParametricDimension{ 0 };
165 
167  OutputAllocations OutputOffsets;
169  std::unordered_map<vtkCellAttribute*, vtkDataArray*> AttributeMap;
173  vtkSmartPointer<vtkIdTypeArray> SourceCellId;
175  vtkSmartPointer<vtkDataArray> SourceCellSite;
176 
178  void operator=(const vtkCellGridSampleQuery&) = delete;
179 };
180 
181 VTK_ABI_NAMESPACE_END
182 #endif // vtkCellGridSampleQuery_h
Perform an operation on cells in a vtkCellMetadata instance.
std::unordered_map< vtkStringToken, vtkIdType > OutputAllocations
A map used to allocate output table rows for various input cell types.
OutputAllocations & GetOutputAllocations()
Return the data structure that AddOutputSamples() modifies in the PassType::CountOutputs pass...
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
vtkIdTypeArray * GetSourceCellIdColumn()
Return the data array holding the input cell ID of each sample (if requested).
PassType
Passes used during processing of this query.
const OutputAllocations & GetOutputAllocations() const
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.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool IsAnotherPassRequired() override
Force two passes through this query.
Represent a string by its integer hash.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
vtkDataArray * GetSourceCellSiteColumn()
Return the data array holding the parametric coordinates (if applicable) of each sample in the output...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Output a table of samples at zero or more points inside each cell.
virtual bool Initialize()
Override this if your query-result state requires initialization.
virtual void StartPass()
Mark the start of a pass through each cell type.