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

Common/vtkPolygon.h

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