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 __PPOINTH__
00045 #define __PPOINTH__
00046
00047 namespace pandore {
00048
00049 class Dimension1d;
00050 class Dimension2d;
00051 class Dimension3d;
00052 class Point1d;
00053 class Point2d;
00054 class Point3d;
00055
00056
00057
00058
00059
00060
00061 template<>
00062 struct TypeName< Point1d > {
00063
00064
00065
00066
00067 static std::string Name() { return "Point1d"; }
00068 };
00069
00070
00071
00072
00073
00074
00075 template<>
00076 struct TypeName< Point2d > {
00081 static std::string Name() { return "Point2d"; }
00082 };
00083
00084
00085
00086
00087
00088
00089 template<>
00090 struct TypeName< Point3d > {
00095 static std::string Name() { return "Point3d"; }
00096 };
00097
00111 class Point: public Pobject {
00112 protected:
00113 Point() {}
00114
00115 public:
00116 ~Point() {}
00117
00123 Pobject* Mask( const Pobject * ) {
00124 return this;
00125 }
00126
00133 Pobject* UnMask( const Pobject * , const Pobject * ) {
00134 return this;
00135 }
00136
00143 Errc LoadAttributes( FILE* ) {
00144 return SUCCESS;
00145 }
00146
00152 Errc SaveAttributes( FILE* ) const {
00153 return SUCCESS;
00154 }
00155 };
00156
00172 class Point1d: public Point {
00173 public:
00175 Long x;
00176
00182 Typobj Type() const { return Po_Point1d; }
00183
00188 std::string Name() const { return TypeName< Point1d >::Name(); }
00189
00194 Point1d(): Point(), x(0) {}
00195
00201 Point1d( Long x ): Point(), x(x) {}
00202
00208 Point1d( const Point1d& p ): Point(), x(p.x) {}
00209
00214 Point1d( const Dimension1d& d ): Point(), x(d.w) {}
00215
00221 const Point1d& operator=( const Point1d& pt ) {
00222 x = pt.x;
00223 return *this;
00224 }
00225
00232 bool operator==( const Point1d& pt ) const {
00233 return pt.x == x;
00234 }
00235
00241 bool operator!=( const Point1d& pt ) const {
00242 return !(pt == *this);
00243 }
00244
00250 Point1d& operator+=( const Point1d& pt ) {
00251 x += pt.x;
00252 return *this;
00253 }
00254
00260 Point1d& operator-=( const Point1d& pt ) {
00261 x -= pt.x;
00262 return *this;
00263 }
00264
00270 Point1d& operator*=( const Point1d& pt ) {
00271 x *= pt.x;
00272 return *this;
00273 }
00274
00280 Point1d& operator/=( const Point1d& pt ) {
00281 x /= pt.x;
00282 return *this;
00283 }
00284
00292 Point1d operator+( const Point1d& pt ) const {
00293 return Point1d(x + pt.x);
00294 }
00295
00303 Point1d operator-( const Point1d& pt ) const {
00304 return Point1d(x - pt.x);
00305 }
00306
00314 Point1d operator*( const Point1d& pt ) const {
00315 return Point1d(x * pt.x);
00316 }
00317
00325 Point1d operator/( const Point1d& pt ) const {
00326 return Point1d(x / pt.x);
00327 }
00328
00332 Pobject* Clone() const {
00333 return new Point1d(x);
00334 }
00335
00341 Errc LoadData( FILE *df ) {
00342 if (this->Fdecode(&x, sizeof(x), 1, df) < 1) {
00343 return FAILURE;
00344 }
00345 return SUCCESS;
00346 }
00347
00353 Errc SaveData( FILE *df ) const {
00354 if (this->Fencode(&x, sizeof(x), 1, df) < 1) {
00355 return FAILURE;
00356 }
00357 return SUCCESS;
00358 }
00359 };
00360
00376 class Point2d: public Point {
00377 public:
00379 Long x;
00381 Long y;
00382
00388 Typobj Type() const { return Po_Point2d; }
00389
00394 std::string Name() const { return TypeName< Point2d >::Name(); }
00395
00400 Point2d(): Point(), x(0), y(0) {}
00401
00407 Point2d( Long i ): Point(), x(i), y(i) {}
00408
00415 Point2d( Long y, Long x ): Point(), x(x), y(y) {}
00416
00422 Point2d( const Point2d& p): Point(), x(p.x), y(p.y) {}
00423
00428 Point2d( const Dimension2d& p): Point(), x(p.w), y(p.h) {}
00429
00435 const Point2d& operator=( const Point2d& pt ) {
00436 x = pt.x;
00437 y = pt.y;
00438 return *this;
00439 }
00440
00447 bool operator==( const Point2d& pt ) const {
00448 return pt.x == x && pt.y == y;
00449 }
00450
00456 bool operator!=( const Point2d& pt ) const {
00457 return !(pt == *this);
00458 }
00459
00465 Point2d& operator+=( const Point2d& pt ) {
00466 x += pt.x;
00467 y += pt.y;
00468 return *this;
00469 }
00470
00476 Point2d& operator-=( const Point2d& pt ) {
00477 x -= pt.x;
00478 y -= pt.y;
00479 return *this;
00480 }
00481
00487 Point2d& operator/=( const Point2d& pt ) {
00488 x /= pt.x;
00489 y /= pt.y;
00490 return *this;
00491 }
00492
00498 Point2d& operator*=( const Point2d& pt ) {
00499 x *= pt.x;
00500 y *= pt.y;
00501 return *this;
00502 }
00503
00511 Point2d operator+( const Point2d& pt ) const {
00512 return Point2d(y + pt.y, x + pt.x);
00513 }
00514
00522 Point2d operator-( const Point2d& pt ) const {
00523 return Point2d(y - pt.y, x - pt.x);
00524 }
00525
00533 Point2d operator*( const Point2d& pt ) const {
00534 return Point2d(y * pt.y, x * pt.x);
00535 }
00536
00544 Point2d operator/( const Point2d& pt ) const {
00545 return Point2d(y / pt.y, x / pt.x);
00546 }
00547
00551 Pobject* Clone() const {
00552 return new Point2d(y, x);
00553 }
00554
00560 Errc LoadData( FILE *df ) {
00561 if (Fdecode(&y, sizeof(y), 1, df) < 1) {
00562 return FAILURE;
00563 }
00564 if (Fdecode(&x, sizeof(x), 1, df) < 1) {
00565 return FAILURE;
00566 }
00567 return SUCCESS;
00568 }
00569
00575 Errc SaveData( FILE *df ) const {
00576 if (this->Fencode(&y, sizeof(y), 1, df) < 1) {
00577 return FAILURE;
00578 }
00579 if (this->Fencode(&x, sizeof(x), 1, df) < 1) {
00580 return FAILURE;
00581 }
00582 return SUCCESS;
00583 }
00584 };
00585
00601 class Point3d: public Point {
00602 public:
00604 Long z;
00606 Long y;
00608 Long x;
00609
00615 Typobj Type() const { return Po_Point3d; }
00616
00621 std::string Name() const { return TypeName< Point3d >::Name(); }
00622
00627 Point3d(): Point(), z(0), y(0), x(0) {}
00628
00634 Point3d( Long i ): Point(), z(i), y(i), x(i) {}
00635
00643 Point3d( Long z, Long y, Long x ): Point(), z(z), y(y), x(x) {}
00644
00649 Point3d( const Dimension3d& p): Point(), z(p.d), y(p.h), x(p.w) {}
00650
00656 Point3d( const Point3d& p): Point(), z(p.z), y(p.y), x(p.x) {}
00657
00663 Point3d operator=( Point3d pt ) {
00664 x = pt.x;
00665 y = pt.y;
00666 z = pt.z;
00667 return *this; }
00668
00675 bool operator==( const Point3d& pt ) const {
00676 return pt.x == x && pt.y == y && pt.z == z;
00677 }
00678
00684 bool operator!=( const Point3d& pt ) const {
00685 return !(pt == *this);
00686 }
00687
00693 Point3d& operator+=( const Point3d& pt ) {
00694 x += pt.x;
00695 y += pt.y;
00696 z += pt.z;
00697 return *this;
00698 }
00699
00705 Point3d& operator-=( const Point3d& pt ) {
00706 x -= pt.x;
00707 y -= pt.y;
00708 z -= pt.z;
00709 return *this;
00710 }
00711
00717 Point3d& operator*=( const Point3d& pt ) {
00718 x *= pt.x;
00719 y *= pt.y;
00720 z *= pt.z;
00721 return *this;
00722 }
00723
00729 Point3d& operator/=( const Point3d& pt ) {
00730 x /= pt.x;
00731 y /= pt.y;
00732 z /= pt.z;
00733 return *this;
00734 }
00735
00743 Point3d operator+( const Point3d& pt ) const {
00744 return Point3d(z + pt.z, y + pt.y, x + pt.x);
00745 }
00746
00754 Point3d operator-( const Point3d& pt ) const {
00755 return Point3d(z - pt.z, y - pt.y, x - pt.x);
00756 }
00757
00765 Point3d operator*( const Point3d& pt ) const {
00766 return Point3d(z * pt.z, y * pt.y, x * pt.x);
00767 }
00768
00776 Point3d operator/( const Point3d& pt ) const {
00777 return Point3d(z / pt.z, y / pt.y, x / pt.x);
00778 }
00779
00783 Pobject* Clone() const {
00784 return new Point3d(z, y, x);
00785 }
00786
00792 Errc LoadData( FILE *df ) {
00793 if (this->Fdecode(&z, sizeof(z), 1, df) < 1) {
00794 return FAILURE;
00795 }
00796 if (this->Fdecode(&y, sizeof(y), 1, df) < 1) {
00797 return FAILURE;
00798 }
00799 if (this->Fdecode(&x, sizeof(x), 1, df) < 1) {
00800 return FAILURE;
00801 }
00802 return SUCCESS;
00803 }
00804
00810 Errc SaveData( FILE *df ) const {
00811 if (this->Fencode(&z, sizeof(z), 1, df) < 1) {
00812 return FAILURE;
00813 }
00814 if (this->Fencode(&y, sizeof(y), 1, df) < 1) {
00815 return FAILURE;
00816 }
00817 if (this->Fencode(&x, sizeof(x), 1, df) < 1) {
00818 return FAILURE;
00819 }
00820 return SUCCESS;
00821 }
00822 };
00823
00824 }
00825
00826 #endif // __PPOINTH__