00001
00002
00003
00004
00005
00006
00008 #ifndef synaps_topology_point3d_H
00009 #define synaps_topology_point3d_H
00010
00011 #include <synaps/init.h>
00012
00013 namespace topology
00014 {
00015
00019 template < class Typ >
00020 class point3d
00021 {
00022
00023 public:
00024
00026 typedef Typ coeff_t;
00027
00028 Typ x;
00029 Typ y;
00030 Typ z;
00031
00033 point3d():x(0),y(0),z(0) {};
00034
00035 point3d(int i):x(0),y(0),z(0) {};
00036
00038 point3d( const Typ num1, const Typ num2, const Typ num3)
00039 :x(num1),y(num2),z(num3) {};
00040
00042 point3d( const point3d & point3D )
00043 {
00044 x = point3D.x;
00045 y = point3D.y;
00046 z = point3D.z;
00047 }
00048
00050 point3d& point3d::operator= (const point3d& point3D)
00051 {
00052 x = point3D.x;
00053 y = point3D.y;
00054 z = point3D.z;
00055
00056 return ( *this );
00057 }
00058
00060 Typ operator[](unsigned i) const
00061 {
00062 if(i==0) return x;
00063 else if (i==1) return y;
00064 else if(i==2) return z;
00065 else return 0;
00066 }
00067
00069 Typ& operator[](unsigned i)
00070 {
00071 assert(i<3);
00072 if(i==0) return x;
00073 else if (i==1) return y;
00074 else if(i==2) return z;
00075 }
00076
00077 };
00078
00080 template < class C >
00081 bool operator == ( const topology::point3d< C >& p1,
00082 const topology::point3d< C >& p2 )
00083 {
00084 return ( p1.x == p2.x ) && ( p1.y == p2.y ) && ( p1.z == p2.z );
00085 }
00086
00088 template < class C >
00089 std::ostream & operator<<( std::ostream & os, const topology::point3d< C > & p )
00090 {
00091 os << p.x << " " << p.y << " " << p.z ;
00092 return os;
00093 }
00094
00095 }
00096
00097
00098
00099 #endif // synaps_topology_point3d_H