VTK  9.1.0
vtkPolyhedron.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPolyhedron.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
35 #ifndef vtkPolyhedron_h
36 #define vtkPolyhedron_h
37 
38 #include "vtkCell3D.h"
39 #include "vtkCommonDataModelModule.h" // For export macro
40 
41 class vtkIdTypeArray;
42 class vtkCellArray;
43 class vtkTriangle;
44 class vtkQuad;
45 class vtkTetra;
46 class vtkPolygon;
47 class vtkLine;
48 class vtkPointIdMap;
49 class vtkIdToIdVectorMapType;
50 class vtkIdToIdMapType;
51 class vtkEdgeTable;
52 class vtkPolyData;
53 class vtkCellLocator;
54 class vtkGenericCell;
55 class vtkPointLocator;
56 
57 class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
58 {
59 public:
61 
64  static vtkPolyhedron* New();
65  vtkTypeMacro(vtkPolyhedron, vtkCell3D);
66  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
70 
74  void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
75  {
76  vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
77  }
78  // @deprecated Replaced by GetEdgePoints(vtkIdType, const vtkIdType*&) as of VTK 9.0
79  VTK_DEPRECATED_IN_9_0_0("Replaced by vtkPolyhedron::GetEdgePoints(vtkIdType, const vtkIdType*&)")
80  void GetEdgePoints(int vtkNotUsed(edgeId), int*& vtkNotUsed(pts)) override
81  {
82  vtkErrorMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented. "
83  "Also note that this signature is deprecated. "
84  "Please use GetEdgePoints(vtkIdType, const vtkIdType*& instead");
85  };
86  vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(pts)) override
87  {
88  vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented");
89  return 0;
90  }
91  // @deprecated Replaced by GetFacePoints(vtkIdType, const vtkIdType*&) as of VTK 9.0
92  VTK_DEPRECATED_IN_9_0_0("Replaced by vtkPolyhedron::GetFacePoints(vtkIdType, const vtkIdType*&)")
93  void GetFacePoints(int vtkNotUsed(faceId), int*& vtkNotUsed(pts)) override
94  {
95  vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented. "
96  "Also note that this signature is deprecated. "
97  "Please use GetFacePoints(vtkIdType, const vtkIdType*& instead");
98  };
100  vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
101  {
102  vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
103  }
105  vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
106  {
107  vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
108  return 0;
109  }
111  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
112  {
113  vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
114  return 0;
115  }
116  vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
118  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
119  {
120  vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
121  return 0;
122  }
123  bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
124  {
125  vtkWarningMacro(<< "vtkPolyhedron::GetCentroid Not Implemented");
126  return false;
127  }
129 
133  double* GetParametricCoords() override;
134 
138  int GetCellType() override { return VTK_POLYHEDRON; }
139 
143  int RequiresInitialization() override { return 1; }
144  void Initialize() override;
145 
147 
151  int GetNumberOfEdges() override;
152  vtkCell* GetEdge(int) override;
153  int GetNumberOfFaces() override;
154  vtkCell* GetFace(int faceId) override;
156 
162  void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
163  vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
164  vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
165 
175  void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
176  vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
177  vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
178 
186  int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
187  double& dist2, double weights[]) override;
188 
193  void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
194 
201  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
202  double pcoords[3], int& subId) override;
203 
219  int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override;
220 
229  int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
230 
235  int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
236 
241  int GetParametricCenter(double pcoords[3]) override;
242 
246  int IsPrimaryCell() override { return 1; }
247 
249 
254  void InterpolateFunctions(const double x[3], double* sf) override;
255  void InterpolateDerivs(const double x[3], double* derivs) override;
257 
259 
267  int RequiresExplicitFaceRepresentation() override { return 1; }
268  void SetFaces(vtkIdType* faces) override;
269  vtkIdType* GetFaces() override;
271 
278  int IsInside(const double x[3], double tolerance);
279 
286  bool IsConvex();
287 
292 
293 protected:
295  ~vtkPolyhedron() override;
296 
297  // Internal classes for supporting operations on this cell
303  vtkIdTypeArray* GlobalFaces; // these are numbered in global id space
305 
306  // vtkCell has the data members Points (x,y,z coordinates) and PointIds
307  // (global cell ids corresponding to cell canonical numbering (0,1,2,....)).
308  // These data members are implicitly organized in canonical space, i.e., where
309  // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id
310  // back to these canonoical point ids.
311  vtkPointIdMap* PointIdMap;
312 
313  // If edges are needed. Note that the edge numbering is in
314  // canonical space.
315  int EdgesGenerated; // true/false
316  vtkEdgeTable* EdgeTable; // keep track of all edges
317  vtkIdTypeArray* Edges; // edge pairs kept in this list, in canonical id space
318  vtkIdTypeArray* EdgeFaces; // face pairs that comprise each edge, with the
319  // same ordering as EdgeTable
320  int GenerateEdges(); // method populates the edge table and edge array
321 
322  // If faces need renumbering into canonical numbering space these members
323  // are used. When initiallly loaded, the face numbering uses global dataset
324  // ids. Once renumbered, they are converted to canonical space.
325  vtkIdTypeArray* Faces; // these are numbered in canonical id space
328 
329  // Bounds management
332  void ComputeParametricCoordinate(const double x[3], double pc[3]);
333  void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
334 
336 
337  // Members for supporting geometric operations
347 
348  // Members used in GetPointToIncidentFaces
351 
352 private:
353  vtkPolyhedron(const vtkPolyhedron&) = delete;
354  void operator=(const vtkPolyhedron&) = delete;
355 };
356 
357 //----------------------------------------------------------------------------
358 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
359 {
360  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
361  return 0;
362 }
363 
364 #endif
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:40
object to represent cell connectivity
Definition: vtkCellArray.h:181
represent and manipulate cell attribute data
Definition: vtkCellData.h:33
octree-based spatial search object to quickly locate cells
abstract class to specify cell behavior
Definition: vtkCell.h:58
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:31
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:34
cell represents a 1D line
Definition: vtkLine.h:31
represent and manipulate point attribute data
Definition: vtkPointData.h:33
quickly locate points in 3-space
represent and manipulate 3D points
Definition: vtkPoints.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:40
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:58
vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:86
vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType *&faceIds) override
See vtkCell3D API for description of these methods.
vtkPointIdMap * PointIdMap
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.
vtkIdList * CellIds
vtkPolyData * GetPolyData()
Construct polydata if no one exist, then return this->PolyData.
int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) override
Use vtkOrderedTriangulator to tetrahedralize the polyhedron mesh.
int GenerateEdges()
int GetNumberOfFaces() override
A polyhedron is represented internally by a set of polygonal faces.
void SetFaces(vtkIdType *faces) override
Methods supporting the definition of 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 ...
~vtkPolyhedron() override
void GenerateFaces()
vtkIdType GetPointToIncidentEdges(vtkIdType vtkNotUsed(pointId), const vtkIdType *&vtkNotUsed(edgeIds)) override
See vtkCell3D API for description of these methods.
vtkQuad * Quad
void ComputeParametricCoordinate(const double x[3], double pc[3])
vtkIdType * ValenceAtPoint
vtkEdgeTable * EdgeTable
void ComputeBounds()
void GetEdgeToAdjacentFaces(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:99
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.
Definition: vtkPolyhedron.h:74
vtkPolygon * Polygon
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
The inverse of EvaluatePosition.
vtkCell * GetFace(int faceId) override
A polyhedron is represented internally by a set of polygonal faces.
static vtkPolyhedron * New()
Standard new methods.
void InterpolateFunctions(const double x[3], double *sf) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
vtkCellLocator * CellLocator
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.
vtkIdTypeArray * EdgeFaces
vtkTriangle * Triangle
int GetParametricCenter(double pcoords[3]) override
Return the center of the cell in parametric coordinates.
vtkIdTypeArray * GlobalFaces
vtkIdTypeArray * Edges
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.
void ConstructPolyData()
vtkIdType ** PointToIncidentFaces
int GetNumberOfEdges() override
A polyhedron is represented internally by a set of polygonal faces.
vtkCell * GetEdge(int) override
A polyhedron is represented internally by a set of polygonal faces.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard new methods.
void GeneratePointToIncidentFacesAndValenceAtPoint()
double * GetParametricCoords() override
See vtkCell3D API for description of this method.
vtkIdTypeArray * Faces
vtkPolyData * PolyData
int IsPrimaryCell() override
A polyhedron is a full-fledged primary cell.
vtkLine * Line
vtkTetra * Tetra
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.
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
vtkGenericCell * Cell
void ComputePositionFromParametricCoordinate(const double pc[3], double x[3])
vtkCellArray * Polys
vtkIdType * GetFaces() override
Methods supporting the definition of faces.
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...
vtkIdTypeArray * FaceLocations
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
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:36
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:42
a cell that represents a triangle
Definition: vtkTriangle.h:36
@ value
Definition: vtkX3D.h:226
@ index
Definition: vtkX3D.h:252
@ VTK_POLYHEDRON
Definition: vtkCellType.h:89
#define VTK_DEPRECATED_IN_9_0_0(reason)
int vtkIdType
Definition: vtkType.h:332