1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkQuad.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 // .NAME vtkQuad - a cell that represents a 2D quadrilateral
16 // .SECTION Description
17 // vtkQuad is a concrete implementation of vtkCell to represent a 2D
18 // quadrilateral. vtkQuad is defined by the four points (0,1,2,3) in
19 // counterclockwise order. vtkQuad uses the standard isoparametric
20 // interpolation functions for a linear quadrilateral.
21 
22 #ifndef vtkQuad_h
23 #define vtkQuad_h
24 
25 #include "vtkCommonDataModelModule.h" // For export macro
26 #include "vtkCell.h"
27 
28 class vtkLine;
29 class vtkTriangle;
30 class vtkIncrementalPointLocator;
31 
32 class VTKCOMMONDATAMODEL_EXPORT vtkQuad : public vtkCell
33 {
34 public:
35   static vtkQuad *New();
36   vtkTypeMacro(vtkQuad,vtkCell);
37   void PrintSelf(ostream& os, vtkIndent indent);
38 
39   // Description:
40   // See the vtkCell API for descriptions of these methods.
GetCellType()41   int GetCellType() {return VTK_QUAD;};
GetCellDimension()42   int GetCellDimension() {return 2;};
GetNumberOfEdges()43   int GetNumberOfEdges() {return 4;};
GetNumberOfFaces()44   int GetNumberOfFaces() {return 0;};
45   vtkCell *GetEdge(int edgeId);
GetFace(int)46   vtkCell *GetFace(int) {return 0;};
47   int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
48   void Contour(double value, vtkDataArray *cellScalars,
49                vtkIncrementalPointLocator *locator, vtkCellArray *verts,
50                vtkCellArray *lines, vtkCellArray *polys,
51                vtkPointData *inPd, vtkPointData *outPd,
52                vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
53   int EvaluatePosition(double x[3], double* closestPoint,
54                        int& subId, double pcoords[3],
55                        double& dist2, double *weights);
56   void EvaluateLocation(int& subId, double pcoords[3], double x[3],
57                         double *weights);
58   int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
59                         double x[3], double pcoords[3], int& subId);
60   int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
61   void Derivatives(int subId, double pcoords[3], double *values,
62                    int dim, double *derivs);
63   virtual double *GetParametricCoords();
64 
65   // Description:
66   // Return the center of the triangle in parametric coordinates.
67   int GetParametricCenter(double pcoords[3]);
68 
69   // Description:
70   // Clip this quad using scalar value provided. Like contouring, except
71   // that it cuts the quad to produce other quads and/or triangles.
72   void Clip(double value, vtkDataArray *cellScalars,
73             vtkIncrementalPointLocator *locator, vtkCellArray *polys,
74             vtkPointData *inPd, vtkPointData *outPd,
75             vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
76             int insideOut);
77 
78   // Description:
79   // @deprecated Replaced by vtkQuad::InterpolateFunctions as of VTK 5.2
80   static void InterpolationFunctions(double pcoords[3], double sf[4]);
81   // Description:
82   // @deprecated Replaced by vtkQuad::InterpolateDerivs as of VTK 5.2
83   static void InterpolationDerivs(double pcoords[3], double derivs[8]);
84   // Description:
85   // Compute the interpolation functions/derivatives
86   // (aka shape functions/derivatives)
InterpolateFunctions(double pcoords[3],double sf[4])87   virtual void InterpolateFunctions(double pcoords[3], double sf[4])
88     {
89     vtkQuad::InterpolationFunctions(pcoords,sf);
90     }
InterpolateDerivs(double pcoords[3],double derivs[8])91   virtual void InterpolateDerivs(double pcoords[3], double derivs[8])
92     {
93     vtkQuad::InterpolationDerivs(pcoords,derivs);
94     }
95 
96   // Description:
97   // Return the ids of the vertices defining edge (`edgeId`).
98   // Ids are related to the cell, not to the dataset.
99   int *GetEdgeArray(int edgeId);
100 
101 protected:
102   vtkQuad();
103   ~vtkQuad();
104 
105   vtkLine     *Line;
106   vtkTriangle *Triangle;
107 
108 private:
109   vtkQuad(const vtkQuad&);  // Not implemented.
110   void operator=(const vtkQuad&);  // Not implemented.
111 };
112 //----------------------------------------------------------------------------
GetParametricCenter(double pcoords[3])113 inline int vtkQuad::GetParametricCenter(double pcoords[3])
114 {
115   pcoords[0] = pcoords[1] = 0.5;
116   pcoords[2] = 0.0;
117   return 0;
118 }
119 
120 
121 #endif
122 
123 
124