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

FreemanCode.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------*
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2004  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the license. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 /**
00029  * @file  FreemanCode.C
00030  * @brief Implementation of class qgar::FreemanCode.
00031  *
00032  *        See file FreemanCode.H for the interface.
00033  *
00034  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00035  * @date   February 3, 2004  17:17
00036  * @since  Qgar 2.1.1
00037  */
00038 
00039 
00040 
00041 // STD
00042 #include <iostream>
00043 #include <sstream>
00044 #include <string>
00045 // QGAR
00046 #include <qgarlib/FreemanCode.H>
00047 #include <qgarlib/image.H>
00048 
00049 
00050 namespace qgar
00051 {
00052 
00053 
00054 // ---------------------------------------------------------------------
00055 // ---------------------------------------------------------------------
00056 // C O N S T R U C T O R S
00057 // ---------------------------------------------------------------------
00058 // ---------------------------------------------------------------------
00059 
00060 
00061 // DEFAULT CONSTRUCTOR
00062 
00063 FreemanCode::FreemanCode()
00064 
00065   : _direction(QGE_DIRECTION_N),
00066     _length(0)
00067 
00068 {
00069   // VOID
00070 }
00071 
00072 // COPY CONSTRUCTOR
00073 
00074 FreemanCode::FreemanCode(const FreemanCode& aCode)
00075 
00076   : _direction(aCode._direction),
00077     _length(aCode._length)
00078 
00079 {
00080   // VOID
00081 }
00082 
00083 // INITIALIZE WITH A DIRECTION AND A LENGTH
00084 
00085 FreemanCode::FreemanCode(QGEdirection aDir, unsigned int aLength)
00086 
00087   : _direction(aDir),
00088     _length(aLength)
00089 
00090 {
00091   // VOID
00092 }
00093 
00094 
00095 // ---------------------------------------------------------------------
00096 // ---------------------------------------------------------------------
00097 // D E S T R U C T O R
00098 // ---------------------------------------------------------------------
00099 // ----------------------------------------------------------------------
00100 
00101 
00102 // VIRTUAL DESTRUCTOR
00103 
00104 FreemanCode::~FreemanCode()
00105 {
00106   // VOID
00107 }
00108 
00109 
00110 // ---------------------------------------------------------------------
00111 // ---------------------------------------------------------------------
00112 // O P E R A T O R S
00113 // ---------------------------------------------------------------------
00114 // ---------------------------------------------------------------------
00115 
00116 
00117 // ASSIGNMENT OPERATOR
00118 
00119 FreemanCode&
00120 FreemanCode::operator=(const FreemanCode& aCode)
00121 {
00122   // Are left hand side and right hand side different objects?
00123   if (this != &aCode)
00124     {
00125       _direction = aCode._direction;
00126       _length    = aCode._length;
00127     }
00128 
00129   return *this;
00130 }
00131 
00132 
00133 // ---------------------------------------------------------------------
00134 // ---------------------------------------------------------------------
00135 // S E R I A L I Z A T I O N / D E S E R I A L I Z A T I O N
00136 // ---------------------------------------------------------------------
00137 // ---------------------------------------------------------------------
00138 
00139 
00140 std::istream& 
00141 FreemanCode::read(std::istream& anInStream)
00142 {
00143   qgReadObjName(anInStream, "FreemanCode");
00144 
00145   int dir;
00146   qgReadObjData(anInStream, dir);
00147   _direction = (QGEdirection) dir;
00148 
00149   qgReadObjData(anInStream, _length);
00150 
00151   return anInStream;
00152 }
00153 
00154 
00155 std::ostream& 
00156 FreemanCode::write(std::ostream& anOutStream) const
00157 {
00158   anOutStream << "FreemanCode("
00159               << _direction
00160               << ")("
00161               << _length
00162               << ')';
00163 
00164   return anOutStream;
00165 }
00166 
00167 
00168 // ----------------------------------------------------------------------
00169 
00170 } // namespace qgar