VTK  9.5.2
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 centroid[3]) const override;
200
204 double* GetParametricCoords() override;
205
209 int GetCellType() override { return VTK_POLYHEDRON; }
210
214 int RequiresInitialization() override { return 1; }
215
221 void Initialize() override;
222
224
228 int GetNumberOfEdges() override;
229 vtkCell* GetEdge(int) override;
230 int GetNumberOfFaces() override;
231 vtkCell* GetFace(int faceId) override;
233
239 void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
240 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
241 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
242
252 void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
253 vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
254 vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
255
263 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
264 double& dist2, double weights[]) override;
265
270 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
271
278 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
279 double pcoords[3], int& subId) override;
280
296 int TriangulateLocalIds(int index, vtkIdList* ptIds) override;
297
305
313
322 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
323
328 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
329
334 int GetParametricCenter(double pcoords[3]) override;
335
339 int IsPrimaryCell() VTK_FUTURE_CONST override { return 1; }
340
342
347 void InterpolateFunctions(const double x[3], double* sf) override;
348 void InterpolateDerivs(const double x[3], double* derivs) override;
350
356 int RequiresExplicitFaceRepresentation() VTK_FUTURE_CONST override { return 1; }
357
375 void SetFaces(vtkIdType* faces) override;
376
393 vtkIdType* GetFaces() override;
394
403
405
414
421 int IsInside(const double x[3], double tolerance);
422
429 bool IsConvex();
430
435
439 void ShallowCopy(vtkCell* c) override;
440
444 void DeepCopy(vtkCell* c) override;
445
446protected:
448 ~vtkPolyhedron() override;
449
450 // Internal classes for supporting operations on this cell
456
457 // Filled with the SetFaces method.
458 // These faces are numbered in global id space
460
461 // Backward compatibility
463
464 // If edges are needed. Note that the edge numbering is in canonical space.
465 int EdgesGenerated = 0; // true/false
466 vtkNew<vtkEdgeTable> EdgeTable; // keep track of all edges
467 vtkNew<vtkIdTypeArray> Edges; // edge pairs kept in this list, in canonical id space
468 vtkNew<vtkIdTypeArray> EdgeFaces; // face pairs that comprise each edge, with the
469 // same ordering as EdgeTable
470 int GenerateEdges(); // method populates the edge table and edge array
471
472 // Numerous methods needs faces to be numbered in the canonical space.
473 // This method uses PointIdMap to fill the Faces member (faces described
474 // with canonical IDs) from the GlobalFaces member (faces described with
475 // global IDs).
477 vtkNew<vtkCellArray> Faces; // These are numbered in canonical id space
478 int FacesGenerated = 0; // True when Faces have been successfully constructed
479
480 // Bounds management
483 void ComputeParametricCoordinate(const double x[3], double pc[3]);
484 void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
485
486 VTK_DEPRECATED_IN_9_4_0("Use GeneratePointToIncidentFaces instead.")
487 void GeneratePointToIncidentFacesAndValenceAtPoint() { this->GeneratePointToIncidentFaces(); }
488
489 // Members for supporting geometric operations
498
499private:
500 vtkPolyhedron(const vtkPolyhedron&) = delete;
501 void operator=(const vtkPolyhedron&) = delete;
502
504
505 // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
506 // These data members are implicitly organized in canonical space, i.e., where the cell
507 // point ids are (0,1,...,npts-1).
508 // The PointIdMap is constructed during the call of the Initialize() method and maps global
509 // point ids to the canonical point ids.
510 vtkPointIdMap PointIdMap;
511
512 void GeneratePointToIncidentFaces();
513
514 // Members used in GetPointToIncidentFaces
515 std::vector<std::vector<vtkIdType>> PointToIncidentFaces;
516
518 std::atomic<bool> IsRandomSequenceSeedInitialized{ false };
519};
520
521VTK_ABI_NAMESPACE_END
522#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
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:32
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.
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).
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.
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.
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.
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 GeneratePointToIncidentFacesAndValenceAtPoint()
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.
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:332