* 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/.
---
milena/ChangeLog | 11 ++++
milena/apps/graph-morpho/Makefile.am | 2 +-
milena/apps/graph-morpho/convert.hh | 4 +-
milena/apps/graph-morpho/io.hh | 96 -------------------------------
milena/apps/graph-morpho/make.hh | 105 ++++++++++++++++++++++++++++++++++
5 files changed, 119 insertions(+), 99 deletions(-)
delete mode 100644 milena/apps/graph-morpho/io.hh
create mode 100644 milena/apps/graph-morpho/make.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 39bc7c2..0e55663 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2009-10-01 Roland Levillain <roland(a)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(a)lrde.epita.fr>
+
Clean up another conversion routine in graph-morpho.
* apps/graph-morpho/io.hh (make_regular_complex1d_image):
diff --git a/milena/apps/graph-morpho/Makefile.am b/milena/apps/graph-morpho/Makefile.am
index 76fb7d7..e4cbb6d 100644
--- a/milena/apps/graph-morpho/Makefile.am
+++ b/milena/apps/graph-morpho/Makefile.am
@@ -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
diff --git a/milena/apps/graph-morpho/convert.hh b/milena/apps/graph-morpho/convert.hh
index 4328765..6e4ad55 100644
--- a/milena/apps/graph-morpho/convert.hh
+++ b/milena/apps/graph-morpho/convert.hh
@@ -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;
diff --git a/milena/apps/graph-morpho/io.hh b/milena/apps/graph-morpho/io.hh
deleted file mode 100644
index 6dac2c4..0000000
--- a/milena/apps/graph-morpho/io.hh
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// 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
-
-/// \file apps/graph-morpho/io.hh
-/// \brief I/O routines for graphs (1-complexes).
-
-# include <mln/core/alias/complex_image.hh>
-# include <mln/core/image/image2d.hh>
-
-inline
-mln::bin_1complex_image2d
-build_regular_complex1d_image(const mln::box2d& support)
-{
- 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;
-
- typedef topo::complex<dim> complex_t;
- complex_t c;
- typedef geom::complex_geometry<dim, point2d> geom_t;
- geom_t geom;
-
- // Vertices.
- for (unsigned row = 0; row < nrows; ++row)
- for (unsigned col = 0; col < ncols; ++col)
- {
- c.add_face();
- geom.add_location(point2d(row,col));
- }
-
- // 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.
- bin_1complex_image2d ima(pc);
- return ima;
-}
-
-
-#endif // ! APPS_GRAPH_MORPHO_IO_HH
diff --git a/milena/apps/graph-morpho/make.hh b/milena/apps/graph-morpho/make.hh
new file mode 100644
index 0000000..4ebd372
--- /dev/null
+++ b/milena/apps/graph-morpho/make.hh
@@ -0,0 +1,105 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// 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_MAKE_HH
+# define APPS_GRAPH_MORPHO_MAKE_HH
+
+/// \file
+/// \brief Creation routines for complex-based images.
+
+# include <mln/core/alias/complex_image.hh>
+# include <mln/core/alias/box2d.hh>
+
+namespace make
+{
+
+ /// 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;
+
+ 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;
+
+ typedef topo::complex<dim> complex_t;
+ complex_t c;
+ typedef geom::complex_geometry<dim, point2d> geom_t;
+ geom_t geom;
+
+ // Vertices.
+ for (unsigned row = 0; row < nrows; ++row)
+ for (unsigned col = 0; col < ncols; ++col)
+ {
+ c.add_face();
+ geom.add_location(point2d(row,col));
+ }
+
+ // 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;
+ }
+
+} // end of namespace make
+
+
+#endif // ! APPS_GRAPH_MORPHO_MAKE_HH
--
1.6.3.1