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_INTER_HH
00027 # define MLN_WIN_INTER_HH
00028 
00032 
00033 # include <mln/core/window.hh>
00034 
00035 
00036 
00037 namespace mln
00038 {
00039 
00041   template <typename W1, typename W2>
00042   mln_regular(W1)
00043   operator && (const Window<W1>& win1, const Window<W2>& win2);
00044 
00045 
00046 # ifndef MLN_INCLUDE_ONLY
00047 
00048   namespace win
00049   {
00050 
00051     namespace impl
00052     {
00053 
00054       template <typename W1, typename W2>
00055       inline
00056       mln_regular(W1)
00057       inter(trait::window::definition::unique,
00058             const W1& win1, const W2& win2)
00059       {
00060         mlc_is(mln_trait_window_size(W1),
00061                trait::window::size::fixed)::check();
00062         mlc_is(mln_trait_window_size(W2),
00063                trait::window::size::fixed)::check();
00064 
00065         mln_regular(W1) tmp;
00066         unsigned n = win1.size();
00067         for (unsigned i = 0; i < n; ++i)
00068           if (win2.has(win1.dp(i)))
00069             tmp.insert(win1.dp(i));
00070         return tmp;
00071       }
00072 
00073       template <typename W1, typename W2>
00074       inline
00075       mln_regular(W1)
00076       inter(trait::window::definition::multiple,
00077             const W1& win1, const W2& win2)
00078       {
00079         mln_precondition(win1.nwindows() == win2.nwindows());
00080         
00081 
00082         mln_regular(W1) tmp(win1.function());
00083         const unsigned nw = win1.nwindows();
00084         for (unsigned w = 0; w < nw; ++w)
00085           tmp.set_window(w, win1.window(w) && win2.window(w));
00086         return tmp;
00087       }
00088 
00089     } 
00090 
00091   } 
00092 
00093 
00094   
00095   template <typename W1, typename W2>
00096   inline
00097   mln_regular(W1)
00098   operator && (const Window<W1>& win1, const Window<W2>& win2)
00099   {
00100     trace::entering("win::inter");
00101 
00102     
00103     mlc_equal(mln_regular(W1), mln_regular(W2))::check();
00104     mlc_converts_to(mln_dpsite(W1), mln_dpsite(W2))::check();
00105 
00106     
00107     mlc_is(mln_trait_window_support(W1),
00108            trait::window::support::regular)::check();
00109     mlc_is(mln_trait_window_support(W2),
00110            trait::window::support::regular)::check();
00111 
00112     
00113     mlc_equal(mln_trait_window_definition(W1),
00114               mln_trait_window_definition(W2))::check();
00115 
00116     mlc_is_not(mln_trait_window_definition(W1),
00117                trait::window::definition::varying)::check();
00118 
00119     mln_regular(W1) tmp = win::impl::inter(mln_trait_window_definition(W1)(),
00120                                            exact(win1), exact(win2));
00121 
00122     trace::exiting("win::inter");
00123     return tmp;
00124   }
00125 
00126 # endif // ! MLN_INCLUDE_ONLY
00127 
00128 } 
00129 
00130 
00131 #endif // ! MLN_WIN_INTER_HH