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_W_WINDOW1D_HH
00029 # define OLENA_CORE_W_WINDOW1D_HH
00030
00031 # include <ntg/basics.hh>
00032 # include <oln/core/abstract/w_windownd.hh>
00033 # include <oln/core/accum.hh>
00034 # include <oln/core/winiter.hh>
00035 # include <oln/core/winneighb.hh>
00036 # include <oln/core/dpoint1d.hh>
00037 # include <oln/core/window1d.hh>
00038 # include <algorithm>
00039
00040 namespace oln {
00041
00042 template<class T>
00043 class w_window1d;
00044
00048 template<class T>
00049 struct struct_elt_traits<w_window1d<T> >: public
00050 struct_elt_traits<abstract::w_windownd<w_window1d<T> > >
00051 {
00052 enum { dim = 1 };
00053 typedef T weight_type;
00054 typedef point1d point_type;
00055 typedef dpoint1d dpoint_type;
00056 typedef winiter< w_window1d<T> > iter_type;
00057 typedef winneighb< w_window1d<T> > neighb_type;
00058 };
00059
00066 template<class T>
00067 class w_window1d : public abstract::w_windownd<w_window1d<T> >
00068 {
00069
00070 typedef abstract::w_windownd< w_window1d<T> > super_type;
00072
00073 public:
00074
00075 typedef w_window1d<T> self_type;
00076
00082 typedef typename struct_elt_traits< self_type >::iter_type iter_type;
00083
00084 typedef typename struct_elt_traits< self_type >::neighb_type neighb_type;
00086
00092 typedef typename struct_elt_traits< self_type >::dpoint_type dpoint_type;
00093
00094 typedef typename struct_elt_traits< self_type >::weight_type weight_type;
00096
00097 friend class abstract::window_base<abstract::w_window<w_window1d>, w_window1d>;
00098
00102 w_window1d(): super_type()
00103 {}
00104
00109 w_window1d(unsigned size) : super_type(size)
00110 {}
00111
00120 w_window1d<T>&
00121 add(const dpoint_type& dp, const weight_type& w)
00122 {
00123 return this->exact().add_(dp, w);
00124 }
00125
00135 w_window1d<T>&
00136 add(coord col, const weight_type& weight)
00137 {
00138 return add(dpoint_type(col), weight);
00139 }
00140
00146 const weight_type&
00147 set(const dpoint_type& dp, const weight_type& weight)
00148 {
00149 return this->exact().set_(dp, weight);
00150 }
00151
00160 const weight_type&
00161 set(coord col, const weight_type& weight)
00162 {
00163 return set(dpoint_type(col), weight);
00164 }
00165
00167 static std::string
00168 name()
00169 {
00170 return std::string("w_window1d<") + ntg_name(T) + ">";
00171 }
00172
00173 protected:
00174
00183 coord
00184 delta_update_(const dpoint_type& dp)
00185 {
00186 delta_(abs(dp.col()));
00187 return this->delta_;
00188 }
00189
00190 };
00191
00198 template<class T>
00199 w_window1d<T>
00200 mk_w_win_from_win(T weight, const window1d& win)
00201 {
00202 w_window1d<T> w_win(win.card());
00203 for (unsigned i = 0; i < win.card(); ++i)
00204 w_win.add(win.dp(i), weight);
00205 return w_win;
00206 }
00207
00208 }
00209
00210 #endif // ! OLENA_CORE_W_WINDOW1D_HH