Blender  V2.59
BOP_Face.h
Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef BOP_FACE_H
00034 #define BOP_FACE_H
00035 
00036 #include "BOP_Tag.h"
00037 #include "MT_Plane3.h"
00038 #include "BOP_Indexs.h"
00039 #include "BOP_BBox.h"
00040 #include "BOP_Misc.h"
00041 #include <iostream>
00042 #include <vector>
00043 using namespace std;
00044 
00045 class BOP_Face;
00046 
00047 typedef vector<BOP_Face *> BOP_Faces;
00048 typedef vector<BOP_Face *>::iterator BOP_IT_Faces;
00049 
00050 class BOP_Face
00051 {
00052 private:
00053         BOP_TAG      m_tag;
00054         MT_Plane3    m_plane;
00055         BOP_Index    m_originalFace;
00056 
00057 protected:
00058         BOP_Index    m_indexs[4];
00059         unsigned int m_size;
00060         unsigned int m_split;
00061         BOP_BBox     *m_bbox;
00062 
00063 public:
00064         BOP_Face(MT_Plane3 plane, BOP_Index originalFace);
00065         virtual ~BOP_Face(){if (m_bbox) delete m_bbox;};
00066         inline MT_Plane3 getPlane() const {return m_plane;};
00067         inline void setPlane(const MT_Plane3 plane) {m_plane = plane;};
00068         inline BOP_TAG getTAG() const {return m_tag;};
00069         inline void setTAG(const BOP_TAG t) {m_tag = t;};
00070         inline BOP_Index getOriginalFace() const {return m_originalFace;};
00071         inline void setOriginalFace(const BOP_Index originalFace) {m_originalFace=originalFace;};
00072         inline BOP_Index getVertex(unsigned int i) const {return m_indexs[i];};
00073         inline void setVertex(const BOP_Index idx, const BOP_Index i) {m_indexs[idx]=i;};
00074         inline unsigned int getSplit() const {return m_split;};
00075         inline void setSplit(const unsigned int i) {m_split=i;};
00076 
00077         void invert();
00078         inline void setBBox(const MT_Point3& p1,const MT_Point3& p2,const MT_Point3& p3) {
00079     m_bbox = new BOP_BBox(p1, p2, p3);};
00080         inline BOP_BBox *getBBox() {return m_bbox;};
00081         inline void freeBBox(){if (m_bbox!=NULL) {delete m_bbox; m_bbox=NULL;} };
00082 
00083         inline unsigned int size() const {return m_size;};
00084         
00085         virtual bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e) = 0;
00086         virtual void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex) = 0;
00087         virtual bool containsVertex(BOP_Index v) = 0;
00088                 
00089 #ifdef BOP_DEBUG
00090         friend ostream &operator<<(ostream &stream, BOP_Face *f);
00091 #endif
00092 };
00093 
00094 class BOP_Face3: public BOP_Face 
00095 {
00096 public:
00097         BOP_Face3(BOP_Index i, BOP_Index j, BOP_Index k, MT_Plane3 p, BOP_Index originalFace);
00098         bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e);
00099         void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex);
00100         bool containsVertex(BOP_Index v);
00101 
00102         bool getNeighbours(BOP_Index v, BOP_Index &prev, BOP_Index &next);
00103         bool getPreviousVertex(BOP_Index v, BOP_Index &w);
00104         bool getNextVertex(BOP_Index v, BOP_Index &w);
00105 };
00106 
00107 class BOP_Face4: public BOP_Face 
00108 {
00109 public:
00110         BOP_Face4(BOP_Index i, BOP_Index j, BOP_Index k, BOP_Index l, MT_Plane3 p, BOP_Index originalFace);
00111         bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e);
00112         void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex);
00113         bool containsVertex(BOP_Index v);
00114 
00115         bool getNeighbours(BOP_Index v, BOP_Index &prev, BOP_Index &next, BOP_Index &opp);
00116         bool getPreviousVertex(BOP_Index v, BOP_Index &w);
00117         bool getNextVertex(BOP_Index v, BOP_Index &w);
00118         bool getOppositeVertex(BOP_Index v, BOP_Index &w);
00119 };
00120 
00121 #endif