Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkPolygon.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPolygon.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00040 #ifndef __vtkPolygon_h
00041 #define __vtkPolygon_h
00042 
00043 #include "vtkCell.h"
00044 
00045 class vtkDoubleArray;
00046 class vtkLine;
00047 class vtkPoints;
00048 class vtkQuad;
00049 class vtkTriangle;
00050 
00051 class VTK_FILTERING_EXPORT vtkPolygon : public vtkCell
00052 {
00053 public:
00054   static vtkPolygon *New();
00055   vtkTypeRevisionMacro(vtkPolygon,vtkCell);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00060   int GetCellType() {return VTK_POLYGON;};
00061   int GetCellDimension() {return 2;};
00062   int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00063   int GetNumberOfFaces() {return 0;};
00064   vtkCell *GetEdge(int edgeId);
00065   vtkCell *GetFace(int) {return 0;};
00066   int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00067   void Contour(double value, vtkDataArray *cellScalars, 
00068                vtkPointLocator *locator,vtkCellArray *verts, 
00069                vtkCellArray *lines, vtkCellArray *polys,
00070                vtkPointData *inPd, vtkPointData *outPd,
00071                vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00072   void Clip(double value, vtkDataArray *cellScalars, 
00073             vtkPointLocator *locator, vtkCellArray *tris,
00074             vtkPointData *inPd, vtkPointData *outPd,
00075             vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00076             int insideOut);
00077   int EvaluatePosition(double x[3], double* closestPoint,
00078                        int& subId, double pcoords[3],
00079                        double& dist2, double *weights);
00080   void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00081                         double *weights);
00082   int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00083                         double x[3], double pcoords[3], int& subId);
00084   int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00085   void Derivatives(int subId, double pcoords[3], double *values, 
00086                    int dim, double *derivs);
00087   int IsPrimaryCell() {return 0;}
00089 
00091 
00092   static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00093                             double n[3]);
00094   static void ComputeNormal(vtkPoints *p, double n[3]);
00096   
00100   static void ComputeNormal(int numPts, double *pts, double n[3]);
00101 
00103   void ComputeWeights(double x[3], double *weights);
00104 
00105 
00107 
00112   int ParameterizePolygon(double p0[3], double p10[3], double &l10, 
00113                           double p20[3], double &l20, double n[3]);
00115   
00117 
00121   static int PointInPolygon(double x[3], int numPts, double *pts, 
00122                             double bounds[6], double n[3]);  
00124 
00129   int Triangulate(vtkIdList *outTris);
00130   
00132 
00138   static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00139                                          int npts2, double *pts2, 
00140                                          double bounds2[3], double tol,
00141                                          double x[3]);
00143 
00144 protected:
00145   vtkPolygon();
00146   ~vtkPolygon();
00147 
00148   // variables used by instances of this class
00149   double   Tolerance; // Intersection tolerance
00150   int      SuccessfulTriangulation; // Stops recursive tri. if necessary
00151   double   Normal[3]; //polygon normal
00152   vtkIdList *Tris;
00153   vtkTriangle *Triangle;
00154   vtkQuad *Quad;
00155   vtkDoubleArray *TriScalars;
00156   vtkLine *Line;
00157 
00158   // Helper methods for triangulation------------------------------
00163   int EarCutTriangulation();
00164 
00165 private:
00166   vtkPolygon(const vtkPolygon&);  // Not implemented.
00167   void operator=(const vtkPolygon&);  // Not implemented.
00168 };
00169 
00170 #endif
00171