* mln/util/multi_site.hh: New.
---
milena/ChangeLog | 6 ++
milena/mln/util/multi_site.hh | 117 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/util/multi_site.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4cd9a13..36dd95d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a multiple-site type.
+
+ * mln/util/multi_site.hh: New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add more services to mln::topo::n_faces_set.
* mln/topo/n_faces_set.hh
diff --git a/milena/mln/util/multi_site.hh b/milena/mln/util/multi_site.hh
new file mode 100644
index 0000000..b7bedae
--- /dev/null
+++ b/milena/mln/util/multi_site.hh
@@ -0,0 +1,117 @@
+// 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_UTIL_MULTI_SITE_HH
+# define MLN_UTIL_MULTI_SITE_HH
+
+/// \file mln/util/multi_site.hh
+/// \brief Definition of a multiple-site type.
+
+# include <cstddef>
+
+# include <vector>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ template <typename P>
+ struct multi_site : public mln::Object< multi_site<P> >
+ {
+ // The type of a single site, called a location.
+ typedef P location;
+ /* FIXME: We should not need to define this typedef
+ (see. mln::internal::image_base's site `coord' typedef). */
+ typedef mln_coord(P) coord;
+
+ typedef std::vector<P> container;
+ typedef typename container::size_type size_type;
+ typedef typename container::reference reference;
+ typedef typename container::const_reference const_reference;
+
+ /// Interface similar to std::vector.
+ /// \{
+ void push_back(const P& p);
+ void reserve(size_type n);
+ size_type size() const;
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+ /// \}
+
+ container sites;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ void
+ multi_site<P>::push_back(const P& p)
+ {
+ sites.push_back(p);
+ }
+
+ template <typename P>
+ void
+ multi_site<P>::reserve(size_type n)
+ {
+ sites.reserve(n);
+ }
+
+ template <typename P>
+ typename multi_site<P>::size_type
+ multi_site<P>::size() const
+ {
+ return sites.size();
+ }
+
+ template <typename P>
+ typename multi_site<P>::reference
+ multi_site<P>::operator[](size_type n)
+ {
+ return sites[n];
+ }
+
+ template <typename P>
+ typename multi_site<P>::const_reference
+ multi_site<P>::operator[](size_type n) const
+ {
+ return sites[n];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of mln::util
+
+} // end of mln
+
+
+#endif // ! MLN_UTIL_MULTI_SITE_HH
--
1.6.0.1
* mln/topo/n_face.hh
(mln::topo::n_face<N, D>::lower_dim_adj_faces)
(mln::topo::n_face<N, D>::higher_dim_adj_faces):
New methods.
(mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
New function.
* mln/topo/face_data.hh
(mln::topo::internal::lower_dim_faces_data_mixin): Make
mln::topo::n_face<N, D>::lower_dim_adj_faces a friend of this
class.
(mln::topo::internal::higher_dim_faces_data_mixin): Make
mln::topo::n_face<N, D>::higher_dim_adj_faces a friend of this
class.
---
milena/ChangeLog | 18 +++++++++
milena/mln/topo/face_data.hh | 10 ++++-
milena/mln/topo/n_face.hh | 79 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7bda463..83ba017 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add more services to mln::topo::n_face.
+
+ * mln/topo/n_face.hh
+ (mln::topo::n_face<N, D>::lower_dim_adj_faces)
+ (mln::topo::n_face<N, D>::higher_dim_adj_faces):
+ New methods.
+ (mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
+ New function.
+ * mln/topo/face_data.hh
+ (mln::topo::internal::lower_dim_faces_data_mixin): Make
+ mln::topo::n_face<N, D>::lower_dim_adj_faces a friend of this
+ class.
+ (mln::topo::internal::higher_dim_faces_data_mixin): Make
+ mln::topo::n_face<N, D>::higher_dim_adj_faces a friend of this
+ class.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Manipulate complexes as plain objects (instead of pointers) in
face handles.
diff --git a/milena/mln/topo/face_data.hh b/milena/mln/topo/face_data.hh
index 28d425e..27e78cd 100644
--- a/milena/mln/topo/face_data.hh
+++ b/milena/mln/topo/face_data.hh
@@ -115,7 +115,10 @@ namespace mln
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_?
+ friend std::vector< n_face<N - 1, D> >
+ mln::topo::n_face<N, D>::lower_dim_adj_faces() const;
+
+ // FIXME: Rename as lower_dim_adj_faces_ (as well as related members).
std::vector< n_face<N - 1, D> > lower_dim_faces_;
};
@@ -127,7 +130,10 @@ namespace mln
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_?
+ friend std::vector< n_face<N + 1, D> >
+ mln::topo::n_face<N, D>::higher_dim_adj_faces() const;
+
+ // FIXME: Rename as higher_dim_adj_faces_ (as well as related members).
std::vector< n_face<N + 1, D> > higher_dim_faces_;
};
/// \}
diff --git a/milena/mln/topo/n_face.hh b/milena/mln/topo/n_face.hh
index 534df69..68a9512 100644
--- a/milena/mln/topo/n_face.hh
+++ b/milena/mln/topo/n_face.hh
@@ -32,6 +32,7 @@
/// \brief n-face of a complex.
#include <limits>
+#include <vector>
#include <mln/core/contract.hh>
@@ -93,6 +94,13 @@ namespace mln
/// Return the mln::topo::face_data pointed by this handle.
face_data<N, D>& data() const;
+
+ /* FIXME: We should not provide lower_dim_adj_faces() when N ==
+ 0 nor higher_dim_adj_faces() when N == D. */
+ /// \Return an array of face handles pointing to adjacent (n-1)-faces.
+ std::vector< n_face<N - 1, D> > lower_dim_adj_faces() const;
+ /// Return an array of face handles pointing to adjacent (n+1)-faces.
+ std::vector< n_face<N + 1, D> > higher_dim_adj_faces() const;
/// \}
private:
@@ -147,6 +155,31 @@ namespace mln
operator<<(std::ostream& ostr, const n_face<N, D>& f);
+ /// \brief Helpers
+ /// \{
+
+ /** \brief Return the 1-face (edge) linking the 0-faces (vertices)
+ \a f1 and \a f2. If there is no 1-face between \a f1 and \a
+ f2, return an invalid 1-face.
+
+ \pre \a f1 and \a f2 must belong to the same complex.
+
+ Note: this routine assumes the complex is not degenerated, i.e,
+ \li it does not check that \a f1 and \a f2 are the only
+ 0-faces adjacent to an hypothetical 1-face; it just checks
+ that \a f1 and \a f2 <em>share</em> a common 1-face;
+
+ \li if there are several ajacent 1-faces shared by \a f1 and
+ \a f2 (if the complex is ill-formed), there is no
+ guarantee on the returned 1-face (the current
+ implementation return the first 1-face found, but client
+ code should not rely on this implementation-defined
+ behavior). */
+ template <unsigned D>
+ n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0, D>& f2);
+ /// \}
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -250,6 +283,26 @@ namespace mln
return cplx_.template face_data_<N>(face_id_);
}
+ template <unsigned N, unsigned D>
+ inline
+ std::vector< n_face<N - 1, D> >
+ n_face<N, D>::lower_dim_adj_faces() const
+ {
+ mln_precondition(N > 0);
+ mln_precondition(is_valid());
+ return cplx_.template face_data_<N>(face_id_).lower_dim_faces_;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ std::vector< n_face<N + 1, D> >
+ n_face<N, D>::higher_dim_adj_faces() const
+ {
+ mln_precondition(N <= D);
+ mln_precondition(is_valid());
+ return cplx_.template face_data_<N>(face_id_).higher_dim_faces_;
+ }
+
template <unsigned N, unsigned D>
inline
@@ -300,6 +353,32 @@ namespace mln
<< ", id = " << f.face_id() << ')';
}
+ /*----------.
+ | Helpers. |
+ `----------*/
+
+ template <unsigned D>
+ n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0, D>& f2)
+ {
+ typedef std::vector< n_face<0, D> > n0_faces_t;
+ typedef std::vector< n_face<1, D> > n1_faces_t;
+
+ n1_faces_t f1_adj_edges = f1.higher_dim_adj_faces();
+ for (typename n1_faces_t::const_iterator e = f1_adj_edges.begin();
+ e != f1_adj_edges.end(); ++e)
+ {
+ n0_faces_t e_adj_vertices = e->lower_dim_adj_faces();
+ for (typename n0_faces_t::const_iterator w = e_adj_vertices.begin();
+ w != e_adj_vertices.end(); ++w)
+ if (*w == f2)
+ // E is the edge linking F1 and F2.
+ return *e;
+ }
+
+ // If no shared edge was found, retun an empty (invalid) 1-face.
+ return n_face<1, D>();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
--
1.6.0.1
---
milena/ChangeLog | 4 ++++
milena/mln/topo/complex.hh | 14 ++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 948ad38..f67a0d3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ * mln/topo/complex.hh (mln::complex<D>::addr): New accessor.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Have mln::point be more generic.
* mln/core/point.hh: Fix a name in documentation.
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index f186f4f..f4e1499 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -153,6 +153,12 @@ namespace mln
void print_faces(std::ostream& ostr) const;
/// \}
+ /// \brief Get the address of the data of this complex.
+ ///
+ /// This address is a concise and useful information to print
+ /// and track the actual content of this complex.
+ const void* addr() const;
+
private:
/// The actual data of the complex.
util::tracked_ptr< internal::complex_data<D> > data_;
@@ -681,6 +687,14 @@ namespace mln
data_->internal::faces_set_mixin<N, D>::print(ostr);
}
+ template <unsigned D>
+ inline
+ const void*
+ complex<D>::addr() const
+ {
+ return data_.ptr_;
+ }
+
namespace internal
{
--
1.6.0.1
* mln/core/alias/point3df.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/core/alias/point3df.hh | 215 +++++++++++++++++++++++++++++++++++++
2 files changed, 221 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/alias/point3df.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3f4208e..860f449 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a floating-point 3-dimensional point type.
+
+ * mln/core/alias/point3df.hh: New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a floating-point coordinate type.
* mln/core/def/coordf.hh: New.
diff --git a/milena/mln/core/alias/point3df.hh b/milena/mln/core/alias/point3df.hh
new file mode 100644
index 0000000..444db8e
--- /dev/null
+++ b/milena/mln/core/alias/point3df.hh
@@ -0,0 +1,215 @@
+// 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.
+
+#ifndef MLN_CORE_ALIAS_POINT3DF_HH
+# define MLN_CORE_ALIAS_POINT3DF_HH
+
+/*! \file mln/core/alias/point3df.hh
+ *
+ * \brief Definition of the mln::point3df alias and of its construction
+ * routine.
+ */
+
+/* FIXME: Factor with mln/core/alias/point3d.hh (these two files are
+ almost identical). */
+
+# include <mln/core/point.hh>
+# include <mln/core/def/coordf.hh>
+// For site_const_impl and site_mutable_impl:
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/core/internal/force_exact.hh>
+
+namespace mln
+{
+
+ /*! \brief Type alias for a point defined on the 3D square grid with
+ * floating-point coordinates.
+ */
+ typedef point<grid::cube, def::coordf> point3df;
+
+ namespace internal
+ {
+
+ // Specialization.
+
+ template <typename C, typename E>
+ struct subject_impl< const point<grid::cube, C>, E >
+ {
+ typedef C coordf;
+ enum { dim = 3 };
+
+ typedef const C& row_t;
+ const C& row() const;
+
+ typedef const C& col_t;
+ const C& col() const;
+
+ typedef const C& sli_t;
+ const C& sli() const;
+
+ const C& operator[](unsigned i) const;
+ const C& last_coord() const;
+ private:
+ const E& exact_() const;
+ };
+
+
+ // Specialization for point<M,C>.
+
+ template <typename C, typename E>
+ struct subject_impl< point<grid::cube, C>, E > :
+ subject_impl< const point<grid::cube, C>, E >
+ {
+ private:
+ typedef subject_impl< const point<grid::cube, C>, E > super_;
+ E& exact_();
+ public:
+
+ using super_::row;
+ C& row();
+
+ using super_::col;
+ C& col();
+
+ using super_::sli;
+ C& sli();
+
+ using super_::operator[];
+ C& operator[](unsigned i);
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::row() const
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::col() const
+ {
+ return exact_().get_subject().col();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::sli() const
+ {
+ return exact_().get_subject().sli();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::operator[](unsigned i) const
+ {
+ mln_precondition(i < 3);
+ return exact_().get_subject()[i];
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::last_coord() const
+ {
+ return this->col();
+ }
+
+ template <typename C, typename E>
+ inline
+ const E&
+ subject_impl< const point<grid::cube, C>, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::row()
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::col()
+ {
+ return exact_().get_subject().col();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::sli()
+ {
+ return exact_().get_subject().sli();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::operator[](unsigned i)
+ {
+ mln_precondition(i < 3);
+ return exact_().get_subject()[i];
+ }
+
+ template <typename C, typename E>
+ inline
+ E&
+ subject_impl< point<grid::cube, C>, E >::exact_()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+
+} // end of namespace mln
+
+// FIXME: File mln/core/alias/dpoint3df does not exist yet.
+# if 0
+# include <mln/core/alias/dpoint3df.hh>
+# endif
+
+#endif // ! MLN_CORE_ALIAS_POINT3DF_HH
--
1.6.0.1
* mln/core/def/coordf.hh: New.
---
milena/ChangeLog | 6 +++++
milena/mln/core/def/coordf.hh | 49 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/def/coordf.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4be6dc1..3f4208e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Add a floating-point coordinate type.
+
+ * mln/core/def/coordf.hh: New.
+
2008-10-15 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make morpho meyer_wst practicable.
diff --git a/milena/mln/core/def/coordf.hh b/milena/mln/core/def/coordf.hh
new file mode 100644
index 0000000..f071af6
--- /dev/null
+++ b/milena/mln/core/def/coordf.hh
@@ -0,0 +1,49 @@
+// 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_DEF_COORDF_HH
+# define MLN_CORE_DEF_COORDF_HH
+
+/// \file mln/core/def/coordf.hh
+/// \brief Definition of the floating coordinate type.
+
+namespace mln
+{
+
+ namespace def
+ {
+
+ /// Definition of the floating coordinate type.
+ /* FIXME: We probably want something smarter than bare `float',
+ i.e., robust to comparisons, etc. */
+ typedef float coordf;
+
+ } // end of namespace mln::def
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_DEF_COORDF_HH
--
1.6.0.1