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
00053 #ifndef __PDIMENSIONH__
00054 #define __PDIMENSIONH__
00055
00056 namespace pandore {
00057
00058 class Dimension1d;
00059 class Dimension2d;
00060 class Dimension3d;
00061
00062
00063
00064
00065
00066
00067 template<>
00068 struct TypeName< Dimension1d > {
00069
00070
00071
00072
00073 static ::std::string Name() { return "Dimension1d"; }
00074 };
00075
00076
00077
00078
00079
00080
00081 template<>
00082 struct TypeName< Dimension2d > {
00083
00084
00085
00086
00087 static std::string Name() { return "Dimension2d"; }
00088 };
00089
00090
00091
00092
00093
00094
00095 template<>
00096 struct TypeName< Dimension3d > {
00097
00098
00099
00100
00101 static std::string Name() { return "Dimension3d"; }
00102 };
00103
00116 class Dimension: public Pobject {
00117 protected:
00118 Dimension() {}
00119
00120 public:
00121 ~Dimension() {}
00122
00128 Pobject* Mask( const Pobject * ) {
00129 return this;
00130 }
00131
00138 Pobject* UnMask( const Pobject * , const Pobject * ) {
00139 return this;
00140 }
00141
00148 Errc LoadAttributes( FILE* ) {
00149 return SUCCESS;
00150 }
00151
00157 Errc SaveAttributes( FILE* ) const {
00158 return SUCCESS;
00159 }
00160 };
00161
00176 class Dimension1d: public Dimension {
00177 public:
00179 Long w;
00180
00186 Typobj Type() const { return Po_Dimension1d; }
00187
00192 std::string Name() const { return TypeName< Dimension1d >::Name(); }
00193
00197 Dimension1d(): Dimension(), w(0) {}
00198
00203 Dimension1d( Long width ): Dimension(), w(width) {}
00204
00209 Dimension1d( const Dimension1d& d ): Dimension(), w(d.w) {}
00210
00216 const Dimension1d& operator=( const Dimension1d& d ) {
00217 w = d.w;
00218 return *this;
00219 }
00220
00226 bool operator==( const Dimension1d& d ) const {
00227 return d.w == w;
00228 }
00229
00235 bool operator!=( const Dimension1d& d ) const {
00236 return !(d == *this);
00237 }
00238
00245 Dimension1d operator+( int x ) const {
00246 return Dimension1d(w + x);
00247 }
00248
00255 Dimension1d operator-( int x ) const {
00256 return Dimension1d(w - x);
00257 }
00258
00265 Dimension1d operator*( int x ) const {
00266 return Dimension1d(w * x);
00267 }
00268
00275 Dimension1d operator/( int x ) const {
00276 return Dimension1d(w / x);
00277 }
00278
00282 Pobject* Clone() const {
00283 return new Dimension1d(w);
00284 }
00285
00291 Errc LoadData( FILE *df ) {
00292 if (this->Fdecode(&w, sizeof(w), 1, df) < 1) {
00293 return FAILURE;
00294 }
00295 return SUCCESS;
00296 }
00297
00303 Errc SaveData( FILE *df ) const {
00304 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00305 return FAILURE;
00306 }
00307 return SUCCESS;
00308 }
00309 };
00310
00318 inline const Dimension1d operator*( int x, const Dimension1d &d ) {
00319 return Dimension1d(d.w * x);
00320 }
00321
00336 class Dimension2d: public Dimension {
00337 public:
00339 Long w;
00341 Long h;
00342
00348 Typobj Type() const { return Po_Dimension2d; }
00349
00354 std::string Name() const { return TypeName< Dimension2d >::Name(); }
00355
00359 Dimension2d(): Dimension(), w(0), h(0) {}
00360
00366 Dimension2d( Long height, Long width ): Dimension(), w(width), h(height) {}
00367
00372 Dimension2d( const Dimension2d& d ): Dimension(), w(d.w), h(d.h) {}
00373
00379 const Dimension2d& operator=( const Dimension2d& d ) {
00380 w = d.w;
00381 h = d.h;
00382
00383 return *this;
00384 }
00385
00391 bool operator==( const Dimension2d& d ) const {
00392 return d.w == w && d.h == h;
00393 }
00394
00400 bool operator!=( const Dimension2d& d ) const {
00401 return !(d == *this);
00402 }
00403
00410 Dimension2d operator+( int x ) const {
00411 return Dimension2d(h + x, w + x);
00412 }
00413
00420 Dimension2d operator-( int x ) const {
00421 return Dimension2d(h - x, w - x);
00422 }
00423
00430 Dimension2d operator*( int x ) const {
00431 return Dimension2d(h * x, w * x);
00432 }
00433
00440 Dimension2d operator/( int x ) const {
00441 return Dimension2d(h / x, w / x);
00442 }
00443
00447 Pobject* Clone() const {
00448 return new Dimension2d(h, w);
00449 }
00450
00456 Errc LoadData( FILE *df ) {
00457 if (Fdecode(&h, sizeof(h), 1, df) < 1) {
00458 return FAILURE;
00459 }
00460 if (Fdecode(&w, sizeof(w), 1, df) < 1) {
00461 return FAILURE;
00462 }
00463 return SUCCESS;
00464 }
00465
00471 Errc SaveData( FILE *df ) const {
00472 if (this->Fencode(&h, sizeof(h), 1, df) < 1) {
00473 return FAILURE;
00474 }
00475 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00476 return FAILURE;
00477 }
00478 return SUCCESS;
00479 }
00480 };
00481
00489 inline const Dimension2d operator*( int x, const Dimension2d &d ) {
00490 return Dimension2d(d.h * x, d.w * x);
00491 }
00492
00507 class Dimension3d: public Dimension {
00508 public:
00510 Long d;
00512 Long h;
00514 Long w;
00515
00521 Typobj Type() const { return Po_Dimension3d; }
00522
00527 std::string Name() const { return TypeName< Dimension3d >::Name(); }
00528
00533 Dimension3d(): Dimension(), d(0), h(0), w(0) {}
00534
00541 Dimension3d( Long depth, Long height, Long width ): Dimension(), d(depth), h(height), w(width) {}
00542
00547 Dimension3d( const Dimension3d &d ): Dimension(), d(d.d), h(d.h), w(d.w) {}
00548
00554 Dimension3d operator=( const Dimension3d &x ) {
00555 w = x.w; h = x.h; d = x.d;
00556 return *this;
00557 }
00558
00564 bool operator==( const Dimension3d &x ) const{
00565 return x.w == w && x.h == h && x.d == d;
00566 }
00567
00573 bool operator!=( const Dimension3d &x ) const {
00574 return !(x == *this);
00575 }
00576
00583 Dimension3d operator+( int x ) const {
00584 return Dimension3d(d + x, h + x, w + x);
00585 }
00586
00593 Dimension3d operator-( int x ) const {
00594 return Dimension3d(d - x, h - x, w - x);
00595 }
00596
00603 Dimension3d operator*( int x ) const {
00604 return Dimension3d(d * x, h * x, w * x);
00605 }
00606
00613 Dimension3d operator/( int x ) const {
00614 return Dimension3d(d / x, h / x, w / x);
00615 }
00616
00620 Pobject* Clone() const {
00621 return new Dimension3d(d, h, w);
00622 }
00623
00629 Errc LoadData( FILE *df ) {
00630 if (this->Fdecode(&d, sizeof(d), 1, df) < 1) {
00631 return FAILURE;
00632 }
00633 if (this->Fdecode(&h, sizeof(h), 1, df) < 1) {
00634 return FAILURE;
00635 }
00636 if (this->Fdecode(&w, sizeof(w), 1, df) < 1) {
00637 return FAILURE;
00638 }
00639 return SUCCESS;
00640 }
00641
00647 Errc SaveData( FILE *df ) const {
00648 if (this->Fencode(&d, sizeof(d), 1, df) < 1) {
00649 return FAILURE;
00650 }
00651 if (this->Fencode(&h, sizeof(h), 1, df) < 1) {
00652 return FAILURE;
00653 }
00654 if (this->Fencode(&w, sizeof(w), 1, df) < 1) {
00655 return FAILURE;
00656 }
00657 return SUCCESS;
00658 }
00659 };
00660
00668 inline const Dimension3d operator*( int x, const Dimension3d &d ) {
00669 return Dimension3d(d.d * x, d.h * x, d.w * x);
00670 }
00671
00672 }
00673
00674 #endif // __PDIMENSIONH__