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_CONVERT_IMPL_FROM_SITE_SET_TO_IMAGE_HH
00027 # define MLN_CONVERT_IMPL_FROM_SITE_SET_TO_IMAGE_HH
00028 
00032 
00033 # include <mln/core/image/dmorph/sub_image.hh>
00034 # include <mln/geom/bbox.hh>
00035 # include <mln/trait/image_from_grid.hh>
00036 # include <mln/data/fill.hh>
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   
00043   template <typename E> struct Site_Set;
00044   template <typename E> struct Image;
00045 
00046 
00047   namespace convert
00048   {
00049 
00050     namespace impl
00051     {
00052 
00054       template <typename S, typename I>
00055       void
00056       from_site_set_to_image(const Site_Set<S>& from, Image<I>& to);
00057 
00058 
00059 
00060 # ifndef MLN_INCLUDE_ONLY
00061 
00062       template <typename S, typename I>
00063       inline
00064       void
00065       from_site_set_to_image(const Site_Set<S>& from_, Image<I>& to_)
00066       {
00067         const S& from = exact(from_);
00068         I& to = exact(to_);
00069         
00070         box<mln_site(S)> b = geom::bbox(from);
00071 
00072         typedef mln_deduce(I, site, grid) G;
00073         typedef mln_value(I) V;
00074         mln_image_from_grid(G, V) ima(b);
00075         data::fill(ima, false);
00076         data::fill((ima | from).rw(), true);
00077 
00078         to = ima;
00079       }
00080 
00081 # endif // ! MLN_INCLUDE_ONLY
00082 
00083     } 
00084 
00085   } 
00086 
00087 } 
00088 
00089 
00090 #endif // ! MLN_CONVERT_IMPL_FROM_SITE_SET_TO_IMAGE_HH