VTK  9.4.20251007
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
122
123#ifndef vtkPolyhedron_h
124#define vtkPolyhedron_h
125
126#include "vtkCell3D.h"
127#include "vtkCommonDataModelModule.h" // For export macro
128#include "vtkDeprecation.h" // For VTK_DEPRECATED
129#include "vtkNew.h" // For vtkNew
130
131VTK_ABI_NAMESPACE_BEGIN
132class vtkIdTypeArray;
133class vtkCellArray;
134class vtkTriangle;
135class vtkQuad;
136class vtkTetra;
137class vtkPolygon;
138class vtkLine;
139class vtkEdgeTable;
140class vtkPolyData;
141class vtkCellLocator;
142class vtkGenericCell;
143class vtkPointLocator;
145
146class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
147{
148public:
149 using vtkPointIdMap = std::map<vtkIdType, vtkIdType>;
150
152
156 vtkTypeMacro(vtkPolyhedron, vtkCell3D);
157 void PrintSelf(ostream& os, vtkIndent indent) override;
159
161
165 void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
166 {
167 vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
168 }
169 vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(pts)) override
170 {
171 vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented");
172 return 0;
173 }
175 vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
176 {
177 vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
178 }
180 vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
181 {
182 vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
183 return 0;
184 }
186 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
187 {
188 vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
189 return 0;
190 }
191 vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
193 vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
194 {
195 vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
196 return 0;
197 }
198 bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
199 {
200 vtkWarningMacro(<< "vtkPolyhedron::GetCentroid Not Implemented");
201 return false;
202 }
203
204
208 double* GetParametricCoords() override;
209
213 int GetCellType() override { return VTK_POLYHEDRON; }
214
218 int RequiresInitialization() override { return 1; }
219
225 void Initialize() override;
226
228
232 int GetNumberOfEdges() override;
233 vtkCell* GetEdge(int) override;
234 int GetNumberOfFaces() override;
235 vtkCell* GetFace(int faceId) override;
237
243 void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
244 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
245 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
246
256 void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
257 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
258 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
259
267 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
268 double& dist2, double weights[]) override;
269
274 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
275
282 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
283 double pcoords[3], int& subId) override;
284
300 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
301
309
317
326 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
327
332 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
333
338 int GetParametricCenter(double pcoords[3]) override;
339
343 int IsPrimaryCell() override { return 1; }
344
346
351 void InterpolateFunctions(const double x[3], double* sf) override;
352 void InterpolateDerivs(const double x[3], double* derivs) override;
354
360 int RequiresExplicitFaceRepresentation() override { return 1; }
361
379 void SetFaces(vtkIdType* faces) override;
380
397 vtkIdType* GetFaces() override;
398
407
409
419
426 int IsInside(const double x[3], double tolerance);
427
434 bool IsConvex();
435
440
444 void ShallowCopy(vtkCell* c) override;
445
449 void DeepCopy(vtkCell* c) override;
450
451protected:
453 ~vtkPolyhedron() override;
454
455 // Internal classes for supporting operations on this cell
461
462 // Filled with the SetFaces method.
463 // These faces are numbered in global id space
465
466 // Backward compatibility
468
469 // If edges are needed. Note that the edge numbering is in canonical space.
470 int EdgesGenerated = 0; // true/false
471 vtkNew<vtkEdgeTable> EdgeTable; // keep track of all edges
472 vtkNew<vtkIdTypeArray> Edges; // edge pairs kept in this list, in canonical id space
473 vtkNew<vtkIdTypeArray> EdgeFaces; // face pairs that comprise each edge, with the
474 // same ordering as EdgeTable
475 int GenerateEdges(); // method populates the edge table and edge array
476
477 // Numerous methods needs faces to be numbered in the canonical space.
478 // This method uses PointIdMap to fill the Faces member (faces described
479 // with canonical IDs) from the GlobalFaces member (faces described with
480 // global IDs).
482 vtkNew<vtkCellArray> Faces; // These are numbered in canonical id space
483 int FacesGenerated = 0; // True when Faces have been successfully constructed
484
485 // Bounds management
488 void ComputeParametricCoordinate(const double x[3], double pc[3]);
489 void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
490
491 VTK_DEPRECATED_IN_9_4_0("Use GeneratePointToIncidentFaces instead.")
492 void GeneratePointToIncidentFacesAndValenceAtPoint() { this->GeneratePointToIncidentFaces(); }
493
494 // Members for supporting geometric operations
503
504private:
505 vtkPolyhedron(const vtkPolyhedron&) = delete;
506 void operator=(const vtkPolyhedron&) = delete;
507
509
510 // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
511 // These data members are implicitly organized in canonical space, i.e., where the cell
512 // point ids are (0,1,...,npts-1).
513 // The PointIdMap is constructed during the call of the Initialize() method and maps global
514 // point ids to the canonical point ids.
515 vtkPointIdMap PointIdMap;
516
517 void GeneratePointToIncidentFaces();
518
519 // Members used in GetPointToIncidentFaces
520 std::vector<std::vector<vtkIdType>> PointToIncidentFaces;
521
523 std::atomic<bool> IsRandomSequenceSeedInitialized{ false };
524};
525
526//----------------------------------------------------------------------------
527inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
528{
529 pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
530 return 0;
531}
532
533VTK_ABI_NAMESPACE_END
534#endif
object to represent cell connectivity
represent and manipulate cell attribute data
Definition vtkCellData.h:32
octree-based spatial search object to quickly locate cells
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
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:24
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:29
cell represents a 1D line
Definition vtkLine.h:23
Park and Miller Sequence of pseudo random numbers.
Allocate and hold a VTK object.
Definition vtkNew.h:58
represent and manipulate point attribute data
quickly locate points in 3-space
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
a cell that represents an n-sided polygon
Definition vtkPolygon.h:33
vtkNew< vtkLine > Line
vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(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.
int RequiresExplicitFaceRepresentation() override
Satisfy the vtkCell API.
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.
int GenerateEdges()
int GetNumberOfFaces() override
A polyhedron is represented internally by a set of polygonal faces.
vtkNew< vtkTetra > Tetra
void SetFaces(vtkIdType *faces) override
Set the faces of the polyhedron.
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 ...
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()
vtkIdType GetPointToIncidentEdges(vtkIdType vtkNotUsed(pointId), const vtkIdType *&vtkNotUsed(edgeIds)) override
See vtkCell3D API for description of these methods.
void ComputeParametricCoordinate(const double x[3], double pc[3])
vtkNew< vtkPolyData > PolyData
int TriangulateFaces(vtkIdList *newFaces)
Triangulate each face of the polyhedron.
void ComputeBounds()
void GetEdgeToAdjacentFaces(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
vtkIdType GetPointToOneRingPoints(vtkIdType vtkNotUsed(pointId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
vtkIdType GetFaceToAdjacentFaces(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(faceIds)) override
See vtkCell3D API for description of these methods.
void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) 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).
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.
vtkNew< vtkIdTypeArray > LegacyGlobalFaces
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).
bool IsConvex()
Determine whether or not a polyhedron is convex.
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 GeneratePointToIncidentFacesAndValenceAtPoint()
int IsPrimaryCell() override
A polyhedron is a full-fledged primary cell.
vtkPolyData * GetPolyData()
Construct polydata if no one exist, then return this->PolyData.
vtkNew< vtkCellArray > Faces
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.
bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
See vtkCell3D API for description of these methods.
vtkNew< vtkIdList > CellIds
vtkIdType * GetFaces() override
Get the faces of the polyhedron.
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:28
a 3D cell that represents a tetrahedron
Definition vtkTetra.h:34
a cell that represents a triangle
Definition vtkTriangle.h:28
@ VTK_POLYHEDRON
Definition vtkCellType.h:80
#define vtkDataArray
#define VTK_DEPRECATED_IN_9_4_0(reason)
int vtkIdType
Definition vtkType.h:315