1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkHexahedron.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   vtkHexahedron
17  * @brief   a cell that represents a linear 3D hexahedron
18  *
19  * vtkHexahedron is a concrete implementation of vtkCell to represent a
20  * linear, 3D rectangular hexahedron (e.g., "brick" topology). vtkHexahedron
21  * uses the standard isoparametric shape functions for a linear
22  * hexahedron. The hexahedron is defined by the eight points (0-7) where
23  * (0,1,2,3) is the base of the hexahedron which, using the right hand rule,
24  * forms a quadrilaterial whose normal points in the direction of the
25  * opposite face (4,5,6,7).
26  *
27  * @sa
28  * vtkConvexPointSet vtkPyramid vtkTetra vtkVoxel vtkWedge
29 */
30 
31 #ifndef vtkHexahedron_h
32 #define vtkHexahedron_h
33 
34 #include "vtkCommonDataModelModule.h" // For export macro
35 #include "vtkCell3D.h"
36 
37 class vtkLine;
38 class vtkQuad;
39 class vtkIncrementalPointLocator;
40 
41 class VTKCOMMONDATAMODEL_EXPORT vtkHexahedron : public vtkCell3D
42 {
43 public:
44   static vtkHexahedron *New();
45   vtkTypeMacro(vtkHexahedron,vtkCell3D);
46   void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48   //@{
49   /**
50    * See vtkCell3D API for description of these methods.
51    */
52   void GetEdgePoints(int edgeId, int* &pts) override;
53   void GetFacePoints(int faceId, int* &pts) override;
54   //@}
55 
56   //@{
57   /**
58    * See the vtkCell API for descriptions of these methods.
59    */
GetCellType()60   int GetCellType() override {return VTK_HEXAHEDRON;}
GetNumberOfEdges()61   int GetNumberOfEdges() override {return 12;}
GetNumberOfFaces()62   int GetNumberOfFaces() override {return 6;}
63   vtkCell *GetEdge(int edgeId) override;
64   vtkCell *GetFace(int faceId) override;
65   int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override;
66   void Contour(double value, vtkDataArray *cellScalars,
67                vtkIncrementalPointLocator *locator, vtkCellArray *verts,
68                vtkCellArray *lines, vtkCellArray *polys,
69                vtkPointData *inPd, vtkPointData *outPd,
70                vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) 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 case table for table-based isocontouring (aka marching cubes
87    * style implementations). A linear 3D cell with N vertices will have 2**N
88    * cases. The returned case array lists three edges in order to produce one
89    * output triangle which may be repeated to generate multiple triangles. The
90    * list of cases terminates with a -1 entry.
91    */
92   static int* GetTriangleCases(int caseId);
93 
94   /**
95    * @deprecated Replaced by vtkHexahedron::InterpolateFunctions as of VTK 5.2
96    */
97   static void InterpolationFunctions(const double pcoords[3], double weights[8]);
98   /**
99    * @deprecated Replaced by vtkHexahedron::InterpolateDerivs as of VTK 5.2
100    */
101   static void InterpolationDerivs(const double pcoords[3], double derivs[24]);
102   //@{
103   /**
104    * Compute the interpolation functions/derivatives
105    * (aka shape functions/derivatives)
106    */
InterpolateFunctions(const double pcoords[3],double weights[8])107   void InterpolateFunctions(const double pcoords[3], double weights[8]) override
108   {
109     vtkHexahedron::InterpolationFunctions(pcoords,weights);
110   }
InterpolateDerivs(const double pcoords[3],double derivs[24])111   void InterpolateDerivs(const double pcoords[3], double derivs[24]) override
112   {
113     vtkHexahedron::InterpolationDerivs(pcoords,derivs);
114   }
115   //@}
116 
117   //@{
118   /**
119    * Return the ids of the vertices defining edge/face (`edgeId`/`faceId').
120    * Ids are related to the cell, not to the dataset.
121    */
122   static int *GetEdgeArray(int edgeId) VTK_SIZEHINT(2);
123   static int *GetFaceArray(int faceId) VTK_SIZEHINT(4);
124   //@}
125 
126   /**
127    * Given parametric coordinates compute inverse Jacobian transformation
128    * matrix. Returns 9 elements of 3x3 inverse Jacobian plus interpolation
129    * function derivatives.
130    */
131   void JacobianInverse(const double pcoords[3], double **inverse, double derivs[24]);
132 
133 protected:
134   vtkHexahedron();
135   ~vtkHexahedron() override;
136 
137   vtkLine *Line;
138   vtkQuad *Quad;
139 
140 private:
141   vtkHexahedron(const vtkHexahedron&) = delete;
142   void operator=(const vtkHexahedron&) = delete;
143 };
144 
145 #endif
146