|
A 2D rectangle with integer coordinates. More...
#include <rect2i.h>
Public Member Functions | |
GfRect2i () | |
Constructs an empty rectangle. | |
GfRect2i (const GfVec2i &min, const GfVec2i &max) | |
Constructs a rectangle with min and max corners. | |
GfRect2i (const GfVec2i &min, int width, int height) | |
Constructs a rectangle with min corner and the indicated width and height . | |
bool | IsNull () const |
Returns true if the rectangle is a null rectangle. | |
bool | IsEmpty () const |
Returns true if the rectangle is empty. | |
bool | IsValid () const |
Return true if the rectangle is valid (equivalently, not empty). | |
GF_API GfRect2i | GetNormalized () const |
Returns a normalized rectangle, i.e. | |
const GfVec2i & | GetMin () const |
Returns the min corner of the rectangle. | |
const GfVec2i & | GetMax () const |
Returns the max corner of the rectangle. | |
int | GetMinX () const |
Return the X value of min corner. | |
void | SetMinX (int x) |
Set the X value of the min corner. | |
int | GetMaxX () const |
Return the X value of the max corner. | |
void | SetMaxX (int x) |
Set the X value of the max corner. | |
int | GetMinY () const |
Return the Y value of the min corner. | |
void | SetMinY (int y) |
Set the Y value of the min corner. | |
int | GetMaxY () const |
Return the Y value of the max corner. | |
void | SetMaxY (int y) |
Set the Y value of the max corner. | |
void | SetMin (const GfVec2i &min) |
Sets the min corner of the rectangle. | |
void | SetMax (const GfVec2i &max) |
Sets the max corner of the rectangle. | |
GfVec2i | GetCenter () const |
Returns the center point of the rectangle. | |
void | Translate (const GfVec2i &displacement) |
Move the rectangle by displ . | |
unsigned long | GetArea () const |
Return the area of the rectangle. | |
GfVec2i | GetSize () const |
Returns the size of the rectangle as a vector (width,height). | |
int | GetWidth () const |
Returns the width of the rectangle. | |
int | GetHeight () const |
Returns the height of the rectangle. | |
GfRect2i | GetIntersection (const GfRect2i &that) const |
Computes the intersection of two rectangles. | |
GfRect2i | Intersect (const GfRect2i &that) const |
Computes the intersection of two rectangles. | |
GfRect2i | GetUnion (const GfRect2i &that) const |
Computes the union of two rectangles. | |
GfRect2i | Union (const GfRect2i &that) const |
Computes the union of two rectangles. | |
bool | Contains (const GfVec2i &p) const |
Returns true if the specified point in the rectangle. | |
GfRect2i | operator+= (const GfRect2i &that) |
Computes the union of two rectangles. | |
Friends | |
size_t | hash_value (const GfRect2i &r) |
bool | operator== (const GfRect2i &r1, const GfRect2i &r2) |
Returns true if r1 and r2 are equal. | |
bool | operator!= (const GfRect2i &r1, const GfRect2i &r2) |
Returns true if r1 and r2 are different. | |
GfRect2i | operator+ (const GfRect2i r1, const GfRect2i &r2) |
A 2D rectangle with integer coordinates.
A rectangle is internally represented as two corners. We refer to these as the min and max corner where the min's x-coordinate and y-coordinate are assumed to be less than or equal to the max's corresponding coordinates. Normally, it is expressed as a min corner and a size.
Note that the max corner is included when computing the size (width and height) of a rectangle as the number of integral points in the x- and y-direction. In particular, if the min corner and max corner are the same, then the width and the height of the rectangle will both be one since we have exactly one integral point with coordinates greater or equal to the min corner and less or equal to the max corner.
Specifically, width = maxX - minX + 1 and height = maxY - minY + 1.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
GF_API GfRect2i GetNormalized | ( | ) | const |
Returns a normalized rectangle, i.e.
one that has a non-negative width and height.
GetNormalized()
swaps the min and max x-coordinates to ensure a non-negative width, and similarly for the y-coordinates.
|
inline |
|
inline |
Computes the intersection of two rectangles.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Computes the union of two rectangles.