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
00041 #include <cmath>
00042 #include <iostream>
00043
00044 #include <qgarlib/ISerializable.H>
00045 #include <qgarlib/math.H>
00046
00047
00048
00049 namespace qgar
00050 {
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 template <class T>
00061 GenQgarSegment<T>::GenQgarSegment(int aThickness,
00062 QGEcolor aColor,
00063 QGEoutline anOutline)
00064
00065 : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00066 _geomStructure(0, 0, 0, 0)
00067
00068 {
00069
00070 }
00071
00072
00073
00074
00075 template <class T>
00076 GenQgarSegment<T>::GenQgarSegment(const GenQgarSegment<T>& aQSeg)
00077
00078 : AbstractGenQgarPrimitive<T>(aQSeg._thickness,
00079 aQSeg._color,
00080 aQSeg._outline),
00081 _geomStructure(aQSeg._geomStructure)
00082
00083 {
00084
00085 }
00086
00087
00088
00089
00090 template <class T>
00091 GenQgarSegment<T>::GenQgarSegment(const GenSegment<T>& aSeg,
00092 int aThickness,
00093 QGEcolor aColor,
00094 QGEoutline anOutline)
00095
00096 : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00097 _geomStructure(aSeg)
00098
00099 {
00100
00101 }
00102
00103
00104
00105
00106 template <class T>
00107 GenQgarSegment<T>::GenQgarSegment(const GenPoint<T>& aSource,
00108 const GenPoint<T>& aTarget,
00109 int aThickness,
00110 QGEcolor aColor,
00111 QGEoutline anOutline)
00112
00113 : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00114 _geomStructure(aSource, aTarget)
00115
00116 {
00117
00118 }
00119
00120
00121
00122
00123 template <class T>
00124 GenQgarSegment<T>::GenQgarSegment(T aXSource,
00125 T aYSource,
00126 T aXTarget,
00127 T aYTarget,
00128 int aThickness,
00129 QGEcolor aColor,
00130 QGEoutline anOutline)
00131
00132 : AbstractGenQgarPrimitive<T>(aThickness, aColor, anOutline),
00133 _geomStructure(aXSource, aYSource, aXTarget, aYTarget)
00134
00135 {
00136
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 template <class T>
00146 GenQgarSegment<T>::~GenQgarSegment()
00147 {
00148
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 template <class T>
00160 inline double
00161 GenQgarSegment<T>::length() const
00162 {
00163 return _geomStructure.length();
00164 }
00165
00166
00167
00168
00169 template <class T>
00170 inline double
00171 GenQgarSegment<T>::sqr_length() const
00172 {
00173 return _geomStructure.sqr_length();
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183 template <class T>
00184 inline double
00185 GenQgarSegment<T>::rho() const
00186 {
00187 return _geomStructure.rho();
00188 }
00189
00190
00191
00192
00193
00194 template <class T>
00195 inline double
00196 GenQgarSegment<T>::theta() const
00197 {
00198 return _geomStructure.theta();
00199 }
00200
00201
00202
00203
00204 template <class T>
00205 inline double
00206 GenQgarSegment<T>::angle() const
00207 {
00208 return _geomStructure.angle();
00209 }
00210
00211
00212
00213
00214 template <class T>
00215 inline double
00216 GenQgarSegment<T>::thetaDegrees() const
00217 {
00218 return _geomStructure.thetaDegrees();
00219 }
00220
00221
00222
00223
00224 template <class T>
00225 inline double
00226 GenQgarSegment<T>::angleDegrees() const
00227 {
00228 return _geomStructure.angleDegrees();
00229 }
00230
00231
00232
00233
00234 template <class T>
00235 inline double
00236 GenQgarSegment<T>::slope() const
00237 {
00238 return _geomStructure.slope();
00239 }
00240
00241
00242
00243
00244 template <class T>
00245 inline double
00246 GenQgarSegment<T>::slopeDegrees() const
00247 {
00248 return _geomStructure.slopeDegrees();
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 template <class T>
00261 inline bool
00262 GenQgarSegment<T>::contains(const GenPoint<T>& c, double aDist)
00263 {
00264 return _geomStructure.contains(c, aDist);
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 template <class T>
00276 GenQgarSegment<T>&
00277 GenQgarSegment<T>::operator=(const GenQgarSegment<T>& aQSeg)
00278 {
00279
00280 if (this != &aQSeg)
00281 {
00282 AbstractGenQgarPrimitive<T>::operator=(aQSeg);
00283 _geomStructure = aQSeg._geomStructure;
00284 }
00285 return *this;
00286 }
00287
00288
00289
00290
00291 template <class T>
00292 inline bool
00293 GenQgarSegment<T>::operator==(const GenQgarSegment<T>& aQSeg) const
00294 {
00295 return this->_geomStructure == aQSeg._geomStructure;
00296 }
00297
00298
00299
00300
00301 template <class T>
00302 inline bool
00303 GenQgarSegment<T>::operator!=(const GenQgarSegment<T>& aQSeg) const
00304 {
00305 return this->_geomStructure != aQSeg._geomStructure;
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 template <class T>
00318 inline bool
00319 GenQgarSegment<T>::eq(const GenQgarSegment<T>& aQSeg) const
00320 {
00321 return (this->_geomStructure).eq(aQSeg._geomStructure);
00322 }
00323
00324
00325
00326
00327 template <class T>
00328 bool
00329 GenQgarSegment<T>::equal(const GenQgarSegment<T>& aQSeg) const
00330 {
00331 return
00332 (this->_geomStructure).eq(aQSeg._geomStructure)
00333 && ((this->_thickness) == (aQSeg._thickness))
00334 && ((this->_color) == (aQSeg._color))
00335 && ((this->_outline) == (aQSeg._outline));
00336 }
00337
00338
00339
00340
00341 template <class T>
00342 inline bool
00343 GenQgarSegment<T>::notEq(const GenQgarSegment<T>& aQSeg) const
00344 {
00345 return (this->_geomStructure).notEq(aQSeg._geomStructure);
00346 }
00347
00348
00349
00350
00351 template <class T>
00352 bool
00353 GenQgarSegment<T>::notEqual(const GenQgarSegment<T>& aQSeg) const
00354 {
00355 return
00356 (this->_geomStructure).notEq(aQSeg._geomStructure)
00357 || ((this->_thickness) != (aQSeg._thickness))
00358 || ((this->_color) != (aQSeg._color))
00359 || ((this->_outline) != (aQSeg._outline));
00360 }
00361
00362
00363
00364
00365
00366
00367
00368 template <class T>
00369 std::istream&
00370 GenQgarSegment<T>::read(std::istream& anInStream)
00371 {
00372 qgReadObjName(anInStream, "QgarSegment");
00373
00374
00375
00376 qgReadObjData(anInStream, _geomStructure);
00377
00378
00379
00380 qgReadObjData(anInStream, this->_thickness);
00381
00382 int color;
00383 qgReadObjData(anInStream, color);
00384 this->_color = static_cast<QGEcolor>(color);
00385
00386 int outline;
00387 qgReadObjData(anInStream, outline);
00388 this->_outline = static_cast<QGEoutline>(outline);
00389
00390 return anInStream;
00391 }
00392
00393
00394 template <class T>
00395 std::ostream&
00396 GenQgarSegment<T>::write(std::ostream& anOutStream) const
00397 {
00398 anOutStream << "QgarSegment("
00399 << this->_geomStructure
00400 << ")("
00401 << this->_thickness
00402 << ")("
00403 << this->_color
00404 << ")("
00405 << this->_outline
00406 << ')';
00407 return anOutStream;
00408 }
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 template <class T>
00428 GenQgarSegment<T>*
00429 GenQgarSegment<T>::clone() const
00430 {
00431 return new GenQgarSegment<T>(*this);
00432 }
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 template <class T>
00444 inline const GenSegment<T>&
00445 GenQgarSegment<T>::accessGeomStructure() const
00446 {
00447 return _geomStructure;
00448 }
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 template <class T>
00460 inline AbstractGenPrimitive<T>&
00461 GenQgarSegment<T>::getGeomStructure()
00462 {
00463 return _geomStructure;
00464 }
00465
00466
00467
00468
00469
00470
00471
00472 }