1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkBiQuadraticQuad.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   vtkBiQuadraticQuad
17  * @brief   cell represents a parabolic, 9-node
18  * isoparametric quad
19  *
20  * vtkQuadraticQuad is a concrete implementation of vtkNonLinearCell to
21  * represent a two-dimensional, 9-node isoparametric parabolic quadrilateral
22  * element with a Centerpoint. The interpolation is the standard finite
23  * element, quadratic isoparametric shape function. The cell includes a
24  * mid-edge node for each of the four edges of the cell and a center node at
25  * the surface. The ordering of the eight points defining the cell are point
26  * ids (0-3,4-8) where ids 0-3 define the four corner vertices of the quad;
27  * ids 4-7 define the midedge nodes (0,1), (1,2), (2,3), (3,0) and 8 define
28  * the face center node.
29  *
30  * @sa
31  * vtkQuadraticEdge vtkQuadraticTriangle vtkQuadraticTetra
32  * vtkQuadraticHexahedron vtkQuadraticWedge vtkQuadraticPyramid
33  * vtkQuadraticQuad
34  *
35  * @par Thanks:
36  * Thanks to Soeren Gebbert who developed this class and
37  * integrated it into VTK 5.0.
38  */
39 
40 #ifndef vtkBiQuadraticQuad_h
41 #define vtkBiQuadraticQuad_h
42 
43 #include "vtkCommonDataModelModule.h" // For export macro
44 #include "vtkNonLinearCell.h"
45 
46 class vtkQuadraticEdge;
47 class vtkQuad;
48 class vtkTriangle;
49 class vtkDoubleArray;
50 
51 class VTKCOMMONDATAMODEL_EXPORT vtkBiQuadraticQuad : public vtkNonLinearCell
52 {
53 public:
54   static vtkBiQuadraticQuad* New();
55   vtkTypeMacro(vtkBiQuadraticQuad, vtkNonLinearCell);
56   void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58   /**
59    * Implement the vtkCell API. See the vtkCell API for descriptions
60    * of these methods.
61    */
GetCellType()62   int GetCellType() override { return VTK_BIQUADRATIC_QUAD; }
GetCellDimension()63   int GetCellDimension() override { return 2; }
GetNumberOfEdges()64   int GetNumberOfEdges() override { return 4; }
GetNumberOfFaces()65   int GetNumberOfFaces() override { return 0; }
66   vtkCell* GetEdge(int) override;
GetFace(int)67   vtkCell* GetFace(int) override { return nullptr; }
68 
69   int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
70   int EvaluatePosition(const double x[3], double* closestPoint, int& subId, double pcoords[3],
71     double& dist2, double* weights) override;
72   void EvaluateLocation(int& subId, const double pcoords[3], double x[3], double* weights) override;
73   int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override;
74   void Derivatives(
75     int subId, const double pcoords[3], const double* values, int dim, double* derivs) override;
76   double* GetParametricCoords() override;
77 
78   void Contour(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
79     vtkCellArray* verts, vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd,
80     vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
81 
82   /**
83    * Clip this biquadratic quad using scalar value provided. Like contouring,
84    * except that it cuts the twi quads to produce linear triangles.
85    */
86   void Clip(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
87     vtkCellArray* polys, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd,
88     vtkIdType cellId, vtkCellData* outCd, int insideOut) override;
89 
90   /**
91    * Line-edge intersection. Intersection has to occur within [0,1] parametric
92    * coordinates and with specified tolerance.
93    */
94   int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
95     double pcoords[3], int& subId) override;
96 
97   /**
98    * Return the center of the pyramid in parametric coordinates.
99    */
100   int GetParametricCenter(double pcoords[3]) override;
101 
InterpolateFunctions(const double pcoords[3],double weights[9])102   void InterpolateFunctions(const double pcoords[3], double weights[9]) override
103   {
104     vtkBiQuadraticQuad::InterpolationFunctionsPrivate(pcoords, weights);
105   }
InterpolateDerivs(const double pcoords[3],double derivs[18])106   void InterpolateDerivs(const double pcoords[3], double derivs[18]) override
107   {
108     vtkBiQuadraticQuad::InterpolationDerivsPrivate(pcoords, derivs);
109   }
110 
111 protected:
112   vtkBiQuadraticQuad();
113   ~vtkBiQuadraticQuad() override;
114 
115   vtkQuadraticEdge* Edge;
116   vtkQuad* Quad;
117   vtkTriangle* Triangle;
118   vtkDoubleArray* Scalars;
119 
120 private:
121   vtkBiQuadraticQuad(const vtkBiQuadraticQuad&) = delete;
122   void operator=(const vtkBiQuadraticQuad&) = delete;
123 
124   static void InterpolationFunctionsPrivate(const double pcoords[3], double weights[9]);
125   static void InterpolationDerivsPrivate(const double pcoords[3], double derivs[18]);
126 };
127 //----------------------------------------------------------------------------
GetParametricCenter(double pcoords[3])128 inline int vtkBiQuadraticQuad::GetParametricCenter(double pcoords[3])
129 {
130   pcoords[0] = pcoords[1] = 0.5;
131   pcoords[2] = 0.;
132   return 0;
133 }
134 
135 #endif
136