Logo Search packages:      
Sourcecode: inkscape version File versions

boost::optional< Rect > NR::intersection ( boost::optional< Rect > const &  a,
boost::optional< Rect > const &  b 
)

Returns the set of points shared by both rectangles.

Definition at line 330 of file nr-rect.cpp.

References NR::Rect::_max, and NR::Rect::_min.

                                                                                               {
    if ( !a || !b ) {
        return boost::optional<Rect>();
    } else {
        Rect r;
        for ( int i=0 ; i < 2 ; i++ ) {
            r._min[i] = std::max(a->_min[i], b->_min[i]);
            r._max[i] = std::min(a->_max[i], b->_max[i]);
            if ( r._min[i] > r._max[i] ) {
            return boost::optional<Rect>();
        }
      }
      return r;
    }
}


Generated by  Doxygen 1.6.0   Back to index