00001 /* 00002 This file is part of the VRender library. 00003 Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) 00004 Version 1.0.0, released on June 27, 2005. 00005 00006 http://artis.imag.fr/Members/Cyril.Soler/VRender 00007 00008 VRender is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 VRender is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with VRender; if not, write to the Free Software Foundation, Inc., 00020 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00021 */ 00022 00023 /**************************************************************************** 00024 00025 Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. 00026 00027 This file is part of the QGLViewer library version 2.4.0. 00028 00029 http://www.libqglviewer.com - contact@libqglviewer.com 00030 00031 This file may be used under the terms of the GNU General Public License 00032 versions 2.0 or 3.0 as published by the Free Software Foundation and 00033 appearing in the LICENSE file included in the packaging of this file. 00034 In addition, as a special exception, Gilles Debunne gives you certain 00035 additional rights, described in the file GPL_EXCEPTION in this package. 00036 00037 libQGLViewer uses dual licensing. Commercial/proprietary software must 00038 purchase a libQGLViewer Commercial License. 00039 00040 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00041 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00042 00043 *****************************************************************************/ 00044 00045 #ifndef _VRENDER_AXISALIGNEDBOX_H 00046 #define _VRENDER_AXISALIGNEDBOX_H 00047 00048 namespace vrender 00049 { 00050 class Vector2; 00051 class Vector3; 00052 00053 template<class T> class AxisAlignedBox 00054 { 00055 public: 00056 AxisAlignedBox() ; 00057 AxisAlignedBox(const T& v) ; 00058 AxisAlignedBox(const T& v,const T& w) ; 00059 00060 const T& mini() const { return _min ; } 00061 const T& maxi() const { return _max ; } 00062 00063 void include(const T& v) ; 00064 void include(const AxisAlignedBox<T>& b) ; 00065 private: 00066 T _min ; 00067 T _max ; 00068 }; 00069 00070 typedef AxisAlignedBox< Vector2 > AxisAlignedBox_xy ; 00071 typedef AxisAlignedBox< Vector3 > AxisAlignedBox_xyz ; 00072 00073 template<class T> AxisAlignedBox<T>::AxisAlignedBox() 00074 : _min(T::inf), _max(-T::inf) 00075 { 00076 } 00077 00078 template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v) 00079 : _min(v), _max(v) 00080 { 00081 } 00082 00083 template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v,const T& w) 00084 : _min(v), _max(v) 00085 { 00086 include(w) ; 00087 } 00088 00089 template<class T> void AxisAlignedBox<T>::include(const T& v) 00090 { 00091 _min = T::mini(_min,v) ; 00092 _max = T::maxi(_max,v) ; 00093 } 00094 00095 template<class T> void AxisAlignedBox<T>::include(const AxisAlignedBox<T>& b) 00096 { 00097 include(b._min) ; 00098 include(b._max) ; 00099 } 00100 } 00101 #endif