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
00044 #ifndef __PDIMENSIONH__
00045 #define __PDIMENSIONH__
00046
00047 namespace pandore {
00048
00049 class Dimension1d;
00050 class Dimension2d;
00051 class Dimension3d;
00052
00053
00054
00055
00056
00057
00058 template<>
00059 struct TypeName< Dimension1d > {
00060
00061
00062
00063
00064 static ::std::string Name() { return "Dimension1d"; }
00065 };
00066
00067
00068
00069
00070
00071
00072 template<>
00073 struct TypeName< Dimension2d > {
00074
00075
00076
00077
00078 static std::string Name() { return "Dimension2d"; }
00079 };
00080
00081
00082
00083
00084
00085
00086 template<>
00087 struct TypeName< Dimension3d > {
00088
00089
00090
00091
00092 static std::string Name() { return "Dimension3d"; }
00093 };
00094
00107 class Dimension: public Pobject {
00108 protected:
00109 Dimension() {}
00110
00111 public:
00112 ~Dimension() {}
00113
00119 Pobject* Mask( const Pobject * ) {
00120 return this;
00121 }
00122
00129 Pobject* UnMask( const Pobject * , const Pobject * ) {
00130 return this;
00131 }
00132
00139 Errc LoadAttributes( FILE* ) {
00140 return SUCCESS;
00141 }
00142
00148 Errc SaveAttributes( FILE* ) const {
00149 return SUCCESS;
00150 }
00151 };
00152
00167 class Dimension1d: public Dimension {
00168 public:
00170 Long w;
00171
00177 Typobj Type() const { return Po_Dimension1d; }
00178
00183 std::string Name() const { return TypeName< Dimension1d >::Name(); }
00184
00188 Dimension1d(): Dimension(), w(0) {}
00189
00194 Dimension1d( Long width ): Dimension(), w(width) {}
00195
00200 Dimension1d( const Dimension1d& d ): Dimension(), w(d.w) {}
00201
00207 const Dimension1d& operator=( const Dimension1d& d ) {
00208 w = d.w;
00209 return *this;
00210 }
00211
00217 bool operator==( const Dimension1d& d ) const {
00218 return d.w == w;
00219 }
00220
00226 bool operator!=( const Dimension1d& d ) const {
00227 return !(d == *this);
00228 }
00229
00236 Dimension1d operator+( int x ) const {
00237 return Dimension1d(w + x);
00238 }
00239
00246 Dimension1d operator-( int x ) const {
00247 return Dimension1d(w - x);
00248 }
00249
00256 Dimension1d operator*( int x ) const {
00257 return Dimension1d(w * x);
00258 }
00259
00266 Dimension1d operator/( int x ) const {
00267 return Dimension1d(w / x);
00268 }
00269
00273 Pobject* Clone() const {
00274 return new Dimension1d(w);
00275 }
00276
00282 Errc LoadData( FILE *df ) {
00283 if (this->Fdecode(&w, sizeof(w), 1, df) < 1) {
00284 return FAILURE;
00285 }
00286 return SUCCESS;
00287 }
00288
00294 Errc SaveData( FILE *df ) const {
00295 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00296 return FAILURE;
00297 }
00298 return SUCCESS;
00299 }
00300 };
00301
00309 inline const Dimension1d operator*( int x, const Dimension1d &d ) {
00310 return Dimension1d(d.w * x);
00311 }
00312
00327 class Dimension2d: public Dimension {
00328 public:
00330 Long w;
00332 Long h;
00333
00339 Typobj Type() const { return Po_Dimension2d; }
00340
00345 std::string Name() const { return TypeName< Dimension2d >::Name(); }
00346
00350 Dimension2d(): Dimension(), w(0), h(0) {}
00351
00357 Dimension2d( Long height, Long width ): Dimension(), w(width), h(height) {}
00358
00363 Dimension2d( const Dimension2d& d ): Dimension(), w(d.w), h(d.h) {}
00364
00370 const Dimension2d& operator=( const Dimension2d& d ) {
00371 w = d.w;
00372 h = d.h;
00373
00374 return *this;
00375 }
00376
00382 bool operator==( const Dimension2d& d ) const {
00383 return d.w == w && d.h == h;
00384 }
00385
00391 bool operator!=( const Dimension2d& d ) const {
00392 return !(d == *this);
00393 }
00394
00401 Dimension2d operator+( int x ) const {
00402 return Dimension2d(h + x, w + x);
00403 }
00404
00411 Dimension2d operator-( int x ) const {
00412 return Dimension2d(h - x, w - x);
00413 }
00414
00421 Dimension2d operator*( int x ) const {
00422 return Dimension2d(h * x, w * x);
00423 }
00424
00431 Dimension2d operator/( int x ) const {
00432 return Dimension2d(h / x, w / x);
00433 }
00434
00438 Pobject* Clone() const {
00439 return new Dimension2d(h, w);
00440 }
00441
00447 Errc LoadData( FILE *df ) {
00448 if (Fdecode(&h, sizeof(h), 1, df) < 1) {
00449 return FAILURE;
00450 }
00451 if (Fdecode(&w, sizeof(w), 1, df) < 1) {
00452 return FAILURE;
00453 }
00454 return SUCCESS;
00455 }
00456
00462 Errc SaveData( FILE *df ) const {
00463 if (this->Fencode(&h, sizeof(h), 1, df) < 1) {
00464 return FAILURE;
00465 }
00466 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00467 return FAILURE;
00468 }
00469 return SUCCESS;
00470 }
00471 };
00472
00480 inline const Dimension2d operator*( int x, const Dimension2d &d ) {
00481 return Dimension2d(d.h * x, d.w * x);
00482 }
00483
00498 class Dimension3d: public Dimension {
00499 public:
00501 Long d;
00503 Long h;
00505 Long w;
00506
00512 Typobj Type() const { return Po_Dimension3d; }
00513
00518 std::string Name() const { return TypeName< Dimension3d >::Name(); }
00519
00524 Dimension3d(): Dimension(), d(0), h(0), w(0) {}
00525
00532 Dimension3d( Long depth, Long height, Long width ): Dimension(), d(depth), h(height), w(width) {}
00533
00538 Dimension3d( const Dimension3d &d ): Dimension(), d(d.d), h(d.h), w(d.w) {}
00539
00545 Dimension3d operator=( const Dimension3d &x ) {
00546 w = x.w; h = x.h; d = x.d;
00547 return *this;
00548 }
00549
00555 bool operator==( const Dimension3d &x ) const{
00556 return x.w == w && x.h == h && x.d == d;
00557 }
00558
00564 bool operator!=( const Dimension3d &x ) const {
00565 return !(x == *this);
00566 }
00567
00574 Dimension3d operator+( int x ) const {
00575 return Dimension3d(d + x, h + x, w + x);
00576 }
00577
00584 Dimension3d operator-( int x ) const {
00585 return Dimension3d(d - x, h - x, w - x);
00586 }
00587
00594 Dimension3d operator*( int x ) const {
00595 return Dimension3d(d * x, h * x, w * x);
00596 }
00597
00604 Dimension3d operator/( int x ) const {
00605 return Dimension3d(d / x, h / x, w / x);
00606 }
00607
00611 Pobject* Clone() const {
00612 return new Dimension3d(d, h, w);
00613 }
00614
00620 Errc LoadData( FILE *df ) {
00621 if (this->Fdecode(&d, sizeof(d), 1, df) < 1) {
00622 return FAILURE;
00623 }
00624 if (this->Fdecode(&h, sizeof(h), 1, df) < 1) {
00625 return FAILURE;
00626 }
00627 if (this->Fdecode(&w, sizeof(w), 1, df) < 1) {
00628 return FAILURE;
00629 }
00630 return SUCCESS;
00631 }
00632
00638 Errc SaveData( FILE *df ) const {
00639 if (this->Fencode(&d, sizeof(d), 1, df) < 1) {
00640 return FAILURE;
00641 }
00642 if (this->Fencode(&h, sizeof(h), 1, df) < 1) {
00643 return FAILURE;
00644 }
00645 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00646 return FAILURE;
00647 }
00648 return SUCCESS;
00649 }
00650 };
00651
00659 inline const Dimension3d operator*( int x, const Dimension3d &d ) {
00660 return Dimension3d(d.d * x, d.h * x, d.w * x);
00661 }
00662
00663 }
00664
00665 #endif // __PDIMENSIONH__