25 #ifndef WBOUNDINGBOX_H
26 #define WBOUNDINGBOX_H
32 #include <osg/BoundingBox>
34 #include "exceptions/WInvalidBoundingBox.h"
53 typedef typename osg::BoundingBoxImpl< VT >::vec_type
vec_type;
58 typedef typename osg::BoundingBoxImpl< VT >::value_type
value_type;
97 using osg::BoundingBoxImpl< VT >::valid;
98 using osg::BoundingBoxImpl< VT >::set;
99 using osg::BoundingBoxImpl< VT >::xMin;
100 using osg::BoundingBoxImpl< VT >::yMin;
101 using osg::BoundingBoxImpl< VT >::zMin;
102 using osg::BoundingBoxImpl< VT >::xMax;
103 using osg::BoundingBoxImpl< VT >::yMax;
104 using osg::BoundingBoxImpl< VT >::zMax;
105 using osg::BoundingBoxImpl< VT >::center;
106 using osg::BoundingBoxImpl< VT >::radius;
117 using osg::BoundingBoxImpl< VT >::corner;
124 osg::BoundingBox
toOSGBB()
const;
126 using osg::BoundingBoxImpl< VT >::expandBy;
153 using osg::BoundingBoxImpl< VT >::contains;
175 : osg::BoundingBoxImpl< VT >()
181 : osg::BoundingBoxImpl< VT >( xmin, ymin, zmin, xmax, ymax, zmax )
187 : osg::BoundingBoxImpl< VT >( min, max )
205 return this->raidus2();
211 return osg::BoundingBox( osg::BoundingBoxImpl< VT >::_min, osg::BoundingBoxImpl< VT >::_max );
217 osg::BoundingBoxImpl< VT >::expandBy( bb );
223 return osg::BoundingBoxImpl< VT >::intersects( bb );
241 inline double intervalDistance(
double a0,
double a1,
double b0,
double b1 )
259 if( !valid() || !bb.valid() )
261 throw WInvalidBoundingBox(
"One of the both bounding boxes inside minDistance computation is not valid." );
264 double dx = intervalDistance( xMin(), xMax(), bb.xMin(), bb.xMax() );
265 double dy = intervalDistance( yMin(), yMax(), bb.yMin(), bb.yMax() );
266 double dz = intervalDistance( zMin(), zMax(), bb.zMin(), bb.zMax() );
267 if( dx == 0.0 && dy == 0.0 && dz == 0.0 )
271 return std::sqrt( dx * dx + dy * dy + dz * dz );
283 inline std::ostream& operator<<( std::ostream& out, const WBoundingBoxImpl< VT >& bb )
285 out << std::scientific << std::setprecision( 16 );
286 out <<
"AABB( min: " << bb.xMin() <<
", " << bb.yMin() <<
", " << bb.zMin();
287 out <<
" max: " << bb.xMax() <<
", " << bb.yMax() <<
", " << bb.zMax() <<
" )";
294 return osg::BoundingBoxImpl< VT >::_min;
300 return osg::BoundingBoxImpl< VT >::_max;
305 #endif // WBOUNDINGBOX_H