VTK  9.5.20251217
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
141
142#ifndef vtkPolyhedron_h
143#define vtkPolyhedron_h
144
145#include "vtkCell3D.h"
146#include "vtkCellStatus.h" // For enum.
147#include "vtkCommonDataModelModule.h" // For export macro
148#include "vtkDeprecation.h" // VTK_DEPRECATED_IN_9_6_0()
149#include "vtkNew.h" // For vtkNew
150
151VTK_ABI_NAMESPACE_BEGIN
152class vtkIdTypeArray;
153class vtkCellArray;
154class vtkTriangle;
155class vtkQuad;
156class vtkTetra;
157class vtkPolygon;
158class vtkLine;
159class vtkEdgeTable;
160class vtkPolyData;
161class vtkCellLocator;
162class vtkGenericCell;
163class vtkPointLocator;
165
166class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
167{
168public:
169 using vtkPointIdMap = std::map<vtkIdType, vtkIdType>;
170
173
175
179 vtkTypeMacro(vtkPolyhedron, vtkCell3D);
180 void PrintSelf(ostream& os, vtkIndent indent) override;
182
184
188 void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
189 {
190 vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
191 }
192 vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(pts)) override
193 {
194 vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented");
195 return 0;
196 }
198 vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
199 {
200 vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
201 }
203 vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
204 {
205 vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
206 return 0;
207 }
209 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
210 {
211 vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
212 return 0;
213 }
214 vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
216 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
217 {
218 vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
219 return 0;
220 }
221 bool GetCentroid(double centroid[3]) const override;
223
227 int GetCellType() override { return VTK_POLYHEDRON; }
228
232 int RequiresInitialization() override { return 1; }
233
239 void Initialize() override;
240
242
246 int GetNumberOfEdges() override;
247 vtkCell* GetEdge(int) override;
248 int GetNumberOfFaces() override;
249 vtkCell* GetFace(int faceId) override;
251
257 void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
258 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
259 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
260
270 void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
271 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
272 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
273
281 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
282 double& dist2, double weights[]) override;
283
288 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
289
296 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
297 double pcoords[3], int& subId) override;
298
314 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
315
323
331
340 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
341
346 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
347
352 int GetParametricCenter(double pcoords[3]) override;
353
357 int IsPrimaryCell() VTK_FUTURE_CONST override { return 1; }
358
360
365 void InterpolateFunctions(const double x[3], double* sf) override;
366 void InterpolateDerivs(const double x[3], double* derivs) override;
368
374 int RequiresExplicitFaceRepresentation() VTK_FUTURE_CONST override { return 1; }
375
393 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetCellFaces")
394 void SetFaces(vtkIdType* faces);
395
412 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use GetCellFaces")
414
423
425
434
441 int IsInside(const double x[3], double tolerance);
442
459 bool IsConvex();
460 Status IsConvex(double planarThreshold);
461
466
470 void ShallowCopy(vtkCell* c) override;
471
475 void DeepCopy(vtkCell* c) override;
476
477protected:
479 ~vtkPolyhedron() override;
480
481 // Internal classes for supporting operations on this cell
487
488 // Filled with the SetFaces method.
489 // These faces are numbered in global id space
491
492 // VTK_DEPRECATED_IN_9_6_0()
493 // Backward compatibility
495
496 // If edges are needed. Note that the edge numbering is in canonical space.
497 int EdgesGenerated = 0; // true/false
498 vtkNew<vtkEdgeTable> EdgeTable; // keep track of all edges
499 vtkNew<vtkIdTypeArray> Edges; // edge pairs kept in this list, in canonical id space
500 vtkNew<vtkIdTypeArray> EdgeFaces; // face pairs that comprise each edge, with the
501 // same ordering as EdgeTable
502 int GenerateEdges(); // method populates the edge table and edge array
503
504 // Numerous methods needs faces to be numbered in the canonical space.
505 // This method uses PointIdMap to fill the Faces member (faces described
506 // with canonical IDs) from the GlobalFaces member (faces described with
507 // global IDs).
509 vtkNew<vtkCellArray> Faces; // These are numbered in canonical id space
510 int FacesGenerated = 0; // True when Faces have been successfully constructed
511
512 // Bounds management
515 void ComputeParametricCoordinate(const double x[3], double pc[3]);
516 void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
517
518 // Members for supporting geometric operations
527
528private:
529 vtkPolyhedron(const vtkPolyhedron&) = delete;
530 void operator=(const vtkPolyhedron&) = delete;
531
533
534 // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
535 // These data members are implicitly organized in canonical space, i.e., where the cell
536 // point ids are (0,1,...,npts-1).
537 // The PointIdMap is constructed during the call of the Initialize() method and maps global
538 // point ids to the canonical point ids.
539 vtkPointIdMap PointIdMap;
540
541 void GeneratePointToIncidentFaces();
542
543 // This variant of GenerateEdges() always regenerates edges but also populates
544 // \a unevenCoedges with a map from edge ID to the signed number of mismatched coedges.
545 int GenerateEdges(std::map<vtkIdType, int>& unevenCoedges);
546
547 // Members used in GetPointToIncidentFaces
548 std::vector<std::vector<vtkIdType>> PointToIncidentFaces;
549
551 std::atomic<bool> IsRandomSequenceSeedInitialized{ false };
552};
553
554VTK_ABI_NAMESPACE_END
555#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:133
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
Park and Miller Sequence of pseudo random numbers.
Allocate and hold a VTK object.
Definition vtkNew.h:167
represent and manipulate point attribute data
quickly locate points in 3-space
concrete dataset represents vertices, lines, polygons, and triangle strips
a cell that represents an n-sided polygon
Definition vtkPolygon.h:132
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 SetFaces(vtkIdType *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.
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
int TriangulateLocalIds(int index, vtkIdList *ptIds) override
Use vtkOrderedTriangulator to tetrahedralize the polyhedron mesh.
void GenerateFaces()
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.
vtkIdType * GetFaces()
Get the faces of the polyhedron.
int IsInside(const double x[3], double tolerance)
A method particular to vtkPolyhedron.
vtkNew< vtkIdTypeArray > LegacyGlobalFaces
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()
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.
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.
friend class vtkPolyhedronUtilities
void ComputePositionFromParametricCoordinate(const double pc[3], double x[3])
static vtkPolyhedron * New()
Standard new methods.
vtkNew< vtkCellLocator > CellLocator
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
vtkCellStatus
Diagnostic values indicating how well-specified a cell is.
@ VTK_POLYHEDRON
Definition vtkCellType.h:79
#define vtkDataArray
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:368