w_window3d.hh

00001 // Copyright (C) 2001, 2002, 2003, 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
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; // forward declaration
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 } // end of oln
00217 
00218 
00219 #endif // ! OLENA_CORE_W_WINDOW3D_HH

Generated on Thu Apr 15 20:13:15 2004 for Olena by doxygen 1.3.6-20040222