| 207 | } |
| 208 | |
| 209 | Rectf Shape2d::calcPreciseBoundingBox() const |
| 210 | { |
| 211 | auto result = Rectf( vec2(), vec2() ); |
| 212 | |
| 213 | // find the first point and initialize the result with that |
| 214 | for( vector<Path2d>::const_iterator contIt = mContours.begin(); contIt != mContours.end(); ++contIt ) { |
| 215 | if( ! contIt->mPoints.empty() ) { |
| 216 | result = Rectf( contIt->mPoints[0], contIt->mPoints[0] ); |
| 217 | break; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // now iterate all the contours and expand the result to include their points |
| 222 | for( vector<Path2d>::const_iterator contIt = mContours.begin(); contIt != mContours.end(); ++contIt ) { |
| 223 | result.include( contIt->calcPreciseBoundingBox() ); |
| 224 | } |
| 225 | |
| 226 | return result; |
| 227 | } |
| 228 | |
| 229 | float Shape2d::calcDistance( const vec2 &pt ) const |
| 230 | { |