VTK  9.5.20250905
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
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 double* GetParametricCoords() override;
228
232 int GetCellType() override { return VTK_POLYHEDRON; }
233
237 int RequiresInitialization() override { return 1; }
238
244 void Initialize() override;
245
247
251 int GetNumberOfEdges() override;
252 vtkCell* GetEdge(int) override;
253 int GetNumberOfFaces() override;
254 vtkCell* GetFace(int faceId) override;
256
262 void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
263 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
264 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
265
275 void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
276 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
277 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
278
286 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
287 double& dist2, double weights[]) override;
288
293 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
294
301 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
302 double pcoords[3], int& subId) override;
303
319 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
320
328
336
345 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
346
351 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
352
357 int GetParametricCenter(double pcoords[3]) override;
358
362 int IsPrimaryCell() VTK_FUTURE_CONST override { return 1; }
363
365
370 void InterpolateFunctions(const double x[3], double* sf) override;
371 void InterpolateDerivs(const double x[3], double* derivs) override;
373
379 int RequiresExplicitFaceRepresentation() VTK_FUTURE_CONST override { return 1; }
380
398 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use SetCellFaces")
399 void SetFaces(vtkIdType* faces);
400
417 VTK_DEPRECATED_IN_9_6_0("This function is deprecated, use GetCellFaces")
418 vtkIdType* GetFaces();
419
427 int SetCellFaces(vtkCellArray* faces);
428
430
437 vtkCellArray* GetCellFaces();
438 void GetCellFaces(vtkCellArray* faces);
440
447 int IsInside(const double x[3], double tolerance);
448
465 bool IsConvex();
466 Status IsConvex(double planarThreshold);
467
471 vtkPolyData* GetPolyData();
472
476 void ShallowCopy(vtkCell* c) override;
477
481 void DeepCopy(vtkCell* c) override;
482
483protected:
485 ~vtkPolyhedron() override;
486
487 // Internal classes for supporting operations on this cell
493
494 // Filled with the SetFaces method.
495 // These faces are numbered in global id space
496 vtkNew<vtkCellArray> GlobalFaces;
497
498 // VTK_DEPRECATED_IN_9_6_0()
499 // Backward compatibility
500 vtkNew<vtkIdTypeArray> LegacyGlobalFaces;
501
502 // If edges are needed. Note that the edge numbering is in canonical space.
503 int EdgesGenerated = 0; // true/false
504 vtkNew<vtkEdgeTable> EdgeTable; // keep track of all edges
505 vtkNew<vtkIdTypeArray> Edges; // edge pairs kept in this list, in canonical id space
506 vtkNew<vtkIdTypeArray> EdgeFaces; // face pairs that comprise each edge, with the
507 // same ordering as EdgeTable
508 int GenerateEdges(); // method populates the edge table and edge array
509
510 // Numerous methods needs faces to be numbered in the canonical space.
511 // This method uses PointIdMap to fill the Faces member (faces described
512 // with canonical IDs) from the GlobalFaces member (faces described with
513 // global IDs).
514 void GenerateFaces();
515 vtkNew<vtkCellArray> Faces; // These are numbered in canonical id space
516 int FacesGenerated = 0; // True when Faces have been successfully constructed
517
518 // Bounds management
519 int BoundsComputed = 0;
520 void ComputeBounds();
521 void ComputeParametricCoordinate(const double x[3], double pc[3]);
522 void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
523
524 // Members for supporting geometric operations
525 int PolyDataConstructed = 0;
527 void ConstructPolyData();
528 int LocatorConstructed = 0;
529 vtkNew<vtkCellLocator> CellLocator;
530 void ConstructLocator();
533
534private:
535 vtkPolyhedron(const vtkPolyhedron&) = delete;
536 void operator=(const vtkPolyhedron&) = delete;
537
539
540 // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
541 // These data members are implicitly organized in canonical space, i.e., where the cell
542 // point ids are (0,1,...,npts-1).
543 // The PointIdMap is constructed during the call of the Initialize() method and maps global
544 // point ids to the canonical point ids.
545 vtkPointIdMap PointIdMap;
546
547 void GeneratePointToIncidentFaces();
548
549 // Members used in GetPointToIncidentFaces
550 std::vector<std::vector<vtkIdType>> PointToIncidentFaces;
551
553 std::atomic<bool> IsRandomSequenceSeedInitialized{ false };
554};
555
556VTK_ABI_NAMESPACE_END
557#endif
abstract class to specify 3D cell interface
Definition vtkCell3D.h:28
object to represent cell connectivity
represent and manipulate cell attribute data
octree-based spatial search object to quickly locate cells
abstract class to specify cell behavior
Definition vtkCell.h:129
abstract superclass for arrays of numeric data
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
vtkPolyhedron utilities
A 3D cell defined by a set of polygonal faces.
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.
vtkIdType GetFaceToAdjacentFaces(vtkIdType faceId, const vtkIdType *&faceIds) override
See vtkCell3D API for description of these methods.
int GetNumberOfFaces() override
A polyhedron is represented internally by a set of polygonal faces.
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 ...
std::map< vtkIdType, vtkIdType > vtkPointIdMap
int TriangulateLocalIds(int index, vtkIdList *ptIds) override
Use vtkOrderedTriangulator to tetrahedralize the polyhedron mesh.
int TriangulateFaces(vtkIdList *newFaces)
Triangulate each face of the polyhedron.
vtkIdType GetPointToIncidentEdges(vtkIdType pointId, const vtkIdType *&edgeIds) override
See vtkCell3D API for description of these methods.
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
The inverse of EvaluatePosition.
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.
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.
double * GetParametricCoords() override
See vtkCell3D API for description of this method.
void InterpolateDerivs(const double x[3], double *derivs) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
int IsPrimaryCell() VTK_FUTURE_CONST override
A polyhedron is a full-fledged primary cell.
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.
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 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.
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
static vtkPolyhedron * New()
Standard new methods.
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...
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:80
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:332