Blender V2.61 - r43446
|
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_BSPNODE_H 00034 #define BOP_BSPNODE_H 00035 00036 #include "MT_Plane3.h" 00037 #include "BOP_Tag.h" 00038 #include "BOP_Face.h" 00039 00040 typedef std::vector<MT_Point3> BOP_BSPPoints; 00041 typedef std::vector<MT_Point3>::const_iterator BOP_IT_BSPPoints; 00042 00043 class BOP_BSPNode 00044 { 00045 protected: 00046 BOP_BSPNode* m_inChild; 00047 BOP_BSPNode* m_outChild; 00048 MT_Plane3 m_plane; 00049 unsigned int m_deep; 00050 00051 public: 00052 // Construction methods 00053 BOP_BSPNode(const MT_Plane3& plane); 00054 ~BOP_BSPNode(); 00055 unsigned int addFace(const BOP_BSPPoints& pts, 00056 const MT_Plane3& plane); 00057 BOP_TAG classifyFace(const MT_Point3& p1, 00058 const MT_Point3& p2, 00059 const MT_Point3& p3, 00060 const MT_Plane3& plane) const; 00061 BOP_TAG simplifiedClassifyFace(const MT_Point3& p1, 00062 const MT_Point3& p2, 00063 const MT_Point3& p3, 00064 const MT_Plane3& plane) const; 00065 00066 protected: 00067 BOP_TAG testPoint(const MT_Point3& p) const; 00068 BOP_TAG classifyFaceIN(const MT_Point3& p1, 00069 const MT_Point3& p2, 00070 const MT_Point3& p3, 00071 const MT_Plane3& plane) const; 00072 BOP_TAG classifyFaceOUT(const MT_Point3& p1, 00073 const MT_Point3& p2, 00074 const MT_Point3& p3, 00075 const MT_Plane3& plane) const; 00076 BOP_TAG simplifiedClassifyFaceIN(const MT_Point3& p1, 00077 const MT_Point3& p2, 00078 const MT_Point3& p3, 00079 const MT_Plane3& plane) const; 00080 BOP_TAG simplifiedClassifyFaceOUT(const MT_Point3& p1, 00081 const MT_Point3& p2, 00082 const MT_Point3& p3, 00083 const MT_Plane3& plane) const; 00084 bool hasSameOrientation(const MT_Plane3& plane) const; 00085 int compChildren() const; 00086 int splitTriangle(MT_Point3* res, 00087 const MT_Plane3& plane, 00088 const MT_Point3& p1, 00089 const MT_Point3& p2, 00090 const MT_Point3& p3, 00091 const BOP_TAG tag) const; 00092 00093 public: 00094 // Inline acces methods 00095 inline void setInChild(BOP_BSPNode* inChild) { m_inChild=inChild; }; 00096 inline void setOutChild(BOP_BSPNode* outChild) { m_outChild=outChild; }; 00097 inline BOP_BSPNode* getInChild() { return m_inChild; }; 00098 inline BOP_BSPNode* getOutChild() { return m_outChild; }; 00099 inline bool isLeaf() const { return !m_inChild && !m_outChild; }; 00100 inline void setPlane(const MT_Plane3& plane) {m_plane=plane;}; 00101 inline MT_Plane3& getPlane() { return m_plane; }; 00102 00103 inline unsigned int getDeep() const {return m_deep;}; 00104 void print(unsigned int deep); 00105 }; 00106 00107 #endif