source: trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h @ 263

Revision 263, 1.7 KB checked in by mattausch, 19 years ago (diff)
Line 
1#ifndef _Polygon3_h__
2#define _Polygon3_h__
3
4
5//#include <iostream>
6//#include <math.h>
7//#include "common.h"
8#include "Containers.h"
9#include "Mesh.h"
10
11class Polygon3;
12class Plane3;
13class Face;
14
15
16/** Class representing a general planar polygon in 3d.
17*/
18class Polygon3
19{
20public:
21        Polygon3();
22        Polygon3(const VertexContainer &vertices);
23
24        /** Copies all the vertices of the face.
25        */
26        Polygon3(Face *face, Mesh *parent);
27       
28        /** Returns supporting plane of this polygon.
29        */
30        Plane3 GetSupportingPlane() const;
31
32        /** Splits polygon.
33                @param partition the split plane
34                @param front the front polygon
35                @param back the back polygon
36                @param splits number of splits
37        */
38        void Split(Plane3 *partition, Polygon3 *front, Polygon3 *back, int &splits);
39
40        enum {BACK_SIDE, FRONT_SIDE, SPLIT, COINCIDENT};
41
42        /** Classify polygon with respect to the plane.
43            @returns one of BACK_SIDE, FRONT_SIDE, SPLIT, COINCIDENT
44        */
45        int ClassifyPlane(const Plane3 &plane) const;
46
47        /** Side of the polygon with respect to the plane.
48                @returns 1 if on front side, -1 if on back side, 0 else.
49        */
50        int Side(const Plane3 &plane) const;
51
52        /** Scales the polygon about its center
53        */
54        void Scale(const float scale);
55       
56        /** Computes the center of mass of the polygon
57         */
58        Vector3 Center() const;
59
60               
61        /// vertices are connected in counterclockwise order.
62        VertexContainer mVertices;
63
64        /// we can also store materials with polygons
65        Material *mMaterial;
66
67        static int mLeastSplitTable[4];
68        static int mBalancedTreeTable[4];
69};
70
71// Overload << operator for C++-style output
72inline ostream&
73operator<< (ostream &s, const Polygon3 &A)
74{
75        VertexContainer::const_iterator it;
76
77        s << "Polygon:\n";
78       
79        for (it = A.mVertices.begin(); it != A.mVertices.end(); ++it)
80                s << *it << endl;
81       
82        return s;
83}
84
85
86#endif
Note: See TracBrowser for help on using the repository browser.