#ifndef KEOS_RECTANGLE_H
#define KEOS_RECTANGLE_H

#include "KeosPrerequisites.h"

namespace Keos
{
    //-----------------------------------------------------------------------
    /** Class of the rectangles 2D in integer coordinates.
     *
     */
    class KEOS_EXPORT CRectangle
    {
    public :

        /** Default constructor.
         *  @param Start (default (0,0))
         *  @param Size (default (0,0))
         */
        CRectangle(const TVector2I& Start = TVector2I(0, 0), const TVector2I& Size = TVector2I(0, 0));

        /** Constructor with 2 coordinates and 2 dimensions.
         */
        CRectangle(int nLeft, int nTop, int nWidth, int nHeight);

        /** Reinitialize the rectangle.
         */
        void Set(int nLeft, int nTop, int nWidth, int nHeight);

        /** Return the left side of the rectangle.
         */
        int Left() const;

        /** Return the right side of the rectangle.
         */
        int Right() const;

        /** Return the top side of the rectangle.
         */
        int Top() const;

        /** Return the bottom side of the rectangle.
         */
        int Bottom() const;

        /** Return the width of the rectangle.
         */
        int Width() const;

        /** Return the height of the rectangle.
         */
        int Height() const;

        /** Return the size of the rectangle.
         */
        TVector2I Size() const;

        /** Test of intersection with a point.
         *  @param Point Point to be tested.
         *  @return Intersection type.
         */
        TIntersection Intersects(const TVector2I& Point) const;

        /** Test of intersection with a rectangle.
         *  @param Rect Rectangle to be tested.
         *  @return Intersection type.
         */
        TIntersection Intersects(const CRectangle& Rect) const;

        // Operators == and !=
        bool operator ==(const CRectangle& Rect) const;
        bool operator !=(const CRectangle& Rect) const;

        //! Top-Left corner
        TVector2I Origin;
        //! Bottom-Right corner
        TVector2I End;
    };

    // Globals functions
    KEOS_EXPORT std::istream& operator >>(std::ostream& Stream, CRectangle& Rect);
    KEOS_EXPORT std::ostream& operator <<(std::ostream& Stream, const CRectangle& Rect);

} // namespace Keos


#endif // KEOS_RECTANGLE_H
