class GRect

Rectangle class.

Public Fields

[more]int xmin
Minimal (inclusive) horizontal coordinate of the rectangle points.
[more]int ymin
Minimal (inclusive) vertical coordinate of the rectangle points.
[more]int xmax
Maximal (exclusive) horizontal coordinate of the rectangle points.
[more]int ymax
Maximal (exclusive) vertical coordinate of the rectangle points.

Public Methods

[more] GRect()
Constructs an empty rectangle
[more] GRect(int xmin, int ymin, unsigned int width=0, unsigned int height=0)
Constructs a rectangle given its minimal coordinates xmin and ymin, and its measurements width and height.
[more]int width() const
Returns the rectangle width.
[more]int height() const
Returns the rectangle height.
[more]int isempty() const
Returns true iff the rectangle is empty.
[more]int contains(int x, int y) const
Returns true iff the rectangle contains point (x,y).
[more]friend int operator==(const GRect & r1, const GRect & r2)
Returns true iff rectangles r1 and r2 are equal.
[more]void clear()
Resets the rectangle to the empty rectangle
[more]int inflate(int dx, int dy)
Fatten the rectangle.
[more]int translate(int dx, int dy)
Translate the rectangle.
[more]int intersect(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the intersection of rectangles rect1 and rect2.
[more]int recthull(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the smallest rectangle containing the points of both rectangles rect1 and rect2.


Documentation

Rectangle class. Each instance of this class represents a rectangle whose sides are parallel to the axis. Such a rectangle is composed of points whose coordinates lies between well defined minimal and maximal values. Member functions can combine several rectangles by computing the intersection of rectangles (intersect) or the smallest rectangle enclosing two rectangles (recthull).
o GRect()
Constructs an empty rectangle

o GRect(int xmin, int ymin, unsigned int width=0, unsigned int height=0)
Constructs a rectangle given its minimal coordinates xmin and ymin, and its measurements width and height. Setting width or height to zero produces an empty rectangle.

oint width() const
Returns the rectangle width.

oint height() const
Returns the rectangle height.

oint isempty() const
Returns true iff the rectangle is empty.

oint contains(int x, int y) const
Returns true iff the rectangle contains point (x,y).

ofriend int operator==(const GRect & r1, const GRect & r2)
Returns true iff rectangles r1 and r2 are equal.

ovoid clear()
Resets the rectangle to the empty rectangle

oint inflate(int dx, int dy)
Fatten the rectangle. Both vertical sides of the rectangle are pushed apart by dx units. Both horizontal sides of the rectangle are pushed apart by dy units. Setting arguments dx (resp. dy) to a negative value reduces the rectangle horizontal (resp. vertical) size.

oint translate(int dx, int dy)
Translate the rectangle. The new rectangle is composed of all the points of the old rectangle translated by dx units horizontally and dy units vertically.

oint intersect(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the intersection of rectangles rect1 and rect2. This function returns true iff the intersection rectangle is not empty.

oint recthull(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the smallest rectangle containing the points of both rectangles rect1 and rect2. This function returns true iff the intersection rectangle is not empty.

oint xmin
Minimal (inclusive) horizontal coordinate of the rectangle points.

oint ymin
Minimal (inclusive) vertical coordinate of the rectangle points.

oint xmax
Maximal (exclusive) horizontal coordinate of the rectangle points.

oint ymax
Maximal (exclusive) vertical coordinate of the rectangle points.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java