12 #ifndef MI_MATH_BBOX_H
 
   13 #define MI_MATH_BBOX_H
 
   47 template <
typename T, Size DIM>
 
   74 template <
typename T, Size DIM>
 
  116         for( 
Size i = 0; i < DIM; i++) {
 
  209     template <
typename InputIterator>
 
  216     template <
typename T2>
 
  283         for( 
Size i = 0; i < DIM; i++) {
 
  301         for( 
Size i = 0; i < DIM; i++)
 
  302             rank += (
min[i] < 
max[i]);
 
  327         for( 
Size i = 0; i < DIM; i++) {
 
  328             if( vec[i] < 
min[i] || vec[i] > 
max[i])
 
  338         for( 
Size i = 0; i < DIM; i++) {
 
  366     template <
typename InputIterator>
 
  415         for( 
Size i = 1; i < DIM; i++)
 
  416             vol *= base::max MI_PREVENT_MACRO_EXPAND ( T(0), diag[i]);
 
  437         for( 
Size i = 1; i < DIM; i++) {
 
  438             if (maxval < diag[i]) {
 
  457 template <
typename T, Size DIM>
 
  462     for( 
Size i = 0; i < DIM; i++) {
 
  463         (result.min)[i] = (bbox.
min)[i] - value;
 
  464         (result.max)[i] = (bbox.
max)[i] + value;
 
  473 template <
typename T, Size DIM>
 
  478     for( 
Size i = 0; i < DIM; i++) {
 
  479         (result.min)[i] = (bbox.
min)[i] + value;
 
  480         (result.max)[i] = (bbox.
max)[i] - value;
 
  489 template <
typename T, Size DIM>
 
  494     for( 
Size i = 0; i < DIM; i++) {
 
  495         (result.min)[i] = (bbox.
min)[i] * factor;
 
  496         (result.max)[i] = (bbox.
max)[i] * factor;
 
  505 template <
typename T, Size DIM>
 
  511     for( 
Size i = 0; i < DIM; i++) {
 
  512         (result.
min)[i] = (bbox.
min)[i] / divisor;
 
  513         (result.
max)[i] = (bbox.
max)[i] / divisor;
 
  522 template <
typename T, Size DIM>
 
  526     for( 
Size i = 0; i < DIM; i++) {
 
  527         (bbox.
min)[i] -= value;
 
  528         (bbox.
max)[i] += value;
 
  537 template <
typename T, Size DIM>
 
  541     for( 
Size i = 0; i < DIM; i++) {
 
  542         (bbox.
min)[i] += value;
 
  543         (bbox.
max)[i] -= value;
 
  551 template <
typename T, Size DIM>
 
  555     for( 
Size i = 0; i < DIM; i++) {
 
  556         (bbox.
min)[i] *= factor;
 
  557         (bbox.
max)[i] *= factor;
 
  565 template <
typename T, Size DIM>
 
  570     for( 
Size i = 0; i < DIM; i++) {
 
  571         (bbox.
min)[i] /= divisor;
 
  572         (bbox.
max)[i] /= divisor;
 
  578 template <
typename T, Size DIM>
 
  581     return (lhs.
min) == (rhs.
min) && (lhs.
max) == (rhs.
max);
 
  585 template <
typename T, Size DIM>
 
  588     return (lhs.
min) != (rhs.
min) || (lhs.
max) != (rhs.
max);
 
  594 template <
typename T, Size DIM>
 
  595 inline bool operator< ( const Bbox<T,DIM> & lhs, 
const Bbox<T,DIM> & rhs)
 
  597     for( 
Size i(0u); i < DIM; ++i) {
 
  598         if( (lhs.min)[i] < (rhs.min)[i])
 
  600         if( (lhs.min)[i] > (rhs.min)[i])
 
  609 template <
typename T, Size DIM>
 
  610 inline bool operator<=( const Bbox<T,DIM>& lhs, 
const Bbox<T,DIM>& rhs)
 
  612     for( 
Size i(0u); i < DIM; ++i) {
 
  613         if( (lhs.min)[i] < (rhs.min)[i])
 
  615         if( (lhs.min)[i] > (rhs.min)[i])
 
  624 template <
typename T, Size DIM>
 
  627     for( 
Size i(0u); i < DIM; ++i) {
 
  628         if( (lhs.
min)[i] > (rhs.
min)[i])
 
  630         if( (lhs.
min)[i] < (rhs.
min)[i])
 
  639 template <
typename T, Size DIM>
 
  642     for( 
Size i(0u); i < DIM; ++i) {
 
  643         if( (lhs.
min)[i] > (rhs.
min)[i])
 
  645         if( (lhs.
min)[i] < (rhs.
min)[i])
 
  659 template <
typename T, Size DIM>
 
  674 template <
typename T, Size DIM>
 
  680     for( 
Size i = 0; i < DIM; i++) {
 
  683         if (result.
max[i] < result.
min[i]) { 
 
  704 template <
typename TT, 
typename T>
 
  705 Bbox<T,3> 
transform_point( 
const Matrix<TT,4,4>& mat, 
const Bbox<T,3>& bbox);
 
  716 template <
typename TT, 
typename T>
 
  717 Bbox<T,3> 
transform_vector( 
const Matrix<TT,4,4>& mat, 
const Bbox<T,3>& bbox);
 
  723 #ifndef MI_FOR_DOXYGEN_ONLY
 
  725 template <
typename T, Size DIM>
 
  726 template <
typename InputIterator>
 
  729     for( ; first != last; ++first)
 
  733 template <
typename T, Size DIM>
 
  734 template <
typename InputIterator>
 
  738     insert( first, last);
 
  741 template <
typename T, Size DIM>
 
  755     for( 
Size i = 0; i < DIM; i++)
 
  760     for( 
Size i = 0; i < DIM; i++)
 
  762     const T margin = max_dist * eps;
 
  767 #endif // MI_FOR_DOXYGEN_ONLY
 
  769 template <
typename TT, 
typename T>
 
  784     corners[0].x += T(mat.wx);
 
  785     corners[0].y += T(mat.wy);
 
  786     corners[0].z += T(mat.wz);
 
  793     corners[1] = corners[0] + dz;                       
 
  794     corners[2] = corners[0] + dy;                       
 
  795     corners[3] = corners[0] + dy + dz;                  
 
  796     corners[4] = corners[0] + dx;                       
 
  797     corners[5] = corners[0] + dx + dz;                  
 
  798     corners[6] = corners[0] + dx + dy;                  
 
  799     corners[7] = corners[0] + dx + dy + dz;             
 
  805     T wx = T( mat.xw * ((bbox.
max).x - (bbox.
min).x));
 
  806     T wy = T( mat.yw * ((bbox.
max).y - (bbox.
min).y));
 
  807     T wz = T( mat.zw * ((bbox.
max).z - (bbox.
min).z));
 
  810     w[0] = T(mat.xw * (bbox.
min).x + mat.yw * (bbox.
min).y + mat.zw * (bbox.
min).z + mat.ww);
 
  813     w[3] = w[0] + wy + wz;                              
 
  815     w[5] = w[0] + wx + wz;                              
 
  816     w[6] = w[0] + wx + wy;                              
 
  817     w[7] = w[0] + wx + wy + wz;                         
 
  820     for( 
unsigned int i=0; i<8; ++i) {
 
  821         if( w[i]!=0 && w[i]!=1) {
 
  832 template <
typename TT, 
typename T>
 
  846     corners[1] = corners[0] + dz;
 
  847     corners[2] = corners[0] + dy;
 
  848     corners[3] = corners[0] + dy + dz;
 
  849     corners[4] = corners[0] + dx;
 
  850     corners[5] = corners[0] + dx + dz;
 
  851     corners[6] = corners[0] + dx + dy;
 
  852     corners[7] = corners[0] + dx + dy + dz;
 
  864 #endif // MI_MATH_BBOX_H