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

make.hh

00001 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena 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 Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef APPS_GRAPH_MORPHO_MAKE_HH
00027 # define APPS_GRAPH_MORPHO_MAKE_HH
00028 
00031 
00032 # include <mln/core/alias/complex_image.hh>
00033 # include <mln/core/alias/box2d.hh>
00034 
00035 namespace make
00036 {
00037 
00040   template <typename V>
00041   inline
00042   mln::complex_image<1, mln::discrete_plane_1complex_geometry, V>
00043   complex1d_image(const mln::box2d& support)
00044   {
00045     using namespace mln;
00046 
00047     unsigned nrows = support.pmax().row() - support.pmin().row() + 1;
00048     unsigned ncols = support.pmax().col() - support.pmin().col() + 1;
00049 
00050     const unsigned dim = 1;
00051     typedef topo::n_face<0, dim> vertex_t;
00052 
00053     typedef topo::complex<dim> complex_t;
00054     complex_t c;
00055     typedef geom::complex_geometry<dim, point2d> geom_t;
00056     geom_t geom;
00057 
00058     // Vertices.
00059     for (unsigned row = 0; row < nrows; ++row)
00060       for (unsigned col = 0; col < ncols; ++col)
00061         {
00062           c.add_face();
00063           geom.add_location(point2d(row,col));
00064         }
00065 
00066     // Edges.
00067     for (unsigned row = 0; row < nrows; ++row)
00068       {
00069         // Horizontal edges.
00070         for (unsigned col = 1; col < ncols; ++col)
00071           {
00072             // First vertex.
00073             vertex_t v1(c, row * ncols + col - 1);
00074             // Second vertex.
00075             vertex_t v2(c, row * ncols + col);
00076             // Edge bewteen V1 and V2.
00077             c.add_face(v1 + v2);
00078           }
00079 
00080         // Vertical edges.
00081         if (row != 0)
00082           for (unsigned col = 0; col < ncols; ++col)
00083             {
00084               // First vertex.
00085               vertex_t v1(c, (row - 1) * ncols + col);
00086               // Second vertex.
00087               vertex_t v2(c, row * ncols + col);
00088               // Edge bewteen V1 and V2.
00089               c.add_face(v1 + v2);
00090             }
00091       }
00092 
00093     // Site set (domain) of the image.
00094     p_complex<dim, geom_t> pc(c, geom);
00095 
00096     // Image based on this site set.
00097     typedef complex_image<dim, geom_t, V> ima_t;
00098     ima_t ima(pc);
00099     return ima;
00100   }
00101 
00102 } // end of namespace make
00103 
00104 
00105 #endif // ! APPS_GRAPH_MORPHO_MAKE_HH

Generated on Tue Oct 4 2011 15:24:03 for Milena (Olena) by  doxygen 1.7.1