00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <iostream>
00041
00042 #include <qgarlib/ISerializable.H>
00043
00044
00045
00046 namespace qgar
00047 {
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 template <class T>
00058 GenArc<T>::GenArc()
00059
00060 : AbstractGenPrimitive<T>(0, 0, 0, 0),
00061 _center(0, 0)
00062
00063 {
00064
00065 }
00066
00067
00068
00069
00070 template <class T>
00071 GenArc<T>::GenArc(const GenArc<T>& anArc)
00072
00073 : AbstractGenPrimitive<T>(anArc._source, anArc._target),
00074 _center(anArc._center)
00075
00076 {
00077
00078 }
00079
00080
00081
00082
00083 template <class T>
00084 GenArc<T>::GenArc(const GenQgarArc<T>& aQArc)
00085
00086 : AbstractGenPrimitive<T>(aQArc.accessSource(), aQArc.accessTarget()),
00087 _center(aQArc.accessCenter())
00088
00089 {
00090
00091 }
00092
00093
00094
00095
00096 template <class T>
00097 GenArc<T>::GenArc(const GenPoint<T>& aSource,
00098 const GenPoint<T>& aTarget,
00099 const GenPoint<T>& aCenter)
00100
00101 : AbstractGenPrimitive<T>(aSource, aTarget),
00102 _center(aCenter)
00103
00104 {
00105
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 template <class T>
00115 GenArc<T>::~GenArc()
00116 {
00117
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 template <class T>
00127 GenArc<T>*
00128 GenArc<T>::clone() const
00129 {
00130 return new GenArc<T>(*this);
00131 }
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 template <class T>
00142 inline double
00143 GenArc<T>::radius() const
00144 {
00145 return qgDist(this->_source, this->_center);
00146 }
00147
00148
00149
00150
00151 template <class T>
00152 double
00153 GenArc<T>::length() const
00154 {
00155 return std::fabs(this->radius() * angle());
00156 }
00157
00158
00159
00160
00161 template <class T>
00162 double
00163 GenArc<T>::angle() const
00164 {
00165 double s = this->sourceAngle();
00166 double t = this->targetAngle();
00167
00168 if(t > s)
00169 {
00170 return t - s;
00171 }
00172 else
00173 {
00174 return t - s + Math::QG_2PI;
00175 }
00176 }
00177
00178
00179
00180
00181 template <class T>
00182 double
00183 GenArc<T>::angleDegrees() const
00184 {
00185 return qgRadiansToDegrees(angle());
00186 }
00187
00188
00189
00190
00191
00192 template <class T>
00193 inline double
00194 GenArc<T>::sourceAngle() const
00195 {
00196 return qgAngle(this->_center, this->_source);
00197 }
00198
00199
00200
00201
00202 template <class T>
00203 inline double
00204 GenArc<T>::sourceAngleDegrees() const
00205 {
00206 return qgRadiansToDegrees(this->sourceAngle());
00207 }
00208
00209
00210
00211
00212
00213 template <class T>
00214 inline double
00215 GenArc<T>::targetAngle() const
00216 {
00217 return qgAngle(this->_center, this->_target);
00218 }
00219
00220
00221
00222
00223 template <class T>
00224 inline double
00225 GenArc<T>::targetAngleDegrees() const
00226 {
00227 return qgRadiansToDegrees(this->targetAngle());
00228 }
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 template <class T>
00239 inline const GenPoint<T>&
00240 GenArc<T>::accessCenter() const
00241 {
00242 return this->_center;
00243 }
00244
00245
00246
00247
00248 template <class T>
00249 inline GenPoint<T>
00250 GenArc<T>::center() const
00251 {
00252 return this->_center;
00253 }
00254
00255
00256
00257
00258 template <class T>
00259 inline T
00260 GenArc<T>::xCenter() const
00261 {
00262 return (this->_center).x();
00263 }
00264
00265
00266
00267
00268 template <class T>
00269 inline T
00270 GenArc<T>::yCenter() const
00271 {
00272 return (this->_center).y();
00273 }
00274
00275
00276
00277
00278
00279 template <class T>
00280 inline void
00281 GenArc<T>::setXCenter(T aX)
00282 {
00283 (this->_center).setX(aX);
00284 }
00285
00286
00287
00288
00289
00290 template <class T>
00291 inline void
00292 GenArc<T>::setYCenter(T aY)
00293 {
00294 (this->_center).setY(aY);
00295 }
00296
00297
00298
00299
00300 template <class T>
00301 inline void
00302 GenArc<T>::setCenter(T aX, T aY)
00303 {
00304 (this->_center).setXY(aX,aY);
00305 }
00306
00307
00308
00309
00310 template <class T>
00311 inline void
00312 GenArc<T>::setCenter(const GenPoint<T>& aCenter)
00313 {
00314 (this->_center) = aCenter;
00315 }
00316
00317
00318
00319
00320
00321
00322
00323 template <class T>
00324 GenArc<T>&
00325 GenArc<T>::operator=(const GenArc<T>& anArc)
00326 {
00327
00328 if (this != &anArc)
00329 {
00330 AbstractGenPrimitive<T>::operator=(anArc);
00331 this->_center = anArc._center;
00332 }
00333
00334 return *this;
00335 }
00336
00337
00338
00339
00340 template <class T>
00341 inline bool
00342 GenArc<T>::operator==(const GenArc<T>& anArc) const
00343 {
00344 return eq(anArc);
00345 }
00346
00347
00348
00349
00350 template <class T>
00351 inline bool
00352 GenArc<T>::operator!=(const GenArc<T>& anArc) const
00353 {
00354 return notEq(anArc);
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 template <class T>
00366 bool
00367 GenArc<T>::eq(const GenArc<T>& anArc) const
00368 {
00369 return
00370 (this->_source == anArc._source)
00371 && (this->_target == anArc._target)
00372 && (this->_center == anArc._center);
00373 }
00374
00375
00376
00377
00378 template <class T>
00379 bool
00380 GenArc<T>::notEq(const GenArc<T>& anArc) const
00381 {
00382 return
00383 (this->_source != anArc._source)
00384 || (this->_target != anArc._target)
00385 || (this->_center != anArc._center);
00386 }
00387
00388
00389
00390
00391
00392
00393
00394 template <class T>
00395 std::istream&
00396 GenArc<T>::read(std::istream& anInStream)
00397 {
00398 qgReadObjName(anInStream, "Arc");
00399
00400 qgReadObjData(anInStream, this->_source);
00401 qgReadObjData(anInStream, this->_target);
00402 qgReadObjData(anInStream, this->_center);
00403
00404 return anInStream;
00405 }
00406
00407
00408 template <class T>
00409 std::ostream&
00410 GenArc<T>::write(std::ostream& anOutStream) const
00411 {
00412 anOutStream << "Arc("
00413 << this->source()
00414 << ")("
00415 << this->target()
00416 << ")("
00417 << this->center()
00418 << ')';
00419 return anOutStream;
00420 }
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438 template <class T>
00439 void
00440 GenArc<T>::updateSource()
00441 {
00442
00443 }
00444
00445
00446
00447
00448 template <class T>
00449 void
00450 GenArc<T>::updateTarget()
00451 {
00452
00453 }
00454
00455
00456
00457
00458 template <class T>
00459 void
00460 GenArc<T>::updateSourceTarget()
00461 {
00462
00463 }
00464
00465
00466
00467
00468
00469
00470
00471 template <class T>
00472 inline void
00473 GenArc<T>::translate(T aTransX, T aTransY)
00474 {
00475 this->setSourceTarget(this->xSource() + aTransX,
00476 this->ySource() + aTransY,
00477 this->xTarget() + aTransX,
00478 this->yTarget() + aTransY);
00479
00480 this->setCenter(_center.x() + aTransX, _center.y() + aTransY);
00481 }
00482
00483
00484
00485
00486
00487
00488
00489 }