VTK  9.3.1
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
123 #ifndef vtkPolyhedron_h
124 #define vtkPolyhedron_h
125 
126 #include "vtkCell3D.h"
127 #include "vtkCommonDataModelModule.h" // For export macro
128 
129 VTK_ABI_NAMESPACE_BEGIN
130 class vtkIdTypeArray;
131 class vtkCellArray;
132 class vtkTriangle;
133 class vtkQuad;
134 class vtkTetra;
135 class vtkPolygon;
136 class vtkLine;
137 class vtkIdToIdVectorMapType;
138 class vtkIdToIdMapType;
139 class vtkEdgeTable;
140 class vtkPolyData;
141 class vtkCellLocator;
142 class vtkGenericCell;
143 class vtkPointLocator;
144 
145 class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
146 {
147 public:
148  typedef std::map<vtkIdType, vtkIdType> vtkPointIdMap;
149 
151 
154  static vtkPolyhedron* New();
155  vtkTypeMacro(vtkPolyhedron, vtkCell3D);
156  void PrintSelf(ostream& os, vtkIndent indent) override;
158 
160 
164  void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
165  {
166  vtkWarningMacro(<< "vtkPolyhedron::GetEdgePoints Not Implemented");
167  }
168  vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(pts)) override
169  {
170  vtkWarningMacro(<< "vtkPolyhedron::GetFacePoints Not Implemented");
171  return 0;
172  }
174  vtkIdType vtkNotUsed(edgeId), const vtkIdType*& vtkNotUsed(pts)) override
175  {
176  vtkWarningMacro(<< "vtkPolyhedron::GetEdgeToAdjacentFaces Not Implemented");
177  }
179  vtkIdType vtkNotUsed(faceId), const vtkIdType*& vtkNotUsed(faceIds)) override
180  {
181  vtkWarningMacro(<< "vtkPolyhedron::GetFaceToAdjacentFaces Not Implemented");
182  return 0;
183  }
185  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(edgeIds)) override
186  {
187  vtkWarningMacro(<< "vtkPolyhedron::GetPointToIncidentEdges Not Implemented");
188  return 0;
189  }
190  vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds) override;
192  vtkIdType vtkNotUsed(pointId), const vtkIdType*& vtkNotUsed(pts)) override
193  {
194  vtkWarningMacro(<< "vtkPolyhedron::GetPointToOneRingPoints Not Implemented");
195  return 0;
196  }
197  bool GetCentroid(double vtkNotUsed(centroid)[3]) const override
198  {
199  vtkWarningMacro(<< "vtkPolyhedron::GetCentroid Not Implemented");
200  return false;
201  }
203 
207  double* GetParametricCoords() override;
208 
212  int GetCellType() override { return VTK_POLYHEDRON; }
213 
217  int RequiresInitialization() override { return 1; }
218 
224  void Initialize() override;
225 
227 
231  int GetNumberOfEdges() override;
232  vtkCell* GetEdge(int) override;
233  int GetNumberOfFaces() override;
234  vtkCell* GetFace(int faceId) override;
236 
242  void Contour(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
243  vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
244  vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
245 
255  void Clip(double value, vtkDataArray* scalars, vtkIncrementalPointLocator* locator,
256  vtkCellArray* connectivity, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
257  vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
258 
266  int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3],
267  double& dist2, double weights[]) override;
268 
273  void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
274 
281  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
282  double pcoords[3], int& subId) override;
283 
299  int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override;
300 
307  int TriangulateFaces(vtkIdList* newFaces);
308 
316  void Derivatives(
317  int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
318 
323  int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
324 
329  int GetParametricCenter(double pcoords[3]) override;
330 
334  int IsPrimaryCell() override { return 1; }
335 
337 
342  void InterpolateFunctions(const double x[3], double* sf) override;
343  void InterpolateDerivs(const double x[3], double* derivs) override;
345 
351  int RequiresExplicitFaceRepresentation() override { return 1; }
352 
369  void SetFaces(vtkIdType* faces) override;
370 
387  vtkIdType* GetFaces() override;
388 
395  int IsInside(const double x[3], double tolerance);
396 
403  bool IsConvex();
404 
408  vtkPolyData* GetPolyData();
409 
410 protected:
411  vtkPolyhedron();
412  ~vtkPolyhedron() override;
413 
414  // Internal classes for supporting operations on this cell
420 
421  // Filled with the SetFaces method.
422  // These faces are numbered in global id space
423  // (in the legacy vtkCellArray form)
425 
426  // Filled with the SetFaces method.
427  // Used to to point to each face in the GlobalFaces array.
429 
430  // vtkCell has the data members Points (x,y,z coordinates) and PointIds (global cell ids).
431  // These data members are implicitly organized in canonical space, i.e., where the cell
432  // point ids are (0,1,...,npts-1).
433  // The PointIdMap is constructed during the call of the Initialize() method and maps global
434  // point ids to the canonical point ids.
435  vtkPointIdMap* PointIdMap;
436 
437  // If edges are needed. Note that the edge numbering is in canonical space.
438  int EdgesGenerated; // true/false
439  vtkEdgeTable* EdgeTable; // keep track of all edges
440  vtkIdTypeArray* Edges; // edge pairs kept in this list, in canonical id space
441  vtkIdTypeArray* EdgeFaces; // face pairs that comprise each edge, with the
442  // same ordering as EdgeTable
443  int GenerateEdges(); // method populates the edge table and edge array
444 
445  // Numerous methods needs faces to be numbered in the canonical space.
446  // This method uses PointIdMap to fill the Faces member (faces described
447  // with canonical IDs) from the GlobalFaces member (faces described with
448  // global IDs).
449  void GenerateFaces();
450  vtkIdTypeArray* Faces; // These are numbered in canonical id space
451  int FacesGenerated; // True when Faces have been successfully constructed
452 
453  // Bounds management
455  void ComputeBounds();
456  void ComputeParametricCoordinate(const double x[3], double pc[3]);
457  void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
458 
459  void GeneratePointToIncidentFacesAndValenceAtPoint();
460 
461  // Members for supporting geometric operations
465  void ConstructPolyData();
468  void ConstructLocator();
471 
472  // Members used in GetPointToIncidentFaces
475 
476 private:
477  vtkPolyhedron(const vtkPolyhedron&) = delete;
478  void operator=(const vtkPolyhedron&) = delete;
479 
481 };
482 
483 //----------------------------------------------------------------------------
484 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
485 {
486  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
487  return 0;
488 }
489 
490 VTK_ABI_NAMESPACE_END
491 #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:29
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.
std::map< vtkIdType, vtkIdType > vtkPointIdMap
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:30
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:380
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:27
vtkPolyData * PolyData
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
provides thread-safe access to cells
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:27
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:29
virtual void InterpolateDerivs(const double vtkNotUsed(pcoords)[3], double *vtkNotUsed(derivs))
Definition: vtkCell.h:383
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.
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:33
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:119
cell represents a 1D line
Definition: vtkLine.h:22
abstract class to specify cell behavior
Definition: vtkCell.h:49
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.
vtkPointIdMap * PointIdMap
vtkIdType GetFacePoints(vtkIdType vtkNotUsed(faceId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkGenericCell * Cell
vtkLine * Line
list of point or cell ids
Definition: vtkIdList.h:22
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void GetEdgePoints(vtkIdType vtkNotUsed(edgeId), const vtkIdType *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:31
vtkIdTypeArray * Edges
vtkPolyhedron utilities
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:175
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:27
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.
virtual vtkIdType * GetFaces()
Definition: vtkCell.h:120
virtual void Initialize()
Definition: vtkCell.h:104
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:28
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.
int GetCellType() override
See the vtkCell API for descriptions of these methods.
int RequiresExplicitFaceRepresentation() override
Satisfy the vtkCell API.