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 
00027 #ifndef MLN_DEBUG_Z_ORDER_HH
00028 # define MLN_DEBUG_Z_ORDER_HH
00029 
00033 
00034 
00035 # include <mln/core/concept/image.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace debug
00042   {
00043 
00051     template <typename I>
00052     void z_order(Image<I>& input);
00053 
00054 
00055 # ifndef MLN_INCLUDE_ONLY
00056 
00057 
00058     
00059 
00060     namespace impl
00061     {
00062 
00063       namespace generic
00064       {
00065 
00066         template <typename I>
00067         inline
00068         void
00069         z_order(Image<I>& input)
00070         {
00071           unsigned row, col;
00072           mln_piter(I) p(input.domain());
00073           for_all(p)
00074           {
00075             row = p.row();
00076             col = p.col();
00077 
00078             mln_value(I)& v = input(p);
00079             v = 0;
00080             int mask = 0x00000001;
00081             int i = 1;
00082             while (row > 0 || col > 0)
00083             {
00084               if (i % 2)
00085               {
00086                 if (col & 0x0000001)
00087                   v = v | mask;
00088                 col = col >> 1;
00089               }
00090               else
00091               {
00092                 if (row & 0x0000001)
00093                   v = v | mask;
00094                 row = row >> 1;
00095               }
00096 
00097               mask = mask << 1;
00098               ++i;
00099             }
00100           }
00101 
00102         }
00103 
00104 
00105       } 
00106 
00107 
00108     } 
00109 
00110 
00111 
00112     
00113 
00114     namespace internal
00115     {
00116 
00117       template <typename I>
00118       inline
00119       void
00120       z_order_dispatch(trait::image::speed::any, Image<I>& input)
00121       {
00122         impl::generic::z_order(input);
00123       }
00124 
00125 
00126       template <typename I>
00127       inline
00128       void
00129       z_order_dispatch(Image<I>& input)
00130       {
00131         z_order_dispatch(mln_trait_image_speed(I)(), input);
00132       }
00133 
00134     }
00135 
00136 
00137     
00138 
00139     template <typename I>
00140     inline
00141     void
00142     z_order(Image<I>& input)
00143     {
00144       trace::entering("debug::z_order");
00145       mln_precondition(exact(input).is_valid());
00146 
00147       internal::z_order_dispatch(input);
00148 
00149       trace::exiting("debug::z_order");
00150     }
00151 
00152 # endif // ! MLN_INCLUDE_ONLY
00153 
00154   } 
00155 
00156 } 
00157 
00158 
00159 #endif // ! MLN_DEBUG_Z_ORDER_HH