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 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
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
00067 for (unsigned row = 0; row < nrows; ++row)
00068 {
00069
00070 for (unsigned col = 1; col < ncols; ++col)
00071 {
00072
00073 vertex_t v1(c, row * ncols + col - 1);
00074
00075 vertex_t v2(c, row * ncols + col);
00076
00077 c.add_face(v1 + v2);
00078 }
00079
00080
00081 if (row != 0)
00082 for (unsigned col = 0; col < ncols; ++col)
00083 {
00084
00085 vertex_t v1(c, (row - 1) * ncols + col);
00086
00087 vertex_t v2(c, row * ncols + col);
00088
00089 c.add_face(v1 + v2);
00090 }
00091 }
00092
00093
00094 p_complex<dim, geom_t> pc(c, geom);
00095
00096
00097 typedef complex_image<dim, geom_t, V> ima_t;
00098 ima_t ima(pc);
00099 return ima;
00100 }
00101
00102 }
00103
00104
00105 #endif // ! APPS_GRAPH_MORPHO_MAKE_HH