---
milena/mln/util/internal/graph_edge.hh | 4 +-
milena/mln/util/internal/graph_edge_impl.hh | 89 +++++++++++++++++++++++++
milena/mln/util/internal/graph_vertex.hh | 4 +-
milena/mln/util/internal/graph_vertex_impl.hh | 89 +++++++++++++++++++++++++
4 files changed, 184 insertions(+), 2 deletions(-)
create mode 100644 milena/mln/util/internal/graph_edge_impl.hh
create mode 100644 milena/mln/util/internal/graph_vertex_impl.hh
diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh
index 78a00c2..24bb716 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -28,6 +28,8 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
# define MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+# include <mln/util/internal/graph_edge_impl.hh>
+
/*! \file mln/util/internal/graph_edge.hh
* \brief Definition of a graph edge.
*/
@@ -44,7 +46,7 @@ namespace mln
/// \brief Edge of a graph \p G.
template <typename G>
- class edge
+ class edge : public internal::edge_impl_<G>
{
typedef mlc_const(G) graph_t;
diff --git a/milena/mln/util/internal/graph_edge_impl.hh b/milena/mln/util/internal/graph_edge_impl.hh
new file mode 100644
index 0000000..2ed90c5
--- /dev/null
+++ b/milena/mln/util/internal/graph_edge_impl.hh
@@ -0,0 +1,89 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 MLN_CORE_INTERNAL_EDGE_IMPL_HH
+# define MLN_CORE_INTERNAL_EDGE_IMPL_HH
+
+/*! \file mln/core/internal/edge_impl.hh
+ *
+ * \brief Define a couple of implementation classes to provide methods
+ * to classes of generalized edges.
+ */
+
+# include <mln/core/internal/force_exact.hh>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ /// Implementation class to equip generalized edge classes.
+ template <typename G>
+ class edge_impl_
+ {
+ protected:
+ edge_impl_();
+ };
+
+ } // end of namespace internal
+
+ } // end of namespace util
+
+} // end of namespace mln
+
+#ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ template <typename G>
+ inline
+ edge_impl_<G>::edge_impl_()
+ {
+ }
+
+ } // end of namespace internal
+
+ } // end of namespace util
+
+} // end of namespace mln
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+#endif // ! MLN_CORE_INTERNAL_EDGE_IMPL_HH
diff --git a/milena/mln/util/internal/graph_vertex.hh b/milena/mln/util/internal/graph_vertex.hh
index c40bf0f..fc4ff2b 100644
--- a/milena/mln/util/internal/graph_vertex.hh
+++ b/milena/mln/util/internal/graph_vertex.hh
@@ -28,6 +28,8 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
+# include <mln/util/internal/graph_vertex_impl.hh>
+
/// \file mln/util/internal/graph_vertex.hh
/// \brief Implementation of a graph vertex.
@@ -39,7 +41,7 @@ namespace mln
/// \brief Vertex of a graph \p G.
template<typename G>
- class vertex
+ class vertex : public internal::vertex_impl_<G>
{
typedef mlc_const(G) graph_t;
diff --git a/milena/mln/util/internal/graph_vertex_impl.hh b/milena/mln/util/internal/graph_vertex_impl.hh
new file mode 100644
index 0000000..863cf25
--- /dev/null
+++ b/milena/mln/util/internal/graph_vertex_impl.hh
@@ -0,0 +1,89 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 MLN_CORE_INTERNAL_VERTEX_IMPL_HH
+# define MLN_CORE_INTERNAL_VERTEX_IMPL_HH
+
+/*! \file mln/core/internal/vertex_impl.hh
+ *
+ * \brief Define a couple of implementation classes to provide methods
+ * to classes of generalized vertexs.
+ */
+
+# include <mln/core/internal/force_exact.hh>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ /// Implementation class to equip generalized vertex classes.
+ template <typename G>
+ class vertex_impl_
+ {
+ protected:
+ vertex_impl_();
+ };
+
+ } // end of namespace internal
+
+ } // end of namespace util
+
+} // end of namespace mln
+
+#ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ template <typename G>
+ inline
+ vertex_impl_<G>::vertex_impl_()
+ {
+ }
+
+ } // end of namespace internal
+
+ } // end of namespace util
+
+} // end of namespace mln
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+#endif // ! MLN_CORE_INTERNAL_VERTEX_IMPL_HH
--
1.5.6.5
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update documentation about image properties.
* tests/level/median_.cc: Update.
* tests/level/Makefile.am: Add the tests in the Makefile.am.
* doc/technical/designs/properties/values.txt: Update.
* mln/accu/histo.hh: Fix a compile mistake.
doc/technical/designs/properties/values.txt | 86 +++++++++++++++++++++++++---
mln/accu/histo.hh | 2
tests/level/Makefile.am | 2
tests/level/median_.cc | 1
4 files changed, 81 insertions(+), 10 deletions(-)
Index: tests/level/median_.cc
--- tests/level/median_.cc (revision 2445)
+++ tests/level/median_.cc (working copy)
@@ -44,4 +44,5 @@
level::impl::median_(lena, rect, out);
io::pgm::save(out, "out.pgm");
}
+
}
Index: tests/level/Makefile.am
--- tests/level/Makefile.am (revision 2445)
+++ tests/level/Makefile.am (working copy)
@@ -14,6 +14,7 @@
fill \
fill_with_value \
median \
+ median_ \
median_dir \
median_fast \
median_hline2d \
@@ -36,6 +37,7 @@
fill_SOURCES = fill.cc
fill_with_value_SOURCES = fill_with_value.cc
median_SOURCES = median.cc
+median__SOURCES = median_.cc
median_dir_SOURCES = median_dir.cc
median_fast_SOURCES = median_fast.cc
median_hline2d_SOURCES = median_hline2d.cc
Index: doc/technical/designs/properties/values.txt
--- doc/technical/designs/properties/values.txt (revision 2445)
+++ doc/technical/designs/properties/values.txt (working copy)
@@ -14,8 +14,21 @@
|
+ -- direct
|
+ + -- semi_direct
+ |
+ -- computed
+=> Definition: This property indicates if the image value are stored in memory.
+
+- direct: Images store all their values in memory, we can take a reference
+of the values.
+
+- semi-direct: Images store partially their value in memory, we can't take
+a reference on them. For instance, images that compute a value at the first
+access and store it in a buffer to speed up the next access, are semi-direct.
+
+- computed: All the image values are computed on the fly, at each access.
+
** value_storage:/any/
|
@@ -27,9 +40,54 @@
| |
| + -- piecewise
|
- + -- disrupted
+ + -- none
-=> Methods related:
+
+*** Definition:
+ Indicate how the value are stored in memory
+
+- singleton: The image has only one values, this values is store in memory.
+ 01
+ --
+0 |ee| values in memory
+1 |ee| ==========> [e]
+ --
+
+
+
+- one_block: All the image values are stored in a buffer in memory.
+
+ 01
+ --
+0 |ef| values in memory
+1 |ge| ==========> [e, f, g, e]
+ --
+
+- piece_wise: The values are stored in several memory locations.
+
+example 1) RLE Image
+
+ 013456
+ ------
+0 |ee | values in memory
+1 | fff | ==========> [e], [f], [g]
+3 | ggg|
+4 | |
+ ------
+
+example 2) Sparse Image
+
+ 013456
+ ------
+0 |ef | values in memory
+1 | faaff| ==========> [e, f], [f, a, a, f, f], [l, l, o, g, g]
+3 | llogg|
+4 | |
+ ------
+
+- none: We don't have any information about the value storage.
+
+*** Methods related:
value_storage == singleton
=> ima.value() -> return the image value
@@ -67,6 +125,23 @@
method of value_wise property value + cell_wise property value
+** site_wise_io:/any/
+ |
+ + -- read_only
+ |
+ + -- read_write
+
+=> Definition:
+ Indicates the io permission for the site access.
+ It replaces the property value_access.
+
+- read_only: We can only read the image values.
+- read_write: We can read and write the image values.
+
+ **Note**: RLE images are read only for the access sites.
+
+FIXME: Do we need a value_wise_io
+
* Impact on the fill and paste algorithms
@@ -158,10 +233,3 @@
r : (5,2), (4, 2), (6, 2)
g : (5,4), (4, 4), (6, 3)
b : (2,2), (1, 2), (3, 2)
-
--differentiate the localization of an image and its storage method.
-
-** Image related with 'special' values access
-
-*** Run Images (sparse, value_encoded)
-*** Pkey Images
Index: mln/accu/histo.hh
--- mln/accu/histo.hh (revision 2445)
+++ mln/accu/histo.hh (working copy)
@@ -199,7 +199,7 @@
inline
std::ostream& operator<<(std::ostream& ostr, const histo<V>& h)
{
- mln_viter(V) v(h.vset());
+ mln_viter(value::set<V>) v(h.vset());
for_all(v)
if (h(v) != 0)
ostr << v << ':' << h(v) << ' ';
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-30 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fixes on median.
* mln/level/median.hh: Add initialisation of p :
p = input.domain().pmin() + up;
* tests/level/median_.cc: Some tests.
---
mln/level/median.hh | 1
tests/level/median_.cc | 54 +++++++++++++++++++------------------------------
2 files changed, 22 insertions(+), 33 deletions(-)
Index: branches/cleanup-2008/milena/tests/level/median_.cc
===================================================================
--- branches/cleanup-2008/milena/tests/level/median_.cc (revision 2444)
+++ branches/cleanup-2008/milena/tests/level/median_.cc (revision 2445)
@@ -1,37 +1,6 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library 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 this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library 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.
-
-/*! \file tests/level/median.cc
- *
- * \brief Test on mln::level::median.
- */
-
#include <mln/core/image/image2d.hh>
#include <mln/win/rectangle2d.hh>
+#include <mln/make/box2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
@@ -41,13 +10,31 @@
#include "tests/data.hh"
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
using value::int_u8;
- win::rectangle2d rect(5, 5);
+ {
+ border::thickness = 5;
+ box2d bb = make::box2d(0, 0, 3, 3);
+ image2d<int_u8> ima(bb);
+ debug::iota(ima);
+ debug::println(ima);
+
+ win::rectangle2d rect(3, 3);
+ image2d<int_u8> out(ima.domain());
+
+ level::impl::median_(ima, rect, out);
+ }
+
+
+ {
+ win::rectangle2d rect(20, 20);
border::thickness = 6;
image2d<int_u8> lena;
@@ -57,3 +44,4 @@
level::impl::median_(lena, rect, out);
io::pgm::save(out, "out.pgm");
}
+}
Index: branches/cleanup-2008/milena/mln/level/median.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/median.hh (revision 2444)
+++ branches/cleanup-2008/milena/mln/level/median.hh (revision 2445)
@@ -143,6 +143,7 @@
void init()
{
med.init();
+ p = input.domain().pmin() + up;
mln_qiter(W) q(win, p);
for_all(q) if (input.has(q))
med.take(input(q));
* mln/topo/internal/complex_relative_iterator_base.hh:
New file.
* mln/topo/adj_lower_face_iter.hh,
* mln/topo/adj_higher_face_iter.hh:
New files.
Include them...
* mln/topo/complex.hh: ...here.
* tests/topo/complex.cc (main): Exercise these iterators.
---
milena/ChangeLog | 13 +
milena/mln/topo/adj_higher_face_iter.hh | 185 +++++++++
milena/mln/topo/adj_lower_face_iter.hh | 185 +++++++++
milena/mln/topo/complex.hh | 4 +
.../internal/complex_relative_iterator_base.hh | 436 ++++++++++++++++++++
milena/tests/topo/complex.cc | 49 ++-
6 files changed, 852 insertions(+), 20 deletions(-)
create mode 100644 milena/mln/topo/adj_higher_face_iter.hh
create mode 100644 milena/mln/topo/adj_lower_face_iter.hh
create mode 100644 milena/mln/topo/internal/complex_relative_iterator_base.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0f28467..040d817 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Add iterators on lower- and higher-dimension adjacent faces.
+
+ * mln/topo/internal/complex_relative_iterator_base.hh:
+ New file.
+ * mln/topo/adj_lower_face_iter.hh,
+ * mln/topo/adj_higher_face_iter.hh:
+ New files.
+ Include them...
+ * mln/topo/complex.hh: ...here.
+ * tests/topo/complex.cc (main): Exercise these iterators.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Print the address of complexes with their face handles.
* mln/topo/face.hh (operator<<(std::ostream&, const face<D>&))
diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh
new file mode 100644
index 0000000..5301c05
--- /dev/null
+++ b/milena/mln/topo/adj_higher_face_iter.hh
@@ -0,0 +1,185 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH
+# define MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH
+
+/// \file mln/topo/adj_higher_face_iter.hh
+/// \brief Definition of forward and backward iterators on the
+/// adjacent (n+1)-faces of a (reference) n-face in a complex.
+
+# include <mln/topo/internal/complex_relative_iterator_base.hh>
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declaration.
+ template <unsigned D> class complex;
+
+
+ /*------------------------------------.
+ | topo::adj_higher_face_fwd_iter<D>. |
+ `------------------------------------*/
+
+ /// \brief Forward iterator on all the faces of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_higher_face_fwd_iter
+ : public internal::forward_complex_relative_iterator_base< face<D>,
+ adj_higher_face_fwd_iter<D> >
+ {
+ private:
+ typedef adj_higher_face_fwd_iter<D> self_;
+ typedef internal::forward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ using super_::is_valid;
+ using super_::invalidate;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ adj_higher_face_fwd_iter();
+ template <typename Fref>
+ adj_higher_face_fwd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+ /*------------------------------------.
+ | topo::adj_higher_face_bkd_iter<D>. |
+ `------------------------------------*/
+
+ /// \brief Backward iterator on all the faces of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_higher_face_bkd_iter
+ : public internal::backward_complex_relative_iterator_base< face<D>,
+ adj_higher_face_bkd_iter<D> >
+ {
+ private:
+ typedef adj_higher_face_bkd_iter<D> self_;
+ typedef internal::backward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ using super_::is_valid;
+ using super_::invalidate;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ adj_higher_face_bkd_iter();
+ template <typename Fref>
+ adj_higher_face_bkd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*------------------------------------.
+ | topo::adj_higher_face_fwd_iter<D>. |
+ `------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_higher_face_fwd_iter<D>::adj_higher_face_fwd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_higher_face_fwd_iter<D>::adj_higher_face_fwd_iter(const Fref& f_ref)
+ {
+ center_at(f_ref);
+ // FIXME: Move this to the super class?
+ invalidate();
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_higher_face_fwd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ this->adj_faces_ = this->c_->higher_dim_adj_faces();
+ }
+
+
+ /*------------------------------------.
+ | topo::adj_higher_face_bkd_iter<D>. |
+ `------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_higher_face_bkd_iter<D>::adj_higher_face_bkd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_higher_face_bkd_iter<D>::adj_higher_face_bkd_iter(const Fref& f_ref)
+ {
+ center_at(f_ref);
+ // FIXME: Move this to the super class?
+ invalidate();
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_higher_face_bkd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ this->adj_faces_ = this->c_->higher_dim_adj_faces();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH
diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh
new file mode 100644
index 0000000..498357b
--- /dev/null
+++ b/milena/mln/topo/adj_lower_face_iter.hh
@@ -0,0 +1,185 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TOPO_ADJ_LOWER_FACE_ITER_HH
+# define MLN_TOPO_ADJ_LOWER_FACE_ITER_HH
+
+/// \file mln/topo/adj_lower_face_iter.hh
+/// \brief Definition of forward and backward iterators on the
+/// adjacent (n-1)-faces of a (reference) n-face in a complex.
+
+# include <mln/topo/internal/complex_relative_iterator_base.hh>
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declaration.
+ template <unsigned D> class complex;
+
+
+ /*-----------------------------------.
+ | topo::adj_lower_face_fwd_iter<D>. |
+ `-----------------------------------*/
+
+ /// \brief Forward iterator on all the faces of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_lower_face_fwd_iter
+ : public internal::forward_complex_relative_iterator_base< face<D>,
+ adj_lower_face_fwd_iter<D> >
+ {
+ private:
+ typedef adj_lower_face_fwd_iter<D> self_;
+ typedef internal::forward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ using super_::is_valid;
+ using super_::invalidate;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ adj_lower_face_fwd_iter();
+ template <typename Fref>
+ adj_lower_face_fwd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+ /*-----------------------------------.
+ | topo::adj_lower_face_bkd_iter<D>. |
+ `-----------------------------------*/
+
+ /// \brief Backward iterator on all the faces of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_lower_face_bkd_iter
+ : public internal::backward_complex_relative_iterator_base< face<D>,
+ adj_lower_face_bkd_iter<D> >
+ {
+ private:
+ typedef adj_lower_face_bkd_iter<D> self_;
+ typedef internal::backward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ using super_::is_valid;
+ using super_::invalidate;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ adj_lower_face_bkd_iter();
+ template <typename Fref>
+ adj_lower_face_bkd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*-----------------------------------.
+ | topo::adj_lower_face_fwd_iter<D>. |
+ `-----------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_face_fwd_iter<D>::adj_lower_face_fwd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_face_fwd_iter<D>::adj_lower_face_fwd_iter(const Fref& f_ref)
+ {
+ center_at(f_ref);
+ // FIXME: Move this to the super class?
+ invalidate();
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_lower_face_fwd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ this->adj_faces_ = this->c_->lower_dim_adj_faces();
+ }
+
+
+ /*-----------------------------------.
+ | topo::adj_lower_face_bkd_iter<D>. |
+ `-----------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_face_bkd_iter<D>::adj_lower_face_bkd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_face_bkd_iter<D>::adj_lower_face_bkd_iter(const Fref& f_ref)
+ {
+ center_at(f_ref);
+ // FIXME: Move this to the super class?
+ invalidate();
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_lower_face_bkd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ this->adj_faces_ = this->c_->lower_dim_adj_faces();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ADJ_LOWER_FACE_ITER_HH
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 643285c..c053879 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -56,6 +56,10 @@
# include <mln/topo/faces_iter.hh>
# endif
+# include <mln/topo/adj_lower_face_iter.hh>
+# include <mln/topo/adj_higher_face_iter.hh>
+
+
namespace mln
{
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
new file mode 100644
index 0000000..599727a
--- /dev/null
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -0,0 +1,436 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH
+# define MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH
+
+/** \file mln/topo/internal/complex_relative_iterator_base.hh
+ \brief Definition of an implementation (factoring) class for
+ iterators on mln::complex.
+
+ The hierarchy of classes in this file is as follows
+
+ \verbatim
+
+ complex_relative_iterator_base<F, E>
+ ^
+ |
+ ,--------------+--------------.
+ | |
+ forward_complex_relative_iterator_base<F, E> |
+ |
+ backward_complex_relative_iterator_base<F, E>
+
+ \endverbatim
+*/
+
+# include <limits>
+
+# include <mln/metal/equal.hh>
+
+# include <mln/core/concept/iterator.hh>
+# include <mln/topo/complex.hh>
+
+/* FIXME: By moving iterator `i_' into
+ internal::complex_relative_iterator_base, we'll be able to factor
+ more methods (do_next_, update_f); this requires the type of this
+ iterator be passed as an extra parameter to
+ internal::complex_relative_iterator_base. */
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ namespace internal
+ {
+
+ /*-------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<F, E>. |
+ `-------------------------------------------------------*/
+
+ /// \brief Factoring class for relative iterators on mln::complex.
+ ///
+ /// \arg \p F The type of the face handle.
+ /// \arg \p E The type exact type of the iterator.
+ template <typename F, typename E>
+ class complex_relative_iterator_base : public Iterator<E>
+ {
+ typedef complex_relative_iterator_base<F, E> self_;
+
+ public:
+ typedef F face;
+ // FIXME: Maybe we could just get the dimension D of the face's
+ // complex, an define complex_type as mln::complex<D>?
+ typedef typename F::complex_type complex_type;
+
+ /// Construction and assignment.
+ /// \{
+ /* FIXME: Keep this non-const? See a (big) comment about this in
+ milena/tests/complex_image.cc. */
+ complex_relative_iterator_base();
+ /// \}
+
+ /// Manipulation.
+ /// \{
+ /// Change the center face.
+ void center_at(const F& c);
+
+ /// Start an iteration.
+ void start();
+ /// Go to the next point.
+ void next_();
+ /// \}
+
+ /// Conversion and accessors.
+ /// \{
+ /// Reference to the corresponding face handle.
+ const face& to_face () const;
+ /// Convert the iterator into an face handle.
+ operator face() const;
+ /// \}
+
+ protected:
+ /// A pointer to the center face around which this iterator
+ /// moves.
+ const face* c_;
+
+ // The type of the set of vicinity sites (adjacent face handles).
+ typedef std::vector<face> adj_faces_t;
+ /// The set of faces adjacent to the reference face.
+ adj_faces_t adj_faces_;
+
+ /// The face handle this iterator is pointing to.
+ face f_;
+ };
+
+
+ /* FIXME: This hand-made delegation is painful. We should rely on
+ the general mechanism provided by Point_Site. But then again, we
+ need to refine/adjust the interface of Point_Site w.r.t. the
+ mandatory conversions to points. */
+ template <typename F, typename E>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const complex_relative_iterator_base<F, E>& p);
+
+
+ /*---------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<F, E>. |
+ `---------------------------------------------------------------*/
+
+ /// \brief Factoring class for forward relative iterators on
+ /// mln::complex.
+ ///
+ /// \arg \p F The type of the face handle.
+ /// \arg \p E The type exact type of the iterator.
+ template <typename F, typename E>
+ class forward_complex_relative_iterator_base
+ : public complex_relative_iterator_base<F, E>
+ {
+ typedef forward_complex_relative_iterator_base<F, E> self_;
+ typedef complex_relative_iterator_base<F, E> super_;
+
+ public:
+ typedef F face;
+ // FIXME: Maybe we could just get the dimension D of the face's
+ // complex, an define complex_type as mln::complex<D>?
+ typedef typename F::complex_type complex_type;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ /* FIXME: Keep this non-const? See a (big) comment about this in
+ milena/tests/complex_image.cc. */
+ forward_complex_relative_iterator_base();
+ /// \}
+
+ public:
+ /// Manipulation
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void do_start_();
+ /// Go to the next point.
+ void do_next_();
+
+ /// Update the target face.
+ void update_f_();
+ /// \}
+
+ protected:
+ /// An iterator on the set of adjacent edges.
+ typename super_::adj_faces_t::const_iterator i_;
+ };
+
+
+ /*----------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<F, E>. |
+ `----------------------------------------------------------------*/
+
+ /// \brief Factoring class for backward relative iterators on
+ /// mln::complex.
+ ///
+ /// \arg \p F The type of the face handle.
+ /// \arg \p E The type exact type of the iterator.
+ template <typename F, typename E>
+ class backward_complex_relative_iterator_base
+ : public complex_relative_iterator_base<F, E>
+ {
+ typedef backward_complex_relative_iterator_base<F, E> self_;
+ typedef complex_relative_iterator_base<F, E> super_;
+
+ public:
+ typedef F face;
+ // FIXME: Maybe we could just get the dimension D of the face's
+ // complex, an define complex_type as mln::complex<D>?
+ typedef typename F::complex_type complex_type;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ /* FIXME: Keep this non-const? See a (big) comment about this in
+ milena/tests/complex_image.cc. */
+ backward_complex_relative_iterator_base();
+ /// \}
+
+ public:
+ /// Manipulation
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void do_start_();
+ /// Go to the next point.
+ void do_next_();
+
+ /// Update the target face.
+ void update_f_();
+ /// \}
+
+ protected:
+ /// An iterator on the set of adjacent edges.
+ typename super_::adj_faces_t::const_reverse_iterator i_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*-------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<F, E>. |
+ `-------------------------------------------------------*/
+
+ template <typename F, typename E>
+ inline
+ complex_relative_iterator_base<F, E>::complex_relative_iterator_base()
+ : c_(0)
+ {
+ // Ensure F and E are compatible.
+ mlc_equal(F, typename E::face)::check();
+ // Check for required methods in E.
+ void (E::*m)() = & E::update_adj_faces_;
+ m = 0;
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ complex_relative_iterator_base<F, E>::center_at(const F& c)
+ {
+ c_ = &c;
+ exact(this)->invalidate();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ complex_relative_iterator_base<F, E>::start()
+ {
+ exact(this)->do_start_();
+ if (exact(this)->is_valid())
+ exact(this)->update_f_();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ complex_relative_iterator_base<F, E>::next_()
+ {
+ exact(this)->do_next_();
+ if (exact(this)->is_valid())
+ exact(this)->update_f_();
+ }
+
+ template <typename F, typename E>
+ inline
+ const F&
+ complex_relative_iterator_base<F, E>::to_face() const
+ {
+ return f_;
+ }
+
+ template <typename F, typename E>
+ inline
+ complex_relative_iterator_base<F, E>::operator F() const
+ {
+ mln_precondition(exact(this)->is_valid());
+ return f_;
+ }
+
+
+ template <typename F, typename E>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr,
+ const complex_relative_iterator_base<F, E>& p)
+ {
+ return ostr << F(p);
+ }
+
+
+ /*---------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<F, E>. |
+ `---------------------------------------------------------------*/
+
+ template <typename F, typename E>
+ inline
+ forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base()
+ {
+ }
+
+ template <typename F, typename E>
+ inline
+ bool
+ forward_complex_relative_iterator_base<F, E>::is_valid() const
+ {
+ return i_ != this->adj_faces_.end();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ forward_complex_relative_iterator_base<F, E>::invalidate()
+ {
+ i_ = this->adj_faces_.end();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ forward_complex_relative_iterator_base<F, E>::do_start_()
+ {
+ exact(this)->update_adj_faces_();
+ i_ = this->adj_faces_.begin();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ forward_complex_relative_iterator_base<F, E>::do_next_()
+ {
+ ++i_;
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ forward_complex_relative_iterator_base<F, E>::update_f_()
+ {
+ this->f_ = *i_;
+ }
+
+
+ /*----------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<F, E>. |
+ `----------------------------------------------------------------*/
+
+ template <typename F, typename E>
+ inline
+ backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base()
+ {
+ }
+
+ template <typename F, typename E>
+ inline
+ bool
+ backward_complex_relative_iterator_base<F, E>::is_valid() const
+ {
+ return i_ != this->adj_faces_.rend();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ backward_complex_relative_iterator_base<F, E>::invalidate()
+ {
+ i_ = this->adj_faces_.rend();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ backward_complex_relative_iterator_base<F, E>::do_start_()
+ {
+ exact(this)->update_adj_faces_();
+ i_ = this->adj_faces_.rbegin();
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ backward_complex_relative_iterator_base<F, E>::do_next_()
+ {
+ ++i_;
+ }
+
+ template <typename F, typename E>
+ inline
+ void
+ backward_complex_relative_iterator_base<F, E>::update_f_()
+ {
+ this->f_ = *i_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo::internal
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 349921c..f079734 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -207,7 +207,8 @@ int main()
milena/tests/core/complex_image.cc) and ticket #162
(https://trac.lrde.org/olena/ticket/162) */
- /* Iterate on the the set of (n-1)-faces adjacent to AF.
+ /* Iterate on the the set of (n-1)- and (n+1)-faces adjacent to the
+ faces of C.
Note: this can be solved with iterators where the dimension can
be either static or dynamic.
@@ -224,13 +225,31 @@ int main()
(Note: we might want to get rid of the name `citer', and use
`fiter' everywhere.).
- A static version might be useful (and more efficient) too.
+ A static version might be useful (and more efficient) too. */
+
+ topo::adj_lower_face_fwd_iter<D> fwd_alf(fwd_f);
+ topo::adj_lower_face_bkd_iter<D> bkd_alf(fwd_f);
+ for_all(fwd_f)
+ {
+ std::cout << "Lower-dimension faces adjacent to " << fwd_f << ": "
+ << std::endl;
+ for_all_2(fwd_alf, bkd_alf)
+ std::cout << " " << fwd_alf << '\t' << bkd_alf << std::endl;
+ }
+ std::cout << std::endl;
- Likewise, our iterators on n-faces (both faces_piter and
- complex_faces_piter) use a static `n'. We should also have
- n-faces iterators where n could be dynamic.
+ topo::adj_higher_face_fwd_iter<D> fwd_ahf(fwd_f);
+ topo::adj_higher_face_bkd_iter<D> bkd_ahf(fwd_f);
+ for_all(fwd_f)
+ {
+ std::cout << "Higher-dimension faces adjacent to " << fwd_f << ": "
+ << std::endl;
+ for_all_2(fwd_ahf, bkd_ahf)
+ std::cout << " " << fwd_ahf << '\t' << bkd_ahf << std::endl;
+ }
+ std::cout << std::endl;
- But first, we need to clarify (existing) names. The one listed
+ /* But first, we need to clarify (existing) names. The one listed
in https://trac.lrde.org/olena/wiki/Olena/ComplexBasedImages
are OK.
@@ -239,26 +258,16 @@ int main()
-----------------------------------------------------------------
Name Definition
-----------------------------------------------------------------
- adj_lower_faces_fwd_iter<D>(c, f) | Iterators on the adjacent
- adj_lower_faces_bkd_iter<D>(c, f) | (lower) (n-1)-faces of the
- | n-face f of the complex c,
- | n being dynamic
-
- adj_higher_faces_fwd_iter<D>(c, f) | Iterators on the adjacent
- adj_higher_faces_bkd_iter<D>(c, f) | (higher) (n+1)-faces of the
- | n-face f of the complex c,
- | n being dynamic
-
- adj_lower_dim_connected_n_faces_fwd_iter<D>(c, f)
- adj_lower_dim_connected_n_faces_bkd_iter<D>(c, f)
+ adj_lower_dim_connected_n_face_fwd_iter<D>(c, f)
+ adj_lower_dim_connected_n_face_bkd_iter<D>(c, f)
(FIXME: These names are admittedly too long.)
| Iterators on the the set of
| n-faces sharing an adjacent
| (n-1)-face with f, n being
| dynamic
- adj_higher_dim_connected_n_faces_fwd_iter<D>(c, f)
- adj_higher_dim_connected_n_faces_bkd_iter<D>(c, f)
+ adj_higher_dim_connected_n_face_fwd_iter<D>(c, f)
+ adj_higher_dim_connected_n_face_bkd_iter<D>(c, f)
(FIXME: These names are admittedly too long.)
| Iterators on the the set of
| n-faces sharing an adjacent
--
1.6.0.1