HDK
|
#include <rect2i.h>
Public Member Functions | |
GfRect2i () | |
Constructs an empty rectangle. More... | |
GfRect2i (const GfVec2i &min, const GfVec2i &max) | |
Constructs a rectangle with min and max corners. More... | |
GfRect2i (const GfVec2i &min, int width, int height) | |
bool | IsNull () const |
bool | IsEmpty () const |
bool | IsValid () const |
Return true if the rectangle is valid (equivalently, not empty). More... | |
GF_API GfRect2i | GetNormalized () const |
const GfVec2i & | GetMin () const |
Returns the min corner of the rectangle. More... | |
const GfVec2i & | GetMax () const |
Returns the max corner of the rectangle. More... | |
int | GetMinX () const |
void | SetMinX (int x) |
int | GetMaxX () const |
void | SetMaxX (int x) |
Set the X value of the max corner. More... | |
int | GetMinY () const |
void | SetMinY (int y) |
int | GetMaxY () const |
Return the Y value of the max corner. More... | |
void | SetMaxY (int y) |
Set the Y value of the max corner. More... | |
void | SetMin (const GfVec2i &min) |
Sets the min corner of the rectangle. More... | |
void | SetMax (const GfVec2i &max) |
Sets the max corner of the rectangle. More... | |
GfVec2i | GetCenter () const |
Returns the center point of the rectangle. More... | |
void | Translate (const GfVec2i &displacement) |
Move the rectangle by displ . More... | |
unsigned long | GetArea () const |
Return the area of the rectangle. More... | |
GfVec2i | GetSize () const |
Returns the size of the rectangle as a vector (width,height). More... | |
int | GetWidth () const |
int | GetHeight () const |
GfRect2i | GetIntersection (const GfRect2i &that) const |
Computes the intersection of two rectangles. More... | |
GfRect2i | Intersect (const GfRect2i &that) const |
GfRect2i | GetUnion (const GfRect2i &that) const |
Computes the union of two rectangles. More... | |
GfRect2i | Union (const GfRect2i &that) const |
bool | Contains (const GfVec2i &p) const |
Returns true if the specified point in the rectangle. More... | |
GfRect2i | operator+= (const GfRect2i &that) |
Friends | |
size_t | hash_value (const GfRect2i &r) |
bool | operator== (const GfRect2i &r1, const GfRect2i &r2) |
Returns true if r1 and r2 are equal. More... | |
bool | operator!= (const GfRect2i &r1, const GfRect2i &r2) |
Returns true if r1 and r2 are different. More... | |
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 |
|
inline |
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 |
Computes the union of two rectangles