Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
30 Sep '08
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) << ' ';
1
0
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));
1
0
30 Sep '08
* 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
1
0
30 Sep '08
* mln/topo/face.hh (operator<<(std::ostream&, const face<D>&))
* mln/topo/n_face.hh (operator<<(std::ostream&, const n_face<N, D>&)):
Do it.
---
milena/ChangeLog | 8 ++++++++
milena/mln/topo/face.hh | 3 ++-
milena/mln/topo/n_face.hh | 3 ++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a9e0511..0f28467 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
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>&))
+ * mln/topo/n_face.hh (operator<<(std::ostream&, const n_face<N, D>&)):
+ Do it.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Overhaul mln::topo::internal::complex_iter_base.
* mln/topo/internal/complex_iter_base.hh
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 1ff81e5..00d6049 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -404,7 +404,8 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const face<D>& f)
{
- return ostr << "(dim = " << f.n() << ", id = " << f.face_id() << ')';
+ return ostr << "(cplx = " << &f.cplx() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ')';
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/topo/n_face.hh b/milena/mln/topo/n_face.hh
index bb4e926..fddf568 100644
--- a/milena/mln/topo/n_face.hh
+++ b/milena/mln/topo/n_face.hh
@@ -259,7 +259,8 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const n_face<N, D>& f)
{
- return ostr << "(dim = " << f.n() << ", id = " << f.face_id() << ')';
+ return ostr << "(cplx = " << &f.cplx() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ')';
}
# endif // ! MLN_INCLUDE_ONLY
--
1.6.0.1
1
0
* mln/topo/internal/complex_iter_base.hh
(mln::topo::internal::complex_iter_base<F, E>::to_face): Remove.
(operator<<(std::ostream&, const complex_iter_base<F, E>&)):
Remove outdated FIXME.
(mln::topo::internal::complex_iter_base<F, E>::face_): Rename as...
(mln::topo::internal::complex_iter_base<F, E>::f_): ...this.
Adjust.
* mln/topo/face_iter.hh,
* mln/topo/n_face_iter.hh,
* mln/topo/static_n_face_iter.hh:
Adjust as well.
---
milena/ChangeLog | 16 +++++++
milena/mln/topo/face_iter.hh | 38 ++++++++--------
milena/mln/topo/internal/complex_iter_base.hh | 56 ++++++++-----------------
milena/mln/topo/n_face_iter.hh | 32 +++++++-------
milena/mln/topo/static_n_face_iter.hh | 30 +++++++-------
5 files changed, 84 insertions(+), 88 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6ce4fb0..a9e0511 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Overhaul mln::topo::internal::complex_iter_base.
+
+ * mln/topo/internal/complex_iter_base.hh
+ (mln::topo::internal::complex_iter_base<F, E>::to_face): Remove.
+ (operator<<(std::ostream&, const complex_iter_base<F, E>&)):
+ Remove outdated FIXME.
+ (mln::topo::internal::complex_iter_base<F, E>::face_): Rename as...
+ (mln::topo::internal::complex_iter_base<F, E>::f_): ...this.
+ Adjust.
+ * mln/topo/face_iter.hh,
+ * mln/topo/n_face_iter.hh,
+ * mln/topo/static_n_face_iter.hh:
+ Adjust as well.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Improve accesses to adjacent faces to mln::topo::face<D>.
* mln/topo/face.hh
diff --git a/milena/mln/topo/face_iter.hh b/milena/mln/topo/face_iter.hh
index 4de87cc..a564831 100644
--- a/milena/mln/topo/face_iter.hh
+++ b/milena/mln/topo/face_iter.hh
@@ -84,7 +84,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -124,7 +124,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -156,8 +156,8 @@ namespace mln
void
face_fwd_iter<D>::start()
{
- face_.set_n(0u);
- face_.set_face_id(0u);
+ f_.set_n(0u);
+ f_.set_face_id(0u);
}
template <unsigned D>
@@ -167,27 +167,27 @@ namespace mln
{
if (is_valid())
{
- unsigned n = face_.n();
- unsigned face_id = face_.face_id();
+ unsigned n = f_.n();
+ unsigned face_id = f_.face_id();
- if (face_id + 1 < face_.cplx().nfaces(n))
+ if (face_id + 1 < f_.cplx().nfaces(n))
/* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id + 1);
+ f_.set_face_id(face_id + 1);
else
// Start to iterate on the faces of the next dimension if
// possible.
if (n <= D)
{
// FIXME: Same remark as above.
- face_.set_n(n + 1);
- face_.set_face_id(0u);
+ f_.set_n(n + 1);
+ f_.set_face_id(0u);
}
else
invalidate();
@@ -220,8 +220,8 @@ namespace mln
void
face_bkd_iter<D>::start()
{
- face_.set_n(D);
- face_.set_face_id(face_.cplx().template nfaces<D>() - 1);
+ f_.set_n(D);
+ f_.set_face_id(f_.cplx().template nfaces<D>() - 1);
}
template <unsigned D>
@@ -231,27 +231,27 @@ namespace mln
{
if (is_valid())
{
- unsigned n = face_.n();
- unsigned face_id = face_.face_id();
+ unsigned n = f_.n();
+ unsigned face_id = f_.face_id();
if (face_id > 0)
/* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id - 1);
+ f_.set_face_id(face_id - 1);
else
// Start to iterate on the faces of the previous dimension
// if it exists.
if (n > 0)
{
// FIXME: Same remark as above.
- face_.set_n(n - 1);
- face_.set_face_id(face_.cplx().nfaces(n - 1) - 1);
+ f_.set_n(n - 1);
+ f_.set_face_id(f_.cplx().nfaces(n - 1) - 1);
}
else
invalidate();
diff --git a/milena/mln/topo/internal/complex_iter_base.hh b/milena/mln/topo/internal/complex_iter_base.hh
index dc479e2..06ffca2 100644
--- a/milena/mln/topo/internal/complex_iter_base.hh
+++ b/milena/mln/topo/internal/complex_iter_base.hh
@@ -39,6 +39,11 @@
# include <mln/core/concept/iterator.hh>
# include <mln/topo/complex.hh>
+// FIXME: Rename as something else?
+// - complex_iterator_base?
+// - complex_set_iterator_base?
+// - faces_set_iterator_base?
+
namespace mln
{
@@ -83,17 +88,15 @@ namespace mln
void invalidate();
/// \}
- /// Conversion and accessors.
+ /// Conversion.
/// \{
- /// Reference to the corresponding face handle.
- const face& to_face () const;
- /// Convert the iterator into an face handle.
- operator face() const;
+ /// Return a reference to the corresponding face handle.
+ operator const face&() const;
/// \}
protected:
/// The face handle this iterator is pointing to.
- face face_;
+ face f_;
};
@@ -124,8 +127,8 @@ namespace mln
// Ensure F and E are compatible.
mlc_equal(F, typename E::face)::check();
- face_.set_cplx(c);
- // Invalidate face_.
+ f_.set_cplx(c);
+ // Invalidate f_.
invalidate();
}
@@ -134,8 +137,8 @@ namespace mln
void
complex_iter_base<F, E>::set_cplx(complex_type& c)
{
- face_.set_cplx(c);
- // Invalidate face_.
+ f_.set_cplx(c);
+ // Invalidate f_.
invalidate();
}
@@ -144,7 +147,7 @@ namespace mln
bool
complex_iter_base<F, E>::is_valid() const
{
- return face_.is_valid();
+ return f_.is_valid();
}
template <typename F, typename E>
@@ -152,23 +155,14 @@ namespace mln
void
complex_iter_base<F, E>::invalidate()
{
- face_.invalidate();
- }
-
- template <typename F, typename E>
- inline
- const F&
- complex_iter_base<F, E>::to_face() const
- {
- return face_;
+ f_.invalidate();
}
template <typename F, typename E>
inline
- complex_iter_base<F, E>::operator F() const
+ complex_iter_base<F, E>::operator const F&() const
{
- mln_precondition(is_valid());
- return face_;
+ return f_;
}
@@ -177,21 +171,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const complex_iter_base<F, E>& p)
{
- /* FIXME: We should use p.to_face() here, but as it lacks the
- precondition the conversion operator has, so we use the latter.
-
- We should
- - rename `to_face' as `to_face_';
- - write a new `to_face' routine checking the validity of the
- iterator;
- - have the conversion operator to face use this new `to_face'
- routine;
- - adjust former clients of `to_face'
-
- This is a general remark that applies to all iterators of
- Milena. */
- F f = p;
- return ostr << f;
+ return ostr << F(p);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/topo/n_face_iter.hh b/milena/mln/topo/n_face_iter.hh
index c4291e2..2a499c2 100644
--- a/milena/mln/topo/n_face_iter.hh
+++ b/milena/mln/topo/n_face_iter.hh
@@ -95,7 +95,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -143,7 +143,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -177,7 +177,7 @@ namespace mln
void
n_face_fwd_iter<D>::start()
{
- face_.set_face_id(0u);
+ f_.set_face_id(0u);
}
template <unsigned D>
@@ -187,19 +187,19 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = face_.face_id();
+ unsigned face_id = f_.face_id();
// The number of faces of dimension N in cplx_.
- unsigned nn_faces = face_.cplx().nfaces(n());
+ unsigned nn_faces = f_.cplx().nfaces(n());
if (face_id + 1 < nn_faces)
/* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id + 1);
+ f_.set_face_id(face_id + 1);
else
invalidate();
}
@@ -210,7 +210,7 @@ namespace mln
unsigned
n_face_fwd_iter<D>::n() const
{
- return face_.n();
+ return f_.n();
}
template <unsigned D>
@@ -219,7 +219,7 @@ namespace mln
n_face_fwd_iter<D>::set_n(unsigned n)
{
mln_precondition(n <= D);
- face_.set_n(n);
+ f_.set_n(n);
}
@@ -250,8 +250,8 @@ namespace mln
void
n_face_bkd_iter<D>::start()
{
- face_.set_n(n());
- face_.set_face_id(face_.cplx().nfaces(n()) - 1);
+ f_.set_n(n());
+ f_.set_face_id(f_.cplx().nfaces(n()) - 1);
}
template <unsigned D>
@@ -261,17 +261,17 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = face_.face_id();
+ unsigned face_id = f_.face_id();
if (face_id > 0)
/* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id - 1);
+ f_.set_face_id(face_id - 1);
else
invalidate();
}
@@ -282,7 +282,7 @@ namespace mln
unsigned
n_face_bkd_iter<D>::n() const
{
- return face_.n();
+ return f_.n();
}
template <unsigned D>
@@ -291,7 +291,7 @@ namespace mln
n_face_bkd_iter<D>::set_n(unsigned n)
{
mln_precondition(n <= D);
- face_.set_n(n);
+ f_.set_n(n);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/topo/static_n_face_iter.hh b/milena/mln/topo/static_n_face_iter.hh
index 291b699..f29c4e4 100644
--- a/milena/mln/topo/static_n_face_iter.hh
+++ b/milena/mln/topo/static_n_face_iter.hh
@@ -81,7 +81,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -124,7 +124,7 @@ namespace mln
/// \}
private:
- using super_::face_;
+ using super_::f_;
};
@@ -142,7 +142,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- face_.set_n(N);
+ f_.set_n(N);
mln_postcondition(!is_valid());
}
@@ -153,7 +153,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- face_.set_n(N);
+ f_.set_n(N);
mln_postcondition(!is_valid());
}
@@ -162,7 +162,7 @@ namespace mln
void
static_n_face_fwd_iter<N, D>::start()
{
- face_.set_face_id(0u);
+ f_.set_face_id(0u);
}
template <unsigned N, unsigned D>
@@ -172,20 +172,20 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = face_.face_id();
+ unsigned face_id = f_.face_id();
// The number of faces of dimension N in cplx_.
- unsigned nn_faces = face_.cplx().template nfaces<N>();
+ unsigned nn_faces = f_.cplx().template nfaces<N>();
if (face_id + 1 < nn_faces)
/* FIXME: Provide accessor face::face_id()
returning a mutable reference? This way, we could just
write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id + 1);
+ f_.set_face_id(face_id + 1);
else
invalidate();
}
@@ -203,7 +203,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- face_.set_n(N);
+ f_.set_n(N);
mln_postcondition(!is_valid());
}
@@ -214,7 +214,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- face_.set_n(N);
+ f_.set_n(N);
mln_postcondition(!is_valid());
}
@@ -223,7 +223,7 @@ namespace mln
void
static_n_face_bkd_iter<N, D>::start()
{
- face_.set_face_id(face_.cplx().template nfaces<N>() - 1);
+ f_.set_face_id(f_.cplx().template nfaces<N>() - 1);
}
template <unsigned N, unsigned D>
@@ -233,18 +233,18 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = face_.face_id();
+ unsigned face_id = f_.face_id();
if (face_id > 0)
/* FIXME: Provide accessor face::face_id()
returning a mutable reference? This way, we could just
write
- ++face_.face_id();
+ ++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
- face_.set_face_id(face_id - 1);
+ f_.set_face_id(face_id - 1);
else
invalidate();
}
--
1.6.0.1
1
0
30 Sep '08
* mln/topo/face.hh
(mln::topo::face<D>::lower_dim_adj_faces):
Return an empty vector if `this' is a 0-face.
(mln::topo::face<D>::higher_dim_adj_faces):
Return an empty vector if `this' is a D-face.
(mln::topo::face<D>::lower_dim_adj_faces)
(mln::topo::face<D>::higher_dim_adj_faces):
Make it const.
(mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
(mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
Adjust.
---
milena/ChangeLog | 16 ++++++++++++++++
milena/mln/topo/face.hh | 26 ++++++++++++++------------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d820e59..6ce4fb0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Improve accesses to adjacent faces to mln::topo::face<D>.
+
+ * mln/topo/face.hh
+ (mln::topo::face<D>::lower_dim_adj_faces):
+ Return an empty vector if `this' is a 0-face.
+ (mln::topo::face<D>::higher_dim_adj_faces):
+ Return an empty vector if `this' is a D-face.
+ (mln::topo::face<D>::lower_dim_adj_faces)
+ (mln::topo::face<D>::higher_dim_adj_faces):
+ Make it const.
+ (mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
+ (mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
+ Adjust.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Delegate pretty-printing of iterators on faces to mln::topo::face.
* mln/topo/internal/complex_iter_base.hh (operator<<): Here.
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index c485697..1ff81e5 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -100,9 +100,9 @@ namespace mln
// FIXME: To be overhauled.
// FIXME: Why no `const' here?
/// Return an array of face handles pointing to adjacent (n-1)-faces.
- std::vector< face<D> > lower_dim_adj_faces();
+ std::vector< face<D> > lower_dim_adj_faces() const;
/// Return an array of face handles pointing to adjacent (n+1)-faces.
- std::vector< face<D> > higher_dim_adj_faces();
+ std::vector< face<D> > higher_dim_adj_faces() const;
/// \}
private:
@@ -264,7 +264,7 @@ namespace mln
template <unsigned N, unsigned D>
struct lower_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(face<D>& face)
+ std::vector< face<D> > operator()(const face<D>& face)
{
metal::bool_< (N <= D) >::check();
metal::bool_< (N > 1) >::check();
@@ -288,7 +288,7 @@ namespace mln
template <unsigned D>
struct lower_dim_adj_faces_if_dim_matches_<1, D>
{
- std::vector< face<D> > operator()(face<D>& face)
+ std::vector< face<D> > operator()(const face<D>& face)
{
/// If we reached this function, then the dimension of FACE
/// has to be 1.
@@ -306,7 +306,7 @@ namespace mln
template <unsigned N, unsigned D>
struct higher_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(face<D>& face)
+ std::vector< face<D> > operator()(const face<D>& face)
{
metal::bool_< (N < D) >::check();
@@ -330,7 +330,7 @@ namespace mln
template <unsigned D>
struct higher_dim_adj_faces_if_dim_matches_<0, D>
{
- std::vector< face<D> > operator()(face<D>& face)
+ std::vector< face<D> > operator()(const face<D>& face)
{
/// If we reached this function, then the dimension of face
/// has to be D - 1.
@@ -350,25 +350,27 @@ namespace mln
template <unsigned D>
inline
std::vector< face<D> >
- face<D>::lower_dim_adj_faces()
+ face<D>::lower_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
metal::bool_< D != 0 >::check();
- mln_precondition(n_ > 0);
- return internal::lower_dim_adj_faces_if_dim_matches_<D, D>()(*this);
+ return n_ > 0 ?
+ internal::lower_dim_adj_faces_if_dim_matches_<D, D>()(*this) :
+ std::vector< face<D> >();
}
template <unsigned D>
inline
std::vector< face<D> >
- face<D>::higher_dim_adj_faces()
+ face<D>::higher_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
metal::bool_< D != 0 >::check();
- mln_precondition(n_ < D);
- return internal::higher_dim_adj_faces_if_dim_matches_<D - 1, D>()(*this);
+ return n_ < D ?
+ internal::higher_dim_adj_faces_if_dim_matches_<D - 1, D>()(*this) :
+ std::vector< face<D> >();
}
--
1.6.0.1
1
0
30 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update reconstruction algorithms in theo's sandbox.
* milena/mln/level/paste.hh: Fix warning.
* milena/sandbox/geraud/Rd/hybrid.hh,
* milena/sandbox/geraud/Rd/queue_based.hh,
* milena/sandbox/geraud/Rd/parallel.cc,
* milena/sandbox/geraud/Rd/union_find.hh,
* milena/sandbox/geraud/Rd/parallel.hh,
* milena/sandbox/geraud/Rd/sequential.cc,
* milena/sandbox/geraud/Rd/utils.hh,
* milena/sandbox/geraud/Rd/hybrid.cc,
* milena/sandbox/geraud/Rd/queue_based.cc,
* milena/sandbox/geraud/Rd/min.cc,
* milena/sandbox/geraud/Rd/sequential.hh,
* milena/sandbox/geraud/Rd/union_find.cc: Update.
mln/level/paste.hh | 2 +
sandbox/geraud/Rd/hybrid.cc | 20 ++++++++-------
sandbox/geraud/Rd/hybrid.hh | 24 +++++++------------
sandbox/geraud/Rd/min.cc | 4 +--
sandbox/geraud/Rd/parallel.cc | 23 ++++++++++--------
sandbox/geraud/Rd/parallel.hh | 20 ++++-----------
sandbox/geraud/Rd/queue_based.cc | 22 +++++++++--------
sandbox/geraud/Rd/queue_based.hh | 19 +++++----------
sandbox/geraud/Rd/sequential.cc | 23 ++++++++----------
sandbox/geraud/Rd/sequential.hh | 13 +---------
sandbox/geraud/Rd/union_find.cc | 22 +++++++++--------
sandbox/geraud/Rd/union_find.hh | 30 ++++++++---------------
sandbox/geraud/Rd/utils.hh | 49 +++++++++++++++++++--------------------
13 files changed, 123 insertions(+), 148 deletions(-)
Index: milena/mln/level/paste.hh
--- milena/mln/level/paste.hh (revision 2439)
+++ milena/mln/level/paste.hh (working copy)
@@ -84,6 +84,8 @@
mlc_converts_to(mln_value(I), mln_value(J))::check();
mln_precondition(exact(data).has_data());
mln_precondition(exact(data).domain() <= exact(destination).domain());
+ (void)data;
+ (void)destination;
}
} // end of namespace mln::level::internal
Index: milena/sandbox/geraud/Rd/hybrid.hh
--- milena/sandbox/geraud/Rd/hybrid.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/hybrid.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -46,17 +46,11 @@
I hybrid(const I& f, const I& g, const N& nbh,
bool echo = false)
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
std::queue<point> q;
- f.name_it("f");
- g.name_it("g");
-
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
@@ -72,8 +66,10 @@
for_all(p)
{
o(p) = min( max_Nplus(o, p,nbh), g(p) );
- for_all(n) if (f.has(n) and n < p) // N+
- if (o(n) < o(p) and o(n) < g(n))
+ for_all(n)
+ if (f.has(n) &&
+ util::ord_strict(n.to_site(), p.to_site())) // N+
+ if (o(n) < o(p) && o(n) < g(n))
{
q.push(p);
++n_init_pushs;
@@ -92,7 +88,7 @@
q.pop();
++n_pops;
for_all(n) if (f.has(n))
- if (o(n) < o(p) and o(n) != g(n))
+ if (o(n) < o(p) && o(n) != g(n))
{
o(n) = min(o(p), g(n));
if (echo) std::cout << " push " << n;
@@ -103,13 +99,11 @@
if (echo) std::cout << std::endl;
}
-
+ if (echo)
std::cout << "n_init_pushs = " << n_init_pushs << std::endl
<< "n_body_pushs = " << n_body_pushs << std::endl
<< "n_pops = " << n_pops << std::endl;
- print_counts();
-
return o;
}
Index: milena/sandbox/geraud/Rd/queue_based.hh
--- milena/sandbox/geraud/Rd/queue_based.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/queue_based.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research && 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
@@ -18,7 +18,7 @@
// 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
+// file, or you compile this file && 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
@@ -52,13 +52,9 @@
if (echo) std::cout << std::endl;
- f.name_it("f");
- g.name_it("g");
-
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
std::queue<point> q;
I o;
- o.name_it("o");
unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
@@ -71,8 +67,8 @@
mln_piter(I) p(f.domain());
mln_niter(N) n(nbh, p);
- for_all(p) if (o(p) != 0) // p in M
- for_all(n) if (f.has(n) and o(n) == 0) // n not in M
+ for_all(p) if (o(p) != 0u) // p in M
+ for_all(n) if (f.has(n) && o(n) == 0u) // n not in M
{
q.push(p);
que(p) = true;
@@ -94,7 +90,7 @@
++n_pops;
for_all(n) if (f.has(n))
{
- if (o(n) < o(p) and o(n) != g(n))
+ if (o(n) < o(p) && o(n) != g(n))
{
o(n) = min(o(p), g(n));
if (echo) std::cout << " push " << n;
@@ -110,12 +106,11 @@
if (echo) std::cout << std::endl;
}
+ if (echo)
std::cout << "n_init_pushs = " << n_init_pushs << std::endl
<< "n_body_pushs = " << n_body_pushs << std::endl
<< "n_pops = " << n_pops << std::endl;
- print_counts();
-
return o;
}
Index: milena/sandbox/geraud/Rd/parallel.cc
--- milena/sandbox/geraud/Rd/parallel.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/parallel.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -14,7 +14,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
- << "reconstruction by dilation (parallel version; may 2007)" << std::endl
+ << "reconstruction by dilation (parallel version; sep 2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -30,22 +30,25 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::parallel(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::parallel(f, g,
+ (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/union_find.hh
--- milena/sandbox/geraud/Rd/union_find.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/union_find.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -44,7 +44,7 @@
template <typename I, typename N>
struct union_find_t
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
typedef mln_value(I) value;
// in:
@@ -56,28 +56,21 @@
// aux:
std::vector<point> S;
- // was: I data;
- mln_ch_value(I, bool) isproc;
+ mln_ch_value(I, bool) deja_vu;
mln_ch_value(I, point) parent;
union_find_t(const I& f, const I& g, const N& nbh)
: f(f), g(g), nbh(nbh)
{
- f.name_it("f");
- g.name_it("g");
initialize(o, f);
- o.name_it("o");
initialize(parent, f);
- parent.name_it("parent");
- initialize(isproc, f);
- isproc.name_it("isproc");
- // was: initialize(data, f);
+ initialize(deja_vu, f);
// init
- level::fill(isproc, false);
+ level::fill(deja_vu, false);
S = histo_reverse_sort(g);
- level::paste(f, o); // new: replace make_set(p) { data(p) = f(p) }
+ level::paste(f, o); // Replace: for all p, make_set(p) { data(p) = f(p) }
// first pass
@@ -90,11 +83,11 @@
for_all(n)
{
if (f.has(n))
- mln_invariant(isproc(n) == is_proc(n, p));
- if (f.has(n) and isproc(n))
+ mln_invariant(deja_vu(n) == is_proc(n, p));
+ if (f.has(n) && deja_vu(n))
do_union(n, p);
}
- isproc(p) = true;
+ deja_vu(p) = true;
}
// second pass
@@ -109,13 +102,12 @@
o(p) = o(parent(p));
}
- print_counts();
-
}
bool is_proc(const point& n, const point& p) const
{
- return g(n) > g(p) or (g(n) == g(p) and n < p);
+ return g(n) > g(p) or (g(n) == g(p) &&
+ util::ord_strict(n, p));
}
void make_set(const point& p)
Index: milena/sandbox/geraud/Rd/parallel.hh
--- milena/sandbox/geraud/Rd/parallel.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/parallel.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -45,21 +45,14 @@
I parallel(const I& f, const I& g, const N& nbh,
bool test = true)
{
-// if (test)
-// mln_precondition(f <= g);
-
- f.name_it("f");
- g.name_it("g");
+ if (test)
+ mln_precondition(f <= g);
I o_(f.domain());
- o_.name_it("o_");
mln_piter(I) p(f.domain());
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
bool stability;
do
@@ -77,9 +70,8 @@
}
while (not stability);
- print_counts();
-
- // mln_postcondition(o <= g);
+ if (test)
+ mln_postcondition(o <= g);
return o;
}
Index: milena/sandbox/geraud/Rd/sequential.cc
--- milena/sandbox/geraud/Rd/sequential.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/sequential.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/debug/println.hh>
#include <mln/io/pgm/load.hh>
@@ -11,7 +11,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
- << "reconstruction by dilation (sequential version; may 2007)" << std::endl
+ << "reconstruction by dilation (sequential version; sep 2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -27,25 +27,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- f.name_it("main.f");
-
- I g = io::pgm::load<int_u8>(argv[2]);
- g.name_it("main.g");
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
if (not (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::sequential(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::sequential(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/utils.hh
--- milena/sandbox/geraud/Rd/utils.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/utils.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -31,9 +31,11 @@
# include <vector>
# include <mln/core/concept/image.hh>
-# include <mln/core/clone.hh>
+# include <mln/core/routine/clone.hh>
-# include <mln/level/fill.hh>
+# include <mln/util/ord.hh>
+
+# include <mln/level/fill_with_value.hh>
# include <mln/level/paste.hh>
# include <mln/level/compare.hh>
@@ -59,7 +61,7 @@
template <typename I>
I minimun(const I& ima1, const I& ima2)
{
- mln_precondition(ima1.has_data() and ima2.has_data());
+ mln_precondition(ima1.has_data() && ima2.has_data());
mln_precondition(ima1.domain() == ima2.domain());
I out(ima1.domain());
mln_piter(I) p(ima1.domain());
@@ -75,7 +77,7 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and ima(n) > v)
+ if (ima.has(n) && ima(n) > v)
v = ima(n);
return v;
}
@@ -87,7 +89,9 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and n > p and ima(n) > v)
+ if (ima.has(n) &&
+ util::ord_strict(p.to_site(), n.to_site()) &&
+ ima(n) > v)
v = ima(n);
return v;
}
@@ -98,7 +102,9 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and n < p and ima(n) > v)
+ if (ima.has(n) &&
+ util::ord_strict(n.to_site(), p.to_site()) &&
+ ima(n) > v)
v = ima(n);
return v;
}
@@ -116,7 +122,7 @@
// template <typename I>
-// std::vector<mln_point(I)> histo_sort(const I& ima)
+// std::vector<mln_site(I)> histo_sort(const I& ima)
// {
// std::vector<unsigned> h = compute_histo(ima);
// // preparing output data
@@ -124,9 +130,9 @@
// loc[0] = 0;
// for (int l = 1; l < 256; ++l)
// loc[l] = loc[l-1] + h[l-1];
-// std::vector<mln_point(I)> vec(ima.points().npoints());
+// std::vector<mln_site(I)> vec(ima.nsites());
// // storing output data
-// mln_piter(I) p(ima.points());
+// mln_piter(I) p(ima.domain());
// for_all(p)
// vec[loc[ima(p)]++] = p;
// return vec;
@@ -134,7 +140,7 @@
template <typename I>
- std::vector<mln_point(I)> histo_reverse_sort(const I& ima)
+ std::vector<mln_site(I)> histo_reverse_sort(const I& ima)
{
std::vector<unsigned> h = compute_histo(ima);
// preparing output data
@@ -142,7 +148,7 @@
loc[255] = 0;
for (int l = 254; l >= 0; --l)
loc[l] = loc[l+1] + h[l+1];
- std::vector<mln_point(I)> vec(ima.domain().npoints());
+ std::vector<mln_site(I)> vec(ima.nsites());
// storing output data
mln_piter(I) p(ima.domain());
for_all(p)
@@ -155,7 +161,7 @@
template <typename I, typename N>
struct regional_maxima_t
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
typedef mln_ch_value(I, bool) image_bool;
typedef mln_ch_value(I, point) image_point;
@@ -168,26 +174,21 @@
// aux:
std::vector<point> S;
- image_bool is_proc;
+ image_bool deja_vu;
image_bool attr;
image_point parent;
regional_maxima_t(const I& f, const N& nbh)
: f(f), nbh(nbh)
{
- f.name_it("rm.f");
initialize(o, f);
- o.name_it("rm.o");
initialize(parent, f);
- parent.name_it("rm.parent");
initialize(attr, f);
- attr.name_it("rm.attr");
- initialize(is_proc, f);
- is_proc.name_it("rm.is_proc");
+ initialize(deja_vu, f);
// init
- level::fill(is_proc, false);
+ level::fill_with_value(deja_vu, false);
S = histo_reverse_sort(f);
// first pass
@@ -199,14 +200,14 @@
make_set(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (f.has(n) and is_proc(n))
+ if (f.has(n) && deja_vu(n))
{
if (f(n) == f(p))
do_union(n, p);
else // f(n) > f(p)
attr(p) = false;
}
- is_proc(p) = true;
+ deja_vu(p) = true;
}
// second pass
@@ -242,7 +243,7 @@
if (r != p)
{
parent(r) = p;
- attr(p) = attr(p) and attr(r);
+ attr(p) = attr(p) && attr(r);
}
}
Index: milena/sandbox/geraud/Rd/hybrid.cc
--- milena/sandbox/geraud/Rd/hybrid.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/hybrid.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -14,7 +14,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
- << "reconstruction by dilation (hybrid version; may 2007)" << std::endl
+ << "reconstruction by dilation (hybrid version; sep 2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -30,22 +30,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
if (not (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::hybrid(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::hybrid(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/queue_based.cc
--- milena/sandbox/geraud/Rd/queue_based.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/queue_based.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -12,7 +12,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
- << "reconstruction by dilation (queue_based version; may 2007)" << std::endl
+ << "reconstruction by dilation (queue_based version; sep 2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -28,22 +28,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::queue_based(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::queue_based(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/min.cc
--- milena/sandbox/geraud/Rd/min.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/min.cc (working copy)
@@ -1,4 +1,4 @@
-#include <mln/core/image2d.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
@@ -7,7 +7,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " 1.pgm 2.pgm out.pgm" << std::endl
- << "(2008 Feb)" << std::endl;
+ << "(sep 2008)" << std::endl;
exit(1);
}
Index: milena/sandbox/geraud/Rd/sequential.hh
--- milena/sandbox/geraud/Rd/sequential.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/sequential.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -45,17 +45,10 @@
{
mln_precondition(f <= g);
- f.name_it("f");
- g.name_it("g");
-
I o_(f.domain());
- o_.name_it("o_");
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
bool stability;
do
@@ -80,8 +73,6 @@
}
while (not stability);
- print_counts();
-
mln_postcondition(o <= g);
return o;
}
Index: milena/sandbox/geraud/Rd/union_find.cc
--- milena/sandbox/geraud/Rd/union_find.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/union_find.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -13,7 +13,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
- << "reconstruction by dilation (union_find version; may 2007)" << std::endl
+ << "reconstruction by dilation (union_find version; sep 2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -29,22 +29,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::union_find(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::union_find(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
1
0
2439: Delegate pretty-printing of iterators on faces to mln::topo::face.
by Roland Levillain 30 Sep '08
by Roland Levillain 30 Sep '08
30 Sep '08
* mln/topo/internal/complex_iter_base.hh (operator<<): Here.
---
milena/ChangeLog | 6 ++++++
milena/mln/topo/internal/complex_iter_base.hh | 7 ++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a376900..d820e59 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Delegate pretty-printing of iterators on faces to mln::topo::face.
+
+ * mln/topo/internal/complex_iter_base.hh (operator<<): Here.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Add accesses to adjacent faces to mln::topo::face<D>.
* mln/topo/face.hh
diff --git a/milena/mln/topo/internal/complex_iter_base.hh b/milena/mln/topo/internal/complex_iter_base.hh
index 8e20801..dc479e2 100644
--- a/milena/mln/topo/internal/complex_iter_base.hh
+++ b/milena/mln/topo/internal/complex_iter_base.hh
@@ -97,10 +97,7 @@ namespace mln
};
- /* 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. */
+ /// Print an mln::topo::internal::complex_iter_base.
template <typename F, typename E>
inline
std::ostream&
@@ -194,7 +191,7 @@ namespace mln
This is a general remark that applies to all iterators of
Milena. */
F f = p;
- return ostr << "(dim = " << f.n() << ", id = " << f.face_id() << ')';
+ return ostr << f;
}
# endif // ! MLN_INCLUDE_ONLY
--
1.6.0.1
1
0
30 Sep '08
* mln/topo/face.hh
(mln::topo::face<D>::lower_dim_adj_faces)
(mln::topo::face<D>::higher_dim_adj_faces):
New.
(mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
(mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
New classes.
* mln/topo/face_data.hh
(mln::topo::internal::lower_dim_faces_data_mixin<N, D>): Allow
mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D> to
access to private data.
(mln::topo::internal::higher_dim_faces_data_mixin<N, D>): Allow
mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D> to
access to private data.
* tests/topo/complex.cc: Exercise accesses to adjacent faces.
---
milena/ChangeLog | 20 +++++++
milena/mln/topo/face.hh | 121 ++++++++++++++++++++++++++++++++++++++++++
milena/mln/topo/face_data.hh | 9 +++
milena/tests/topo/complex.cc | 25 +++++++++
4 files changed, 175 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 42ea6ad..a376900 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,25 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Add accesses to adjacent faces to mln::topo::face<D>.
+
+ * mln/topo/face.hh
+ (mln::topo::face<D>::lower_dim_adj_faces)
+ (mln::topo::face<D>::higher_dim_adj_faces):
+ New.
+ (mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
+ (mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
+ New classes.
+ * mln/topo/face_data.hh
+ (mln::topo::internal::lower_dim_faces_data_mixin<N, D>): Allow
+ mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D> to
+ access to private data.
+ (mln::topo::internal::higher_dim_faces_data_mixin<N, D>): Allow
+ mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D> to
+ access to private data.
+ * tests/topo/complex.cc: Exercise accesses to adjacent faces.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
* tests/topo/complex.cc: Fix diagram in documentation.
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 0d32c33..c485697 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -96,6 +96,13 @@ namespace mln
/// Return the mln::topo::face_data pointed by this handle.
template <unsigned N>
face_data<N, D>& data() const;
+
+ // FIXME: To be overhauled.
+ // FIXME: Why no `const' here?
+ /// Return an array of face handles pointing to adjacent (n-1)-faces.
+ std::vector< face<D> > lower_dim_adj_faces();
+ /// Return an array of face handles pointing to adjacent (n+1)-faces.
+ std::vector< face<D> > higher_dim_adj_faces();
/// \}
private:
@@ -251,6 +258,120 @@ namespace mln
}
+ // FIXME: This is way too complicated.
+ namespace internal
+ {
+ template <unsigned N, unsigned D>
+ struct lower_dim_adj_faces_if_dim_matches_
+ {
+ std::vector< face<D> > operator()(face<D>& face)
+ {
+ metal::bool_< (N <= D) >::check();
+ metal::bool_< (N > 1) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< n_face<N - 1, D> > lower_dim_faces =
+ data.lower_dim_faces_;
+ std::vector< topo::face<D> > result;
+ for (typename std::vector< n_face<N - 1, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+ };
+
+ template <unsigned D>
+ struct lower_dim_adj_faces_if_dim_matches_<1, D>
+ {
+ std::vector< face<D> > operator()(face<D>& face)
+ {
+ /// If we reached this function, then the dimension of FACE
+ /// has to be 1.
+ mln_precondition(face.n() == 1);
+ face_data<1, D>& data = face.template data<1>();
+ std::vector< n_face<0, D> > lower_dim_faces = data.lower_dim_faces_;
+ std::vector< topo::face<D> > result;
+ for (typename std::vector< n_face<0, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ };
+
+ template <unsigned N, unsigned D>
+ struct higher_dim_adj_faces_if_dim_matches_
+ {
+ std::vector< face<D> > operator()(face<D>& face)
+ {
+ metal::bool_< (N < D) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< n_face<N + 1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::face<D> > result;
+ for (typename std::vector< n_face<N + 1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return
+ internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+ };
+
+ template <unsigned D>
+ struct higher_dim_adj_faces_if_dim_matches_<0, D>
+ {
+ std::vector< face<D> > operator()(face<D>& face)
+ {
+ /// If we reached this function, then the dimension of face
+ /// has to be D - 1.
+ mln_precondition(face.n() == 0);
+ face_data<0, D>& data = face.template data<0>();
+ std::vector< n_face<1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::face<D> > result;
+ for (typename std::vector< n_face<1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ };
+ }
+
+ template <unsigned D>
+ inline
+ std::vector< face<D> >
+ face<D>::lower_dim_adj_faces()
+ {
+ // FIXME: Warning: might prevent any attempt to build a complex<0>.
+ metal::bool_< D != 0 >::check();
+
+ mln_precondition(n_ > 0);
+ return internal::lower_dim_adj_faces_if_dim_matches_<D, D>()(*this);
+ }
+
+ template <unsigned D>
+ inline
+ std::vector< face<D> >
+ face<D>::higher_dim_adj_faces()
+ {
+ // FIXME: Warning: might prevent any attempt to build a complex<0>.
+ metal::bool_< D != 0 >::check();
+
+ mln_precondition(n_ < D);
+ return internal::higher_dim_adj_faces_if_dim_matches_<D - 1, D>()(*this);
+ }
+
+
template <unsigned D>
inline
bool
diff --git a/milena/mln/topo/face_data.hh b/milena/mln/topo/face_data.hh
index 7c94ddd..28d425e 100644
--- a/milena/mln/topo/face_data.hh
+++ b/milena/mln/topo/face_data.hh
@@ -51,6 +51,11 @@ namespace mln
{
template <unsigned N, unsigned D> struct lower_dim_faces_set_mixin;
template <unsigned N, unsigned D> struct higher_dim_faces_set_mixin;
+
+ template <unsigned N, unsigned D>
+ struct lower_dim_adj_faces_if_dim_matches_;
+ template <unsigned N, unsigned D>
+ struct higher_dim_adj_faces_if_dim_matches_;
}
// Forward declarations (internal).
@@ -109,6 +114,8 @@ namespace mln
void connect_lower_dim_face (const n_face<N - 1, D>& f);
private:
friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
+ friend class mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>;
+ // FIXME: Rename as lower_dim_adj_faces_?
std::vector< n_face<N - 1, D> > lower_dim_faces_;
};
@@ -119,6 +126,8 @@ namespace mln
void connect_higher_dim_face(const n_face<N + 1, D>& f);
private:
friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
+ friend class mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>;
+ // FIXME: Rename as higher_dim_adj_faces_?
std::vector< n_face<N + 1, D> > higher_dim_faces_;
};
/// \}
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index d4f824a..349921c 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -28,6 +28,8 @@
/// \file tests/topo/complex.cc
/// \brief Test of mln::complex.
+#include <algorithm>
+#include <iterator>
#include <iostream>
#include <mln/topo/complex.hh>
@@ -114,6 +116,8 @@ int main()
// Get the face data from (``static'') face handle E0.
const topo::face_data<1, D>& face1 = e0.data();
+ /* FIXME: Rename AF (everywhere) as `any-face handles' have been
+ renamed to `face'. */
// Any-face handle.
topo::face<D> af(e0);
// Get the face data from (``dynamic'') face handle AF.
@@ -121,6 +125,27 @@ int main()
mln_assertion(&face1 == &face2);
+ /*-----------------.
+ | Adjacent faces. |
+ `-----------------*/
+
+ // Adjacent lower-dimension faces of AF.
+ std::vector< topo::face<D> > af_lower_dim_adj_faces =
+ af.lower_dim_adj_faces();
+ std::cout << "lower-dimension faces adjacent to " << af << ":" << std::endl;
+ std::copy (af_lower_dim_adj_faces.begin(), af_lower_dim_adj_faces.end(),
+ std::ostream_iterator< topo::face<D> > (std::cout, "\n"));
+ std::cout << std::endl;
+
+ // Adjacent higher-dimension faces of AF.
+ std::vector< topo::face<D> > af_higher_dim_adj_faces =
+ af.higher_dim_adj_faces();
+ std::cout << "higher-dimension faces adjacent to " << af << ":" << std::endl;
+ std::copy (af_higher_dim_adj_faces.begin(), af_higher_dim_adj_faces.end(),
+ std::ostream_iterator< topo::face<D> > (std::cout, "\n"));
+ std::cout << std::endl;
+
+
/*------------.
| Iteration. |
`------------*/
--
1.6.0.1
1
0
30 Sep '08
---
milena/ChangeLog | 4 ++++
milena/tests/topo/complex.cc | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f912670..42ea6ad 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+ * tests/topo/complex.cc: Fix diagram in documentation.
+
+2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Add pretty-printing operators for face handles.
* mln/topo/face.hh (operator<<(std::ostream&, const face<D>))
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 848b139..d4f824a 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -52,9 +52,9 @@ int main()
v0 e3 v3
o-----------o v0----e3----v3
/ \ ,-----. / / \ | /
- / . \ \ t2/ / / \ t2 /
+ / . \ \ t1/ / / \ t1 /
e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
- / /t1 \ \ ' / / t1 \ /
+ / /t0 \ \ ' / / t0 \ /
/ `-----' \ / / | \ /
o-----------o v1----e2----v2
v1 e2 v2
--
1.6.0.1
1
0