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_DEBUG_PUT_WORD_HH
00027 # define MLN_DEBUG_PUT_WORD_HH
00028 
00032 
00033 # include <string>
00034 # include <mln/core/image/image2d.hh>
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   namespace debug
00041   {
00042 
00045     inline
00046     void
00047     put_word(image2d<char>& inout, const point2d& word_start,
00048              const std::string& word);
00049 
00050 
00051 # ifndef MLN_INCLUDE_ONLY
00052 
00053     inline
00054     void
00055     put_word(image2d<char>& inout, const point2d& word_start,
00056              const std::string& word)
00057     {
00058       mln_precondition(word.length() != 0);
00059       mln_precondition(inout.has(word_start));
00060 
00061       point2d word_end = word_start;
00062 
00063       word_end.last_coord() = static_cast<def::coord>(word_end.last_coord() + word.length() - 1);
00064 
00065       if (! inout.has(word_end))
00066         trace::warning("Cannot write text outside the image domain");
00067 
00068       const unsigned n = word.length();
00069       point2d p = word_start;
00070       for (unsigned i = 0; i < n && inout.has(p); ++i)
00071         {
00072           inout(p) = word[i];
00073           p += right;
00074         }
00075     }
00076 
00077 # endif // ! MLN_INCLUDE_ONLY
00078 
00079   } 
00080 
00081 } 
00082 
00083 
00084 #endif // ! MLN_DEBUG_PUT_WORD_HH