const R3Point R3Box:: ClosestPoint(const R3Point& point) const { // Return closest point in box R3Point closest(point); if (closest.X() < XMin()) closest[RN_X] = XMin(); else if (closest.X() > XMax()) closest[RN_X] = XMax(); if (closest.Y() < YMin()) closest[RN_Y] = YMin(); else if (closest.Y() > YMax()) closest[RN_Y] = YMax(); if (closest.Z() < ZMin()) closest[RN_Z] = ZMin(); else if (closest.Z() > ZMax()) closest[RN_Z] = ZMax(); return closest; }
bool Box::Contains( Box const& other ) const { return ( XMin() <= other.XMin() && XMax() >= other.XMax() && YMin() <= other.YMin() && YMax() >= other.YMax() ); }
void Box::Merge( Box const& other ) { if( other.Empty() ) return; if( Empty() ) { *this = other; return; } int l = std::min(x, other.x ); int t = std::min(y, other.y ); int r = std::max( XMax(), other.XMax() ); int b = std::max( YMax(), other.YMax() ); x = l; y = t; w = (r-l)+1; h = (b-t)+1; }