00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00027 #ifndef __vtkPolygon_h
00028 #define __vtkPolygon_h
00029
00030 #include "vtkCell.h"
00031
00032 class vtkDoubleArray;
00033 class vtkIdTypeArray;
00034 class vtkLine;
00035 class vtkPoints;
00036 class vtkQuad;
00037 class vtkTriangle;
00038
00039 class VTK_FILTERING_EXPORT vtkPolygon : public vtkCell
00040 {
00041 public:
00042 static vtkPolygon *New();
00043 vtkTypeRevisionMacro(vtkPolygon,vtkCell);
00044 void PrintSelf(ostream& os, vtkIndent indent);
00045
00047
00048 int GetCellType() {return VTK_POLYGON;};
00049 int GetCellDimension() {return 2;};
00050 int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00051 int GetNumberOfFaces() {return 0;};
00052 vtkCell *GetEdge(int edgeId);
00053 vtkCell *GetFace(int) {return 0;};
00054 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00055 void Contour(double value, vtkDataArray *cellScalars,
00056 vtkPointLocator *locator,vtkCellArray *verts,
00057 vtkCellArray *lines, vtkCellArray *polys,
00058 vtkPointData *inPd, vtkPointData *outPd,
00059 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00060 void Clip(double value, vtkDataArray *cellScalars,
00061 vtkPointLocator *locator, vtkCellArray *tris,
00062 vtkPointData *inPd, vtkPointData *outPd,
00063 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00064 int insideOut);
00065 int EvaluatePosition(double x[3], double* closestPoint,
00066 int& subId, double pcoords[3],
00067 double& dist2, double *weights);
00068 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00069 double *weights);
00070 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00071 double x[3], double pcoords[3], int& subId);
00072 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00073 void Derivatives(int subId, double pcoords[3], double *values,
00074 int dim, double *derivs);
00075 int IsPrimaryCell() {return 0;}
00077
00079
00081 virtual void InterpolateFunctions(double pcoords[3], double *sf);
00082 virtual void InterpolateDerivs(double pcoords[3], double *derivs);
00084
00086
00087 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00088 double n[3]);
00089 static void ComputeNormal(vtkPoints *p, double n[3]);
00090 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
00092
00096 static void ComputeNormal(int numPts, double *pts, double n[3]);
00097
00099
00100 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
00101 double centroid[3]);
00103
00107 VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
00108
00110
00113 static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
00114 double normal[3]);
00116
00118
00123 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00124 double p20[3], double &l20, double n[3]);
00126
00128
00132 static int PointInPolygon(double x[3], int numPts, double *pts,
00133 double bounds[6], double n[3]);
00135
00140 int Triangulate(vtkIdList *outTris);
00141
00144 int NonDegenerateTriangulate(vtkIdList *outTris);
00145
00147
00150 static double DistanceToPolygon(double x[3], int numPts, double *pts,
00151 double bounds[6], double closest[3]);
00153
00155
00161 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00162 int npts2, double *pts2,
00163 double bounds2[3], double tol,
00164 double x[3]);
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
00178 double tol, double p0[3], double p1[3]);
00179
00180 protected:
00181 vtkPolygon();
00182 ~vtkPolygon();
00183
00184
00185 double Tolerance;
00186 int SuccessfulTriangulation;
00187 double Normal[3];
00188 vtkIdList *Tris;
00189 vtkTriangle *Triangle;
00190 vtkQuad *Quad;
00191 vtkDoubleArray *TriScalars;
00192 vtkLine *Line;
00193
00194
00199 int EarCutTriangulation();
00200
00201 private:
00202 vtkPolygon(const vtkPolygon&);
00203 void operator=(const vtkPolygon&);
00204 };
00205
00206 #endif
00207