VTK  9.2.6
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 =========================================================================*/
38 #ifndef vtkPolyhedron_h
39 #define vtkPolyhedron_h
40 
41 #include "vtkCell3D.h"
42 #include "vtkCommonDataModelModule.h" // For export macro
43 
44 class vtkIdTypeArray;
45 class vtkCellArray;
46 class vtkTriangle;
47 class vtkQuad;
48 class vtkTetra;
49 class vtkPolygon;
50 class vtkLine;
51 class vtkPointIdMap;
52 class vtkIdToIdVectorMapType;
53 class vtkIdToIdMapType;
54 class vtkEdgeTable;
55 class vtkPolyData;
56 class vtkCellLocator;
57 class vtkGenericCell;
58 class vtkPointLocator;
59 
60 class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
61 {
62 public:
64 
67  static vtkPolyhedron* New();
68  vtkTypeMacro(vtkPolyhedron, vtkCell3D);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
73 
77  void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
78  {
79  vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
80  }
81  vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(pts)) override
82  {
83  vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented");
84  return 0;
85  }
87  vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
88  {
89  vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
90  }
92  vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
93  {
94  vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
95  return 0;
96  }
98  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
99  {
100  vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
101  return 0;
102  }
103  vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
105  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
106  {
107  vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
108  return 0;
109  }
110  bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
111  {
112  vtkWarningMacro(<< "vtkPolyhedron::GetCentroid Not Implemented");
113  return false;
114  }
116 
120  double* GetParametricCoords() override;
121 
125  int GetCellType() override { return VTK_POLYHEDRON; }
126 
130  int RequiresInitialization() override { return 1; }
131  void Initialize() override;
132 
134 
138  int GetNumberOfEdges() override;
139  vtkCell* GetEdge(int) override;
140  int GetNumberOfFaces() override;
141  vtkCell* GetFace(int faceId) override;
143 
149  void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
150  vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
151  vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
152 
162  void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
163  vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
164  vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
165 
173  int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
174  double& dist2, double weights[]) override;
175 
180  void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
181 
188  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
189  double pcoords[3], int& subId) override;
190 
206  int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override;
207 
215  void Derivatives(
216  int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
217 
222  int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
223 
228  int GetParametricCenter(double pcoords[3]) override;
229 
233  int IsPrimaryCell() override { return 1; }
234 
236 
241  void InterpolateFunctions(const double x[3], double* sf) override;
242  void InterpolateDerivs(const double x[3], double* derivs) override;
244 
246 
254  int RequiresExplicitFaceRepresentation() override { return 1; }
255  void SetFaces(vtkIdType* faces) override;
256  vtkIdType* GetFaces() override;
258 
265  int IsInside(const double x[3], double tolerance);
266 
273  bool IsConvex();
274 
278  vtkPolyData* GetPolyData();
279 
280 protected:
281  vtkPolyhedron();
282  ~vtkPolyhedron() override;
283 
284  // Internal classes for supporting operations on this cell
290  vtkIdTypeArray* GlobalFaces; // these are numbered in global id space
292 
293  // vtkCell has the data members Points (x,y,z coordinates) and PointIds
294  // (global cell ids corresponding to cell canonical numbering (0,1,2,....)).
295  // These data members are implicitly organized in canonical space, i.e., where
296  // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id
297  // back to these canonoical point ids.
298  vtkPointIdMap* PointIdMap;
299 
300  // If edges are needed. Note that the edge numbering is in
301  // canonical space.
302  int EdgesGenerated; // true/false
303  vtkEdgeTable* EdgeTable; // keep track of all edges
304  vtkIdTypeArray* Edges; // edge pairs kept in this list, in canonical id space
305  vtkIdTypeArray* EdgeFaces; // face pairs that comprise each edge, with the
306  // same ordering as EdgeTable
307  int GenerateEdges(); // method populates the edge table and edge array
308 
309  // If faces need renumbering into canonical numbering space these members
310  // are used. When initiallly loaded, the face numbering uses global dataset
311  // ids. Once renumbered, they are converted to canonical space.
312  vtkIdTypeArray* Faces; // these are numbered in canonical id space
314  void GenerateFaces();
315 
316  // Bounds management
318  void ComputeBounds();
319  void ComputeParametricCoordinate(const double x[3], double pc[3]);
320  void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
321 
322  void GeneratePointToIncidentFacesAndValenceAtPoint();
323 
324  // Members for supporting geometric operations
328  void ConstructPolyData();
331  void ConstructLocator();
334 
335  // Members used in GetPointToIncidentFaces
338 
339 private:
340  vtkPolyhedron(const vtkPolyhedron&) = delete;
341  void operator=(const vtkPolyhedron&) = delete;
342 };
343 
344 //----------------------------------------------------------------------------
345 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
346 {
347  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
348  return 0;
349 }
350 
351 #endif
vtkCellLocator * CellLocator
vtkTetra * Tetra
void Contour(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) override
Generate contouring primitives.
vtkPolygon * Polygon
vtkIdType GetPointToOneRingPoints(vtkIdType vtkNotUsed(pointId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
represent and manipulate point attribute data
Definition: vtkPointData.h:41
virtual int GetNumberOfFaces()=0
Return the number of faces in the cell.
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
quickly locate points in 3-space
vtkIdTypeArray * GlobalFaces
vtkIdType ** PointToIncidentFaces
vtkIdTypeArray * EdgeFaces
vtkQuad * Quad
vtkEdgeTable * EdgeTable
vtkTriangle * Triangle
represent and manipulate cell attribute data
Definition: vtkCellData.h:41
vtkIdType * ValenceAtPoint
Abstract class in support of both point location and point insertion.
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
Generate simplices of proper dimension.
virtual void InterpolateFunctions(const double vtkNotUsed(pcoords)[3], double *vtkNotUsed(weight))
Compute the interpolation functions/derivatives (aka shape functions/derivatives) No-ops at this leve...
Definition: vtkCell.h:391
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:38
vtkPolyData * PolyData
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
provides thread-safe access to cells
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:38
virtual int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts)=0
Given parametric coordinates of a point, return the closest cell boundary, and whether the point is i...
vtkIdTypeArray * Faces
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:40
virtual void InterpolateDerivs(const double vtkNotUsed(pcoords)[3], double *vtkNotUsed(derivs))
Definition: vtkCell.h:394
int IsPrimaryCell() override
A polyhedron is a full-fledged primary cell.
vtkIdType GetFaceToAdjacentFaces(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(faceIds)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:91
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:44
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:130
cell represents a 1D line
Definition: vtkLine.h:33
abstract class to specify cell behavior
Definition: vtkCell.h:60
virtual void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights)=0
Determine global coordinate (x[3]) from subId and parametric coordinates.
octree-based spatial search object to quickly locate cells
void GetEdgeToAdjacentFaces(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:86
vtkPointIdMap * PointIdMap
vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:81
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkGenericCell * Cell
vtkLine * Line
list of point or cell ids
Definition: vtkIdList.h:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:77
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:42
vtkIdTypeArray * Edges
bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
See vtkCell3D API for description of these methods.
virtual vtkCell * GetFace(int faceId)=0
Return the face cell from the faceId of the cell.
virtual int GetNumberOfEdges()=0
Return the number of edges in the cell.
virtual int EvaluatePosition(const double x[3], double closestPoint[3], int &subId, double pcoords[3], double &dist2, double weights[])=0
Given a point x[3] return inside(=1), outside(=0) cell, or (-1) computational problem encountered; ev...
vtkIdList * CellIds
object to represent cell connectivity
Definition: vtkCellArray.h:186
virtual vtkCell * GetEdge(int edgeId)=0
Return the edge cell from the edgeId of the cell.
a cell that represents a triangle
Definition: vtkTriangle.h:38
virtual void Derivatives(int subId, const double pcoords[3], const double *values, int dim, double *derivs)=0
Compute derivatives given cell subId and parametric coordinates.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:60
virtual vtkIdType * GetFaces()
Definition: vtkCell.h:131
virtual void Initialize()
Definition: vtkCell.h:115
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual double * GetParametricCoords())
Return a contiguous array of parametric coordinates of the points defining this cell.
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)=0
Intersect with a ray.
virtual vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType *&faceIds)=0
Get the ids of the incident faces point of id pointId.
void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
Cut (or clip) the cell based on the input cellScalars and the specified value.
vtkIdTypeArray * FaceLocations
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkCellArray * Polys
int GetParametricCenter(double pcoords[3]) override
Return the center of the cell in parametric coordinates.
vtkIdType GetPointToIncidentEdges(vtkIdType vtkNotUsed(pointId), const vtkIdType *&vtkNotUsed(edgeIds)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:97
int GetCellType() override
See the vtkCell API for descriptions of these methods.
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.