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_WINDOW3D_HH
00029 # define OLENA_CORE_W_WINDOW3D_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/dpoint3d.hh>
00037 # include <oln/core/window3d.hh>
00038 # include <algorithm>
00039
00040 namespace oln {
00041
00042 template<class T>
00043 class w_window3d;
00044
00048 template<class T>
00049 struct struct_elt_traits<w_window3d<T> >: public
00050 struct_elt_traits<abstract::w_windownd<w_window3d<T> > >
00051 {
00052 enum { dim = 3 };
00053 typedef T weight_type;
00054 typedef point3d point_type;
00055 typedef dpoint3d dpoint_type;
00056 typedef winiter< w_window3d<T> > iter_type;
00057 typedef winneighb< w_window3d<T> > neighb_type;
00058 };
00059
00060
00067 template<class T>
00068 class w_window3d : public abstract::w_windownd<w_window3d<T> >
00069 {
00070
00071 typedef abstract::w_windownd< w_window3d<T> > super_type;
00073
00074 public:
00075
00076 typedef w_window3d<T> self_type;
00077
00083 typedef typename struct_elt_traits< self_type >::iter_type iter_type;
00084
00085
00086 typedef typename struct_elt_traits< self_type >::neighb_type neighb_type;
00088
00094 typedef typename struct_elt_traits< self_type >::dpoint_type dpoint_type;
00095
00096 typedef typename struct_elt_traits< self_type >::weight_type weight_type;
00098
00099 friend class abstract::window_base<abstract::w_window<w_window3d>, w_window3d>;
00100
00104 w_window3d(): super_type()
00105 {}
00106
00111 w_window3d(unsigned size) : super_type(size)
00112 {}
00113
00122 w_window3d<T>&
00123 add(const dpoint_type& dp, const weight_type& w)
00124 {
00125 return this->exact().add_(dp, w);
00126 }
00127
00139 w_window3d<T>&
00140 add(coord slice, coord row, coord col, const weight_type& weight)
00141 {
00142 return add(dpoint_type(slice, row, col), weight);
00143 }
00144
00150 const weight_type&
00151 set(const dpoint_type& dp, const weight_type& weight)
00152 {
00153 return this->exact().set_(dp, weight);
00154 }
00155
00166 const weight_type&
00167 set(coord slice, coord row, coord col, const weight_type& weight)
00168 {
00169 return set(dpoint_type(slice, row, col), weight);
00170 }
00171
00173 static std::string
00174 name()
00175 {
00176 return std::string("w_window3d") + ntg_name(T) + ">";
00177 }
00178
00179 protected:
00180
00189 coord
00190 delta_update_(const dpoint_type& dp)
00191 {
00192 delta_(abs(dp.slice()));
00193 delta_(abs(dp.row()));
00194 delta_(abs(dp.col()));
00195 return this->delta_;
00196 }
00197
00198 };
00199
00206 template<class T>
00207 w_window3d<T>
00208 mk_w_win_from_win(T weight, const window3d& win)
00209 {
00210 w_window3d<T> w_win(win.card());
00211 for (unsigned i = 0; i < win.card(); ++i)
00212 w_win.add(win.dp(i), weight);
00213 return w_win;
00214 }
00215
00216 }
00217
00218
00219 #endif // ! OLENA_CORE_W_WINDOW3D_HH