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_UTIL_TREE_FAST_TO_IMAGE_HH
00027 # define MLN_UTIL_TREE_FAST_TO_IMAGE_HH
00028 
00037 # include <mln/core/concept/image.hh>
00038 # include <mln/util/tree_fast.hh>
00039 # include <mln/core/site_set/p_set.hh>
00040 # include <list>
00041 
00042 namespace mln
00043 {
00044 
00045   namespace util
00046   {
00047 
00054     template <typename T, typename I>
00055     void
00056     tree_fast_to_image(tree_fast<T>& tree, Image<I>& output_);
00057 
00058 # ifndef MLN_INCLUDE_ONLY
00059 
00060     namespace impl
00061     {
00062 
00063       template <typename T, typename I>
00064       inline
00065       void
00066       tree_fast_to_image(tree_fast<T>& tree, Image<I>& output_)
00067       {
00068         trace::entering("util::impl::tree_fast_to_image");
00069 
00070         I& output = exact(output_);
00071         std::list<unsigned> l;
00072 
00073         l.push_back (tree.root_);
00074         while (! l.empty())
00075           {
00076             unsigned current = l.front();
00077             for (unsigned i = 0; i < tree.child_[current].size(); ++i)
00078               l.push_back(tree.child_[current][i]);
00079 
00080             mln_piter(p_set<point2d>) p(tree.data_[current].points);
00081 
00082             for_all(p)
00083               {
00084                 output(p) = tree.data_[current].value;
00085               }
00086             l.pop_front();
00087           }
00088 
00089         trace::exiting("util::impl::tree_fast_to_image");
00090       }
00091 
00092     } 
00093 
00094 
00095 
00096     template <typename T, typename I>
00097     inline
00098     void
00099     tree_fast_to_image(tree_fast<T>& tree, Image<I>& output_)
00100     {
00101       trace::entering("util::tree_fast_to_image");
00102 
00103       impl::tree_fast_to_image(tree, output_);
00104 
00105       trace::exiting("util::tree_fast_to_image");
00106     }
00107 
00108 # endif // ! MLN_INCLUDE_ONLY
00109 
00110   } 
00111 
00112 } 
00113 
00114 #endif // ! MLN_UTIL_TREE_FAST_TO_IMAGE_HH