1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkLagrangeHexahedron.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 vtkLagrangeHexahedron
17 * @brief A 3D cell that represents an arbitrary order Lagrange hex
18 *
19 * vtkLagrangeHexahedron is a concrete implementation of vtkCell to represent a
20 * 3D hexahedron using Lagrange shape functions of user specified order.
21 *
22 * @sa
23 * vtkHexahedron
24 */
25
26 #ifndef vtkLagrangeHexahedron_h
27 #define vtkLagrangeHexahedron_h
28
29 #include "vtkCommonDataModelModule.h" // For export macro
30 #include "vtkNonLinearCell.h"
31 #include "vtkSmartPointer.h" // For member variable.
32 #include "vtkCellType.h" // For GetCellType.
33 #include "vtkNew.h" // For member variable.
34
35 class vtkCellData;
36 class vtkDoubleArray;
37 class vtkHexahedron;
38 class vtkIdList;
39 class vtkLagrangeCurve;
40 class vtkLagrangeInterpolation;
41 class vtkLagrangeQuadrilateral;
42 class vtkPointData;
43 class vtkPoints;
44 class vtkVector3d;
45 class vtkVector3i;
46
47 class VTKCOMMONDATAMODEL_EXPORT vtkLagrangeHexahedron : public vtkNonLinearCell
48 {
49 public:
50 static vtkLagrangeHexahedron* New();
51 vtkTypeMacro(vtkLagrangeHexahedron,vtkNonLinearCell);
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
GetCellType()54 int GetCellType() override { return VTK_LAGRANGE_HEXAHEDRON; }
GetCellDimension()55 int GetCellDimension() override { return 3; }
RequiresInitialization()56 int RequiresInitialization() override { return 1; }
GetNumberOfEdges()57 int GetNumberOfEdges() override { return 12; }
GetNumberOfFaces()58 int GetNumberOfFaces() override { return 6; }
59 vtkCell* GetEdge(int edgeId) override;
60 vtkCell* GetFace(int faceId) override;
61
62 void Initialize() override;
63
64 int CellBoundary(int subId, const double pcoords[3], vtkIdList* pts) override;
65 int EvaluatePosition(const double x[3], double closestPoint[3],
66 int& subId, double pcoords[3],
67 double& dist2, double weights[]) override;
68 void EvaluateLocation(
69 int& subId, const double pcoords[3], double x[3],
70 double* weights) override;
71 void Contour(
72 double value, vtkDataArray* cellScalars,
73 vtkIncrementalPointLocator* locator, vtkCellArray* verts,
74 vtkCellArray* lines, vtkCellArray* polys,
75 vtkPointData* inPd, vtkPointData* outPd,
76 vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd) override;
77 void Clip(
78 double value, vtkDataArray* cellScalars,
79 vtkIncrementalPointLocator* locator, vtkCellArray* polys,
80 vtkPointData* inPd, vtkPointData* outPd,
81 vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd,
82 int insideOut) override;
83 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
84 double x[3], double pcoords[3], int& subId) override;
85 int Triangulate(int index, vtkIdList* ptIds, vtkPoints* pts) override;
86 void Derivatives(
87 int subId, const double pcoords[3], const double* values,
88 int dim, double* derivs) override;
89 double* GetParametricCoords() override;
90 int GetParametricCenter(double center[3]) override;
91
92 double GetParametricDistance(const double pcoords[3]) override;
93
94 const int* GetOrder();
GetOrder(int i)95 int GetOrder(int i) { return this->GetOrder()[i]; }
96
97 void InterpolateFunctions(const double pcoords[3], double* weights) override;
98 void InterpolateDerivs(const double pcoords[3], double* derivs) override;
99
100 bool SubCellCoordinatesFromId(vtkVector3i& ijk, int subId);
101 bool SubCellCoordinatesFromId(int& i, int& j, int& k, int subId);
102 static int PointIndexFromIJK(int i, int j, int k, const int* order);
103 int PointIndexFromIJK(int i, int j, int k);
104 bool TransformApproxToCellParams(int subCell, double* pcoords);
105 bool TransformFaceToCellParams(int bdyFace, double* pcoords);
106
107 protected:
108 vtkLagrangeHexahedron();
109 ~vtkLagrangeHexahedron() override;
110
111 vtkHexahedron* GetApprox();
112 void PrepareApproxData(vtkPointData* pd, vtkCellData* cd, vtkIdType cellId, vtkDataArray* cellScalars);
113 vtkHexahedron* GetApproximateHex(
114 int subId, vtkDataArray* scalarsIn = nullptr, vtkDataArray* scalarsOut = nullptr);
115
116 int Order[4];
117 vtkSmartPointer<vtkPoints> PointParametricCoordinates;
118 vtkSmartPointer<vtkHexahedron> Approx;
119 vtkSmartPointer<vtkPointData> ApproxPD;
120 vtkSmartPointer<vtkCellData> ApproxCD;
121 vtkNew<vtkDoubleArray> CellScalars;
122 vtkNew<vtkDoubleArray> Scalars;
123 vtkNew<vtkPoints> TmpPts;
124 vtkNew<vtkIdList> TmpIds;
125 vtkNew<vtkLagrangeQuadrilateral> FaceCell;
126 vtkNew<vtkLagrangeCurve> EdgeCell;
127 vtkNew<vtkLagrangeInterpolation> Interp;
128
129 private:
130 vtkLagrangeHexahedron(const vtkLagrangeHexahedron&) = delete;
131 void operator=(const vtkLagrangeHexahedron&) = delete;
132 };
133
GetParametricCenter(double center[3])134 inline int vtkLagrangeHexahedron::GetParametricCenter(double center[3])
135 {
136 center[0] = center[1] = center[2] = 0.5;
137 return 0;
138 }
139
140 #endif // vtkLagrangeHexahedron_h
141