VTK  9.4.20241108
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
38VTK_ABI_NAMESPACE_BEGIN
39
41
42class VTKFILTERSCELLGRID_EXPORT vtkCellGridToUnstructuredGrid : public vtkUnstructuredGridAlgorithm
43{
44public:
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
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
168protected:
170 ~vtkCellGridToUnstructuredGrid() override = default;
171
172 int FillInputPortInformation(int port, vtkInformation* info) override;
174 vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* ouInfo) override;
175
177
178private:
180 void operator=(const vtkCellGridToUnstructuredGrid&) = delete;
181};
182
183VTK_ABI_NAMESPACE_END
184#endif // vtkCellGridToUnstructuredGrid_h
A function defined over the physical domain of a vtkCellGrid.
Perform an operation on cells in a vtkCellMetadata instance.
A query corresponding to this algorithm.
std::unordered_map< vtkCellAttribute *, vtkDataArray * > AttributeMap
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.
vtkNew< vtkIncrementalOctreePointLocator > Locator
A locator used to insert cell-grid points into a vtkPoints instance.
std::unordered_map< vtkStringToken, OutputAllocation > OutputAllocations
A map used to allocate space for the unstructured-grid's vtkCellArray.
std::unordered_map< vtkIdType, vtkIdType > ConnectivityTransformType
Return a map of per-cell-type point IDs to unstructured-grid point IDs.
std::unordered_map< vtkStringToken, ConnectivityTransformType > ConnectivityTransforms
Connectivity transforms per input cell type.
ConnectivityTransformType & GetConnectivityTransform(vtkStringToken cellType)
const OutputAllocations & GetOutputAllocations() const
vtkCellGrid * GetInput() const
Get the request's input cell-grid.
ConnectivityCountType ConnectivityCount
Number of cells referencing a given output point.
bool IsAnotherPassRequired() override
Force three passes through this query.
OutputAllocations & GetOutputAllocations()
Return the data structure used in the CountOutputs pass.
vtkIncrementalOctreePointLocator * GetLocator()
Return the point-locator.
OutputAllocations OutputOffsets
Map output cell-typename to input cell-typename to count (offset after the AllocateOutputs pass has r...
vtkDataArray * GetOutputArray(vtkCellAttribute *inputAttribute)
Return an output attribute (or null).
std::vector< float > ConnectivityWeightType
The reciprocal of this->GetConnectivityCount().
void StartPass() override
Mark the start of a pass through each cell type.
bool Finalize() override
Override this if your query-result state requires finalization.
vtkUnstructuredGrid * GetOutput() const
Get the request's output cell-grid.
bool Initialize() override
Override this if your query-result state requires initialization.
std::map< vtkIdType, int > ConnectivityCountType
This map is used to count the number of references to output points.
Create an unstructured grid that approximates a cell-grid.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkCellGridToUnstructuredGrid * New()
~vtkCellGridToUnstructuredGrid() override=default
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int RequestData(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *ouInfo) override
This is called by the superclass.
Visualization data composed of cells of arbitrary type.
Definition vtkCellGrid.h:49
abstract superclass for arrays of numeric data
Incremental octree in support of both point location and point insertion.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Allocate and hold a VTK object.
Definition vtkNew.h:167
Represent a string by its integer hash.
Superclass for algorithms that produce only unstructured grid as output.
dataset represents arbitrary combinations of all possible cell types
A placeholder for space to be occupied in a vtkCellArray.
@ VTK_EMPTY_CELL
Definition vtkCellType.h:37
int vtkIdType
Definition vtkType.h:315