#ifndef _Polygon3_h__ #define _Polygon3_h__ //#include //#include //#include "common.h" #include "Containers.h" #include "Mesh.h" class Polygon3; class Plane3; class Face; /** Container storing polygons used during BSP tree construction */ typedef vector PolygonContainer; /** Class representing a general planar polygon in 3d. */ class Polygon3 { public: Polygon3(); Polygon3(const VertexContainer &vertices); /** Copies all the vertices of the face. */ Polygon3(Face *face, Mesh *parent); /** Returns supporting plane of this polygon. */ Plane3 GetSupportingPlane() const; /** Splits polygon. @param partition the split plane @param front the front polygon @param back the back polygon @param splits number of splits */ void Split(Plane3 *partition, Polygon3 *front, Polygon3 *back, int &splits); enum {BACK_SIDE, FRONT_SIDE, SPLIT, COINCIDENT}; /** Classify polygon with respect to the plane. @returns one of BACK_SIDE, FRONT_SIDE, SPLIT, COINCIDENT */ int ClassifyPlane(const Plane3 &plane) const; /** Side of the polygon with respect to the plane. @returns 1 if on front side, -1 if on back side, 0 else. */ int Side(const Plane3 &plane) const; /** Deletes all polygons om the queue. */ static void DeletePolygons(PolygonContainer *polys); /// vertices are connected in counterclockwise order. VertexContainer mVertices; }; // Overload << operator for C++-style output inline ostream& operator<< (ostream &s, const Polygon3 &A) { VertexContainer::const_iterator it; s << "Polygon:\n"; for (it = A.mVertices.begin(); it != A.mVertices.end(); ++it) s << *it << endl; return s; } #endif