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