• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

diff.hh

00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_WIN_DIFF_HH
00027 # define MLN_WIN_DIFF_HH
00028 
00032 
00033 # include <mln/trait/op/minus.hh>
00034 # include <mln/core/window.hh>
00035 # include <mln/core/neighb.hh>
00036 
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace win
00043   {
00044 
00047     //
00048     template <typename W1, typename W2>
00049     mln_regular(W1)
00050     diff(const Window<W1>& win1, const Window<W2>& win2);
00051 
00052 
00055     //
00056     template <typename N1, typename N2>
00057     neighb<mln_deduce(N1, window, regular)>
00058     diff(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2);
00059 
00060   } // end of namespace mln::win
00061 
00062 
00066   //
00067   template <typename W1, typename W2>
00068   mln_regular(W1)
00069   operator-(const Window<W1>& win1, const Window<W2>& win2);
00070 
00073   //
00074   template <typename N1, typename N2>
00075   neighb<mln_deduce(N1, window, regular)>
00076   operator-(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2);
00077 
00078 
00079   namespace trait
00080   {
00081 
00082     template <typename W1, typename W2>
00083     struct set_binary_< op::minus, mln::Window, W1,  mln::Window, W2 >
00084     {
00085       typedef mln_regular(W1) ret;
00086     };
00087     
00088 
00089     template <typename N1, typename N2>
00090     struct set_binary_< op::minus, mln::Neighborhood, N1,  mln::Neighborhood, N2 >
00091     {
00092       typedef mln::neighb<mln_deduce(N1, window, regular)> ret;
00093     };
00094 
00095   } // end of namespace mln::trait
00096 
00097 
00098 
00099 # ifndef MLN_INCLUDE_ONLY
00100 
00101   namespace win
00102   {
00103 
00104     template <typename W1, typename W2>
00105     inline
00106     mln_regular(W1)
00107     diff(const Window<W1>& win1_, const Window<W2>& win2_)
00108     {
00109       trace::entering("win::diff");
00110 
00111       mln_is_simple_window(W1)::check();
00112       mln_is_simple_window(W2)::check();
00113 
00114       const W1& win1 = exact(win1_);
00115       const W2& win2 = exact(win2_);
00116       mln_regular(W1) tmp;
00117 
00118       const unsigned n = win1.size();
00119       for (unsigned i = 0; i < n; ++i)
00120         {
00121           if (win2.has(win1.dp(i)))
00122             continue;
00123           tmp.insert(win1.dp(i));
00124         }
00125 
00126       trace::exiting("win::diff");
00127       return tmp;
00128     }
00129 
00130     template <typename N1, typename N2>
00131     neighb<mln_deduce(N1, window, regular)>
00132     diff(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2)
00133     {
00134       typedef mln_deduce(N1, window, regular) W1;
00135       W1 win = diff(exact(nbh1).win(), exact(nbh2).win());
00136       neighb<W1> tmp(win);
00137       return tmp;
00138     }
00139 
00140   } // end of namespace mln::win
00141 
00142 
00143   // Operators.
00144 
00145   template <typename W1, typename W2>
00146   inline
00147   mln_regular(W1)
00148   operator-(const Window<W1>& win1, const Window<W2>& win2)
00149   {
00150     return win::diff(win1, win2);
00151   }
00152 
00153   template <typename N1, typename N2>
00154   neighb<mln_deduce(N1, window, regular)>
00155   operator-(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2)
00156   {
00157     return win::diff(nbh1, nbh2);
00158   }
00159 
00160 # endif // ! MLN_INCLUDE_ONLY
00161 
00162 } // end of namespace mln
00163 
00164 
00165 #endif // ! MLN_WIN_DIFF_HH

Generated on Tue Oct 4 2011 15:23:41 for Milena (Olena) by  doxygen 1.7.1