VTK  9.7.20261102
vtkPolyhedron.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
146
147#ifndef vtkPolyhedron_h
148#define vtkPolyhedron_h
149
150#include "vtkCell3D.h"
151#include "vtkCellStatus.h" // For enum.
152#include "vtkCommonDataModelModule.h" // For export macro
153#include "vtkNew.h" // For vtkNew
154
155VTK_ABI_NAMESPACE_BEGIN
156class vtkIdTypeArray;
157class vtkCellArray;
158class vtkTriangle;
159class vtkQuad;
160class vtkTetra;
161class vtkPolygon;
162class vtkLine;
163class vtkEdgeTable;
164class vtkPolyData;
165class vtkCellLocator;
166class vtkGenericCell;
169
170class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
171{
172public:
173 using vtkPointIdMap = std::map<vtkIdType, vtkIdType>;
174
177
179
183 vtkTypeMacro(vtkPolyhedron, vtkCell3D);
184 void PrintSelf(ostream& os, vtkIndent indent) override;
186
191
193
197 void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
198 {
199 vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
200 }
201 vtkIdType GetFacePoints(vtkIdType faceId, const vtkIdType*& pts) override;
203 vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
204 {
205 vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
206 }
208 vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
209 {
210 vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
211 return 0;
212 }
214 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
215 {
216 vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
217 return 0;
218 }
219 vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
221 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
222 {
223 vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
224 return 0;
225 }
226 bool GetCentroid(double centroid[3]) const override;
227
235
239 int GetCellType() override { return Traits::CellType; }
240
244 int RequiresInitialization() override { return 1; }
245
251 void Initialize() override;
252
254
258 int GetNumberOfEdges() override;
259 vtkCell* GetEdge(int) override;
260 int GetNumberOfFaces() override;
261 vtkCell* GetFace(int faceId) override;
263
269 void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
270 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
271 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
272
282 void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
283 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
284 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
285
293 void ClipWithContext(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
294 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
295 vtkIdType cellId, vtkCellData* outCd, int insideOut, vtkCellArray* outFaces,
296 vtkCellArray* outFaceLocs);
297
302 void ClipWithContext(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
303 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
304 vtkIdType cellId, vtkCellData* outCd, int insideOut, vtkUnstructuredGrid* outUG);
305
313 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
314 double& dist2, double weights[]) override;
315
320 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
321
328 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
329 double pcoords[3], int& subId) override;
330
346 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
347
355
363
372 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
373
378 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
379
384 int GetParametricCenter(double pcoords[3]) override;
385
389 int IsPrimaryCell() VTK_FUTURE_CONST override { return 1; }
390
392
397 void InterpolateFunctions(const double x[3], double* sf) override;
398 void InterpolateDerivs(const double x[3], double* derivs) override;
400
406 int RequiresExplicitFaceRepresentation() VTK_FUTURE_CONST override { return 1; }
407
416
418
427
434 int IsInside(const double x[3], double tolerance);
435
452 bool IsConvex();
453 Status IsConvex(double planarThreshold);
454
459
463 void ShallowCopy(vtkCell* c) override;
464
468 void DeepCopy(vtkCell* c) override;
469
470protected:
472 ~vtkPolyhedron() override;
473
474 // Internal classes for supporting operations on this cell
480
481 // Filled with the SetFaces method.
482 // These faces are numbered in global id space
484
491
492 // If edges are needed. Note that the edge numbering is in canonical space.
493 int EdgesGenerated = 0; // true/false
494 vtkNew<vtkEdgeTable> EdgeTable; // keep track of all edges
495 vtkNew<vtkIdTypeArray> Edges; // edge pairs kept in this list, in canonical id space
496 vtkNew<vtkIdTypeArray> EdgeFaces; // face pairs that comprise each edge, with the
497 // same ordering as EdgeTable
498 int GenerateEdges(); // method populates the edge table and edge array
499
500 // Numerous methods needs faces to be numbered in the canonical space.
501 // This method uses PointIdMap to fill the Faces member (faces described
502 // with canonical IDs) from the GlobalFaces member (faces described with
503 // global IDs).
505 vtkNew<vtkCellArray> Faces; // These are numbered in canonical id space
506 int FacesGenerated = 0; // True when Faces have been successfully constructed
507
508 // Bounds management
511 void ComputeParametricCoordinate(const double x[3], double pc[3]);
512 void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
513
514 // Members for supporting geometric operations
523
524private:
525 vtkPolyhedron(const vtkPolyhedron&) = delete;
526 void operator=(const vtkPolyhedron&) = delete;
527
530
531 // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
532 // These data members are implicitly organized in canonical space, i.e., where the cell
533 // point ids are (0,1,...,npts-1).
534 // The PointIdMap is constructed during the call of the Initialize() method and maps global
535 // point ids to the canonical point ids.
536 vtkPointIdMap PointIdMap;
537
538 void GeneratePointToIncidentFaces();
539
540 // This variant of GenerateEdges() always regenerates edges but also populates
541 // \a unevenCoedges with a map from edge ID to the signed number of mismatched coedges.
542 int GenerateEdges(std::map<vtkIdType, int>& unevenCoedges);
543
544 // Members used in GetPointToIncidentFaces
545 std::vector<std::vector<vtkIdType>> PointToIncidentFaces;
546};
547
548VTK_ABI_NAMESPACE_END
549#endif
object to represent cell connectivity
represent and manipulate cell attribute data
octree-based spatial search object to quickly locate cells
keep track of edges (edge is pair of integer id's)
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:135
dynamic, self-adjusting array of vtkIdType
Abstract class in support of both point location and point insertion.
a simple class to control print indentation
Definition vtkIndent.h:108
cell represents a 1D line
Definition vtkLine.h:132
Allocate and hold a VTK object.
Definition vtkNew.h:168
represent and manipulate point attribute data
concrete dataset represents vertices, lines, polygons, and triangle strips
a cell that represents an n-sided polygon
Definition vtkPolygon.h:139
Isosurface extraction using López polygon tracing algorithm.
vtkNew< vtkLine > Line
vtkIdType GetFacePoints(vtkIdType faceId, const vtkIdType *&pts) override
See vtkCell3D API for description of these methods.
void GetEdgePoints(vtkIdType edgeId, const vtkIdType *&pts) override
See vtkCell3D API for description of these methods.
vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType *&faceIds) override
See vtkCell3D API for description of these methods.
vtkCellArray * GetCellFaces()
Get the faces of the polyhedron.
vtkNew< vtkCellArray > GlobalFaces
int SetCellFaces(vtkCellArray *faces)
Set the faces of the polyhedron.
void ShallowCopy(vtkCell *c) override
Shallow copy of a polyhedron.
vtkIdType GetFaceToAdjacentFaces(vtkIdType faceId, const vtkIdType *&faceIds) override
See vtkCell3D API for description of these methods.
int GenerateEdges()
int GetNumberOfFaces() override
A polyhedron is represented internally by a set of polygonal faces.
Status IsConvex(double planarThreshold)
vtkNew< vtkTetra > Tetra
int EvaluatePosition(const double x[3], double closestPoint[3], int &subId, double pcoords[3], double &dist2, double weights[]) override
Satisfy the vtkCell API.
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
Intersect the line (p1,p2) with a given tolerance tol to determine a point of intersection x[3] with ...
vtkCellStatus Status
Adopt vtkCellStatus to describe degenerate polyhedral cells.
vtkNew< vtkTriangle > Triangle
std::map< vtkIdType, vtkIdType > vtkPointIdMap
void GetCellFaces(vtkCellArray *faces)
Get the faces of the polyhedron.
~vtkPolyhedron() override
int TriangulateLocalIds(int index, vtkIdList *ptIds) override
Use vtkOrderedTriangulator to tetrahedralize the polyhedron mesh.
void GenerateFaces()
friend class vtkPolyhedronContour
void ComputeParametricCoordinate(const double x[3], double pc[3])
vtkNew< vtkPolyData > PolyData
int TriangulateFaces(vtkIdList *newFaces)
Triangulate each face of the polyhedron.
void ComputeBounds()
vtkIdType GetPointToIncidentEdges(vtkIdType pointId, const vtkIdType *&edgeIds) override
See vtkCell3D API for description of these methods.
vtkNew< vtkQuad > Quad
vtkNew< vtkGenericCell > Cell
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
The inverse of EvaluatePosition.
vtkNew< vtkPolygon > Polygon
void InterpolateFunctions(const double x[3], double *sf) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
int RequiresExplicitFaceRepresentation() VTK_FUTURE_CONST override
Satisfy the vtkCell API.
void Contour(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) override
Satisfy the vtkCell API.
int IsInside(const double x[3], double tolerance)
A method particular to vtkPolyhedron.
vtkCellTypeTraitsMembersMacro(VTK_POLYHEDRON)
The traits of the cell type, see vtkCellTypeTraits.
bool GetCentroid(double centroid[3]) const override
See vtkCell3D API for description of these methods.
int GetParametricCenter(double pcoords[3]) override
Return the center of the cell in parametric coordinates.
int TriangulateFaces(vtkCellArray *newFaces)
Triangulate each face of the polyhedron.
void InterpolateDerivs(const double x[3], double *derivs) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
bool IsConvex()
Determine whether or not a polyhedron is convex.
int IsPrimaryCell() VTK_FUTURE_CONST override
A polyhedron is a full-fledged primary cell.
vtkNew< vtkIdTypeArray > EdgeFaces
void ConstructPolyData()
void ClipWithContext(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut, vtkCellArray *outFaces, vtkCellArray *outFaceLocs)
Clip this polyhedron and write faces directly into outFaces and outFaceLocs, bypassing the embedded f...
int GetNumberOfEdges() override
A polyhedron is represented internally by a set of polygonal faces.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard new methods.
void GetEdgeToAdjacentFaces(vtkIdType edgeId, const vtkIdType *&pts) override
See vtkCell3D API for description of these methods.
vtkPolyData * GetPolyData()
Construct polydata if no one exist, then return this->PolyData.
vtkNew< vtkCellArray > Faces
vtkIdType GetPointToOneRingPoints(vtkIdType pointId, const vtkIdType *&pts) override
See vtkCell3D API for description of these methods.
vtkCell * GetEdge(int) override
A polyhedron is represented internally by a set of polygonal faces.
void ClipWithContext(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut, vtkUnstructuredGrid *outUG)
Convenience overload of ClipWithContext that extracts outFaces and outFaceLocs from the given output ...
vtkCell * GetFace(int faceId) override
A polyhedron is represented internally by a set of polygonal faces.
void DeepCopy(vtkCell *c) override
Deep copy of a polyhedron.
void ConstructLocator()
void Derivatives(int subId, const double pcoords[3], const double *values, int dim, double *derivs) override
Computes derivatives at the point specified by the parameter coordinate.
vtkNew< vtkIdList > CellIds
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
vtkIdType GetGlobalFacePoints(vtkIdType faceId, const vtkIdType *&pts)
Face points as mesh (global) point ids, matching the GlobalFaces representation.
friend class vtkPolyhedronUtilities
void ComputePositionFromParametricCoordinate(const double pc[3], double x[3])
static vtkPolyhedron * New()
Standard new methods.
vtkNew< vtkCellLocator > CellLocator
double ComputeVolume()
Compute the volume of the polyhedron using the divergence theorem.
int GetCellType() override
See the vtkCell API for descriptions of these methods.
int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override
Find the boundary face closest to the point defined by the pcoords[3] and subId of the cell (subId ca...
vtkNew< vtkEdgeTable > EdgeTable
vtkNew< vtkIdTypeArray > Edges
void Clip(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
Satisfy the vtkCell API.
void Initialize() override
The Initialize method builds up internal structures of vtkPolyhedron.
a cell that represents a 2D quadrilateral
Definition vtkQuad.h:87
a 3D cell that represents a tetrahedron
Definition vtkTetra.h:113
a cell that represents a triangle
dataset represents arbitrary combinations of all possible cell types
vtkCellStatus
Diagnostic values indicating how well-specified a cell is.
@ VTK_POLYHEDRON
Definition vtkCellType.h:80
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363