Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgar::FreemanCode Class Reference
[Points]

#include <qgarlib/FreemanCode.H>

Inheritance diagram for qgar::FreemanCode:

qgar::ISerializable List of all members.

Detailed Description

A Freeman code, defined as a pair (direction, length).

A direction is coded using predefined enum type qgar::QGEdirection. As the origin of the coordinates system in images is at top left corner, North and South are upside down for more convenience:

  (0,0) +---------------------------------------------> X
        |
        |                 QGE_DIRECTION_N
        |                        |  
        |     QGE_DIRECTION_NW \ | / QGE_DIRECTION_NE
        |                       \|/
        |   QGE_DIRECTION_W -----+----- QGE_DIRECTION_E
        |                       /|\
        |     QGE_DIRECTION_SW / | \ QGE_DIRECTION_SE
        |                        |
        |                 QGE_DIRECTION_S
      Y V

Author:
Gérald Masini
Date:
February 3, 2004 17:17
Since:
Qgar 2.1.1

Definition at line 89 of file FreemanCode.H.

Public Member Functions

Constructors
 FreemanCode ()
 Default constructor.
 FreemanCode (const FreemanCode &aCode)
 Copy constructor.
 FreemanCode (QGEdirection aDir, unsigned int aLength)
 Initialize with a direction and a length.
Destructor
virtual ~FreemanCode ()
 Virtual destructor.
Access
QGEdirection direction () const
 Get direction.
int length () const
 Get length.
Transformation
void setDir (QGEdirection aDir)
 Set direction.
void setLength (unsigned int aLength)
 Set length.
void setDirLength (QGEdirection aDir, unsigned int aLength)
 Set both direction and length.
Conversions
template<class T>
GenPoint< T > toPoint (const GenPoint< T > &aPt) const
 Return the point at the location defined by the current Freeman code, starting from the given point.
template<class T>
GenPoint< T > toOppositePoint (const GenPoint< T > &aPt) const
 Return the point at the location defined by the current Freeman code, whose direction is changed into its opposite, starting from the given point.
Operators
FreemanCodeoperator= (const FreemanCode &aCode)
 Assignment operator.
Serialization/deserialization
virtual std::istream & read (std::istream &anInStream)
 Deserializes the current Freeman code from an input stream.
virtual std::ostream & write (std::ostream &anOutStream) const
 Serializes the current Freeman code to an input stream.

Protected Attributes

Representation of a Freeman code
QGEdirection _direction
 The direction code.
int _length
 The length.

Private Member Functions

Auxiliaries
template<class T>
GenPoint< T > toPointAUX (const GenPoint< T > &aPt, QGEdirection aDir, unsigned int aLength) const throw (QgarErrorInvalidArg)
 Return the point located at given length in given direction from the given point.


Constructor & Destructor Documentation

qgar::FreemanCode::FreemanCode  ) 
 

Default constructor.

Direction is initialized to qgar::QGE_DIRECTION_N and length to 0.

Definition at line 63 of file FreemanCode.C.

qgar::FreemanCode::FreemanCode const FreemanCode aCode  ) 
 

Copy constructor.

Parameters:
aCode a Freeman code

Definition at line 74 of file FreemanCode.C.

qgar::FreemanCode::FreemanCode QGEdirection  aDir,
unsigned int  aLength
 

Initialize with a direction and a length.

Parameters:
aDir a direction
aLength a length
Warning:
Length may be initialized to 0.

Definition at line 85 of file FreemanCode.C.

qgar::FreemanCode::~FreemanCode  )  [virtual]
 

Virtual destructor.

Definition at line 104 of file FreemanCode.C.


Member Function Documentation

QGEdirection qgar::FreemanCode::direction  )  const [inline]
 

Get direction.

Definition at line 307 of file FreemanCode.H.

References _direction.

Referenced by qgar::FreemanChain::push_front().

int qgar::FreemanCode::length  )  const [inline]
 

Get length.

Definition at line 315 of file FreemanCode.H.

References _length.

Referenced by qgar::FreemanChain::push_front().

FreemanCode & qgar::FreemanCode::operator= const FreemanCode aCode  ) 
 

Assignment operator.

Parameters:
aCode a Freeman code

Definition at line 120 of file FreemanCode.C.

References _direction, and _length.

std::istream & qgar::FreemanCode::read std::istream &  anInStream  )  [virtual]
 

Deserializes the current Freeman code from an input stream.

Parameters:
anInStream the input stream
A serialized Freeman code is represented as:
FreemanCode ( <DIRECTION> ) ( <LENGTH> )

See also:
qgar::qgReadObjName, qgar::qgReadObjData

Implements qgar::ISerializable.

Definition at line 141 of file FreemanCode.C.

References _direction, _length, qgar::qgReadObjData(), and qgar::qgReadObjName().

void qgar::FreemanCode::setDir QGEdirection  aDir  )  [inline]
 

Set direction.

Parameters:
aDir a direction

Definition at line 328 of file FreemanCode.H.

References _direction.

void qgar::FreemanCode::setDirLength QGEdirection  aDir,
unsigned int  aLength
[inline]
 

Set both direction and length.

Parameters:
aDir a direction
aLength a length
Warning:
Length may be initialized to 0.

Definition at line 344 of file FreemanCode.H.

References _direction, and _length.

Referenced by qgar::FreemanChain::push_front().

void qgar::FreemanCode::setLength unsigned int  aLength  )  [inline]
 

Set length.

Parameters:
aLength a direction
Warning:
Length may be initialized to 0.

Definition at line 336 of file FreemanCode.H.

References _length.

template<class T>
GenPoint< T > qgar::FreemanCode::toOppositePoint const GenPoint< T > &  aPt  )  const
 

Return the point at the location defined by the current Freeman code, whose direction is changed into its opposite, starting from the given point.

Parameters:
aPt a point
Exceptions:
qgar::QgarErrorInvalidArg (unknown direction)

Definition at line 369 of file FreemanCode.H.

References _direction, _length, qgar::qgOpposite(), and toPointAUX().

template<class T>
GenPoint< T > qgar::FreemanCode::toPoint const GenPoint< T > &  aPt  )  const
 

Return the point at the location defined by the current Freeman code, starting from the given point.

Parameters:
aPt a point
Exceptions:
qgar::QgarErrorInvalidArg (unknown direction)

Definition at line 359 of file FreemanCode.H.

References _direction, _length, and toPointAUX().

Referenced by qgar::FreemanChain::FreemanChain(), qgar::FreemanChain::push_back(), and qgar::FreemanChain::push_front().

template<class T>
GenPoint< T > qgar::FreemanCode::toPointAUX const GenPoint< T > &  aPt,
QGEdirection  aDir,
unsigned int  aLength
const throw (QgarErrorInvalidArg) [private]
 

Return the point located at given length in given direction from the given point.

Parameters:
aPt a point
aDir a direction
aLength a length

Definition at line 384 of file FreemanCode.H.

References qgar::QGE_DIRECTION_E, qgar::QGE_DIRECTION_N, qgar::QGE_DIRECTION_NE, qgar::QGE_DIRECTION_NW, qgar::QGE_DIRECTION_S, qgar::QGE_DIRECTION_SE, qgar::QGE_DIRECTION_SW, and qgar::QGE_DIRECTION_W.

Referenced by toOppositePoint(), and toPoint().

std::ostream & qgar::FreemanCode::write std::ostream &  anOutStream  )  const [virtual]
 

Serializes the current Freeman code to an input stream.

Parameters:
anOutStream the output stream
A serialized Freeman code is represented as:
FreemanCode ( <DIRECTION> ) ( <LENGTH> )

Implements qgar::ISerializable.

Definition at line 156 of file FreemanCode.C.

References _direction, and _length.


Member Data Documentation

QGEdirection qgar::FreemanCode::_direction [protected]
 

The direction code.

Definition at line 257 of file FreemanCode.H.

Referenced by direction(), operator=(), read(), setDir(), setDirLength(), toOppositePoint(), toPoint(), and write().

int qgar::FreemanCode::_length [protected]
 

The length.

Definition at line 262 of file FreemanCode.H.

Referenced by length(), operator=(), read(), setDirLength(), setLength(), toOppositePoint(), toPoint(), and write().


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