Blender  V2.59
SG_BBox.h
Go to the documentation of this file.
00001 /*
00002  * $Id: SG_BBox.h 35082 2011-02-22 19:30:37Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00035 #ifndef __SG_BBOX_H__
00036 #define __SG_BBOX_H__
00037  
00038 #include "MT_Scalar.h"
00039 #include "MT_Point3.h"
00040 #include "MT_Vector3.h"
00041 #include "MT_Transform.h"
00042 
00043 #include <vector> 
00044 
00045 #ifdef WITH_CXX_GUARDEDALLOC
00046 #include "MEM_guardedalloc.h"
00047 #endif
00048 
00049 class SG_Node;
00050 
00056 class SG_BBox
00057 {
00058         MT_Point3 m_min;
00059         MT_Point3 m_max;
00060 public:
00061         typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
00062         SG_BBox();
00063         SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
00064         SG_BBox(const SG_BBox &other, const MT_Transform &world);
00065         SG_BBox(const SG_BBox &other);
00066         ~SG_BBox();
00067 
00071         SG_BBox& operator +=(const MT_Point3 &point);
00075         SG_BBox& operator +=(const SG_BBox &bbox);
00076         
00077         SG_BBox operator + (const SG_BBox &bbox2) const;
00078 #if 0
00079 
00082         void translate(const MT_Vector3 &dx);
00086         void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0., 0., 0.));
00087 #endif
00088         SG_BBox transform(const MT_Transform &world) const;
00092         MT_Scalar volume() const;
00093         
00097         bool inside(const MT_Point3 &point) const;
00098         
00102         bool inside(const SG_BBox &other) const;
00103 
00107         bool outside(const SG_BBox &other) const;
00108         
00112         bool intersects(const SG_BBox &other) const;
00113         
00117         intersect test(const SG_BBox &other) const;
00118         
00124         void get(MT_Point3 *box, const MT_Transform &world) const;
00131         void getaa(MT_Point3 *box, const MT_Transform &world) const;
00132         
00133         void getmm(MT_Point3 *box, const MT_Transform &world) const;
00134 
00135         void split(SG_BBox &left, SG_BBox &right) const;
00136         
00137         friend class SG_Tree;
00138 
00139 
00140 #ifdef WITH_CXX_GUARDEDALLOC
00141 public:
00142         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_BBox"); }
00143         void operator delete( void *mem ) { MEM_freeN(mem); }
00144 #endif
00145 };
00146 
00147 #endif /* __SG_BBOX_H__ */