1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkHexagonalPrism.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 =========================================================================*/
15 /**
16 * @class vtkHexagonalPrism
17 * @brief a 3D cell that represents a prism with
18 * hexagonal base
19 *
20 * vtkHexagonalPrism is a concrete implementation of vtkCell to represent a
21 * linear 3D prism with hexagonal base. Such prism is defined by the twelve points
22 * (0-12) where (0,1,2,3,4,5) is the base of the prism which, using the right
23 * hand rule, forms a hexagon whose normal points is in the direction of the
24 * opposite face (6,7,8,9,10,11).
25 *
26 * @par Thanks:
27 * Thanks to Philippe Guerville who developed this class.
28 * Thanks to Charles Pignerol (CEA-DAM, France) who ported this class under
29 * VTK 4.
30 * Thanks to Jean Favre (CSCS, Switzerland) who contributed to integrate this
31 * class in VTK.
32 * Please address all comments to Jean Favre (jfavre at cscs.ch).
33 */
34
35 #ifndef vtkHexagonalPrism_h
36 #define vtkHexagonalPrism_h
37
38 #include "vtkCommonDataModelModule.h" // For export macro
39 #include "vtkCell3D.h"
40
41 class vtkLine;
42 class vtkPolygon;
43 class vtkQuad;
44
45 class VTKCOMMONDATAMODEL_EXPORT vtkHexagonalPrism : public vtkCell3D
46 {
47 public:
48 static vtkHexagonalPrism *New();
49 vtkTypeMacro(vtkHexagonalPrism,vtkCell3D);
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
52 //@{
53 /**
54 * See vtkCell3D API for description of these methods.
55 */
56 void GetEdgePoints(int edgeId, int* &pts) override;
57 void GetFacePoints(int faceId, int* &pts) override;
58 //@}
59
60 //@{
61 /**
62 * See the vtkCell API for descriptions of these methods.
63 */
GetCellType()64 int GetCellType() override {return VTK_HEXAGONAL_PRISM;};
GetCellDimension()65 int GetCellDimension() override {return 3;};
GetNumberOfEdges()66 int GetNumberOfEdges() override {return 18;};
GetNumberOfFaces()67 int GetNumberOfFaces() override {return 8;};
68 vtkCell *GetEdge(int edgeId) override;
69 vtkCell *GetFace(int faceId) override;
70 int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override;
71 //@}
72
73 int EvaluatePosition(const double x[3], double closestPoint[3],
74 int& subId, double pcoords[3],
75 double& dist2, double weights[]) override;
76 void EvaluateLocation(int& subId, const double pcoords[3], double x[3],
77 double *weights) override;
78 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
79 double x[3], double pcoords[3], int& subId) override;
80 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) override;
81 void Derivatives(int subId, const double pcoords[3], const double *values,
82 int dim, double *derivs) override;
83 double *GetParametricCoords() override;
84
85 /**
86 * Return the center of the wedge in parametric coordinates.
87 */
88 int GetParametricCenter(double pcoords[3]) override;
89
90 /**
91 * @deprecated Replaced by vtkHexagonalPrism::InterpolateFunctions as of VTK 5.2
92 */
93 static void InterpolationFunctions(const double pcoords[3], double weights[12]);
94 /**
95 * @deprecated Replaced by vtkHexagonalPrism::InterpolateDerivs as of VTK 5.2
96 */
97 static void InterpolationDerivs(const double pcoords[3], double derivs[36]);
98 //@{
99 /**
100 * Compute the interpolation functions/derivatives
101 * (aka shape functions/derivatives)
102 */
InterpolateFunctions(const double pcoords[3],double weights[12])103 void InterpolateFunctions(const double pcoords[3], double weights[12]) override
104 {
105 vtkHexagonalPrism::InterpolationFunctions(pcoords,weights);
106 }
InterpolateDerivs(const double pcoords[3],double derivs[36])107 void InterpolateDerivs(const double pcoords[3], double derivs[36]) override
108 {
109 vtkHexagonalPrism::InterpolationDerivs(pcoords,derivs);
110 }
111 //@}
112
113 //@{
114 /**
115 * Return the ids of the vertices defining edge/face (`edgeId`/`faceId').
116 * Ids are related to the cell, not to the dataset.
117 */
118 static int *GetEdgeArray(int edgeId);
119 static int *GetFaceArray(int faceId);
120 //@}
121
122 /**
123 * Given parametric coordinates compute inverse Jacobian transformation
124 * matrix. Returns 9 elements of 3x3 inverse Jacobian plus interpolation
125 * function derivatives.
126 */
127 void JacobianInverse(const double pcoords[3], double **inverse, double derivs[36]);
128
129 protected:
130 vtkHexagonalPrism();
131 ~vtkHexagonalPrism() override;
132
133 vtkLine *Line;
134 vtkQuad *Quad;
135 vtkPolygon *Polygon;
136
137 private:
138 vtkHexagonalPrism(const vtkHexagonalPrism&) = delete;
139 void operator=(const vtkHexagonalPrism&) = delete;
140 };
141
142 //----------------------------------------------------------------------------
GetParametricCenter(double pcoords[3])143 inline int vtkHexagonalPrism::GetParametricCenter(double pcoords[3])
144 {
145 pcoords[0] = pcoords[1] = 0.5;
146 pcoords[2] = 0.5;
147 return 0;
148 }
149 #endif
150
151
152