25 #ifndef WBOUNDINGBOX_H
26 #define WBOUNDINGBOX_H
30 #include <osg/BoundingBox>
32 #include "exceptions/WInvalidBoundingBox.h"
33 #include "math/linearAlgebra/WLinearAlgebra.h"
51 typedef typename osg::BoundingBoxImpl< VT >::vec_type
vec_type;
56 typedef typename osg::BoundingBoxImpl< VT >::value_type
value_type;
95 using osg::BoundingBoxImpl< VT >::valid;
96 using osg::BoundingBoxImpl< VT >::set;
97 using osg::BoundingBoxImpl< VT >::xMin;
98 using osg::BoundingBoxImpl< VT >::yMin;
99 using osg::BoundingBoxImpl< VT >::zMin;
100 using osg::BoundingBoxImpl< VT >::xMax;
101 using osg::BoundingBoxImpl< VT >::yMax;
102 using osg::BoundingBoxImpl< VT >::zMax;
103 using osg::BoundingBoxImpl< VT >::center;
104 using osg::BoundingBoxImpl< VT >::radius;
115 using osg::BoundingBoxImpl< VT >::corner;
122 osg::BoundingBox
toOSGBB()
const;
124 using osg::BoundingBoxImpl< VT >::expandBy;
151 using osg::BoundingBoxImpl< VT >::contains;
203 return this->raidus2();
209 return osg::BoundingBox( osg::BoundingBoxImpl< VT >::_min, osg::BoundingBoxImpl< VT >::_max );
215 osg::BoundingBoxImpl< VT >::expandBy( bb );
221 return osg::BoundingBoxImpl< VT >::intersects( bb );
239 inline double intervalDistance(
double a0,
double a1,
double b0,
double b1 )
257 if( !valid() || !bb.valid() )
259 throw WInvalidBoundingBox(
"One of the both bounding boxes inside minDistance computation is not valid." );
262 double dx = intervalDistance( xMin(), xMax(), bb.xMin(), bb.xMax() );
263 double dy = intervalDistance( yMin(), yMax(), bb.yMin(), bb.yMax() );
264 double dz = intervalDistance( zMin(), zMax(), bb.zMin(), bb.zMax() );
265 if( dx == 0.0 && dy == 0.0 && dz == 0.0 )
269 return std::sqrt( dx * dx + dy * dy + dz * dz );
281 inline std::ostream& operator<<( std::ostream& out, const WBoundingBoxImpl< VT >& bb )
283 out << std::scientific << std::setprecision( 16 );
284 out <<
"AABB( min: " << bb.xMin() <<
", " << bb.yMin() <<
", " << bb.zMin();
285 out <<
" max: " << bb.xMax() <<
", " << bb.yMax() <<
", " << bb.zMax() <<
" )";
292 return osg::BoundingBoxImpl< VT >::_min;
298 return osg::BoundingBoxImpl< VT >::_max;
303 #endif // WBOUNDINGBOX_H