Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cRegion Class Reference

#include <cRegion.h>

Inheritance diagram for GrayLib::cRegion:
Gray::CObject GrayLib::cRegion3f GrayLib::cSurfaceDiff

Public Member Functions

 cRegion (const cRectI &rect)
 
 cRegion ()
 
virtual ~cRegion ()
 
virtual bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
bool isRegionEmpty () const
 
void EmptyRegion ()
 
void AddRegion (const cRegion *pRegionTest)
 
bool SubtractRegion (const cRegion *pRegionTest)
 
void SetRegionSubtract (const cRectI &rect1, const cRectI &rect2)
 
const cRectIget_RectUnion () const
 
void put_RectUnion (const cRectI &rect)
 
ITERATE_t get_RegionRectCount () const
 
const cRectIGetRegionRect (ITERATE_t i) const
 
cRectIRefRegionRect (ITERATE_t i)
 
virtual bool AddRegionRect (const cRectI &rect)
 
virtual void RemoveRegionRect (ITERATE_t i)
 
bool SubtractRegionRect (const cRectI &rect)
 
void OptimizeRegionRects ()
 
cPoint2i GetRegionCorner (DIR_TYPE eDir=DIR_QTY) const
 
bool PtInRegion (int x, int y) const
 
bool PtInRegion (const cPoint2i &pt) const
 
bool IsOverlapped (const cRectI &rect) const
 
bool IsInsideMe (const cRectI &rect) const
 
bool IsInsideMe (const cRegion *pRegionIsSmaller) const
 
bool IsOverlapped (const cRegion *pRegionTest) const
 
bool IsEqualRegion (const cRegion *pRegionTest) const
 
HRESULT v_SetRegion (const cVariant &vVal)
 
void v_GetRegion (cVariant &vVal) const
 
 UNITTEST_FRIEND (cRegion)
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 

Protected Attributes

cRectI m_rectUnion
 The union rectangle. (may have holes in it of course) More...
 

Detailed Description

A 2d (integer) region made of rectangles. loosely based on http://www.codeproject.com/KB/GDI/Regions.aspx

Constructor & Destructor Documentation

◆ cRegion() [1/2]

GrayLib::cRegion::cRegion ( const cRectI rect)

◆ cRegion() [2/2]

GrayLib::cRegion::cRegion ( )

◆ ~cRegion()

GrayLib::cRegion::~cRegion ( )
virtual

Member Function Documentation

◆ AddRegion()

void GrayLib::cRegion::AddRegion ( const cRegion pRegionTest)

◆ AddRegionRect()

bool GrayLib::cRegion::AddRegionRect ( const cRectI rect)
virtual
Note
we really should normalize this rect with any existing rects !

◆ EmptyRegion()

void GrayLib::cRegion::EmptyRegion ( )
inline

◆ get_RectUnion()

const cRectI& GrayLib::cRegion::get_RectUnion ( ) const
inline

◆ get_RegionRectCount()

ITERATE_t GrayLib::cRegion::get_RegionRectCount ( ) const

How many rectangles in this region ?

◆ GetRegionCorner()

cPoint2i GrayLib::cRegion::GetRegionCorner ( DIR_TYPE  eDir = DIR_QTY) const
Note
DIR_QTY = center.

◆ GetRegionRect()

const cRectI & GrayLib::cRegion::GetRegionRect ( ITERATE_t  i) const

Get a particular rectangle.

◆ IsEqualRegion()

bool GrayLib::cRegion::IsEqualRegion ( const cRegion pRegionTest) const

Find dupe rectangles.

◆ IsInsideMe() [1/2]

bool GrayLib::cRegion::IsInsideMe ( const cRectI rect) const

Is rect fully inside this region?

◆ IsInsideMe() [2/2]

bool GrayLib::cRegion::IsInsideMe ( const cRegion pRegionIsSmaller) const

Is the pRegionTest completely inside this region ?

◆ IsOverlapped() [1/2]

bool GrayLib::cRegion::IsOverlapped ( const cRectI rect) const

Does the region overlap this rectangle.

◆ IsOverlapped() [2/2]

bool GrayLib::cRegion::IsOverlapped ( const cRegion pRegionTest) const

Does the region overlap this other region.

◆ isRegionEmpty()

bool GrayLib::cRegion::isRegionEmpty ( ) const
inline

◆ isValidCheck()

virtual bool GrayLib::cRegion::isValidCheck ( ) const
inlinevirtualnoexcept

< memory allocation and structure definitions are valid.

NOT in MFC so use COBJECT_IsValidCheck to call.

Note
This can't be called in constructors and destructors of course !

Reimplemented from Gray::CObject.

◆ OptimizeRegionRects()

void GrayLib::cRegion::OptimizeRegionRects ( )

Get rid of overlapping rects. Combine adjacent rects that may be combined. m_rectUnion should not change !

◆ PtInRegion() [1/2]

bool GrayLib::cRegion::PtInRegion ( const cPoint2i pt) const
inline

◆ PtInRegion() [2/2]

bool GrayLib::cRegion::PtInRegion ( int  x,
int  y 
) const

is this point in the region?

◆ put_RectUnion()

void GrayLib::cRegion::put_RectUnion ( const cRectI rect)
inline

◆ RefRegionRect()

cRectI & GrayLib::cRegion::RefRegionRect ( ITERATE_t  i)

Get a particular rectangle. allow it to be modified!

◆ RemoveRegionRect()

void GrayLib::cRegion::RemoveRegionRect ( ITERATE_t  i)
virtual

Get rid of a rectangle.

◆ SetRegionSubtract()

void GrayLib::cRegion::SetRegionSubtract ( const cRectI rect1,
const cRectI rect2 
)

Create a region by subtracting rect2 from rect1

◆ SubtractRegion()

bool GrayLib::cRegion::SubtractRegion ( const cRegion pRegionTest)
Returns
true = was overlapped.

◆ SubtractRegionRect()

bool GrayLib::cRegion::SubtractRegionRect ( const cRectI rect)

Subtract rect from this region.

Returns
true = overlap.

◆ UNITTEST_FRIEND()

GrayLib::cRegion::UNITTEST_FRIEND ( cRegion  )

◆ v_GetRegion()

void GrayLib::cRegion::v_GetRegion ( cVariant vVal) const

Get this as a Variant.

◆ v_SetRegion()

HRESULT GrayLib::cRegion::v_SetRegion ( const cVariant vVal)

set this from a Variant.

Member Data Documentation

◆ m_rectUnion

cRectI GrayLib::cRegion::m_rectUnion
protected

The union rectangle. (may have holes in it of course)


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