VTK  9.7.1
vtkCellGridToUnstructuredGrid.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
26 #ifndef vtkCellGridToUnstructuredGrid_h
27 #define vtkCellGridToUnstructuredGrid_h
28 
29 #include "vtkCellGrid.h" // For subclass
30 #include "vtkCellType.h" // For initializer
31 #include "vtkFiltersCellGridModule.h" // For export macro
32 #include "vtkNew.h" // For ivar
33 #include "vtkStringToken.h" // For ivars
35 
36 #include <unordered_map>
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 
41 
42 class VTKFILTERSCELLGRID_EXPORT vtkCellGridToUnstructuredGrid : public vtkUnstructuredGridAlgorithm
43 {
44 public:
48  class Query : public vtkCellGridQuery
49  {
50  public:
51  static Query* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
57  {
58  int CellType{ VTK_EMPTY_CELL };
59  vtkIdType NumberOfCells{ 0 };
60  vtkIdType NumberOfConnectivityEntries{ 0 };
61  vtkIdType CellOffset{ 0 };
62  vtkIdType ConnOffset{ 0 };
63  };
64 
68  using OutputAllocations = std::unordered_map<vtkStringToken, OutputAllocation>;
69 
77  enum PassType : int
78  {
79  CountOutputs = 0,
80  GenerateConnectivity =
81  1,
82  GeneratePointData = 2
83  };
84 
85  bool Initialize() override;
86  void StartPass() override;
87  bool Finalize() override;
88 
90  bool IsAnotherPassRequired() override { return this->Pass < PassType::GeneratePointData; }
91 
93  vtkUnstructuredGrid* GetOutput() const { return this->Output; }
95  vtkCellGrid* GetInput() const { return this->Input; }
96 
98  OutputAllocations& GetOutputAllocations() { return this->OutputOffsets; }
99  const OutputAllocations& GetOutputAllocations() const { return this->OutputOffsets; }
100 
102  vtkDataArray* GetOutputArray(vtkCellAttribute* inputAttribute);
103 
110  vtkIncrementalOctreePointLocator* GetLocator() { return this->Locator.GetPointer(); }
111 
117  using ConnectivityTransformType = std::unordered_map<vtkIdType, vtkIdType>;
119  {
120  return this->ConnectivityTransforms[cellType];
121  }
122 
128  using ConnectivityCountType = std::map<vtkIdType, int>;
129  ConnectivityCountType& GetConnectivityCount() { return this->ConnectivityCount; }
130 
134  using ConnectivityWeightType = std::vector<float>;
135  ConnectivityWeightType& GetConnectivityWeights() { return this->ConnectivityWeights; }
136 
137  protected:
139  Query() = default;
140  ~Query() override = default;
141 
142  vtkCellGrid* Input{ nullptr };
143  vtkUnstructuredGrid* Output{ nullptr };
144 
148  // Map input to output attributes:
149  std::unordered_map<vtkCellAttribute*, vtkDataArray*> AttributeMap;
153  std::unordered_map<vtkStringToken, ConnectivityTransformType> ConnectivityTransforms;
158 
159  private:
160  Query(const Query&) = delete;
161  void operator=(const Query&) = delete;
162  };
163 
166  void PrintSelf(ostream& os, vtkIndent indent) override;
167 
168 protected:
169  vtkCellGridToUnstructuredGrid() = default;
170  ~vtkCellGridToUnstructuredGrid() override = default;
171 
172  int FillInputPortInformation(int port, vtkInformation* info) override;
173  int RequestData(
174  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* ouInfo) override;
175 
177 
178 private:
180  void operator=(const vtkCellGridToUnstructuredGrid&) = delete;
181 };
182 
183 VTK_ABI_NAMESPACE_END
184 #endif // vtkCellGridToUnstructuredGrid_h
Perform an operation on cells in a vtkCellMetadata instance.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
Store vtkAlgorithm input/output information.
A placeholder for space to be occupied in a vtkCellArray.
static vtkUnstructuredGridAlgorithm * New()
std::unordered_map< vtkStringToken, OutputAllocation > OutputAllocations
A map used to allocate space for the unstructured-grid's vtkCellArray.
std::map< vtkIdType, int > ConnectivityCountType
This map is used to count the number of references to output points.
int vtkIdType
Definition: vtkType.h:363
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
std::vector< float > ConnectivityWeightType
The reciprocal of this->GetConnectivityCount().
std::unordered_map< vtkIdType, vtkIdType > ConnectivityTransformType
Return a map of per-cell-type point IDs to unstructured-grid point IDs.
~vtkCellGridToUnstructuredGrid() override=default
ConnectivityWeightType ConnectivityWeights
The reciprocal of every entry in ConnectivityCount.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
vtkIncrementalOctreePointLocator * GetLocator()
Return the point-locator.
vtkUnstructuredGrid * GetOutput() const
Get the request's output cell-grid.
a simple class to control print indentation
Definition: vtkIndent.h:28
Create an unstructured grid that approximates a cell-grid.
A function defined over the physical domain of a vtkCellGrid.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
vtkCellGrid * GetInput() const
Get the request's input cell-grid.
Represent a string by its integer hash.
vtkNew< vtkIncrementalOctreePointLocator > Locator
A locator used to insert cell-grid points into a vtkPoints instance.
Superclass for algorithms that produce only unstructured grid as output.
const OutputAllocations & GetOutputAllocations() const
std::unordered_map< vtkStringToken, ConnectivityTransformType > ConnectivityTransforms
Connectivity transforms per input cell type.
OutputAllocations OutputOffsets
Map output cell-typename to input cell-typename to count (offset after the AllocateOutputs pass has r...
Store zero or more vtkInformation instances.
ConnectivityCountType ConnectivityCount
Number of cells referencing a given output point.
ConnectivityTransformType & GetConnectivityTransform(vtkStringToken cellType)
OutputAllocations & GetOutputAllocations()
Return the data structure used in the CountOutputs pass.
std::unordered_map< vtkCellAttribute *, vtkDataArray * > AttributeMap
bool IsAnotherPassRequired() override
Force three passes through this query.
A query corresponding to this algorithm.
Incremental octree in support of both point location and point insertion.