Commit d147656d authored by Roland Levillain's avatar Roland Levillain
Browse files

Clean up a creation routine in graph-morpho.

	* apps/graph-morpho/io.hh: Rename as...
	* apps/graph-morpho/make.hh: ...this.
	(build_regular_complex1d_image): Turn into...
	(make::complex1d_image<V>): ...this.
	* apps/graph-morpho/convert.hh: Adjust client.
	* apps/graph-morpho/Makefile.am (noinst_HEADERS): s/io.hh/make.hh/.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4593 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent f5dd2fb9
2009-10-01 Roland Levillain <roland@lrde.epita.fr>
Clean up a creation routine in graph-morpho.
* apps/graph-morpho/io.hh: Rename as...
* apps/graph-morpho/make.hh: ...this.
(build_regular_complex1d_image): Turn into...
(make::complex1d_image<V>): ...this.
* apps/graph-morpho/convert.hh: Adjust client.
* apps/graph-morpho/Makefile.am (noinst_HEADERS): s/io.hh/make.hh/.
2009-10-01 Roland Levillain <roland@lrde.epita.fr>
 
Clean up another conversion routine in graph-morpho.
......@@ -20,7 +20,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/milena -I$(top_builddir)/milena
APPS_CXXFLAGS = @APPS_CXXFLAGS@
AM_CXXFLAGS = $(APPS_CXXFLAGS)
noinst_HEADERS = convert.hh debug.hh io.hh morpho.hh make_complex2d.hh
noinst_HEADERS = convert.hh debug.hh make.hh morpho.hh make_complex2d.hh
noinst_PROGRAMS = samples-complex1d samples-image2d asf-complex1d asf-image2d
samples_complex1d_SOURCES = samples-complex1d.cc
......
......@@ -34,7 +34,7 @@
# include <mln/math/abs.hh>
# include "apps/graph-morpho/io.hh"
# include "apps/graph-morpho/make.hh"
namespace convert
......@@ -132,7 +132,7 @@ namespace convert
// consider only vertices (edges are set ``between'' vertices).
box2d output_box(input_box.nrows() / 2 + 1,
input_box.ncols() / 2 + 1);
bin_1complex_image2d output = build_regular_complex1d_image(output_box);
bin_1complex_image2d output = ::make::complex1d_image<bool>(output_box);
const unsigned dim = 1;
typedef geom::complex_geometry<dim, point2d> geom_t;
......
......@@ -23,74 +23,83 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef APPS_GRAPH_MORPHO_IO_HH
# define APPS_GRAPH_MORPHO_IO_HH
#ifndef APPS_GRAPH_MORPHO_MAKE_HH
# define APPS_GRAPH_MORPHO_MAKE_HH
/// \file apps/graph-morpho/io.hh
/// \brief I/O routines for graphs (1-complexes).
/// \file
/// \brief Creation routines for complex-based images.
# include <mln/core/alias/complex_image.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/box2d.hh>
inline
mln::bin_1complex_image2d
build_regular_complex1d_image(const mln::box2d& support)
namespace make
{
using namespace mln;
unsigned nrows = support.pmax().row() - support.pmin().row() + 1;
unsigned ncols = support.pmax().col() - support.pmin().col() + 1;
const unsigned dim = 1;
typedef topo::n_face<0, dim> vertex_t;
/// Create a 1-complex images in the 2D plane of which domain is
/// based on an mln::box2d.
template <typename V>
inline
mln::complex_image<1, mln::discrete_plane_1complex_geometry, V>
complex1d_image(const mln::box2d& support)
{
using namespace mln;
typedef topo::complex<dim> complex_t;
complex_t c;
typedef geom::complex_geometry<dim, point2d> geom_t;
geom_t geom;
unsigned nrows = support.pmax().row() - support.pmin().row() + 1;
unsigned ncols = support.pmax().col() - support.pmin().col() + 1;
// Vertices.
for (unsigned row = 0; row < nrows; ++row)
for (unsigned col = 0; col < ncols; ++col)
{
c.add_face();
geom.add_location(point2d(row,col));
}
const unsigned dim = 1;
typedef topo::n_face<0, dim> vertex_t;
// Edges.
for (unsigned row = 0; row < nrows; ++row)
{
// Horizontal edges.
for (unsigned col = 1; col < ncols; ++col)
{
// First vertex.
vertex_t v1(c, row * ncols + col - 1);
// Second vertex.
vertex_t v2(c, row * ncols + col);
// Edge bewteen V1 and V2.
c.add_face(v1 + v2);
}
typedef topo::complex<dim> complex_t;
complex_t c;
typedef geom::complex_geometry<dim, point2d> geom_t;
geom_t geom;
// Vertical edges.
if (row != 0)
// Vertices.
for (unsigned row = 0; row < nrows; ++row)
for (unsigned col = 0; col < ncols; ++col)
{
// First vertex.
vertex_t v1(c, (row - 1) * ncols + col);
// Second vertex.
vertex_t v2(c, row * ncols + col);
// Edge bewteen V1 and V2.
c.add_face(v1 + v2);
c.add_face();
geom.add_location(point2d(row,col));
}
}
// Site set (domain) of the image.
p_complex<dim, geom_t> pc(c, geom);
// Edges.
for (unsigned row = 0; row < nrows; ++row)
{
// Horizontal edges.
for (unsigned col = 1; col < ncols; ++col)
{
// First vertex.
vertex_t v1(c, row * ncols + col - 1);
// Second vertex.
vertex_t v2(c, row * ncols + col);
// Edge bewteen V1 and V2.
c.add_face(v1 + v2);
}
// Vertical edges.
if (row != 0)
for (unsigned col = 0; col < ncols; ++col)
{
// First vertex.
vertex_t v1(c, (row - 1) * ncols + col);
// Second vertex.
vertex_t v2(c, row * ncols + col);
// Edge bewteen V1 and V2.
c.add_face(v1 + v2);
}
}
// Site set (domain) of the image.
p_complex<dim, geom_t> pc(c, geom);
// Image based on this site set.
typedef complex_image<dim, geom_t, V> ima_t;
ima_t ima(pc);
return ima;
}
// Image based on this site set.
bin_1complex_image2d ima(pc);
return ima;
}
} // end of namespace make
#endif // ! APPS_GRAPH_MORPHO_IO_HH
#endif // ! APPS_GRAPH_MORPHO_MAKE_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment