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

#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 GfVec2iGetMin () const
 Returns the min corner of the rectangle. More...
 
const GfVec2iGetMax () 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)
 

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 60 of file rect2i.h.

Constructor & Destructor Documentation

GfRect2i::GfRect2i ( )
inline

Constructs an empty rectangle.

Definition at line 63 of file rect2i.h.

GfRect2i::GfRect2i ( const GfVec2i min,
const GfVec2i max 
)
inline

Constructs a rectangle with min and max corners.

Definition at line 68 of file rect2i.h.

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

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

Definition at line 75 of file rect2i.h.

Member Function Documentation

bool GfRect2i::Contains ( const GfVec2i p) const
inline

Returns true if the specified point in the rectangle.

Definition at line 263 of file rect2i.h.

unsigned long GfRect2i::GetArea ( ) const
inline

Return the area of the rectangle.

Definition at line 199 of file rect2i.h.

GfVec2i GfRect2i::GetCenter ( ) const
inline

Returns the center point of the rectangle.

Definition at line 188 of file rect2i.h.

int GfRect2i::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 220 of file rect2i.h.

GfRect2i GfRect2i::GetIntersection ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Definition at line 225 of file rect2i.h.

const GfVec2i& GfRect2i::GetMax ( ) const
inline

Returns the max corner of the rectangle.

Definition at line 128 of file rect2i.h.

int GfRect2i::GetMaxX ( ) const
inline

Return the X value of the max corner.

Definition at line 146 of file rect2i.h.

int GfRect2i::GetMaxY ( ) const
inline

Return the Y value of the max corner.

Definition at line 168 of file rect2i.h.

const GfVec2i& GfRect2i::GetMin ( ) const
inline

Returns the min corner of the rectangle.

Definition at line 123 of file rect2i.h.

int GfRect2i::GetMinX ( ) const
inline

Return the X value of min corner.

Definition at line 134 of file rect2i.h.

int GfRect2i::GetMinY ( ) const
inline

Return the Y value of the min corner

Definition at line 157 of file rect2i.h.

GF_API GfRect2i 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 GfRect2i::GetSize ( ) const
inline

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

Definition at line 204 of file rect2i.h.

GfRect2i GfRect2i::GetUnion ( const GfRect2i that) const
inline

Computes the union of two rectangles.

Definition at line 244 of file rect2i.h.

int GfRect2i::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 212 of file rect2i.h.

GfRect2i GfRect2i::Intersect ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Deprecated:
Use GetIntersection() instead

Definition at line 239 of file rect2i.h.

bool GfRect2i::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 104 of file rect2i.h.

bool GfRect2i::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 94 of file rect2i.h.

bool GfRect2i::IsValid ( ) const
inline

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

Definition at line 109 of file rect2i.h.

GfRect2i GfRect2i::operator+= ( const GfRect2i that)
inline

Computes the union of two rectangles.

See Also
GetUnion()

Definition at line 284 of file rect2i.h.

void GfRect2i::SetMax ( const GfVec2i max)
inline

Sets the max corner of the rectangle.

Definition at line 183 of file rect2i.h.

void GfRect2i::SetMaxX ( int  x)
inline

Set the X value of the max corner.

Definition at line 151 of file rect2i.h.

void GfRect2i::SetMaxY ( int  y)
inline

Set the Y value of the max corner.

Definition at line 173 of file rect2i.h.

void GfRect2i::SetMin ( const GfVec2i min)
inline

Sets the min corner of the rectangle.

Definition at line 178 of file rect2i.h.

void GfRect2i::SetMinX ( int  x)
inline

Set the X value of the min corner.

Definition at line 140 of file rect2i.h.

void GfRect2i::SetMinY ( int  y)
inline

Set the Y value of the min corner.

Definition at line 163 of file rect2i.h.

void GfRect2i::Translate ( const GfVec2i displacement)
inline

Move the rectangle by displ.

Definition at line 193 of file rect2i.h.

GfRect2i GfRect2i::Union ( const GfRect2i that) const
inline

Computes the union of two rectangles

Deprecated:
Use GetUnion() instead.

Definition at line 258 of file rect2i.h.

Friends And Related Function Documentation

size_t hash_value ( const GfRect2i r)
friend

Definition at line 268 of file rect2i.h.

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

Returns true if r1 and r2 are different.

Definition at line 278 of file rect2i.h.

GfRect2i operator+ ( const GfRect2i  r1,
const GfRect2i r2 
)
friend

Definition at line 289 of file rect2i.h.

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

Returns true if r1 and r2 are equal.

Definition at line 273 of file rect2i.h.


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