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

sample_utils.hh

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

Generated on Fri Oct 19 2012 04:16:21 for Milena (Olena) by  doxygen 1.7.1