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 #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   } 
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   } 
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   } 
00141 
00142 
00143   
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 } 
00163 
00164 
00165 #endif // ! MLN_WIN_DIFF_HH