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

_QGAR_GenQgarArc.TCC

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------+
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2002  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 licence. |
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   _QGAR_GenQgarArc.TCC
00030  * @brief  Implementation of function members of class qgar::GenQgarArc.
00031  *
00032  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00033  * @date   December 14, 2004  17:17
00034  * @since  Qgar 2.2
00035  */
00036 
00037 
00038 
00039 // STD
00040 #include <iostream>
00041 #include <cmath>
00042 // QGAR
00043 #include <qgarlib/ISerializable.H>
00044 
00045 
00046 
00047 namespace qgar
00048 {
00049 
00050 
00051 // -------------------------------------------------------------------
00052 // C O N S T R U C T O R S
00053 // -------------------------------------------------------------------
00054 
00055 
00056 // DEFAULT CONSTRUCTOR
00057 
00058 template <class T>
00059 GenQgarArc<T>::GenQgarArc(int aThickness,
00060                           QGEcolor aColor,
00061                           QGEoutline anOutline)
00062 
00063   : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00064     _geomStructure(GenPoint<T>(static_cast<T>(0),static_cast<T>(0)),
00065                    GenPoint<T>(static_cast<T>(0),static_cast<T>(0)),
00066                    GenPoint<T>(static_cast<T>(0),static_cast<T>(0)))
00067 
00068 {
00069   // VOID
00070 }
00071 
00072 
00073 // COPY-CONSTRUCTOR
00074 
00075 template <class T>
00076 GenQgarArc<T>::GenQgarArc(const GenQgarArc<T>& aQArc)
00077   
00078   : AbstractGenQgarPrimitive<T>(aQArc._thickness,
00079                                 aQArc._color,
00080                                 aQArc._outline),
00081     _geomStructure(aQArc._geomStructure)
00082 
00083 {
00084   // VOID
00085 }
00086 
00087 
00088 // INITIALIZE FROM A GEOMETRICAL ARC
00089 
00090 template <class T>
00091 GenQgarArc<T>::GenQgarArc(const GenArc<T>& anArc,
00092                           int aThickness,
00093                           QGEcolor aColor,
00094                           QGEoutline anOutline)
00095 
00096   : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00097     _geomStructure(anArc)
00098 
00099 {
00100   // VOID
00101 }
00102 
00103 
00104 // INITIALIZE FROM THREE POINTS
00105 
00106 template <class T>
00107 GenQgarArc<T>::GenQgarArc(const GenPoint<T>& aSource,
00108                           const GenPoint<T>& aTarget,
00109                           const GenPoint<T>& aCenter,
00110                           int aThickness,
00111                           QGEcolor aColor,
00112                           QGEoutline anOutline)
00113 
00114   : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00115     _geomStructure(aSource, aTarget, aCenter)
00116 
00117 {
00118   // VOID
00119 }
00120 
00121 
00122 // -------------------------------------------------------------------
00123 // D E S T R U C T O R 
00124 // -------------------------------------------------------------------
00125 
00126 
00127 template <class T>
00128 GenQgarArc<T>::~GenQgarArc()
00129 {
00130   // VOID
00131 }
00132 
00133 
00134 // -------------------------------------------------------------------
00135 // O P E R A T O R S 
00136 // -------------------------------------------------------------------
00137 
00138 
00139 // ASSIGNMENT
00140 
00141 template <class T>
00142 GenQgarArc<T>&
00143 GenQgarArc<T>::operator=(const GenQgarArc<T>& aQArc)
00144 {
00145   // Are left hand side and right hand side different objects?
00146   if (this != &aQArc)
00147     {
00148       AbstractGenQgarPrimitive<T>::operator=(aQArc);
00149       this->_geomStructure = aQArc._geomStructure;
00150     }
00151   return *this;
00152 }
00153 
00154 
00155 // SAME AS FUNCTION qgar::GenQgarArc::eq
00156 
00157 template <class T>
00158 inline bool
00159 GenQgarArc<T>::operator==(const GenQgarArc<T>& aQArc) const
00160 {
00161   return eq(aQArc);
00162 }
00163 
00164 
00165 // SAME AS FUNCTION qgar::GenQgarArc::notEq
00166 
00167 template <class T>
00168 inline bool
00169 GenQgarArc<T>::operator!=(const GenQgarArc<T>& aQArc) const
00170 {
00171   return notEq(aQArc);
00172 }
00173   
00174 
00175 // -------------------------------------------------------------------
00176 // F U N C T I O N A L   O P E R A T O R S 
00177 // -------------------------------------------------------------------
00178 
00179 
00180 // EQUALITY OF GEOMETRICAL STRUCTURES
00181 
00182 template <class T>
00183 inline bool
00184 GenQgarArc<T>::eq(const GenQgarArc<T>& aQArc) const
00185 {
00186   return (this->accessGeomStructure()).eq(aQArc.accessGeomStructure());
00187 }
00188 
00189 
00190 // FULL EQUALITY
00191 
00192 template <class T>
00193 bool
00194 GenQgarArc<T>::equal(const GenQgarArc<T>& aQArc) const
00195 {
00196   return
00197        (this->eq(aQArc))
00198     && (this->_thickness == aQArc._thickness)
00199     && (this->_color     == aQArc._color)
00200     && (this->_outline   == aQArc._outline);
00201 }
00202 
00203 
00204 // INEQUALITY OF GEOMETRICAL STRUCTURES
00205 
00206 template <class T>
00207 inline bool
00208 GenQgarArc<T>::notEq(const GenQgarArc<T>& aQArc) const
00209 {
00210   return (this->accessGeomStructure()).notEq(aQArc.accessGeomStructure());
00211 }
00212 
00213 
00214 // FULL INEQUALITY
00215 
00216 template <class T>
00217 bool
00218 GenQgarArc<T>::notEqual(const GenQgarArc<T>& aQArc) const
00219 {
00220   return
00221        (this->notEq(aQArc))
00222     || (this->_source != aQArc._source) 
00223     || (this->_target != aQArc._target)
00224     || (this->_center != aQArc._center);
00225 }
00226 
00227 
00228 // -------------------------------------------------------------------
00229 // A C C E S S   T O   G E O M E T R I C A L   F E A T U R E S
00230 // -------------------------------------------------------------------
00231 
00232 
00233 // GET THE RADIUS
00234 
00235 template <class T>
00236 inline double
00237 GenQgarArc<T>::radius() const
00238 {
00239   return (this->_geomStructure).radius();
00240 }
00241 
00242 
00243 // GET LENGTH OF THE ARC
00244 
00245 template <class T>
00246 inline double
00247 GenQgarArc<T>::length() const
00248 {
00249   return (this->_geomStructure).length();
00250 }
00251 
00252 
00253 // GET THE SOURCE ANGLE, IN [0, 2PI] RADIANS
00254 
00255 template <class T>
00256 inline double
00257 GenQgarArc<T>::sourceAngle() const
00258 {
00259   return (this->_geomStructure).sourceAngle();
00260 }
00261 
00262 
00263 // GET THE SOURCE ANGLE, IN [0, 360] DEGREES
00264 
00265 template <class T>
00266 inline double
00267 GenQgarArc<T>::sourceAngleDegrees() const
00268 {
00269   return (this->_geomStructure).sourceAngleDegrees();
00270 }
00271 
00272 
00273 // GET THE TARGET ANGLE, IN [0, 2PI] RADIANS
00274 
00275 template <class T>
00276 inline double
00277 GenQgarArc<T>::targetAngle() const
00278 {
00279   return (this->_geomStructure).targetAngle();
00280 }
00281 
00282 
00283 // GET THE TARGET ANGLE, IN [0, 360] DEGREES
00284 
00285 template <class T>
00286 inline double
00287 GenQgarArc<T>::targetAngleDegrees() const
00288 {
00289   return (this->_geomStructure).targetAngleDegrees();
00290 }
00291 
00292 
00293 // GET THE ANGLE OF THE ARC, IN [0, 2PI] RADIANS
00294 
00295 template <class T>
00296 inline double
00297 GenQgarArc<T>::angle() const
00298 {
00299   return (this->_geomStructure).angle();
00300 }
00301 
00302 
00303 // GET THE ANGLE OF THE ARC, IN [0, 360] DEGREES
00304 
00305 template <class T>
00306 inline double
00307 GenQgarArc<T>::angleDegrees() const
00308 {
00309   return (this->_geomStructure).angleDegrees();
00310 }
00311 
00312 
00313 // -------------------------------------------------------------------
00314 // C E N T E R
00315 // -------------------------------------------------------------------
00316 
00317 
00318 // GET THE CENTER POINT
00319 
00320 template <class T>
00321 inline const GenPoint<T>&
00322 GenQgarArc<T>::accessCenter() const
00323 {
00324   return (this->_geomStructure).accessCenter();
00325 }
00326 
00327 
00328 // GET A COPY OF THE CENTER POINT
00329 
00330 template <class T>
00331 inline GenPoint<T>
00332 GenQgarArc<T>::center() const
00333 {
00334   return (this->_geomStructure).center();
00335 }
00336 
00337 
00338 // GET X COORDINATE OF CENTER POINT
00339 
00340 template <class T>
00341 inline T
00342 GenQgarArc<T>::xCenter() const
00343 {
00344   return (this->_geomStructure).xCenter();
00345 }
00346 
00347 
00348 // GET Y COORDINATE OF CENTER POINT
00349 
00350 template <class T>
00351 inline T
00352 GenQgarArc<T>::yCenter() const
00353 {
00354   return (this->_geomStructure).yCenter();
00355 }
00356 
00357 
00358 // SET X COORDINATE OF THE CENTER POINT
00359 
00360 template <class T>
00361 inline void
00362 GenQgarArc<T>::setXCenter(T aX)
00363 {
00364   (this->_geomStructure).setXCenter(aX);
00365 }
00366 
00367  
00368 // SET Y COORDINATE OF THE CENTER POINT
00369 
00370 template <class T>
00371 inline void
00372 GenQgarArc<T>::setYCenter(T aY)
00373 {
00374   (this->_geomStructure).setYCenter(aY);
00375 }
00376 
00377 
00378 // SET THE CENTER POINT
00379 
00380 template <class T>
00381 inline void
00382 GenQgarArc<T>::setCenter(T aX, T aY)
00383 {
00384   (this->_geomStructure).setCenter(aX,aY);
00385 }
00386 
00387 
00388 template <class T>
00389 inline void
00390 GenQgarArc<T>::setCenter(const GenPoint<T>& aCenter)
00391 {
00392   (this->_geomStructure).setCenter(aCenter);
00393 }
00394 
00395 
00396 // -------------------------------------------------------------------
00397 // 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
00398 // -------------------------------------------------------------------
00399 
00400 
00401 template <class T>
00402 std::istream& 
00403 GenQgarArc<T>::read(std::istream& anInStream)
00404 {
00405   qgReadObjName(anInStream, "QgarArc");
00406 
00407   // Geometrical structure
00408 
00409   qgReadObjData(anInStream, this->_geomStructure);
00410 
00411   // Attributes
00412 
00413   qgReadObjData(anInStream, this->_thickness);
00414 
00415   int color;
00416   qgReadObjData(anInStream, color);
00417   this->_color = static_cast<QGEcolor>(color);
00418 
00419   int outline;
00420   qgReadObjData(anInStream, outline);
00421   this->_outline = static_cast<QGEoutline>(outline);
00422 
00423   return anInStream;
00424 }
00425 
00426 
00427 template <class T>
00428 std::ostream& 
00429 GenQgarArc<T>::write(std::ostream& anOutStream) const
00430 {
00431   anOutStream << "QgarArc("
00432               << this->_geomStructure
00433               << ")("
00434               << this->_thickness
00435               << ")("
00436               << this->_color
00437               << ")("
00438               << this->_outline
00439               << ')';
00440 
00441   return anOutStream;  
00442 }
00443 
00444 
00445 // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
00446 // V                                                                 V
00447 // V            IMPLEMENTATION OF PURE VIRTUAL FUNCTIONS             V
00448 // V            INHERITED FROM AbstractGenQgarPrimitive              V
00449 // V                                                                 V
00450 // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
00451 
00452 
00453 // -------------------------------------------------------------------
00454 // C O P Y
00455 // -------------------------------------------------------------------
00456 
00457 
00458 // GET A COPY OF THE STRUCTURE IMPLEMENTING
00459 // THE GEOMETRICAL ASPECT OF A QGAR ARC
00460 
00461 template <class T>
00462 GenQgarArc<T>*
00463 GenQgarArc<T>::clone() const
00464 {
00465   return new GenQgarArc<T>(*this);
00466 }
00467 
00468 
00469 // -------------------------------------------------------------------
00470 // A C C E S S   T O   G E O M E T R I C A L   F E A T U R E S
00471 // -------------------------------------------------------------------
00472 
00473 
00474 // GET THE STRUCTURE IMPLEMENTING
00475 // THE GEOMETRICAL ASPECT OF A QGAR ARC
00476 
00477 template <class T>
00478 inline const GenArc<T>&
00479 GenQgarArc<T>::accessGeomStructure() const
00480 {
00481   return this->_geomStructure;
00482 }
00483 
00484 
00485 // -------------------------------------------------------------------
00486 // NON-PROTECTED ACCESS TO THE GEOMETRICAL ASPECT
00487 // -------------------------------------------------------------------
00488 
00489 
00490 // RETURN THE GEOMETRICAL ASPECT, THAT MAY THEN BE MODIFIED
00491 // USING APPROPRIATE TRANSFORMATION FUNCTION MEMBERS
00492 
00493 template <class T>
00494 inline AbstractGenPrimitive<T>&
00495 GenQgarArc<T>::getGeomStructure()
00496 {
00497   return this->_geomStructure;
00498 }
00499 
00500 
00501 // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
00502 // V                                                                 V
00503 // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
00504 
00505 
00506 } // namespace qgar