Beispiel #1
0
/*! Find a minimal rectangle that encapsulates the polygon. The
    rectangle is defined by ptMin and ptMax Point2D objects.
 */
void Polygon2D::GetSurroundingRectangle(
   Point2D& ptMin,   //!< Result - stores minimal x and y value. 
   Point2D& ptMax    //!< Result . stores maximal x and y value.
) const
{
   if(m_vecV.size()) {
      VecVertex::const_iterator i=m_vecV.begin();
      ptMin = ptMax = *i;
      // loop over remaining points
      for(i++; i!=m_vecV.end(); i++) {
         ptMin.SetX(GetMin(ptMin.GetX(), i->GetX()));
         ptMin.SetY(GetMin(ptMin.GetY(), i->GetY()));
         ptMax.SetX(GetMax(ptMax.GetX(), i->GetX()));
         ptMax.SetY(GetMax(ptMax.GetY(), i->GetY()));
      }
   }
}