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 #ifndef OLENA_CORE_FDPOINT2D_HH
00029 # define OLENA_CORE_FDPOINT2D_HH
00030
00031 # include <iostream>
00032
00033 # include <oln/core/abstract/image.hh>
00034 # include <oln/core/fpoint2d.hh>
00035
00036 namespace oln {
00037
00038
00039 template <class F>
00040 class dfpoint2d;
00041
00042
00043
00049 template<class F>
00050 struct dpoint_traits<fdpoint2d<F> >
00051 {
00052 enum { dim = 2 };
00053 typedef fpoint2d<F> point_type;
00054 };
00055
00060 template <class F>
00061 class fdpoint2d
00062 {
00063 private:
00064
00065 F coord_[2];
00066
00067
00068 public:
00069
00070
00071 typedef fdpoint2d<F> exact_type;
00072
00073 fdpoint2d()
00074 {}
00075
00077
00078 fdpoint2d(F row, F col)
00079 {
00080 coord_[0] = row;
00081 coord_[1] = col;
00082 }
00083
00085 fdpoint2d(const exact_type& p)
00086 {
00087 coord_[0] = p.row();
00088 coord_[1] = p.col();
00089 }
00090
00092
00093 F
00094 row() const
00095 {
00096 return coord_[0];
00097 }
00098
00100
00101 F&
00102 row()
00103 {
00104 return coord_[0];
00105 }
00106
00108
00109 F
00110 col() const
00111 {
00112 return coord_[1];
00113 }
00114
00116
00117 F&
00118 col()
00119 {
00120 return coord_[1];
00121 }
00122
00123 static std::string
00124 name()
00125 {
00126 return "fdpoint2d";
00127 }
00128
00129 exact_type
00130 operator+(const exact_type& dp) const
00131 {
00132 exact_type tmp(*this);
00133 tmp += dp;
00134 return tmp;
00135 }
00136
00141 exact_type
00142 operator-() const
00143 {
00144 exact_type dp(-row(), -col());
00145 return dp;
00146 }
00147
00148
00153 exact_type
00154 operator-(const exact_type& dp) const
00155 {
00156 exact_type tmp = *this;
00157 tmp -= dp;
00158 return tmp;
00159 }
00160
00161
00166 exact_type&
00167 operator+=(const exact_type& dp)
00168 {
00169 row() += dp.row();
00170 col() += dp.col();
00171 return *this;
00172 }
00173
00178 exact_type&
00179 operator-=(const exact_type& dp)
00180 {
00181 row() -= dp.row();
00182 col() -= dp.col();
00183 return *this;
00184 }
00185 };
00186
00187
00188 }
00189
00191
00192 template <class F>
00193 inline std::ostream&
00194 operator<<(std::ostream& o, const oln::fdpoint2d<F> dp)
00195 {
00196 o << "(" << dp.row() << "," << dp.col() << ")" << std::endl;
00197 return o;
00198 }
00199
00200
00201 #endif // !OLENA_CORE_FDPOINT2D_HH