00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef POINT3D_H
00024 #define POINT3D_H
00025
00026
00027
00028 #include <BasicUtils/BasicString.h>
00029
00030 #include <iostream>
00031
00032 namespace CompuCell3D {
00033
00038 class Point3D {
00039 public:
00040 short x;
00041 short y;
00042 short z;
00043
00047 Point3D() : x(0), y(0), z(0) {}
00048
00049 Point3D(const short x, const short y, const short z) :
00050 x(x), y(y), z(z) {}
00051
00055 Point3D(const Point3D &pt) : x(pt.x), y(pt.y), z(pt.z) {}
00056
00060 Point3D &operator=(const Point3D pt) {
00061 x = pt.x;
00062 y = pt.y;
00063 z = pt.z;
00064 return *this;
00065 }
00066
00070 Point3D &operator+=(const Point3D pt) {
00071 x += pt.x;
00072 y += pt.y;
00073 z += pt.z;
00074 return *this;
00075 }
00076
00080 Point3D &operator-=(const Point3D pt) {
00081 x -= pt.x;
00082 y -= pt.y;
00083 z -= pt.z;
00084 return *this;
00085 }
00086
00088 bool operator==(const Point3D pt) const {
00089 return (x == pt.x && y == pt.y && z == pt.z);
00090 }
00092 bool operator!=(const Point3D pt) const {
00093
00094 return !(*this==pt);
00095 }
00096
00097 bool operator<(const Point3D _rhs) const{
00098 return x < _rhs.x || (!(_rhs.x < x)&& y < _rhs.y)
00099 ||(!(_rhs.x < x)&& !(_rhs.y <y )&& z < _rhs.z);
00100 }
00102
00103
00105
00106 friend std::ostream &operator<<(std::ostream &stream, const Point3D &pt);
00107 };
00108
00113 inline std::ostream &operator<<(std::ostream &stream, const Point3D &pt) {
00114 stream << '(' << pt.x << ',' << pt.y << ',' << pt.z << ')';
00115 return stream;
00116 }
00117
00121 inline Point3D operator+(const Point3D pt1, const Point3D pt2) {
00122 return Point3D(pt1.x + pt2.x, pt1.y + pt2.y, pt1.z + pt2.z);
00123 }
00124
00128 inline Point3D operator-(const Point3D pt1, const Point3D pt2) {
00129 return Point3D(pt1.x - pt2.x, pt1.y - pt2.y, pt1.z - pt2.z);
00130 }
00131
00135 inline std::string operator+(const std::string s, const Point3D pt) {
00136 return s + "(" + BasicString(pt.x) + "," + BasicString(pt.y) + "," +
00137 BasicString(pt.z) + ")";
00138 }
00139 };
00140 #endif