VTK  9.7.20261003
vtkDGCell.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
18
19#ifndef vtkDGCell_h
20#define vtkDGCell_h
21
22#include "vtkFiltersCellGridModule.h" // For export macro.
23
24#include "vtkCellAttribute.h" // For CellTypeInfo.
25#include "vtkCellGridResponders.h" // For vtkCellGridResponders::TagSet.
26#include "vtkCellMetadata.h"
27#include "vtkDGOperatorEntry.h" // For GetOperatorEntry API.
28#include "vtkDataArray.h" // for vtkDataArray::PrintValues
29#include "vtkStringToken.h" // For vtkStringToken::Hash.
30#include "vtkVector.h" // For GetSignedParametricDistance, GetParametricCenterOfSide APIs.
31
32#include <vector> // for side connectivity
33
34VTK_ABI_NAMESPACE_BEGIN
35
37class vtkCellGrid;
38class vtkDataArray;
40class vtkTypeFloat32Array;
41class vtkTypeInt32Array;
42
43class VTKFILTERSCELLGRID_EXPORT vtkDGCell : public vtkCellMetadata
44{
45public:
62 using OperatorMap = std::unordered_map<vtkStringToken, // operator name
63 std::unordered_map<vtkStringToken, // function space
64 std::unordered_map<vtkStringToken, // basis name
65 std::unordered_map<int, // order or -1
66 std::unordered_map<vtkStringToken, // cell type-name
68
70 enum Shape : int
71 {
80
82 // It is probably more efficient to create a new cell type for arbitrary shapes
83 // than to attempt generalizing vtkDGCell, but for the sake of completeness:
84 // Polygon //!< We may one day support an n-sided polygonal face.
85 // Polyhedron //!< We may one day support an n-faced polyhedral volume with polygonal sides.
86 };
87
99
101 struct Source
102 {
103 Source() = default;
104 Source(const Source&) = default;
105 Source(vtkDataArray* conn, vtkIdType off, bool blank, Shape shape, int sideType);
106 Source(vtkDataArray* conn, vtkIdType off, bool blank, Shape shape, int sideType, int selnType,
107 vtkDataArray* nodalGhostMarks);
108 Source& operator=(const Source&) = default;
110 virtual ~Source() = default;
111
112 friend ostream& operator<<(ostream& os, const Source& source)
113 {
114 os << "vtkDGCell::Source(" << &source << ")\n";
115 source.Connectivity->PrintValues(os);
116 os << "Connectivity: " << source.Connectivity << '\n';
117 os << "NodalGhostMarks: " << source.NodalGhostMarks << '\n';
118 os << "Offset: " << source.Offset << '\n';
119 os << "Blanked: " << (source.Blanked ? "T\n" : "F\n");
120 os << "SourceShape: " << source.SourceShape << '\n';
121 os << "SideType: " << source.SideType << '\n';
122 os << "SelectionType: " << source.SelectionType << '\n';
123 return os;
124 }
125
133
140
143
145 bool Blanked{ false };
146
149
152 int SideType{ -1 };
153
159 int SelectionType{ -1 };
160 };
161
164 void PrintSelf(ostream& os, vtkIndent indent) override;
165
167 Source& GetCellSpec() { return this->CellSpec; }
168
170 std::vector<Source>& GetSideSpecs() { return this->SideSpecs; }
171
173 const Source& GetCellSource(int sideType = -1) const;
174 Source& GetCellSource(int sideType = -1);
175
177 std::size_t GetNumberOfCellSources() const { return this->SideSpecs.size(); }
178
182 vtkDataArray* GetCellSourceConnectivity(int sideType = -1) const;
184 vtkIdType GetCellSourceOffset(int sideType = -1) const;
185 bool GetCellSourceIsBlanked(int sideType = -1) const;
186 Shape GetCellSourceShape(int sideType = -1) const;
187 int GetCellSourceSideType(int sideType = -1) const;
188 int GetCellSourceSelectionType(int sideType = -1) const;
189
192
195 void ShallowCopy(vtkCellMetadata* other) override;
196 void DeepCopy(vtkCellMetadata* other) override;
198
204 virtual double GetSignedParametricDistance(const vtkVector3d& rst) const = 0;
205
207 bool IsInside(const vtkVector3d& rst, double tolerance = 1e-6) const
208 {
209 return this->GetSignedParametricDistance(rst) <= std::abs(tolerance);
210 }
211
212 static int GetShapeCornerCount(Shape shape);
213 static int GetShapeDimension(Shape shape);
226
228 virtual Shape GetShape() const = 0;
229
232
234 virtual int GetDimension() const { return vtkDGCell::GetShapeDimension(this->GetShape()); }
235
237 virtual int GetNumberOfCorners() const
238 {
240 }
241
247 virtual const std::array<double, 3>& GetCornerParameter(int corner) const = 0;
248
258 virtual vtkVector3d GetParametricCenterOfSide(int sideId) const;
259
263 virtual int GetNumberOfSideTypes() const = 0;
264
287 virtual std::pair<int, int> GetSideRangeForType(int sideType) const = 0;
288
291
296 virtual std::pair<int, int> GetSideRangeForDimension(int dimension) const;
297
299 int* GetSideRangeForSideDimension(int sideDimension) VTK_SIZEHINT(2);
300
320 virtual int GetNumberOfSidesOfDimension(int dimension) const = 0;
321
328 virtual Shape GetSideShape(int side) const = 0;
329
334 virtual int GetSideTypeForShape(Shape s) const;
335
344 virtual const std::vector<vtkIdType>& GetSideConnectivity(int side) const = 0;
345
352 virtual const std::vector<vtkIdType>& GetSidesOfSide(int side) const = 0;
353
359 virtual vtkTypeFloat32Array* GetReferencePoints() const = 0;
360
368 virtual vtkTypeInt32Array* GetSideConnectivity() const = 0;
369
375 virtual vtkTypeInt32Array* GetSideOffsetsAndShapes() const = 0;
376
378 void FillReferencePoints(vtkTypeFloat32Array* arr) const;
379
381 void FillSideConnectivity(vtkTypeInt32Array* arr) const;
382
403 void FillSideOffsetsAndShapes(vtkTypeInt32Array* arr) const;
404
418 vtkCellAttribute* attribute, bool inheritedTypes = false);
419
430 std::vector<int> GetBasisOrder(const vtkCellAttribute::CellTypeInfo& attributeInfo) const;
431
440 vtkStringToken opName, const vtkCellAttribute::CellTypeInfo& attributeInfo);
441
444
445protected:
447 ~vtkDGCell() override;
448
454 std::vector<Source> SideSpecs;
455
456private:
457 vtkDGCell(const vtkDGCell&) = delete;
458 void operator=(const vtkDGCell&) = delete;
459};
460
461VTK_ABI_NAMESPACE_END
462#endif
RealT rst
Definition TetF2Basis.h:17
A function defined over the physical domain of a vtkCellGrid.
std::unordered_map< vtkStringToken, std::unordered_set< vtkStringToken > > TagSet
A map of tag names (such as the cell's type-name) to values of the tag accepted or provided for that ...
Visualization data composed of cells of arbitrary type.
Definition vtkCellGrid.h:49
vtkCellMetadata()=default
void FillSideConnectivity(vtkTypeInt32Array *arr) const
Fill the passed array with the connectivity (point IDs) of all the element's sides.
bool IsInside(const vtkVector3d &rst, double tolerance=1e-6) const
Return true if rst lies inside the reference cell (within tolerance).
Definition vtkDGCell.h:207
std::vector< int > GetBasisOrder(const vtkCellAttribute::CellTypeInfo &attributeInfo) const
Return the polynomial order of attributeInfo along each parametric axis.
virtual const std::array< double, 3 > & GetCornerParameter(int corner) const =0
Return the coordinates of the reference element's corner vertex.
~vtkDGCell() override
Shape
All possible shapes for DG cells.
Definition vtkDGCell.h:71
@ Hexahedron
An eight-cornered volume; a quadrilateral prism.
Definition vtkDGCell.h:77
@ Triangle
A three-cornered face bounded by 3 edges.
Definition vtkDGCell.h:74
@ Tetrahedron
A four-cornered volume bounded by 4 triangular shapes.
Definition vtkDGCell.h:76
@ Quadrilateral
A four-cornered face bounded by 4 edges.
Definition vtkDGCell.h:75
@ None
A placeholder for an indeterminate or invalid shape.
Definition vtkDGCell.h:81
@ Wedge
A volumetric, triangular prism.
Definition vtkDGCell.h:78
@ Pyramid
A volumetric shape whose quadrilateral base attaches to a vertex.
Definition vtkDGCell.h:79
@ Edge
A curve connecting two vertices.
Definition vtkDGCell.h:73
@ Vertex
A corner point.
Definition vtkDGCell.h:72
std::vector< Source > SideSpecs
The connectivity array(s) specifying sides.
Definition vtkDGCell.h:454
static int GetShapeDimension(Shape shape)
virtual Shape GetSideShape(int side) const =0
For a given side, return its cell shape.
void DeepCopy(vtkCellMetadata *other) override
vtkDataArray * GetCellSourceConnectivity(int sideType=-1) const
Python-accessible methods to fetch cell source information.
static int GetShapeCornerCount(Shape shape)
void FillReferencePoints(vtkTypeFloat32Array *arr) const
Fill the passed array with the parametric coordinates of all the element's corners.
static ShapeType GetShapeType(Shape shape)
For the given shape, return a description of the parameter space.
ShapeType GetParameterSpaceType() const
Return a description of the cell's parameter space.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfCells() override
Return the number of cells (and sides) of this type present in this cell grid.
bool GetCellSourceIsBlanked(int sideType=-1) const
virtual Shape GetShape() const =0
Return the topological shape of this cell or side type.
static vtkStringToken GetShapeTypeName(ShapeType shapeType)
Given a shapeType, return a user-presentable string token describing it.
std::size_t GetNumberOfCellSources() const
Python-accessible method to identify number of cell sources.
Definition vtkDGCell.h:177
const Source & GetCellSource(int sideType=-1) const
Provide access to cell specifications in a uniform way (for both cells and sides).
virtual const std::vector< vtkIdType > & GetSideConnectivity(int side) const =0
Return the connectivity of the given side.
virtual int GetSideTypeForShape(Shape s) const
Return the side type index for the given shape (or -1).
Source CellSpec
The connectivity array specifying cells.
Definition vtkDGCell.h:451
int * GetSideRangeForSideType(int sideType)
A python-wrapped version of GetSideRangeForType.
Source & GetCellSource(int sideType=-1)
virtual vtkTypeInt32Array * GetSideConnectivity() const =0
Return a singleton array initialized with point-ids of each side's corners.
void FillSideOffsetsAndShapes(vtkTypeInt32Array *arr) const
Fill the passed array with tuples of (1) offsets into the side-connectivity and (2) shapes for each t...
virtual vtkTypeFloat32Array * GetReferencePoints() const =0
Return a singleton array initialized with the reference-cell's corner point coordinates.
vtkIdType GetCellSourceOffset(int sideType=-1) const
virtual std::pair< int, int > GetSideRangeForType(int sideType) const =0
Return the range of sides of the ii-th type, where ii is in [-2, this->GetNumberOfSideTypes()[.
virtual int GetDimension() const
Return the parametric dimension of this cell type (0, 1, 2, or 3).
Definition vtkDGCell.h:234
std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< int, std::unordered_map< vtkStringToken, vtkDGOperatorEntry > > > > > OperatorMap
A map holding operators that evaluate DG cells.
Definition vtkDGCell.h:62
vtkInheritanceHierarchyOverrideMacro(vtkDGCell)
virtual double GetSignedParametricDistance(const vtkVector3d &rst) const =0
Return the signed parametric distance of rst from the reference element boundary.
ShapeType
Information about whether a shape's parameterization is simplicial (barycentric), tensor-product (pri...
Definition vtkDGCell.h:93
@ Prismatic
The parameter-space is a tensor product of independent coordinate axes.
Definition vtkDGCell.h:95
@ Barycentric
The parameter-space is a augmented with a dependent coordinate.
Definition vtkDGCell.h:96
@ Null
A null parameter space (the null set is the cell's parameter space).
Definition vtkDGCell.h:94
@ Mixed
Some parameter-space axes are prismatic and some are barycentric.
Definition vtkDGCell.h:97
virtual int GetNumberOfSideTypes() const =0
Return the number of different side shapes of this cell type.
vtkCellGridResponders::TagSet GetAttributeTags(vtkCellAttribute *attribute, bool inheritedTypes=false)
A convenience function to fetch attribute-calculator tags for an attribute.
std::vector< Source > & GetSideSpecs()
Provide access to the (cellId,sideId)-arrays used to define side-cells of this type.
Definition vtkDGCell.h:170
void ShallowCopy(vtkCellMetadata *other) override
virtual std::pair< int, int > GetSideRangeForDimension(int dimension) const
Return the range of side IDs for all sides of the given dimension.
virtual vtkTypeInt32Array * GetSideOffsetsAndShapes() const =0
Return a singleton array initialized with 2-tuples of (offset, shape) values.
Source & GetCellSpec()
Provide access to the connectivity array used to define cells of this type.
Definition vtkDGCell.h:167
int * GetSideRangeForSideDimension(int sideDimension)
A python-wrapped version of GetSideRangeForDimension.
vtkDGOperatorEntry GetOperatorEntry(vtkStringToken opName, const vtkCellAttribute::CellTypeInfo &attributeInfo)
Return an operator entry.
virtual vtkVector3d GetParametricCenterOfSide(int sideId) const
Return the parametric center of a cell or its side.
static OperatorMap & GetOperators()
Return a map of operators registered for vtkDGCell and its subclasses.
static vtkStringToken GetShapeName(Shape shape)
int GetCellSourceSelectionType(int sideType=-1) const
virtual int GetNumberOfSidesOfDimension(int dimension) const =0
Return the number of boundaries this type of cell has of a given dimension.
Shape GetCellSourceShape(int sideType=-1) const
vtkDataArray * GetCellSourceNodalGhostMarks(int sideType=-1) const
static ShapeType GetShapeTypeName(vtkStringToken shapeTypeName)
Given a string shapeTypeName, return its matching shape type.
int GetCellSourceSideType(int sideType=-1) const
virtual int GetNumberOfCorners() const
Return the number of corner points for this cell type.
Definition vtkDGCell.h:237
virtual const std::vector< vtkIdType > & GetSidesOfSide(int side) const =0
Return a vector of side IDs given an input side ID.
static Shape GetShapeEnum(vtkStringToken shapeName)
Given a string description of a cell shape, return the DG equivalent enum.
A record for a basis in a function space that is specific to one cell shape.
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition vtkIndent.h:108
Represent a string by its integer hash.
Records describing the source arrays for cells or cell-sides.
Definition vtkDGCell.h:102
vtkDataArray * Connectivity
An array holding cell connectivity or (cell-id, side-id) tuples.
Definition vtkDGCell.h:132
vtkDataArray * NodalGhostMarks
An array holding per-point "ghost" information (or null).
Definition vtkDGCell.h:139
virtual ~Source()=default
Override the destructor to de-reference Connectivity, NodalGhostMarks.
friend ostream & operator<<(ostream &os, const Source &source)
Definition vtkDGCell.h:112
vtkIdType Offset
Offset (start ID; used for picking) of the first cell or side in Connectivity.
Definition vtkDGCell.h:142
int SideType
The type of the side (for calling GetSideRangeForType).
Definition vtkDGCell.h:152
Shape SourceShape
The shape of this type of cell/side.
Definition vtkDGCell.h:148
Source(vtkDataArray *conn, vtkIdType off, bool blank, Shape shape, int sideType, int selnType, vtkDataArray *nodalGhostMarks)
Source & operator=(const Source &)=default
int SelectionType
If SideType >= 0, this determines what should be selected.
Definition vtkDGCell.h:159
bool Blanked
True when the cells/sides should be omitted from processing.
Definition vtkDGCell.h:145
Source(const Source &)=default
Source(vtkDataArray *conn, vtkIdType off, bool blank, Shape shape, int sideType)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
#define VTK_SIZEHINT(...)