VTK  9.7.20260912
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
40
41#ifndef vtkCellGridToUnstructuredGrid_h
42#define vtkCellGridToUnstructuredGrid_h
43
44#include "vtkCellGrid.h" // For subclass
45#include "vtkCellType.h" // For initializer
46#include "vtkFiltersCellGridModule.h" // For export macro
47#include "vtkNew.h" // For ivar
48#include "vtkStringToken.h" // For ivars
50
51#include <unordered_map>
52
53VTK_ABI_NAMESPACE_BEGIN
54
56
57class VTKFILTERSCELLGRID_EXPORT vtkCellGridToUnstructuredGrid : public vtkUnstructuredGridAlgorithm
58{
59public:
63 class Query : public vtkCellGridQuery
64 {
65 public:
66 static Query* New();
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
84
88 using OutputAllocations = std::unordered_map<vtkStringToken, OutputAllocation>;
89
104
105 bool Initialize() override;
106 void StartPass() override;
107 bool Finalize() override;
108
118 vtkSetClampMacro(SubdivisionLevel, int, 0, VTK_INT_MAX);
119 vtkGetMacro(SubdivisionLevel, int);
121
130 vtkSetClampMacro(PointMergeTolerance, double, 0., VTK_DOUBLE_MAX);
131 vtkGetMacro(PointMergeTolerance, double);
133
139 bool IsAborted() { return this->Algorithm && this->Algorithm->CheckAbort(); }
140
147 {
148 constexpr int maxShift = 8 * static_cast<int>(sizeof(vtkIdType)) - 2;
149 unsigned shift = static_cast<unsigned>(
150 this->SubdivisionLevel > maxShift ? maxShift : this->SubdivisionLevel);
151 return static_cast<vtkIdType>(1) << shift;
152 }
153
155 bool IsAnotherPassRequired() override { return this->Pass < PassType::GeneratePointData; }
156
158 vtkUnstructuredGrid* GetOutput() const { return this->Output; }
160 vtkCellGrid* GetInput() const { return this->Input; }
161
164 const OutputAllocations& GetOutputAllocations() const { return this->OutputOffsets; }
165
168
175 vtkIncrementalOctreePointLocator* GetLocator() { return this->Locator.GetPointer(); }
176
182 using ConnectivityCountType = std::map<vtkIdType, int>;
184
188 using ConnectivityWeightType = std::vector<float>;
190
191 protected:
193 Query() = default;
194 ~Query() override = default;
195
196 vtkCellGrid* Input{ nullptr };
198
202 double PointMergeTolerance{ 1e-12 };
205
209 // Map input to output attributes:
210 std::unordered_map<vtkCellAttribute*, vtkDataArray*> AttributeMap;
217
218 private:
219 Query(const Query&) = delete;
220 void operator=(const Query&) = delete;
221 };
222
225 void PrintSelf(ostream& os, vtkIndent indent) override;
226
243 virtual void SetSubdivisionLevel(int level);
244 virtual int GetSubdivisionLevel() const;
246
258 virtual void SetPointMergeTolerance(double tolerance);
259 virtual double GetPointMergeTolerance() const;
261
262protected:
264 ~vtkCellGridToUnstructuredGrid() override = default;
265
266 int FillInputPortInformation(int port, vtkInformation* info) override;
268 vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* ouInfo) override;
269
271
272private:
274 void operator=(const vtkCellGridToUnstructuredGrid&) = delete;
275};
276
277VTK_ABI_NAMESPACE_END
278#endif // vtkCellGridToUnstructuredGrid_h
A function defined over the physical domain of a vtkCellGrid.
vtkCellGridQuery()=default
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.
const OutputAllocations & GetOutputAllocations() const
vtkCellGrid * GetInput() const
Get the request's input cell-grid.
vtkIdType GetSubdivisionCount() const
Return the number of subdivisions along each parametric axis.
bool IsAborted()
Return true if the user has asked the filter to stop.
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.
double PointMergeTolerance
The relative distance within which samples merge (see SetPointMergeTolerance()).
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.
vtkCellGridToUnstructuredGrid * Algorithm
The algorithm running this query, used only to poll for an abort.
@ CountOutputs
Responders should insert into GetOutputAllocations().
@ GeneratePointData
Responders should populate point-data.
@ GenerateConnectivity
Responders should insert points into the locator, point-count map, and connectivity.
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.
int SubdivisionLevel
How many times each cell is halved per axis (see SetSubdivisionLevel()).
virtual void SetSubdivisionLevel(int level)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual double GetPointMergeTolerance() const
virtual int GetSubdivisionLevel() const
virtual void SetPointMergeTolerance(double tolerance)
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
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:168
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
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
#define VTK_DOUBLE_MAX
Definition vtkType.h:202
#define VTK_INT_MAX
Definition vtkType.h:192