1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkBiQuadraticQuadraticHexahedron.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 vtkBiQuadraticQuadraticHexahedron 17 * @brief cell represents a biquadratic, 18 * 24-node isoparametric hexahedron 19 * 20 * vtkBiQuadraticQuadraticHexahedron is a concrete implementation of vtkNonLinearCell to 21 * represent a three-dimensional, 24-node isoparametric biquadratic 22 * hexahedron. The interpolation is the standard finite element, 23 * biquadratic-quadratic 24 * isoparametric shape function. The cell includes mid-edge and center-face nodes. The 25 * ordering of the 24 points defining the cell is point ids (0-7,8-19, 20-23) 26 * where point ids 0-7 are the eight corner vertices of the cube; followed by 27 * twelve midedge nodes (8-19), nodes 20-23 are the center-face nodes. Note that 28 * these midedge nodes correspond lie 29 * on the edges defined by (0,1), (1,2), (2,3), (3,0), (4,5), (5,6), (6,7), 30 * (7,4), (0,4), (1,5), (2,6), (3,7). The center face nodes laying in quad 31 * 22-(0,1,5,4), 21-(1,2,6,5), 23-(2,3,7,6) and 22-(3,0,4,7) 32 * 33 * \verbatim 34 * 35 * top 36 * 7--14--6 37 * | | 38 * 15 13 39 * | | 40 * 4--12--5 41 * 42 * middle 43 * 19--23--18 44 * | | 45 * 20 21 46 * | | 47 * 16--22--17 48 * 49 * bottom 50 * 3--10--2 51 * | | 52 * 11 9 53 * | | 54 * 0-- 8--1 55 * 56 * \endverbatim 57 * 58 * 59 * @sa 60 * vtkQuadraticEdge vtkQuadraticTriangle vtkQuadraticTetra 61 * vtkQuadraticQuad vtkQuadraticPyramid vtkQuadraticWedge 62 * 63 * @par Thanks: 64 * Thanks to Soeren Gebbert who developed this class and 65 * integrated it into VTK 5.0. 66 */ 67 68 #ifndef vtkBiQuadraticQuadraticHexahedron_h 69 #define vtkBiQuadraticQuadraticHexahedron_h 70 71 #include "vtkCommonDataModelModule.h" // For export macro 72 #include "vtkNonLinearCell.h" 73 74 class vtkQuadraticEdge; 75 class vtkQuadraticQuad; 76 class vtkBiQuadraticQuad; 77 class vtkHexahedron; 78 class vtkDoubleArray; 79 80 class VTKCOMMONDATAMODEL_EXPORT vtkBiQuadraticQuadraticHexahedron : public vtkNonLinearCell 81 { 82 public: 83 static vtkBiQuadraticQuadraticHexahedron* New(); 84 vtkTypeMacro(vtkBiQuadraticQuadraticHexahedron, vtkNonLinearCell); 85 void PrintSelf(ostream& os, vtkIndent indent) override; 86 87 ///@{ 88 /** 89 * Implement the vtkCell API. See the vtkCell API for descriptions 90 * of these methods. 91 */ GetCellType()92 int GetCellType() override { return VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON; } GetCellDimension()93 int GetCellDimension() override { return 3; } GetNumberOfEdges()94 int GetNumberOfEdges() override { return 12; } GetNumberOfFaces()95 int GetNumberOfFaces() override { return 6; } 96 vtkCell* GetEdge(int) override; 97 vtkCell* GetFace(int) override; 98 ///@} 99 100 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override; 101 void Contour(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator, 102 vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd, 103 vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override; 104 int EvaluatePosition(const double x[3], double closestPoint[3], int& subId, double pcoords[3], 105 double& dist2, double weights[]) override; 106 void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override; 107 int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override; 108 void Derivatives( 109 int subId, const double pcoords[3], const double* values, int dim, double* derivs) override; 110 double* GetParametricCoords() override; 111 112 /** 113 * Clip this biquadratic hexahedron using scalar value provided. Like 114 * contouring, except that it cuts the hex to produce linear 115 * tetrahedron. 116 */ 117 void Clip(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator, 118 vtkCellArray* tetras, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd, 119 vtkIdType cellId, vtkCellData* outCd, int insideOut) override; 120 121 /** 122 * Line-edge intersection. Intersection has to occur within [0,1] parametric 123 * coordinates and with specified tolerance. 124 */ 125 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3], 126 double pcoords[3], int& subId) override; 127 128 static void InterpolationFunctions(const double pcoords[3], double weights[24]); 129 static void InterpolationDerivs(const double pcoords[3], double derivs[72]); 130 ///@{ 131 /** 132 * Compute the interpolation functions/derivatives 133 * (aka shape functions/derivatives) 134 */ InterpolateFunctions(const double pcoords[3],double weights[24])135 void InterpolateFunctions(const double pcoords[3], double weights[24]) override 136 { 137 vtkBiQuadraticQuadraticHexahedron::InterpolationFunctions(pcoords, weights); 138 } InterpolateDerivs(const double pcoords[3],double derivs[72])139 void InterpolateDerivs(const double pcoords[3], double derivs[72]) override 140 { 141 vtkBiQuadraticQuadraticHexahedron::InterpolationDerivs(pcoords, derivs); 142 } 143 ///@} 144 ///@{ 145 /** 146 * Return the ids of the vertices defining edge/face (`edgeId`/`faceId'). 147 * Ids are related to the cell, not to the dataset. 148 * 149 * @note The return type changed. It used to be int*, it is now const vtkIdType*. 150 * This is so ids are unified between vtkCell and vtkPoints. 151 */ 152 static const vtkIdType* GetEdgeArray(vtkIdType edgeId); 153 static const vtkIdType* GetFaceArray(vtkIdType faceId); 154 ///@} 155 156 /** 157 * Given parametric coordinates compute inverse Jacobian transformation 158 * matrix. Returns 9 elements of 3x3 inverse Jacobian plus interpolation 159 * function derivatives. 160 */ 161 void JacobianInverse(const double pcoords[3], double** inverse, double derivs[72]); 162 163 protected: 164 vtkBiQuadraticQuadraticHexahedron(); 165 ~vtkBiQuadraticQuadraticHexahedron() override; 166 167 vtkQuadraticEdge* Edge; 168 vtkQuadraticQuad* Face; 169 vtkBiQuadraticQuad* BiQuadFace; 170 vtkHexahedron* Hex; 171 vtkPointData* PointData; 172 vtkCellData* CellData; 173 vtkDoubleArray* CellScalars; 174 vtkDoubleArray* Scalars; 175 176 void Subdivide( 177 vtkPointData* inPd, vtkCellData* inCd, vtkIdType cellId, vtkDataArray* cellScalars); 178 179 private: 180 vtkBiQuadraticQuadraticHexahedron(const vtkBiQuadraticQuadraticHexahedron&) = delete; 181 void operator=(const vtkBiQuadraticQuadraticHexahedron&) = delete; 182 }; 183 184 #endif 185