Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

RobotFlow::CRect Class Reference

#include <CRect.h>

Inheritance diagram for RobotFlow::CRect:

Inheritance graph
Collaboration diagram for RobotFlow::CRect:

Collaboration graph

Detailed Description


A CRect is a rectangle defined by its upper left corner and its lower right corner and contains ImageCell elements of multiple lines.

Dominic Letourneau
{verbatim} Creation : 23/02/2001 Last Modification:
2005/03/29 15:20:47

Public Member Functions

 CRect ()
 CRect (int x1, int y1, int x2, int y2)
 CRect (const CRect &r)
 CRect (CPoint &p1, CPoint &p2)
virtual ~CRect ()
void cell_cleanup ()
void IntersectRect (CRect &inter, const CRect &rect2)
void UnionRect (CRect &uni, const CRect &rect2)
void SetRect (CPoint &p1, CPoint &p2)
bool IsRectEmpty () const
int Height () const
int Width () const
int MeanCellWidth (int *pCellMin, int *pCellMax, int nSize, int nWidthMax)
float MeanCellWidth ()
int Area () const
CPoint TopLeft ()
CPoint BottomRight ()
bool operator== (const CRect &rect) const
bool operator< (const CRect &rect)
bool operator> (const CRect &rect)
CRectoperator= (const CRect &rect)
void add_cell (ImageCell *cell, bool update=false, bool serialized=false)
std::list< ImageCell * > & get_cell_list ()
void set_values (int x1, int y1, int x2, int y2)
void get_values (int &x1, int &y1, int &x2, int &y2)
bool inside (CRect *rect)
void center_of_gravity ()
void get_center_of_gravity (double &center_x, double &center_y)
void printOn (std::ostream &out=std::cout) const
void readFrom (std::istream &in)
void merge (CRect *rect)
double dist (CRect *rect)
double dist (double x, double y)
void ref ()
void unref ()
int unique ()
virtual void destroy ()
virtual void serialize (std::ostream &out) const
virtual void unserialize (std::istream &in)
virtual void doesNotUnderstand (std::string method)
virtual bool isNil () const
virtual void prettyPrint (std::ostream &out=std::cout) const
virtual ObjectRef clone ()
virtual std::string className () const

Static Public Member Functions

static ObjectRef newObject (const std::string &objType)
static int addObjectType (const std::string &objType, _ObjectFactory *factory)
static std::map< std::string,
_ObjectFactory * > & 
ObjectFactoryDictionary ()
static TypeMap< _ObjectFactory * > & TypeidDictionary ()

Protected Attributes

AtomicCounter ref_count

Private Attributes

double m_center_y
 Center of gravity y.
double m_center_x
 Center of gravity x.
int m_area
 Area of the ImageCells.
int m_x1
int m_y1
int m_x2
int m_y2
std::list< ImageCell * > m_cell_list
 The list of cells.
std::list< ImageCell * > m_serialized_list
 The temp serialized cells list.


friend std::ostream & operator<< (std::ostream &out, const Object &obj)

Constructor & Destructor Documentation

RobotFlow::CRect::CRect  ) 

Ctor default with (x1,y1,x2,y2) = (0,0,0,0)

RobotFlow::CRect::CRect int  x1,
int  y1,
int  x2,
int  y2

Ctor with corner values

x1 ulx
y1 uly
x2 lrx
y2 lry

RobotFlow::CRect::CRect const CRect r  ) 

Copy ctor

r The CRect to copy

RobotFlow::CRect::CRect CPoint p1,
CPoint p2

Ctor with CPoints for ulc and lrc

p1 ulc
p2 lrc

RobotFlow::CRect::~CRect  )  [virtual]

Dtor Destructor

Member Function Documentation

void RobotFlow::CRect::add_cell ImageCell cell,
bool  update = false,
bool  serialized = false

Adds a ImageCell to the CRect

cell,The ImageCell to be added
update,True if the area and the coordinates are to be updated

int RobotFlow::CRect::Area  )  const

Returns the Area of the CRect. The Area is not the Area of the rectangle but what's contained in it. This is the area of all ImageCell put together that are added in the CRect.

int Area

CPoint RobotFlow::CRect::BottomRight  ) 

Returns the lower right corner

CPoint The lrc

void RobotFlow::CRect::cell_cleanup  ) 

Cleanup for unused cells

void RobotFlow::CRect::center_of_gravity  ) 

Calculates the center of gravity from the ImageCells

double RobotFlow::CRect::dist double  x,
double  y

double RobotFlow::CRect::dist CRect rect  ) 

Distance (cog to cog) of two CRect

double the distance

list< ImageCell * > & RobotFlow::CRect::get_cell_list  ) 

Returns the list of cell in the CRect

list<ImageCell*>& The list of cells

void RobotFlow::CRect::get_center_of_gravity double &  center_x,
double &  center_y

Gets the center of gravity. You must call center_of_gravity() first to calculate it.

center_x the x center of gravity
center_y the y center of gravity

void RobotFlow::CRect::get_values int &  x1,
int &  y1,
int &  x2,
int &  y2

Returns the coordinates of the upper left corner and the lower right corner

x1 ulx
y1 uly
x2 lrx
y2 lry

int RobotFlow::CRect::Height  )  const

Returns the height of the CRect

int The height

bool RobotFlow::CRect::inside CRect rect  ) 

Verifies if a Crect is inside another one

rect The rect to verify
bool true if the rect is inside

void RobotFlow::CRect::IntersectRect CRect inter,
const CRect rect2

Intersection between two CRect

inter the CRect we are doing intersection with (destination)
rect2 the Crect we are doing intersectino with (source)

bool RobotFlow::CRect::IsRectEmpty  )  const

Verifies if the CRect is empty

bool True if the CRect is empty

float RobotFlow::CRect::MeanCellWidth  ) 

Returns the mean cell width for a CRect

int the mean_width

int RobotFlow::CRect::MeanCellWidth int *  pCellMin,
int *  pCellMax,
int  nSize,
int  nWidthMax

Returns the mean of the cell width

int the mean of the cell width

void RobotFlow::CRect::merge CRect rect  ) 

Merge two CRect (adding cells)

rect The rect to merge with

bool RobotFlow::CRect::operator< const CRect rect  ) 

Verifies if the area is smaller

bool True if smaller

CRect & RobotFlow::CRect::operator= const CRect rect  ) 

Assignation operator between two CRect

rect a CRect Instance to equals
CRect& a CRect Instance

bool RobotFlow::CRect::operator== const CRect rect  )  const

Verifies if two CRect are identical

bool True if they are identical

bool RobotFlow::CRect::operator> const CRect rect  ) 

Verifies if the area is larger

bool True if larger

void RobotFlow::CRect::printOn std::ostream &  out = std::cout  )  const [virtual]

Implements FD::Object.

void RobotFlow::CRect::readFrom std::istream &  in  )  [virtual]

Reimplemented from FD::Object.

void RobotFlow::CRect::set_values int  x1,
int  y1,
int  x2,
int  y2

Sets the corner values of the CRect.

x1 ulx
y1 uly
x2 lrx
y2 lry

void RobotFlow::CRect::SetRect CPoint p1,
CPoint p2

Sets the values of its coordinates

p1 ulc
p2 lrc

CPoint RobotFlow::CRect::TopLeft  ) 

Returns the upper left corner

CPoint The ulc

void RobotFlow::CRect::UnionRect CRect uni,
const CRect rect2

Union between two CRect

uni the CRect we are doing intersection with (destination)
rect2 the Crect we are doing intersectino with (source)

int RobotFlow::CRect::Width  )  const

Returns the width of the CRect

int The width

Field Documentation

int RobotFlow::CRect::m_area [private]

std::list<ImageCell*> RobotFlow::CRect::m_cell_list [private]

double RobotFlow::CRect::m_center_x [private]

double RobotFlow::CRect::m_center_y [private]

std::list<ImageCell*> RobotFlow::CRect::m_serialized_list [private]

int RobotFlow::CRect::m_x1 [private]

int RobotFlow::CRect::m_x2 [private]

int RobotFlow::CRect::m_y1 [private]

int RobotFlow::CRect::m_y2 [private]

The documentation for this class was generated from the following files:
Generated on Wed Oct 5 14:36:33 2005 for RobotFlow by  doxygen 1.4.4