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

_QGAR_AbstractGenPrimitive.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_AbstractGenPrimitive.TCC
00030  * @brief    Implementation of the function members
00031  *           of class qgar::AbstractGenPrimitive.
00032  *
00033  * @author  <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00034  * @date    December 14, 2004  14:14
00035  * @since   Qgar 2.2
00036  */
00037 
00038 
00039 
00040 namespace qgar
00041 {
00042 
00043 
00044 // -------------------------------------------------------------------
00045 // JUST A FAKE CLASS (NOT DEFINED)
00046 // TO BE USED TO CAUSE COMPILATION ERRORS WHEN SOME TEMPLATE FUNCTION
00047 // CANNOT BE INSTANTIATED USING ANY TYPE
00048 // -------------------------------------------------------------------
00049 
00050 
00051 class TEMPLATE_FUNCTION_CANNOT_BE_INSTANTIATED_SEE_DOC;
00052 
00053 
00054 // -------------------------------------------------------------------
00055 // C O N S T R U C T O R S
00056 // -------------------------------------------------------------------
00057 
00058 
00059 // DEFAULT CONSTRUCTOR
00060 
00061 
00062 template <class T>
00063 AbstractGenPrimitive<T>::AbstractGenPrimitive()
00064 
00065   : _source(static_cast<T>(0), static_cast<T>(0)),
00066     _target(static_cast<T>(0), static_cast<T>(0))
00067 
00068 {
00069   // VOID
00070 }
00071 
00072 
00073 // COPY-CONSTRUCTOR
00074 
00075 
00076 template <class T>
00077 AbstractGenPrimitive<T>::AbstractGenPrimitive(const AbstractGenPrimitive<T>& aPrim)
00078 
00079   : _source(aPrim._source),
00080     _target(aPrim._target)
00081 
00082 {
00083   // VOID
00084 }
00085 
00086 
00087 // INITIALIZE FROM SOURCE AND TARGET
00088 
00089 
00090 template <class T>
00091 AbstractGenPrimitive<T>::AbstractGenPrimitive(const GenPoint<T> aSource,
00092                                               const GenPoint<T> aTarget)
00093 
00094   : _source(aSource),
00095     _target(aTarget)
00096 
00097 {
00098   // VOID
00099 }
00100 
00101 
00102 // INITIALIZE FROM COORDINATES
00103 
00104 
00105 template <class T>
00106 AbstractGenPrimitive<T>::AbstractGenPrimitive(T aXSource,
00107                                               T aYSource,
00108                                               T aXTarget,
00109                                               T aYTarget)
00110 
00111   : _source(aXSource, aYSource),
00112     _target(aXTarget, aYTarget)
00113 
00114 {
00115   // VOID
00116 }
00117 
00118 
00119 // -------------------------------------------------------------------
00120 // D E S T R U C T O R 
00121 // -------------------------------------------------------------------
00122 
00123 
00124 // VIRTUAL DESTRUCTOR
00125 
00126 
00127 template <class T>
00128 AbstractGenPrimitive<T>::~AbstractGenPrimitive()
00129 {
00130   // VOID
00131 }
00132 
00133 
00134 // -------------------------------------------------------------------
00135 // A C C E S S   T O   S O U R C E   A N D   T A R G E T 
00136 // -------------------------------------------------------------------
00137 
00138 
00139 // GET SOURCE POINT
00140 
00141 template <class T>
00142 inline const GenPoint<T>&
00143 AbstractGenPrimitive<T>::accessSource() const
00144 {
00145   return _source;
00146 }
00147 
00148 
00149 // GET A COPY OF THE SOURCE POINT
00150 
00151 template <class T>
00152 inline GenPoint<T>
00153 AbstractGenPrimitive<T>::source() const
00154 {
00155   return _source;
00156 }
00157 
00158 
00159 // GET TARGET POINT
00160 
00161 template <class T>
00162 inline const GenPoint<T>&
00163 AbstractGenPrimitive<T>::accessTarget() const
00164 {
00165   return _target;
00166 }
00167 
00168 
00169 // GET A COPY OF THE TARGET POINT
00170 
00171 template <class T>
00172 inline GenPoint<T>
00173 AbstractGenPrimitive<T>::target() const
00174 {
00175   return _target;
00176 }
00177 
00178 
00179 // -------------------------------------------------------------------
00180 // A C C E S S   T O   S E P A R A T E   C O O R D I N A T E S 
00181 // -------------------------------------------------------------------
00182 
00183 
00184 // GET X COORDINATE OF THE SOURCE POINT
00185 
00186 template <class T>
00187 inline T
00188 AbstractGenPrimitive<T>::xSource() const
00189 {
00190   return _source.x();
00191 }
00192 
00193 
00194 // GET X COORDINATE OF THE TARGET POINT
00195 
00196 template <class T>
00197 inline T
00198 AbstractGenPrimitive<T>::xTarget() const
00199 {
00200   return _target.x();
00201 }
00202 
00203 
00204 // GET Y COORDINATE OF THE SOURCE POINT
00205 
00206 template <class T>
00207 inline T
00208 AbstractGenPrimitive<T>::ySource() const
00209 {
00210   return _source.y();
00211 }
00212 
00213 
00214 // GET Y COORDINATE OF THE TARGET POINT
00215 
00216 template <class T>
00217 inline T
00218 AbstractGenPrimitive<T>::yTarget() const
00219 {
00220   return _target.y();
00221 }
00222 
00223 
00224 // -------------------------------------------------------------------
00225 // ACCESS TO GEOMETRICAL CHARACTERISTICS
00226 // -------------------------------------------------------------------
00227 
00228 
00229 // VERTICAL (SIGNED) DISTANCE
00230 
00231 template <class T>
00232 inline T
00233 AbstractGenPrimitive<T>::dx() const
00234 {
00235   return (_target.x() - _source.x());
00236 }
00237 
00238 
00239 // HORIZONTAL (SIGNED) DISTANCE
00240 
00241 template <class T>
00242 inline T
00243 AbstractGenPrimitive<T>::dy() const
00244 {
00245   return (_target.y() - _source.y());
00246 }
00247  
00248 
00249 // -------------------------------------------------------------------
00250 // SET SOURCE AND/OR TARGET WITHOUT UPDATE
00251 // -------------------------------------------------------------------
00252 
00253 
00254 // SET SOURCE POINT
00255 
00256 
00257 template <class T>
00258 inline void
00259 AbstractGenPrimitive<T>::setSource(T aX, T aY)
00260 {
00261   _source.setXY(aX,aY);
00262 }
00263 
00264 
00265 template <class T>
00266 inline void
00267 AbstractGenPrimitive<T>::setSource(const GenPoint<T>& aPt)
00268 {
00269   _source = aPt;
00270 }
00271 
00272 
00273 // SET TARGET POINT
00274 
00275 
00276 template <class T>
00277 inline void
00278 AbstractGenPrimitive<T>::setTarget(T aX, T aY)
00279 {
00280   _target.setXY(aX,aY);
00281 }
00282 
00283 
00284 template <class T>
00285 inline void
00286 AbstractGenPrimitive<T>::setTarget(const GenPoint<T>& aPt)
00287 {
00288   _target = aPt;
00289 }
00290 
00291 
00292 // SET BOTH SOURCE AND TARGET POINTS
00293 
00294 
00295 template <class T>
00296 void
00297 AbstractGenPrimitive<T>::setSourceTarget(T aXSource,
00298                                          T aYSource,
00299                                          T aXTarget,
00300                                          T aYTarget)
00301 {
00302   _source.setXY(aXSource, aYSource);
00303   _target.setXY(aXTarget, aYTarget);
00304 }
00305 
00306 
00307 template <class T>
00308 void
00309 AbstractGenPrimitive<T>::setSourceTarget(const GenPoint<T>& aSource,
00310                                          const GenPoint<T>& aTarget)
00311 {
00312   _source = aSource;
00313   _target = aTarget;
00314 }
00315 
00316 
00317 // -------------------------------------------------------------------
00318 // SET SOURCE AND/OR TARGET WITH UPDATE
00319 // -------------------------------------------------------------------
00320 
00321 
00322 // SET SOURCE POINT
00323 
00324 
00325 template <class T>
00326 void
00327 AbstractGenPrimitive<T>::fixSource(T aX, T aY)
00328 {
00329   this->setSource(aX,aY);
00330   this->updateSource();
00331 }
00332 
00333 
00334 template <class T>
00335 void
00336 AbstractGenPrimitive<T>::fixSource(const GenPoint<T>& aPt)
00337 {
00338   this->setSource(aPt);
00339   this->updateSource();
00340 }
00341 
00342 
00343 // SET TARGET POINT
00344 
00345 
00346 template <class T>
00347 void
00348 AbstractGenPrimitive<T>::fixTarget(T aX, T aY)
00349 {
00350   this->setTarget(aX,aY);
00351   this->updateTarget();
00352 }
00353 
00354 
00355 template <class T>
00356 void
00357 AbstractGenPrimitive<T>::fixTarget(const GenPoint<T>& aPt)
00358 {
00359   this->setTarget(aPt);
00360   this->updateTarget();
00361 }
00362 
00363 
00364 // SET BOTH SOURCE AND TARGET POINTS
00365 
00366 
00367 template <class T>
00368 void
00369 AbstractGenPrimitive<T>::fixSourceTarget(T aXSource,
00370                                          T aYSource,
00371                                          T aXTarget,
00372                                          T aYTarget)
00373 {
00374   this->setSourceTarget(aXSource, aYSource, aXTarget, aYTarget);
00375   this->updateSourceTarget();
00376 }
00377 
00378 
00379 template <class T>
00380 void
00381 AbstractGenPrimitive<T>::fixSourceTarget(const GenPoint<T>& aSource,
00382                                          const GenPoint<T>& aTarget)
00383 {
00384   this->setSourceTarget(aSource, aTarget);
00385   this->updateSourceTarget();
00386 }
00387 
00388 
00389 // -------------------------------------------------------------------
00390 //  SET SEPARATE COORDINATES WITHOUT UPDATE
00391 // -------------------------------------------------------------------
00392 
00393 
00394 // SET X COORDINATE OF THE SOURCE POINT
00395 
00396 template <class T>
00397 inline void
00398 AbstractGenPrimitive<T>::setXSource(T aX) 
00399 {
00400   (this->_source).setX(aX);
00401 }
00402 
00403 
00404 // SET X COORDINATE OF THE TARGET POINT
00405 
00406 template <class T>
00407 inline void
00408 AbstractGenPrimitive<T>::setXTarget(T aX)
00409 {
00410   (this->_target).setX(aX);
00411 }
00412 
00413 
00414 // SET Y COORDINATE OF THE SOURCE POINT
00415 
00416 template <class T>
00417 inline void
00418 AbstractGenPrimitive<T>::setYSource(T aY)
00419 {
00420   (this->_source).setY(aY);
00421 }
00422 
00423 
00424 // SET Y COORDINATE OF THE TARGET POINT
00425 
00426 template <class T>
00427 inline void
00428 AbstractGenPrimitive<T>::setYTarget(T aY)
00429 {
00430   (this->_target).setY(aY);
00431 }
00432 
00433 
00434 // -------------------------------------------------------------------
00435 //  SET SEPARATE COORDINATES WITH UPDATE
00436 // -------------------------------------------------------------------
00437 
00438 
00439 // SET X COORDINATE OF THE SOURCE POINT
00440 
00441 template <class T>
00442 void
00443 AbstractGenPrimitive<T>::fixXSource(T aX) 
00444 {
00445   this->setXSource(aX);
00446   this->updateSource();
00447 }
00448 
00449 
00450 // SET X COORDINATE OF THE TARGET POINT
00451 
00452 template <class T>
00453 void
00454 AbstractGenPrimitive<T>::fixXTarget(T aX)
00455 {
00456   this->setXTarget(aX);
00457   this->updateTarget();
00458 }
00459 
00460 
00461 // SET Y COORDINATE OF THE SOURCE POINT
00462 
00463 template <class T>
00464 void
00465 AbstractGenPrimitive<T>::fixYSource(T aY)
00466 {
00467   this->setYSource(aY);
00468   this->updateSource();
00469 }
00470 
00471 
00472 // SET Y COORDINATE OF THE TARGET POINT
00473 
00474 template <class T>
00475 void
00476 AbstractGenPrimitive<T>::fixYTarget(T aY)
00477 {
00478   this->setYTarget(aY);
00479   this->updateTarget();
00480 }
00481 
00482 
00483 // -------------------------------------------------------------------
00484 // O P E R A T O R S 
00485 // -------------------------------------------------------------------
00486 
00487 
00488 // ASSIGNMENT
00489 
00490 template <class T>
00491 AbstractGenPrimitive<T>&
00492 AbstractGenPrimitive<T>::operator=(const AbstractGenPrimitive<T>& aPrim)
00493 {
00494   // Are left hand side and right hand side different objects?
00495   if (this != &aPrim)
00496     {
00497       this->_source = aPrim._source;
00498       this->_target = aPrim._target;
00499     }
00500 
00501   return *this;
00502 }
00503 
00504 
00505 
00506 // // -------------------------------------------------------------------
00507 // // G E O M E T R Y :   S Y M M E T R Y 
00508 // // -------------------------------------------------------------------
00509 
00510 
00511 // // TRANSFORM CURRENT PRIMITIVE INTO ITS SYMMETRICAL PRIMITIVE
00512 // // RELATIVELY TO THE POINT OF GIVEN COORDINATES
00513 
00514 
00515 // template <class T>
00516 // inline void
00517 // AbstractGenPrimitive<T>::symmetry(T aX, T aY)
00518 // {
00519 //   qgSymmetry(*this, aX, aY);
00520 // }
00521 
00522 
00523 // // TRANSFORM CURRENT PRIMITIVE INTO ITS SYMMETRICAL PRIMITIVE
00524 // // RELATIVELY TO THE GIVEN CENTER
00525 
00526 
00527 // template <class T>
00528 // inline void
00529 // AbstractGenPrimitive<T>::symmetry(const GenPoint<T>& aCenter)
00530 // {
00531 //   qgSymmetry(*this, aCenter);
00532 // }
00533 
00534 
00535 // // TRANSFORM CURRENT PRIMITIVE INTO ITS SYMMETRICAL PRIMITIVE
00536 // // RELATIVELY TO THE LINE SUPPORTING THE GIVEN SEGMENT
00537 
00538 // // WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
00539 // // W                                                                 W
00540 // // W WARNING: THESE FUNCTIONS APPLY TO POINTS WITH COORDINATES       W
00541 // // W          OF TYPE DOUBLE ONLY                                    W
00542 // // W                                                                 W
00543 // // WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
00544 
00545 
00546 // // TRANSFORM CURRENT PRIMITIVE INTO ITS SYMMETRICAL PRIMITIVE
00547 // // RELATIVELY TO THE LINE PASSING THROUGH THE GIVEN POINTS
00548 
00549 
00550 // template <>
00551 // void
00552 // AbstractGenPrimitive<double>::symmetry(const GenSegment<double>& aPt1,
00553 //                                     const GenSegment<double>& aPt2)
00554 // {
00555 //   qgSymmetry(*this, aPt1, aPt2);
00556 // }
00557 
00558 
00559 // template <class T>
00560 // void
00561 // AbstractGenPrimitive<T>::symmetry(const GenSegment<double>& aSeg)
00562 // {
00563 //   TEMPLATE_FUNCTION_CANNOT_BE_INSTANTIATED_SEE_DOC();
00564 // }
00565 
00566 
00567 // // TRANSFORM CURRENT PRIMITIVE INTO ITS SYMMETRICAL PRIMITIVE
00568 // // RELATIVELY TO THE LINE SUPPORTING THE GIVEN SEGMENT
00569 
00570 
00571 // template <>
00572 // void
00573 // AbstractGenPrimitive<double>::symmetry(const GenSegment<double>& aSeg)
00574 // {
00575 //   qgSymmetry(*this, aSeg);
00576 // }
00577 
00578 
00579 // template <class T>
00580 // void
00581 // AbstractGenPrimitive<T>::symmetry(const GenSegment<double>& aSeg)
00582 // {
00583 //   TEMPLATE_FUNCTION_CANNOT_BE_INSTANTIATED_SEE_DOC();
00584 // }
00585 
00586 
00587 // -------------------------------------------------------------------
00588 
00589 
00590 } // namespace qgar