Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Celartem::Rect Struct Reference

#include <cel_geom.h>

Public Member Functions

ssize_t right () const
 
ssize_t bottom () const
 
Point leftTop () const
 
Point leftBottom () const
 
Point rightTop () const
 
Point rightBottom () const
 
 Rect (ssize_t inLeft=0, ssize_t inTop=0, ssize_t inWidth=0, ssize_t inHeight=0)
 
 Rect (const Rect &inRect)
 
Rectoperator= (const Rect &inRect)
 
bool operator== (const Rect &inRect) const
 
bool operator!= (const Rect &inRect) const
 
void zeroReset ()
 
bool isValid () const
 
bool isInside (const Rect &inRect) const
 
Rect unionRect (const Rect &inRect)
 
bool intersectWith (const Rect &inRect) const
 
Rect intersectionRect (const Rect &inRect) const
 
void offset (ssize_t inHorzOffset, ssize_t inVertOffset)
 
void offset (const Point &inOffset)
 
void inflate (ssize_t size)
 
void deflate (ssize_t size)
 

Static Public Member Functions

static void unionRects (Rect &outRect, const Rect &inRect1, const Rect &inRect2)
 
static void unionRects (Rect &outRect, const Rect *inRects, size_t inCount)
 
static bool intersection (Rect &outRect, const Rect &inRect1, const Rect &inRect2)
 

Public Attributes

ssize_t left
 X-coordinate of the upper-left corner. More...
 
ssize_t top
 Y-coordinate of the upper-left corner. More...
 
ssize_t width
 Width of the rectangle. More...
 
ssize_t height
 Height of the rectangle. More...
 

Detailed Description

A Rect struct stores the upper-left corner, width, and height of a rectangle.

Constructor & Destructor Documentation

Celartem::Rect::Rect ( ssize_t  inLeft = 0,
ssize_t  inTop = 0,
ssize_t  inWidth = 0,
ssize_t  inHeight = 0 
)
inline

This constructor initializes a Rect instance whose x-coordinate, y-coordinate, width, and height are all zero.

Parameters
inLeftX-coordinate of the upper-left corner of the rectangle.
inTopY-coordinate of the upper-left corner of the rectangle.
inWidthWidth of the rectangle.
inHeightHeight of the rectangle.

Referenced by intersection(), and unionRects().

Celartem::Rect::Rect ( const Rect inRect)
inline

This constructor copies the specified Rect instance.

Parameters
inRectA rectangle instance.

Member Function Documentation

ssize_t Celartem::Rect::bottom ( ) const
inline

This function returns the Y-coordinate of the bottom line.

Returns
Y-coordinate of the bottom line.

Referenced by intersection(), isInside(), leftBottom(), rightBottom(), and unionRects().

void Celartem::Rect::deflate ( ssize_t  size)
inline

This function inflates this rectangle by the specified size.
For example, if the original rectangle is Left=0, Top=0, Width=8, Height=8 and then do defration by 2, the result is Left=2, Top=2, Width=4, Height=4.
Please note that this function does not check the validity of the resulting rectangle (negative width/height).

Parameters
sizeSize to deflate.
void Celartem::Rect::inflate ( ssize_t  size)
inline

This function inflates this rectangle by the specified size.
For example, if the original rectangle is Left=0, Top=0, Width=8, Height=8 and then do infration by 2, the result is Left=-2, Top=-2, Width=12, Height=12.

Parameters
sizeSize to inflate.

Referenced by deflate().

static bool Celartem::Rect::intersection ( Rect outRect,
const Rect inRect1,
const Rect inRect2 
)
inlinestatic

This function calculates the intersection of the two rectangles specified by inRect1 and inRect2.

Parameters
outRectThe result rectangle.
inRect1
inRect2The rectangles to calculate the intersection.
Returns
true if there're a valid intersection between the rectangles, otherwise false.

Referenced by intersectionRect(), and intersectWith().

Rect Celartem::Rect::intersectionRect ( const Rect inRect) const
inline

This function returns intersection of the instance and another.

Parameters
rectThe rectangle to get intersection with.
Returns
The result rectangle.
If the rectangles do not have intersection, the result is empty rectangle.
bool Celartem::Rect::intersectWith ( const Rect inRect) const
inline

This function determines whether this Rect intersects with the specified Rect instance or not.

Parameters
inRectThe rectangle to calculate the intersection.
Returns
true if there're a valid intersection between the rectangles, otherwise false.
bool Celartem::Rect::isInside ( const Rect inRect) const
inline

This function checks wether the specified rectangle is in the rectangle or not. In the judgement, the 4 border lines of the inner rectangle can be overwrapped onto the lines of the outer rectangle.

Parameters
inRectThe rectangle to check the containment.
Returns
true if the rectangle is in this rectangle, otherwise false.
bool Celartem::Rect::isValid ( ) const
inline

This function checks whether this rectangle stands for some valid area or not.

Returns
true if the rectangle is valid, otherwise false.

Referenced by intersection(), and unionRects().

Point Celartem::Rect::leftBottom ( ) const
inline

This function returns the left-bottom position.

Returns
The left-bottom position in Point structure.
Point Celartem::Rect::leftTop ( ) const
inline

This function returns the left-top position.

Returns
The left-top position in Point structure.
void Celartem::Rect::offset ( ssize_t  inHorzOffset,
ssize_t  inVertOffset 
)
inline

This function moves this rectangle the specified offsets.

Parameters
inHorzOffsetHorizontal offset to move the rectangle.
inVertOffsetVertical offset to move the rectangle.

Referenced by offset().

void Celartem::Rect::offset ( const Point inOffset)
inline

This function moves this rectangle the specified offsets.

Parameters
inOffsetOffset to move the rectangle.
bool Celartem::Rect::operator!= ( const Rect inRect) const
inline

This function compares this instance with another.

Returns
true if this instance is not identical to inRect, otherwise false.
Rect& Celartem::Rect::operator= ( const Rect inRect)
inline

This function copies the specified Rect instance.

Parameters
inRectA rectangle instance.
Returns
Reference to this instance.
bool Celartem::Rect::operator== ( const Rect inRect) const
inline

This function compares this instance with another.

Returns
true if this instance is identical to inRect, otherwise false.
ssize_t Celartem::Rect::right ( ) const
inline

This function returns the X-coordinate of the right line.

Returns
X-coordinate of the right line.

Referenced by intersection(), isInside(), rightBottom(), rightTop(), and unionRects().

Point Celartem::Rect::rightBottom ( ) const
inline

This function returns the right-bottom position.

Returns
The right-bottom position in Point structure.
Point Celartem::Rect::rightTop ( ) const
inline

This function returns the right-top position.

Returns
The right-top position in Point structure.
Rect Celartem::Rect::unionRect ( const Rect inRect)
inline

This function returns union of the instance and another.

Parameters
rectThe rectangle to union with.
Returns
The result rectangle.
static void Celartem::Rect::unionRects ( Rect outRect,
const Rect inRect1,
const Rect inRect2 
)
inlinestatic

This function calculates the smallest rectangle that can contain both of the two rectangles specified by inRect1 and inRect2.

Parameters
outRectThe result rectangle.
inRect1
inRect2The rectangles to be contained.

Referenced by unionRect().

static void Celartem::Rect::unionRects ( Rect outRect,
const Rect inRects,
size_t  inCount 
)
inlinestatic

This function calculates the smallest rectangle that can contain all the rectangles specified.

Parameters
outRectThe result rectangle.
inRectsAn array of Rect instances.
inCountThe count of Rect instances in the array.
void Celartem::Rect::zeroReset ( )
inline

This function initializes the Rect instance to (0,0,0,0).

Member Data Documentation

ssize_t Celartem::Rect::height
ssize_t Celartem::Rect::left
ssize_t Celartem::Rect::top
ssize_t Celartem::Rect::width

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo