Blender V2.61 - r43446

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 
00044 class BOP_Face;
00045 
00046 typedef std::vector<BOP_Face *> BOP_Faces;
00047 typedef std::vector<BOP_Face *>::iterator BOP_IT_Faces;
00048 
00049 class BOP_Face
00050 {
00051 private:
00052     BOP_TAG      m_tag;
00053     MT_Plane3    m_plane;
00054     BOP_Index    m_originalFace;
00055 
00056 protected:
00057     BOP_Index    m_indexs[4];
00058     unsigned int m_size;
00059     unsigned int m_split;
00060     BOP_BBox     *m_bbox;
00061 
00062 public:
00063     BOP_Face(MT_Plane3 plane, BOP_Index originalFace);
00064     virtual ~BOP_Face(){if (m_bbox) delete m_bbox;};
00065     inline MT_Plane3 getPlane() const {return m_plane;};
00066     inline void setPlane(const MT_Plane3 plane) {m_plane = plane;};
00067     inline BOP_TAG getTAG() const {return m_tag;};
00068     inline void setTAG(const BOP_TAG t) {m_tag = t;};
00069     inline BOP_Index getOriginalFace() const {return m_originalFace;};
00070     inline void setOriginalFace(const BOP_Index originalFace) {m_originalFace=originalFace;};
00071     inline BOP_Index getVertex(unsigned int i) const {return m_indexs[i];};
00072     inline void setVertex(const BOP_Index idx, const BOP_Index i) {m_indexs[idx]=i;};
00073     inline unsigned int getSplit() const {return m_split;};
00074     inline void setSplit(const unsigned int i) {m_split=i;};
00075 
00076     void invert();
00077     inline void setBBox(const MT_Point3& p1,const MT_Point3& p2,const MT_Point3& p3) {
00078     m_bbox = new BOP_BBox(p1, p2, p3);};
00079     inline BOP_BBox *getBBox() {return m_bbox;};
00080     inline void freeBBox(){if (m_bbox!=NULL) {delete m_bbox; m_bbox=NULL;} };
00081 
00082     inline unsigned int size() const {return m_size;};
00083     
00084     virtual bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e) = 0;
00085     virtual void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex) = 0;
00086     virtual bool containsVertex(BOP_Index v) = 0;
00087         
00088 #ifdef BOP_DEBUG
00089     friend ostream &operator<<(ostream &stream, BOP_Face *f);
00090 #endif
00091 };
00092 
00093 class BOP_Face3: public BOP_Face 
00094 {
00095 public:
00096     BOP_Face3(BOP_Index i, BOP_Index j, BOP_Index k, MT_Plane3 p, BOP_Index originalFace);
00097     bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e);
00098     void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex);
00099     bool containsVertex(BOP_Index v);
00100 
00101     bool getNeighbours(BOP_Index v, BOP_Index &prev, BOP_Index &next);
00102     bool getPreviousVertex(BOP_Index v, BOP_Index &w);
00103     bool getNextVertex(BOP_Index v, BOP_Index &w);
00104 };
00105 
00106 class BOP_Face4: public BOP_Face 
00107 {
00108 public:
00109     BOP_Face4(BOP_Index i, BOP_Index j, BOP_Index k, BOP_Index l, MT_Plane3 p, BOP_Index originalFace);
00110     bool getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e);
00111     void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex);
00112     bool containsVertex(BOP_Index v);
00113 
00114     bool getNeighbours(BOP_Index v, BOP_Index &prev, BOP_Index &next, BOP_Index &opp);
00115     bool getPreviousVertex(BOP_Index v, BOP_Index &w);
00116     bool getNextVertex(BOP_Index v, BOP_Index &w);
00117     bool getOppositeVertex(BOP_Index v, BOP_Index &w);
00118 };
00119 
00120 #endif