• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

sample_utils.hh

00001 // Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of the Milena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
00016 // Boston, MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef DOC_TUTORIAL_TOOLS_SAMPLE_UTILS_HH
00029 # define DOC_TUTORIAL_TOOLS_SAMPLE_UTILS_HH
00030 
00031 # include <mln/core/image/image2d.hh>
00032 # include <mln/io/pbm/all.hh>
00033 # include <mln/io/pgm/all.hh>
00034 # include <mln/io/ppm/all.hh>
00035 
00036 namespace doc
00037 {
00038 
00039   inline
00040   std::string
00041   file(const std::string& name, const std::string& extension)
00042   {
00043     static int file_id = 1;
00044 
00045     std::ostringstream os;
00046     os << "../figures/"
00047       << name
00048       << "-"
00049       << file_id++
00050       << "."
00051       << extension;
00052     return os.str();
00053   }
00054 
00055   template <typename I>
00056   inline
00057   void
00058   ppmsave(const mln::Image<I>& ima, const std::string& name)
00059   {
00060     mln::io::ppm::save(ima, file(name, "ppm"));
00061   }
00062 
00063   template <typename I>
00064   inline
00065   void
00066   pbmsave(const mln::Image<I>& ima, const std::string& name)
00067   {
00068     mln::io::pbm::save(ima, file(name, "pbm"));
00069   }
00070 
00071   template <typename I>
00072   inline
00073   void
00074   pgmsave(const mln::Image<I>& ima, const std::string& name)
00075   {
00076     mln::io::pgm::save(ima, file(name, "pgm"));
00077   }
00078 
00079   inline
00080   void
00081   begin_output()
00082   {
00083     std::cout << "// \\{" << std::endl;
00084   }
00085 
00086   inline
00087   void
00088   end_output()
00089   {
00090     std::cout << "// \\}" << std::endl;
00091   }
00092 
00093 } // end of namespace doc
00094 
00095 #endif // ! DOC_TUTORIAL_TOOLS_SAMPLE_UTILS_HH
00096 

Generated on Thu Sep 8 2011 18:32:24 for Milena (Olena) by  doxygen 1.7.1