00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00030 #ifndef __vtkPolygon_h
00031 #define __vtkPolygon_h
00032
00033 #include "vtkCell.h"
00034
00035 class vtkDoubleArray;
00036 class vtkLine;
00037 class vtkPoints;
00038 class vtkQuad;
00039 class vtkTriangle;
00040
00041 class VTK_COMMON_EXPORT vtkPolygon : public vtkCell
00042 {
00043 public:
00044 static vtkPolygon *New();
00045 vtkTypeRevisionMacro(vtkPolygon,vtkCell);
00046
00048
00049 int GetCellType() {return VTK_POLYGON;};
00050 int GetCellDimension() {return 2;};
00051 int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00052 int GetNumberOfFaces() {return 0;};
00053 vtkCell *GetEdge(int edgeId);
00054 vtkCell *GetFace(int) {return 0;};
00055 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00056 void Contour(double value, vtkDataArray *cellScalars,
00057 vtkPointLocator *locator,vtkCellArray *verts,
00058 vtkCellArray *lines, vtkCellArray *polys,
00059 vtkPointData *inPd, vtkPointData *outPd,
00060 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00061 void Clip(double value, vtkDataArray *cellScalars,
00062 vtkPointLocator *locator, vtkCellArray *tris,
00063 vtkPointData *inPd, vtkPointData *outPd,
00064 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00065 int insideOut);
00066 int EvaluatePosition(double x[3], double* closestPoint,
00067 int& subId, double pcoords[3],
00068 double& dist2, double *weights);
00069 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00070 double *weights);
00071 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00072 double x[3], double pcoords[3], int& subId);
00073 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00074 void Derivatives(int subId, double pcoords[3], double *values,
00075 int dim, double *derivs);
00076 int IsPrimaryCell() {return 0;}
00078
00080
00081 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00082 double n[3]);
00083 static void ComputeNormal(vtkPoints *p, double n[3]);
00085
00089 static void ComputeNormal(int numPts, double *pts, double n[3]);
00090
00092 void ComputeWeights(double x[3], double *weights);
00093
00094
00096
00101 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00102 double p20[3], double &l20, double n[3]);
00104
00106
00110 static int PointInPolygon(double x[3], int numPts, double *pts,
00111 double bounds[6], double n[3]);
00113
00118 int Triangulate(vtkIdList *outTris);
00119
00121
00127 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00128 int npts2, double *pts2,
00129 double bounds2[3], double tol,
00130 double x[3]);
00132
00133 protected:
00134 vtkPolygon();
00135 ~vtkPolygon();
00136
00137
00138 double Tolerance;
00139 int SuccessfulTriangulation;
00140 double Normal[3];
00141 vtkIdList *Tris;
00142 vtkTriangle *Triangle;
00143 vtkQuad *Quad;
00144 vtkDoubleArray *TriScalars;
00145 vtkLine *Line;
00146
00147
00152 int EarCutTriangulation();
00153
00154 private:
00155 vtkPolygon(const vtkPolygon&);
00156 void operator=(const vtkPolygon&);
00157 };
00158
00159 #endif
00160