All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfRect2i Class Reference

A 2D rectangle with integer coordinates. More...

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)
 Constructs a rectangle with min corner and the indicated width and height. More...
 
bool IsNull () const
 Returns true if the rectangle is a null rectangle. More...
 
bool IsEmpty () const
 Returns true if the rectangle is empty. More...
 
bool IsValid () const
 Return true if the rectangle is valid (equivalently, not empty). More...
 
GF_API GfRect2i GetNormalized () const
 Returns a normalized rectangle, i.e. More...
 
const GfVec2iGetMin () const
 Returns the min corner of the rectangle. More...
 
const GfVec2iGetMax () const
 Returns the max corner of the rectangle. More...
 
int GetMinX () const
 Return the X value of min corner. More...
 
void SetMinX (int x)
 Set the X value of the min corner. More...
 
int GetMaxX () const
 Return the X value of the max corner. More...
 
void SetMaxX (int x)
 Set the X value of the max corner. More...
 
int GetMinY () const
 Return the Y value of the min corner. More...
 
void SetMinY (int y)
 Set the Y value of the min corner. More...
 
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
 Returns the width of the rectangle. More...
 
int GetHeight () const
 Returns the height of the rectangle. More...
 
GfRect2i GetIntersection (const GfRect2i &that) const
 Computes the intersection of two rectangles. More...
 
GfRect2i Intersect (const GfRect2i &that) const
 Computes the intersection of two rectangles. More...
 
GfRect2i GetUnion (const GfRect2i &that) const
 Computes the union of two rectangles. More...
 
GfRect2i Union (const GfRect2i &that) const
 Computes the union of two rectangles. More...
 
bool Contains (const GfVec2i &p) const
 Returns true if the specified point in the rectangle. More...
 
GfRect2i operator+= (const GfRect2i &that)
 Computes the union of two rectangles. More...
 

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)
 

Detailed Description

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.

Definition at line 61 of file rect2i.h.

Constructor & Destructor Documentation

GfRect2i ( )
inline

Constructs an empty rectangle.

Definition at line 64 of file rect2i.h.

GfRect2i ( const GfVec2i min,
const GfVec2i max 
)
inline

Constructs a rectangle with min and max corners.

Definition at line 69 of file rect2i.h.

GfRect2i ( const GfVec2i min,
int  width,
int  height 
)
inline

Constructs a rectangle with min corner and the indicated width and height.

Definition at line 76 of file rect2i.h.

Member Function Documentation

bool Contains ( const GfVec2i p) const
inline

Returns true if the specified point in the rectangle.

Definition at line 264 of file rect2i.h.

unsigned long GetArea ( ) const
inline

Return the area of the rectangle.

Definition at line 200 of file rect2i.h.

GfVec2i GetCenter ( ) const
inline

Returns the center point of the rectangle.

Definition at line 189 of file rect2i.h.

int GetHeight ( ) const
inline

Returns the height of the rectangle.

Note
If the min and max y-coordinates are coincident, the height is one.

Definition at line 221 of file rect2i.h.

GfRect2i GetIntersection ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Definition at line 226 of file rect2i.h.

const GfVec2i& GetMax ( ) const
inline

Returns the max corner of the rectangle.

Definition at line 129 of file rect2i.h.

int GetMaxX ( ) const
inline

Return the X value of the max corner.

Definition at line 147 of file rect2i.h.

int GetMaxY ( ) const
inline

Return the Y value of the max corner.

Definition at line 169 of file rect2i.h.

const GfVec2i& GetMin ( ) const
inline

Returns the min corner of the rectangle.

Definition at line 124 of file rect2i.h.

int GetMinX ( ) const
inline

Return the X value of min corner.

Definition at line 135 of file rect2i.h.

int GetMinY ( ) const
inline

Return the Y value of the min corner.

Definition at line 158 of file rect2i.h.

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.

GfVec2i GetSize ( ) const
inline

Returns the size of the rectangle as a vector (width,height).

Definition at line 205 of file rect2i.h.

GfRect2i GetUnion ( const GfRect2i that) const
inline

Computes the union of two rectangles.

Definition at line 245 of file rect2i.h.

int GetWidth ( ) const
inline

Returns the width of the rectangle.

Note
If the min and max x-coordinates are coincident, the width is one.

Definition at line 213 of file rect2i.h.

GfRect2i Intersect ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Deprecated:
Use GetIntersection() instead

Definition at line 240 of file rect2i.h.

bool IsEmpty ( ) const
inline

Returns true if the rectangle is empty.

An empty rectangle has one or both of its min coordinates strictly greater than the corresponding max coordinate.

An empty rectangle is not valid.

Definition at line 105 of file rect2i.h.

bool IsNull ( ) const
inline

Returns true if the rectangle is a null rectangle.

A null rectangle has both the width and the height set to 0, that is

* GetMaxX() == GetMinX() - 1
*

and

* GetMaxY() == GetMinY() - 1
*

Remember that if GetMinX() and GetMaxX() return the same value then the rectangle has width 1, and similarly for the height.

A null rectangle is both empty, and not valid.

Definition at line 95 of file rect2i.h.

bool IsValid ( ) const
inline

Return true if the rectangle is valid (equivalently, not empty).

Definition at line 110 of file rect2i.h.

GfRect2i operator+= ( const GfRect2i that)
inline

Computes the union of two rectangles.

See Also
GetUnion()

Definition at line 288 of file rect2i.h.

void SetMax ( const GfVec2i max)
inline

Sets the max corner of the rectangle.

Definition at line 184 of file rect2i.h.

void SetMaxX ( int  x)
inline

Set the X value of the max corner.

Definition at line 152 of file rect2i.h.

void SetMaxY ( int  y)
inline

Set the Y value of the max corner.

Definition at line 174 of file rect2i.h.

void SetMin ( const GfVec2i min)
inline

Sets the min corner of the rectangle.

Definition at line 179 of file rect2i.h.

void SetMinX ( int  x)
inline

Set the X value of the min corner.

Definition at line 141 of file rect2i.h.

void SetMinY ( int  y)
inline

Set the Y value of the min corner.

Definition at line 164 of file rect2i.h.

void Translate ( const GfVec2i displacement)
inline

Move the rectangle by displ.

Definition at line 194 of file rect2i.h.

GfRect2i Union ( const GfRect2i that) const
inline

Computes the union of two rectangles.

Deprecated:
Use GetUnion() instead.

Definition at line 259 of file rect2i.h.

Friends And Related Function Documentation

bool operator!= ( const GfRect2i r1,
const GfRect2i r2 
)
friend

Returns true if r1 and r2 are different.

Definition at line 282 of file rect2i.h.

bool operator== ( const GfRect2i r1,
const GfRect2i r2 
)
friend

Returns true if r1 and r2 are equal.

Definition at line 277 of file rect2i.h.


The documentation for this class was generated from the following file: