Blender V2.61 - r43446

SG_BBox.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 __SG_BBOX_H__
00034 #define __SG_BBOX_H__
00035  
00036 #include "MT_Scalar.h"
00037 #include "MT_Point3.h"
00038 #include "MT_Vector3.h"
00039 #include "MT_Transform.h"
00040 
00041 #include <vector> 
00042 
00043 #ifdef WITH_CXX_GUARDEDALLOC
00044 #include "MEM_guardedalloc.h"
00045 #endif
00046 
00047 class SG_Node;
00048 
00054 class SG_BBox
00055 {
00056     MT_Point3 m_min;
00057     MT_Point3 m_max;
00058 public:
00059     typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
00060     SG_BBox();
00061     SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
00062     SG_BBox(const SG_BBox &other, const MT_Transform &world);
00063     SG_BBox(const SG_BBox &other);
00064     ~SG_BBox();
00065 
00069     SG_BBox& operator +=(const MT_Point3 &point);
00073     SG_BBox& operator +=(const SG_BBox &bbox);
00074     
00075     SG_BBox operator + (const SG_BBox &bbox2) const;
00076 #if 0
00077 
00080     void translate(const MT_Vector3 &dx);
00084     void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0., 0., 0.));
00085 #endif
00086     SG_BBox transform(const MT_Transform &world) const;
00090     MT_Scalar volume() const;
00091     
00095     bool inside(const MT_Point3 &point) const;
00096     
00100     bool inside(const SG_BBox &other) const;
00101 
00105     bool outside(const SG_BBox &other) const;
00106     
00110     bool intersects(const SG_BBox &other) const;
00111     
00115     intersect test(const SG_BBox &other) const;
00116     
00122     void get(MT_Point3 *box, const MT_Transform &world) const;
00129     void getaa(MT_Point3 *box, const MT_Transform &world) const;
00130     
00131     void getmm(MT_Point3 *box, const MT_Transform &world) const;
00132 
00133     void split(SG_BBox &left, SG_BBox &right) const;
00134     
00135     friend class SG_Tree;
00136 
00137 
00138 #ifdef WITH_CXX_GUARDEDALLOC
00139 public:
00140     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_BBox"); }
00141     void operator delete( void *mem ) { MEM_freeN(mem); }
00142 #endif
00143 };
00144 
00145 #endif /* __SG_BBOX_H__ */