https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add pset and pvec point sets.
* tests/sort_points.cc: New.
* tests/pset.cc: New.
* tests/histo.cc: Update.
* mln/histo/sort.hh: Rename as...
* mln/level/sort_points.hh: ...this new file.
(sort_points): New overload.
* mln/histo/data.hh (vec): Rename as...
(vect): ...this.
* mln/core/dpoints_piter.hh: Update.
* mln/core/pvec.hh: New.
* mln/core/pset.hh: New.
* mln/core/internal/set_of.hh: Update.
* mln/accu/histo.hh: Update.
* mln/accu/bbox.hh: New.
mln/accu/bbox.hh | 134 ++++++++++++++++++
mln/accu/histo.hh | 4
mln/core/dpoints_piter.hh | 2
mln/core/internal/set_of.hh | 6
mln/core/pset.hh | 162 ++++++++++++++++++++++
mln/core/pvec.hh | 323 ++++++++++++++++++++++++++++++++++++++++++++
mln/histo/data.hh | 4
mln/level/sort_points.hh | 158 +++++++++++++++++++++
tests/histo.cc | 6
tests/pset.cc | 59 ++++++++
tests/sort_points.cc | 56 +++++++
11 files changed, 901 insertions(+), 13 deletions(-)
Index: tests/sort_points.cc
--- tests/sort_points.cc (revision 0)
+++ tests/sort_points.cc (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/histo.cc
+ *
+ * \brief Tests on mln::accu::histo<S> and mln::histo::data<S>.
+ */
+
+#include <iterator>
+
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/level/sort_points.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d_b<int_u8> ima(3, 3);
+ debug::iota(ima);
+ std::vector<point2d> vec = level::sort_points(ima);
+
+ std::copy(vec.begin(), vec.end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+
+}
Index: tests/pset.cc
--- tests/pset.cc (revision 0)
+++ tests/pset.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/pset.cc
+ *
+ * \brief Tests on mln::pset.
+ */
+
+#include <iterator>
+
+#include <mln/core/point2d.hh>
+#include <mln/core/pset.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ pset<point2d> ps;
+ ps
+ .insert(make::point2d(6, 9))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(5, 1));
+ mln_assertion(ps.npoints() = 3);
+
+ std::cout << ps.bbox() << std::endl;
+
+ std::copy(ps.vect().begin(), ps.vect().end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+
+
+}
Index: tests/histo.cc
--- tests/histo.cc (revision 1037)
+++ tests/histo.cc (working copy)
@@ -38,7 +38,6 @@
#include <mln/debug/iota.hh>
#include <mln/accu/histo.hh>
#include <mln/histo/compute.hh>
-#include <mln/histo/sort.hh>
@@ -65,11 +64,6 @@
debug::iota(ima);
histo::data< value::set<int_u8> > h = histo::compute(ima);
std::cout << h << std::endl;
-
- std::vector<point2d> vec = histo::sort_points_decreasing(ima);
- std::copy(vec.begin(), vec.end(),
- std::ostream_iterator<point2d>(std::cout, " "));
- std::cout << std::endl;
}
}
Index: mln/histo/data.hh
--- mln/histo/data.hh (revision 1037)
+++ mln/histo/data.hh (working copy)
@@ -60,7 +60,7 @@
std::size_t operator()(const value& v) const;
std::size_t& operator()(const value& v);
- const std::vector<std::size_t>& vec() const;
+ const std::vector<std::size_t>& vect() const;
const S& vset() const;
std::size_t operator[](unsigned i) const;
@@ -124,7 +124,7 @@
template <typename S>
const std::vector<std::size_t>&
- data<S>::vec() const
+ data<S>::vect() const
{
return h_;
}
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh (revision 1037)
+++ mln/core/dpoints_piter.hh (working copy)
@@ -118,7 +118,7 @@
template <typename Dps, typename Pref>
dpoints_fwd_piter<D>::dpoints_fwd_piter(const Dps& dps,
const Generalized_Point<Pref>& p_ref)
- : dps_(exact(dps).vec()),
+ : dps_(exact(dps).vect()),
p_ref_(* internal::force_exact<Pref>(p_ref).pointer_())
{
invalidate();
Index: mln/core/pvec.hh
--- mln/core/pvec.hh (revision 0)
+++ mln/core/pvec.hh (revision 0)
@@ -0,0 +1,323 @@
+// Copyright (C) 2007 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_PVEC_HH
+# define MLN_CORE_PVEC_HH
+
+/*! \file mln/core/pvec.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/internal/fixme.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct pvec_fwd_piter_;
+ template <typename P> struct pvec_bkd_piter_;
+
+
+ /*! \brief Point set class based on std::vector.
+ *
+ * This is a multi-set of points.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints(). FIXME: Explain!
+ */
+ template <typename P>
+ class pvec : public Point_Set< pvec<P> >
+ {
+ public:
+
+ /// Point associated type.
+ typedef mln_point(P) point;
+
+ /// Point_Site associated type.
+ typedef P psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef pvec_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef internal::fixme bkd_piter;
+
+ /// Constructor.
+ pvec();
+
+ /// Constructor from a vector \p vect.
+ pvec(const std::vector<P>& vect);
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<point>& bbox() const;
+
+ /// Append a point \p p.
+ pvec<P>& append(const P& p);
+
+ /// Clear this set.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::vector<P> vect_;
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+
+ void update_bb_();
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+
+ /*! \brief Forward iterator on points of a pvec<P>.
+ *
+ */
+ template <typename P>
+ struct pvec_fwd_piter_
+ {
+ enum { dim = P::dim };
+
+ /// Point_Site associated type.
+ typedef P psite;
+
+ /// Point associated type.
+ typedef mln_point(P) point;
+
+ /// Dpoint associated type.
+ typedef mln_dpoint(P) dpoint;
+
+ /// Coordinate associated type.
+ typedef mln_coord(P) coord;
+
+ /// Coordinate associated type.
+ template <typename S>
+ pvec_fwd_piter_(const Point_Set<S>& s);
+
+ /// Give a hook to the point address.
+ const point* pointer_() const;
+
+ /// Read-only access to the \p i-th coordinate.
+ coord operator[](unsigned i) const;
+
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ /// Convert the iterator into a point.
+ operator P() const;
+
+ protected:
+ const std::vector<P>& vect_;
+ point p_;
+ };
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // pvec<P>
+
+
+ template <typename P>
+ pvec<P>::pvec()
+ {
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ pvec<P>::pvec(const std::vector<P>& vect)
+ : vect_(vect)
+ {
+ bb_needs_update_ = true;
+ }
+
+ template <typename P>
+ void
+ pvec<P>::update_bb_()
+ {
+ bb_.clear();
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ bb_.take(vect_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ bool
+ pvec<P>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] = p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ std::size_t
+ pvec<P>::npoints() const
+ {
+ return vect_.size();
+ }
+
+ template <typename P>
+ const box_<mln_point(P)>&
+ pvec<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ update_bb_();
+ return bb_.to_value();
+ }
+
+ template <typename P>
+ pvec<P>&
+ pvec<P>::append(const P& p)
+ {
+ vect_.push_back(p);
+ return *this;
+ }
+
+ template <typename P>
+ void
+ pvec<P>::clear()
+ {
+ vect_.clear();
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ const std::vector<P>&
+ pvec<P>::vect() const
+ {
+ return vect_;
+ }
+
+ template <typename P>
+ const P&
+ pvec<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+
+
+ // pvec_fwd_piter_<P>
+
+
+ template <typename P>
+ template <typename S>
+ pvec_fwd_piter_<P>::pvec_fwd_piter_(const Point_Set<S>& s)
+ : vect_(exact(s).vect())
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ const mln_point(P)*
+ pvec_fwd_piter_<P>::pointer_() const
+ {
+ return & p_;
+ }
+
+ template <typename P>
+ mln_coord(P)
+ pvec_fwd_piter_<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < dim);
+ mln_precondition(is_valid());
+ return p_[i];
+ }
+
+ template <typename P>
+ bool
+ pvec_fwd_piter_<P>::is_valid() const
+ {
+ return i < vect_.size();
+ }
+
+ template <typename P>
+ void
+ pvec_fwd_piter_<P>::invalidate()
+ {
+ i = vect_.size();
+ }
+
+ template <typename P>
+ void
+ pvec_fwd_piter_<P>::start()
+ {
+ i = 0;
+ }
+
+ template <typename P>
+ void
+ pvec_fwd_piter_<P>::next_()
+ {
+ ++i;
+ }
+
+ template <typename P>
+ pvec_fwd_piter_<P>::operator P() const
+ {
+ mln_precondition(is_valid());
+ return p_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PVEC_HH
Index: mln/core/pset.hh
--- mln/core/pset.hh (revision 0)
+++ mln/core/pset.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 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_PSET_HH
+# define MLN_CORE_PSET_HH
+
+/*! \file mln/core/pset.hh
+ *
+ * \brief Definition of a point set class based on std::set.
+ */
+
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/internal/set_of.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/pvec.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class based on std::set.
+ *
+ * This is a mathematical set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo Test if \p P being a Point_Site is ok.
+ */
+ template <typename P>
+ class pset : public Point_Set< pset<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+
+ /// Point associated type.
+ typedef mln_point(P) point;
+
+ /// Point_Site associated type.
+ typedef P psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef pvec_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef internal::fixme bkd_piter;
+
+ /// Constructor.
+ pset();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ pset<P>& insert(const P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<point>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ pset<P>::pset()
+ {
+ }
+
+ template <typename P>
+ bool
+ pset<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ std::size_t
+ pset<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ pset<P>&
+ pset<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+ template <typename P>
+ const P&
+ pset<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ void
+ pset<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ const box_<mln_point(P)>&
+ pset<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_value();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PSET_HH
Index: mln/core/internal/set_of.hh
--- mln/core/internal/set_of.hh (revision 1037)
+++ mln/core/internal/set_of.hh (working copy)
@@ -59,6 +59,8 @@
*
* The parameter \c E is the element type, which shall not be
* const-qualified.
+ *
+ * \todo Add a remove method.
*/
template <typename E>
class set_of_
@@ -123,7 +125,7 @@
*
* \return An array (std::vector) of elements.
*/
- const std::vector<E>& vec() const;
+ const std::vector<E>& vect() const;
protected:
@@ -245,7 +247,7 @@
template <typename E>
const std::vector<E>&
- set_of_<E>::vec() const
+ set_of_<E>::vect() const
{
if (needs_update_)
update_();
Index: mln/core/concept/point_iterator.hh
Index: mln/core/concept/point_site.hh
Index: mln/level/sort_points.hh
--- mln/level/sort_points.hh (revision 0)
+++ mln/level/sort_points.hh (revision 0)
@@ -0,0 +1,158 @@
+// Copyright (C) 2007 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_LEVEL_SORT_POINTS_HH
+# define MLN_LEVEL_SORT_POINTS_HH
+
+/*! \file mln/level/sort_points.hh
+ *
+ * \brief Sort_Points the contents of an image into another one.
+ */
+
+# include <vector>
+# include <utility>
+# include <algorithm>
+
+# include <mln/core/concept/image.hh>
+# include <mln/histo/compute.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ /*! Sort points the image \p input through a function \p f to set
+ * the \p output image.
+ *
+ * \param[in] input The input image.
+ *
+ * \pre \p input.has_data
+ */
+ template <typename I>
+ std::vector<mln_point(I)> sort_points(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ struct value_point_less_
+ {
+ const I& ima_;
+
+ value_point_less_(const I& ima)
+ : ima_(ima)
+ {
+ }
+
+ bool operator()(const mln_point(I)& lhs,
+ const mln_point(I)& rhs) const
+ {
+ return ima_(lhs) < ima_(rhs) || (ima_(lhs) = ima_(rhs)
+ && lhs < rhs);
+ }
+ };
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points(metal::false_, // general case
+ const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ std::vector<mln_point(I)> vec;
+ vec.reserve(input.npoints());
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ vec.push_back(p);
+
+ std::sort(vec.begin(), vec.end(),
+ value_point_less_<I>(input));
+ return vec;
+ }
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points(metal::true_, // low quantization
+ const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ typedef mln_vset(I) S;
+ const S& vset = input.values();
+ const unsigned n = vset.nvalues();
+
+ // h
+ histo::data<S> h = histo::compute(input);
+
+ // preparing output data
+ std::vector<unsigned> loc(vset.nvalues());
+ loc[0] = 0;
+ for (unsigned i = 1; i != n; ++i)
+ loc[i] = loc[i-1] + h[i-1];
+
+ /*
+ MEMO. Decreasing case is:
+ loc[n-1] = 0;
+ for (unsigned i = n - 2; i != 0; --i)
+ loc[i] = loc[i+1] + h[i+1];
+ */
+
+ // computing output data
+ std::vector<mln_point(I)> vec(input.npoints());
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ vec[loc[vset.index_of(input(p))]++] = p;
+
+ return vec;
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points(const Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ return impl::sort_points(mln_is_value_lowq(I)(), exact(input));
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_SORT_POINTS_HH
Index: mln/accu/histo.hh
--- mln/accu/histo.hh (revision 1037)
+++ mln/accu/histo.hh (working copy)
@@ -67,7 +67,7 @@
std::size_t nvalues() const;
std::size_t sum() const;
- const std::vector<std::size_t>& vec() const;
+ const std::vector<std::size_t>& vect() const;
const S& vset() const;
@@ -160,7 +160,7 @@
template <typename S>
const std::vector<std::size_t>&
- histo<S>::vec() const
+ histo<S>::vect() const
{
return h_;
}
Index: mln/accu/bbox.hh
--- mln/accu/bbox.hh (revision 0)
+++ mln/accu/bbox.hh (revision 0)
@@ -0,0 +1,134 @@
+// Copyright (C) 2007 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_ACCU_BBOX_HH
+# define MLN_ACCU_BBOX_HH
+
+/*! \file mln/accu/bbox.hh
+ *
+ * \brief Define an accumulator that computes a bbox.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+# include <mln/core/box.hh>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /*! Generic bbox accumulator class.
+ *
+ * The parameter \c P is the type of points.
+ */
+ template <typename P>
+ struct bbox : public Accumulator< bbox<P> >
+ {
+ typedef P value;
+
+ bbox();
+ void take(const P& p);
+ void init();
+
+ operator box_<P>() const;
+ const box_<P>& to_value() const;
+
+ bool is_valid() const;
+
+ protected:
+
+ bool is_valid_;
+ box_<P> b_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ bbox<P>::bbox()
+ {
+ init();
+ }
+
+ template <typename P>
+ void bbox<P>::take(const P& p)
+ {
+ if (! is_valid_)
+ {
+ b_.pmin() = p;
+ b_.pmax() = p;
+ is_valid_ = true;
+ return;
+ }
+ for (unsigned i = 0; i < P::dim; ++i)
+ if (p[i] < b_.pmin()[i])
+ b_.pmin()[i] = p[i];
+ else if (p[i] > b_.pmax()[i])
+ b_.pmax()[i] = p[i];
+ }
+
+ template <typename P>
+ void
+ bbox<P>::init()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ bbox<P>::operator box_<P>() const
+ {
+ mln_precondition(is_valid_);
+ return b_;
+ }
+
+ template <typename P>
+ const box_<P>&
+ bbox<P>::to_value() const
+ {
+ mln_precondition(is_valid_);
+ return b_;
+ }
+
+ template <typename P>
+ bool
+ bbox<P>::is_valid() const
+ {
+ return is_valid_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_BBOX_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add int_s, an histogram class, and distributed sort.
* tests/int_s8.cc: New.
* tests/int_u8.cc: Augment.
* mln/histo/sort.hh: New.
* mln/histo/data.hh: New.
* mln/histo/compute.hh: New.
* mln/accu/histo.hh: Fix doc.
* mln/accu/median.hh: Fix doc.
* mln/value/int_s8.hh: New.
* mln/value/int_u16.hh: New.
* mln/value/int_u8.hh: New.
* mln/value/int_s.hh: New.
* mln/value/int_u.hh (zero, one): New.
(encoding_): Move to...
* mln/value/internal/encoding.hh: ...this new file.
* tests/median.cc,
* tests/fast_median.cc,
* tests/main.cc,
* tests/hmedian.cc,
* tests/erosion.cc,
* tests/naive_median.cc,
* tests/vset.cc,
* tests/histo.cc,
* mln/io/save_pgm.hh,
* mln/io/load_pgm.hh: Update.
mln/accu/histo.hh | 2
mln/accu/median.hh | 2
mln/histo/compute.hh | 95 +++++++++++++++++++++++
mln/histo/data.hh | 149 +++++++++++++++++++++++++++++++++++++
mln/histo/sort.hh | 147 ++++++++++++++++++++++++++++++++++++
mln/io/load_pgm.hh | 2
mln/io/save_pgm.hh | 2
mln/value/int_s.hh | 163 +++++++++++++++++++++++++++++++++++++++++
mln/value/int_s8.hh | 55 +++++++++++++
mln/value/int_u.hh | 79 ++++++++++++-------
mln/value/int_u16.hh | 55 +++++++++++++
mln/value/int_u8.hh | 55 +++++++++++++
mln/value/internal/encoding.hh | 86 +++++++++++++++++++++
tests/erosion.cc | 2
tests/fast_median.cc | 2
tests/histo.cc | 26 ++++++
tests/hmedian.cc | 2
tests/int_s8.cc | 51 ++++++++++++
tests/int_u8.cc | 9 ++
tests/main.cc | 9 +-
tests/median.cc | 2
tests/naive_median.cc | 2
tests/vset.cc | 2
23 files changed, 951 insertions(+), 48 deletions(-)
Index: tests/median.cc
--- tests/median.cc (revision 1036)
+++ tests/median.cc (working copy)
@@ -36,7 +36,7 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/level/median.hh>
#include <mln/level/approx/median.hh>
Index: tests/int_s8.cc
--- tests/int_s8.cc (revision 0)
+++ tests/int_s8.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/int_s.cc
+ *
+ * \brief Tests on mln::value::int_s.
+ */
+
+#include <mln/value/int_s.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_s;
+
+ {
+ int_s<7> i = 3;
+ i = 2;
+ mln_assertion(i = 2);
+ mln_assertion(i != 3);
+
+ mln_assertion(-i = -2);
+ mln_assertion(-3 * i = -6);
+ }
+
+}
Index: tests/int_u8.cc
--- tests/int_u8.cc (revision 1036)
+++ tests/int_u8.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::value::int_u8.
*/
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
@@ -39,6 +39,7 @@
using namespace mln;
using value::int_u8;
+ {
int_u8 i = 3;
i = 2;
mln_assertion(i = 2);
@@ -47,3 +48,9 @@
mln_assertion(-i = -2);
mln_assertion(-3 * i = -6);
}
+
+ {
+ int_u8 i = 128;
+ std::cout << i + i << std::endl;
+ }
+}
Index: tests/fast_median.cc
--- tests/fast_median.cc (revision 1036)
+++ tests/fast_median.cc (working copy)
@@ -36,7 +36,7 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
#include <mln/level/fast_median.hh>
Index: tests/main.cc
--- tests/main.cc (revision 1036)
+++ tests/main.cc (working copy)
@@ -39,13 +39,12 @@
#include <mln/morpho/erosion.hh>
#include <mln/morpho/Rd.hh>
+#include <mln/value/int_u8.hh>
-typedef unsigned char int_u8;
-
-// static int_u8 cos_sin(const mln::point2d& p)
+// static value::int_u8 cos_sin(const mln::point2d& p)
// {
-// return (int_u8)(255 * std::cos(float(p.row())) * std::sin(float(p.col())));
+// return (value::int_u8)(255 * std::cos(float(p.row())) * std::sin(float(p.col())));
// }
@@ -54,7 +53,7 @@
using namespace mln;
const unsigned size = 1000;
- image2d_b<int_u8> f(size, size);
+ image2d_b<value::int_u8> f(size, size);
morpho::Rd(f, f, c8());
}
Index: tests/hmedian.cc
--- tests/hmedian.cc (revision 1036)
+++ tests/hmedian.cc (working copy)
@@ -36,7 +36,7 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/level/median.hh>
#include <mln/level/compare.hh>
Index: tests/erosion.cc
--- tests/erosion.cc (revision 1036)
+++ tests/erosion.cc (working copy)
@@ -36,7 +36,7 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/level/fill.hh>
#include <mln/morpho/erosion.hh>
Index: tests/naive_median.cc
--- tests/naive_median.cc (revision 1036)
+++ tests/naive_median.cc (working copy)
@@ -36,7 +36,7 @@
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/level/naive/median.hh>
Index: tests/vset.cc
--- tests/vset.cc (revision 1036)
+++ tests/vset.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::value::set_<T>.
*/
-#include <mln/value/int_u.hh>
+#include <mln/value/int_u8.hh>
#include <mln/value/set.hh>
Index: tests/histo.cc
--- tests/histo.cc (revision 1036)
+++ tests/histo.cc (working copy)
@@ -27,17 +27,27 @@
/*! \file tests/histo.cc
*
- * \brief Tests on mln::value::histo<S>.
+ * \brief Tests on mln::accu::histo<S> and mln::histo::data<S>.
*/
+#include <iterator>
+
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
#include <mln/accu/histo.hh>
+#include <mln/histo/compute.hh>
+#include <mln/histo/sort.hh>
int main()
{
using namespace mln;
+ using value::int_u8;
+ {
accu::histo< value::set<bool> > h;
for (unsigned i = 0; i < 5; ++i)
@@ -49,3 +59,17 @@
mln_assertion(h[0] * 10 + h[1] = 51);
mln_assertion(h(false) * 10 + h(true) = 51);
}
+
+ {
+ image2d_b<int_u8> ima(3, 3);
+ debug::iota(ima);
+ histo::data< value::set<int_u8> > h = histo::compute(ima);
+ std::cout << h << std::endl;
+
+ std::vector<point2d> vec = histo::sort_points_decreasing(ima);
+ std::copy(vec.begin(), vec.end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+ }
+
+}
Index: mln/histo/sort.hh
--- mln/histo/sort.hh (revision 0)
+++ mln/histo/sort.hh (revision 0)
@@ -0,0 +1,147 @@
+// Copyright (C) 2007 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_HISTO_SORT_HH
+# define MLN_HISTO_SORT_HH
+
+/*! \file mln/histo/sort.hh
+ *
+ * \brief Routine to sort an histogram.
+ */
+
+# include <vector>
+
+# include <mln/core/concept/image.hh>
+# include <mln/histo/compute.hh>
+
+
+namespace mln
+{
+
+ namespace histo
+ {
+
+ /// Sort points of image \p input by decreasing values.
+ template <typename I>
+ std::vector<mln_point(I)> sort_points_decreasing(const Image<I>& input);
+
+ /// Sort points of image \p input by increasing values.
+ template <typename I>
+ std::vector<mln_point(I)> sort_points_increasing(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points_decreasing(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ typedef mln_vset(I) S;
+ const S& vset = input.values();
+ const unsigned n = vset.nvalues();
+
+ // h
+ histo::data<S> h = compute(input);
+
+ // preparing output data
+ std::vector<unsigned> loc(vset.nvalues());
+ loc[n-1] = 0;
+ for (unsigned i = n - 2; i != 0; --i)
+ loc[i] = loc[i+1] + h[i+1];
+
+ // computing output data
+ std::vector<mln_point(I)> vec(input.npoints());
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ vec[loc[vset.index_of(input(p))]++] = p;
+
+ return vec;
+ }
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points_increasing(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ typedef mln_vset(I) S;
+ const S& vset = input.values();
+ const unsigned n = vset.nvalues();
+
+ // h
+ histo::data<S> h = compute(input);
+
+ // preparing output data
+ std::vector<unsigned> loc(vset.nvalues());
+ loc[0] = 0;
+ for (unsigned i = 1; i != n; ++i)
+ loc[i] = loc[i-1] + h[i-1];
+
+ // computing output data
+ std::vector<mln_point(I)> vec(input.npoints());
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ vec[loc[vset.index_of(input(p))]++] = p;
+
+ return vec;
+ }
+
+ } // end of namespace mln::histo::impl
+
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points_decreasing(const Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ mln_precondition(exact(input).values().nvalues() > 1); // FIXME
+ return impl::sort_points_decreasing(exact(input));
+ }
+
+
+ template <typename I>
+ std::vector<mln_point(I)>
+ sort_points_increasing(const Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ mln_precondition(exact(input).values().nvalues() > 1); // FIXME
+ return impl::sort_points_increasing(exact(input));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::histo
+
+} // end of namespace mln
+
+
+#endif // ! MLN_HISTO_SORT_HH
Index: mln/histo/data.hh
--- mln/histo/data.hh (revision 0)
+++ mln/histo/data.hh (revision 0)
@@ -0,0 +1,149 @@
+// Copyright (C) 2007 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_HISTO_DATA_HH
+# define MLN_HISTO_DATA_HH
+
+/*! \file mln/histo/data.hh
+ *
+ * \brief Define a generic histogram class.
+ */
+
+# include <vector>
+# include <algorithm>
+
+# include <mln/core/concept/value_set.hh>
+
+
+namespace mln
+{
+
+ namespace histo
+ {
+
+
+ /*! Generic histogram class over a value set with type \c S.
+ */
+ template <typename S>
+ struct data
+ {
+ typedef mln_value(S) value;
+
+ data(const Value_Set<S>& s);
+
+ void clear();
+
+ std::size_t operator()(const value& v) const;
+ std::size_t& operator()(const value& v);
+
+ const std::vector<std::size_t>& vec() const;
+ const S& vset() const;
+ std::size_t operator[](unsigned i) const;
+
+ protected:
+
+ const S& s_;
+ std::vector<std::size_t> h_;
+ };
+
+
+ template <typename S>
+ std::ostream& operator<<(std::ostream& ostr, const data<S>& h);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S>
+ data<S>::data(const Value_Set<S>& s)
+ : s_(exact(s)),
+ h_(s_.nvalues(), 0)
+ {
+ clear();
+ }
+
+ template <typename S>
+ void
+ data<S>::clear()
+ {
+ std::fill(h_.begin(), h_.end(), 0);
+ }
+
+ template <typename S>
+ std::size_t
+ data<S>::operator()(const value& v) const
+ {
+ return h_[s_.index_of(v)];
+ }
+
+ template <typename S>
+ std::size_t&
+ data<S>::operator()(const value& v)
+ {
+ return h_[s_.index_of(v)];
+ }
+
+ template <typename S>
+ const S&
+ data<S>::vset() const
+ {
+ return s_;
+ }
+
+ template <typename S>
+ std::size_t
+ data<S>::operator[](unsigned i) const
+ {
+ mln_precondition(i < s_.nvalues());
+ return h_[i];
+ }
+
+ template <typename S>
+ const std::vector<std::size_t>&
+ data<S>::vec() const
+ {
+ return h_;
+ }
+
+ template <typename S>
+ std::ostream& operator<<(std::ostream& ostr, const data<S>& h)
+ {
+ mln_viter(S) v(h.vset());
+ for_all(v)
+ if (h(v) != 0)
+ ostr << v << ':' << h(v) << ' ';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::histo
+
+} // end of namespace mln
+
+
+#endif // ! MLN_HISTO_DATA_HH
Index: mln/histo/compute.hh
--- mln/histo/compute.hh (revision 0)
+++ mln/histo/compute.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 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_HISTO_COMPUTE_HH
+# define MLN_HISTO_COMPUTE_HH
+
+/*! \file mln/histo/compute.hh
+ *
+ * \brief Routine to compute an histogram.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/histo/data.hh>
+
+
+namespace mln
+{
+
+ namespace histo
+ {
+
+ /// Compute the histogram of image \p input.
+ template <typename I>
+ data<mln_vset(I)> compute(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ data<mln_vset(I)> compute(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+ data<mln_vset(I)> h(input.values());
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ ++h(input(p));
+ return h;
+ }
+
+ template <typename I>
+ data<mln_vset(I)> compute(const Fast_Image<I>& input_)
+ {
+ const I& input = exact(input_);
+ data<mln_vset(I)> h(input.values());
+ mln_pixter(const I) p(input);
+ for_all(p)
+ ++h(*p);
+ return h;
+ }
+
+ } // end of namespace mln::histo::impl
+
+
+ template <typename I>
+ data<mln_vset(I)> compute(const Image<I>& input)
+ {
+ mln_precondition(exact(input).has_data());
+ return impl::compute(exact(input));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::histo
+
+} // end of namespace mln
+
+
+#endif // ! MLN_HISTO_COMPUTE_HH
Index: mln/io/save_pgm.hh
--- mln/io/save_pgm.hh (revision 1036)
+++ mln/io/save_pgm.hh (working copy)
@@ -33,7 +33,7 @@
# include <fstream>
# include <mln/core/image2d_b.hh>
-# include <mln/value/int_u.hh>
+# include <mln/value/int_u8.hh>
namespace mln
Index: mln/io/load_pgm.hh
--- mln/io/load_pgm.hh (revision 1036)
+++ mln/io/load_pgm.hh (working copy)
@@ -34,7 +34,7 @@
# include <string>
# include <mln/core/image2d_b.hh>
-# include <mln/value/int_u.hh>
+# include <mln/value/int_u8.hh>
namespace mln
Index: mln/accu/histo.hh
--- mln/accu/histo.hh (revision 1036)
+++ mln/accu/histo.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/accu/histo.hh
*
- * \brief Define a couple of generic histogram classes.
+ * \brief Define a generic histogram accumulator class.
*/
# include <vector>
Index: mln/accu/median.hh
--- mln/accu/median.hh (revision 1036)
+++ mln/accu/median.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/accu/median.hh
*
- * \brief Define FIXME
+ * \brief Define a generic median accumulator class.
*/
# include <mln/core/concept/accumulator.hh>
Index: mln/value/int_s8.hh
--- mln/value/int_s8.hh (revision 0)
+++ mln/value/int_s8.hh (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (C) 2007 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_VALUE_INT_S8_HH
+# define MLN_VALUE_INT_S8_HH
+
+/*! \file mln/value/int_s8.hh
+ *
+ * \brief Define the alias value::int_s8.
+ */
+
+# include <mln/value/int_s.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ /// Alias for signed 8 bit integers.
+ typedef int_s<8> int_s8;
+
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INT_S8_HH
Index: mln/value/int_u16.hh
--- mln/value/int_u16.hh (revision 0)
+++ mln/value/int_u16.hh (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (C) 2007 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_VALUE_INT_U16_HH
+# define MLN_VALUE_INT_U16_HH
+
+/*! \file mln/value/int_u16.hh
+ *
+ * \brief Define the alias value::int_u16.
+ */
+
+# include <mln/value/int_u.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ /// Alias for unsigned 16 bit integers.
+ typedef int_u<16> int_u16;
+
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INT_U16_HH
Index: mln/value/int_u8.hh
--- mln/value/int_u8.hh (revision 0)
+++ mln/value/int_u8.hh (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (C) 2007 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_VALUE_INT_U8_HH
+# define MLN_VALUE_INT_U8_HH
+
+/*! \file mln/value/int_u8.hh
+ *
+ * \brief Define the alias value::int_u8.
+ */
+
+# include <mln/value/int_u.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ /// Alias for unsigned 8 bit integers.
+ typedef int_u<8> int_u8;
+
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INT_U8_HH
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 0)
+++ mln/value/int_s.hh (revision 0)
@@ -0,0 +1,163 @@
+// Copyright (C) 2007 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_VALUE_INT_S_HH
+# define MLN_VALUE_INT_S_HH
+
+/*! \file mln/value/int_s.hh
+ *
+ * \brief Define a generic class for signed integers.
+ */
+
+# include <mln/metal/math.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/encoding.hh>
+# include <mln/value/props.hh>
+# include <mln/value/set.hh>
+# include <mln/debug/format.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ /*! \brief Signed integer value class.
+ *
+ * The parameter is \c n the number of encoding bits.
+ */
+ template <unsigned n>
+ struct int_s
+ : public internal::value_like_< typename internal::encoding_int_s_<n>::ret,
+ int_s<n> >
+ {
+ protected:
+ typedef internal::value_like_< typename internal::encoding_int_s_<n>::ret,
+ int_s<n> > super;
+
+ public:
+
+ /// Encoding associated type.
+ typedef typename super::enc enc;
+
+ /// Constructor without argument.
+ int_s();
+
+ /// Constructor from an integer.
+ int_s(int i);
+
+ /// Negation.
+ int_s<n> operator-() const;
+
+ /// Zero value.
+ static const int_s<n> zero;
+
+ /// Unit value.
+ static const int_s<n> one;
+ };
+
+
+
+ template <unsigned n>
+ struct props< int_s<n> >
+ {
+ static const int_s<n> max; // = 2^(n-1) - 1
+ static const int_s<n> min; // = - max
+ static const std::size_t card = metal::pow<2, n>::value;
+ static const unsigned nbits = n;
+ typedef data_kind kind;
+ };
+
+
+ // Safety.
+ template <> struct int_s<0>;
+ template <> struct int_s<1>;
+
+
+
+ /*! \brief Print an signed integer \p i into the output stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] i An signed integer.
+ *
+ * \return The modified output stream \p ostr.
+ */
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const int_s<n>& i);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n>
+ int_s<n>::int_s()
+ {
+ }
+
+ template <unsigned n>
+ int_s<n>::int_s(int i)
+ {
+ mln_precondition(i >= mln_min(enc));
+ mln_precondition(i <= mln_max(enc));
+ this->v_ = enc(i);
+ }
+
+ template <unsigned n>
+ int_s<n> int_s<n>::operator-() const
+ {
+ return - this->v_;
+ }
+
+ template <unsigned n>
+ const int_s<n> int_s<n>::zero = 0;
+
+ template <unsigned n>
+ const int_s<n> int_s<n>::one = 1;
+
+ template <unsigned n>
+ const int_s<n>
+ props< int_s<n> >::min = 1 - metal::pow<2, n - 1>::value;
+
+ template <unsigned n>
+ const int_s<n>
+ props< int_s<n> >::max = metal::pow<2, n - 1>::value - 1;
+
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const int_s<n>& i)
+ {
+ return ostr << debug::format(i.to_equiv());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INT_S_HH
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1036)
+++ mln/value/int_u.hh (working copy)
@@ -35,8 +35,10 @@
# include <mln/metal/math.hh>
# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/encoding.hh>
# include <mln/value/props.hh>
# include <mln/value/set.hh>
+# include <mln/debug/format.hh>
namespace mln
@@ -46,25 +48,18 @@
{
- namespace internal
- {
- template <unsigned n> struct encoding_;
- template <> struct encoding_<8> { typedef unsigned char ret; };
- }
-
-
/*! \brief Unsigned integer value class.
*
* The parameter is \c n the number of encoding bits.
*/
template <unsigned n>
- struct int_u_
- : public internal::value_like_< typename internal::encoding_<n>::ret,
- int_u_<n> >
+ struct int_u
+ : public internal::value_like_< typename internal::encoding_int_u_<n>::ret,
+ int_u<n> >
{
protected:
- typedef internal::value_like_< typename internal::encoding_<n>::ret,
- int_u_<n> > super;
+ typedef internal::value_like_< typename internal::encoding_int_u_<n>::ret,
+ int_u<n> > super;
public:
@@ -72,60 +67,82 @@
typedef typename super::enc enc;
/// Constructor without argument.
- int_u_();
+ int_u();
/// Constructor from an integer.
- int_u_(int i);
+ int_u(int i);
+
+ /// Zero value.
+ static const int_u<n> zero;
+
+ /// Unit value.
+ static const int_u<n> one;
};
+ // Safety.
+ template <> struct int_u<0>;
+ template <> struct int_u<1>;
+
template <unsigned n>
- struct props< int_u_<n> > : public props< typename internal::encoding_<n>::ret >
+ struct props< int_u<n> >
{
- static const unsigned nbits = n;
static const std::size_t card = metal::pow<2, n>::value;
+ static const int_u<n> min; // = 0
+ static const int_u<n> max; // = card - 1
+ static const unsigned nbits = n;
+ typedef data_kind kind;
};
- /// Alias for unsigned 8bit integers.
- typedef int_u_<8> int_u8;
-
- /// Alias for the set of unsigned 8bit integers.
- typedef set<int_u8> int_u8_set;
-
-
-
- /*! \brief Print an int_u8 \p i into the output stream \p ostr.
+ /*! \brief Print an unsigned integer \p i into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
- * \param[in] i An int_u8.
+ * \param[in] i An unsigned integer.
*
* \return The modified output stream \p ostr.
*/
- std::ostream& operator<<(std::ostream& ostr, const int_u8& i);
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i);
# ifndef MLN_INCLUDE_ONLY
template <unsigned n>
- int_u_<n>::int_u_()
+ int_u<n>::int_u()
{
}
template <unsigned n>
- int_u_<n>::int_u_(int i)
+ int_u<n>::int_u(int i)
{
mln_precondition(i >= 0);
mln_precondition(i <= mln_max(enc));
this->v_ = enc(i);
}
- std::ostream& operator<<(std::ostream& ostr, const int_u8& i)
+ template <unsigned n>
+ const int_u<n> int_u<n>::zero = 0;
+
+ template <unsigned n>
+ const int_u<n> int_u<n>::one = 1;
+
+
+ template <unsigned n>
+ const int_u<n>
+ props< int_u<n> >::min = 0;
+
+ template <unsigned n>
+ const int_u<n>
+ props< int_u<n> >::max = metal::pow<2, n>::value - 1;
+
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i)
{
- return ostr << unsigned(i.to_equiv());
+ return ostr << debug::format(i.to_equiv());
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/internal/encoding.hh
--- mln/value/internal/encoding.hh (revision 0)
+++ mln/value/internal/encoding.hh (revision 0)
@@ -0,0 +1,86 @@
+// Copyright (C) 2007 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_VALUE_INTERNAL_ENCODING_HH
+# define MLN_VALUE_INTERNAL_ENCODING_HH
+
+/*! \file mln/value/internal/encoding.hh
+ *
+ * \brief Define some information about how to encode some value types.
+ */
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ namespace internal
+ {
+
+ template <unsigned n> struct encoding_int_u_;
+
+ template <> struct encoding_int_u_<8> { typedef unsigned char ret; };
+ template <> struct encoding_int_u_<16> { typedef unsigned short ret; };
+ template <> struct encoding_int_u_<32> { typedef unsigned int ret; }; // FIXME!!!
+ template <> struct encoding_int_u_<64> { typedef unsigned long ret; }; // FIXME!!!
+
+ template <> struct encoding_int_u_<99> { typedef void ret; }; // stopper
+
+ template <unsigned n>
+ struct encoding_int_u_
+ {
+ typedef typename encoding_int_u_<n+1>::ret ret;
+ };
+
+
+
+ template <unsigned n> struct encoding_int_s_;
+
+ template <> struct encoding_int_s_<8> { typedef signed char ret; };
+ template <> struct encoding_int_s_<16> { typedef signed short ret; };
+ template <> struct encoding_int_s_<32> { typedef signed int ret; }; // FIXME!!!
+ template <> struct encoding_int_s_<64> { typedef signed long ret; }; // FIXME!!!
+
+ template <> struct encoding_int_s_<99> { typedef void ret; }; // stopper
+
+ template <unsigned n>
+ struct encoding_int_s_
+ {
+ typedef typename encoding_int_s_<n+1>::ret ret;
+ };
+
+
+ } // end of namespace mln::value::internal
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INTERNAL_ENCODING_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add some morphers and handle constness in pixterators.
Add new morphers.
* tests/cast_image.cc: New.
* tests/assign.cc: New.
* tests/fimage.cc: New.
* mln/core/fimage.hh: New.
* mln/level/assign.hh: New.
* mln/value/cast.hh: New.
* mln/core/safe.hh: Rename as...
* mln/core/safe_image.hh: ...this.
* tests/safe_image.cc: Update.
* mln/core/vec.hh: Rename as...
* mln/metal/vec.hh: ...this.
Handle constness in pixel iterators.
* mln/core/internal/pixel_impl.hh (value_): New.
(address): Update.
* mln/core/internal/pixel_iterator_base.hh
(qualified_value, value_): New.
* mln/core/pixter2d_b.hh (value_): Update.
* mln/core/dpoints_pixter.hh (value_): Update.
* mln/core/internal/image_adaptor.hh
(vset, values): Fix missing.
* mln/core/concept/generalized_pixel.hh
(ctor): Comment check on address.
* mln/core/concept/pixel_iterator.hh
(ctor): Comment check on lvalue and op*.
* mln/core/concept/fast_image.hh (offset): Fix missing const.
* mln/core/image2d_b.hh: Likewise.
* mln/core/concept/doc/image.hh: Cosmetic changes.
* mln/level/fast_median.hh (input): Update.
* TODO: Update.
TODO | 2
mln/core/concept/doc/image.hh | 2
mln/core/concept/fast_image.hh | 8 -
mln/core/concept/generalized_pixel.hh | 5
mln/core/concept/pixel_iterator.hh | 9 -
mln/core/dpoints_pixter.hh | 10 -
mln/core/fimage.hh | 170 ++++++++++++++++++++++++++++++
mln/core/image2d_b.hh | 14 +-
mln/core/internal/image_adaptor.hh | 16 ++
mln/core/internal/pixel_impl.hh | 12 +-
mln/core/internal/pixel_iterator_base.hh | 20 +++
mln/core/pixter2d_b.hh | 3
mln/core/safe.hh | 7 -
mln/level/assign.hh | 103 ++++++++++++++++++
mln/level/fast_median.hh | 10 -
mln/metal/vec.hh | 11 +
mln/value/cast.hh | 175 +++++++++++++++++++++++++++++++
tests/assign.cc | 48 ++++++++
tests/cast_image.cc | 48 ++++++++
tests/fimage.cc | 44 +++++++
tests/safe_image.cc | 2
21 files changed, 681 insertions(+), 38 deletions(-)
Index: tests/cast_image.cc
--- tests/cast_image.cc (revision 0)
+++ tests/cast_image.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/cast_image.cc
+ *
+ * \brief Tests on mln::value::cast_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/fun/chess.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/value/cast.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d_b<bool> ima(8, 8);
+ level::fill(ima, fun::chess);
+ debug::println(ima);
+ debug::println( value::cast<int>(ima) );
+}
Index: tests/safe_image.cc
--- tests/safe_image.cc (revision 1033)
+++ tests/safe_image.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/safe_image.hh>
+#include <mln/core/safe.hh>
#include <mln/level/paste.hh>
Index: tests/assign.cc
--- tests/assign.cc (revision 0)
+++ tests/assign.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/assign.cc
+ *
+ * \brief Tests on mln::level::assign.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/assign.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 1000;
+ image2d_b<int> rhs(size, size), lhs(rhs.domain());
+ debug::iota(rhs);
+ level::assign(lhs, rhs);
+ mln_assertion(lhs = rhs);
+}
Index: tests/fimage.cc
--- tests/fimage.cc (revision 0)
+++ tests/fimage.cc (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/fimage.cc
+ *
+ * \brief Tests on mln::fimage.
+ */
+
+#include <mln/core/fimage.hh>
+#include <mln/core/box2d.hh>
+#include <mln/fun/chess.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ debug::println( fun::chess | make::box2d(8, 8) );
+}
Index: TODO
--- TODO (revision 1033)
+++ TODO (working copy)
@@ -17,7 +17,6 @@
value::proxy to dispatch read/write + the corresponding image type
a mean_value object { sum; count } and operator+
-value_cast<T>(image)
t_image to "transpose" the 0 and the i-th coordinates
image defined by f/pset
@@ -45,6 +44,5 @@
fast versions of level::fill and level::paste
histogram class
sorting points w.r.t. their value (array of offsets, psites, points)
-border::* and no-op versions if not fast image
arith::inplace_plus et al.
linear:: for convolutions
Index: mln/core/fimage.hh
--- mln/core/fimage.hh (revision 0)
+++ mln/core/fimage.hh (revision 0)
@@ -0,0 +1,170 @@
+// Copyright (C) 2007 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_FIMAGE_HH
+# define MLN_CORE_FIMAGE_HH
+
+/*! \file mln/core/fimage.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <mln/core/internal/image_base.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/value/set.hh>
+
+
+namespace mln
+{
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename F, typename S>
+ struct fimage : public internal::image_base_< S, fimage<F,S> >
+ {
+ /// Point_Site associated type.
+ typedef mln_psite(S) psite;
+
+ /// Point_Set associated type.
+ typedef S pset;
+
+ /// Value associated type.
+ typedef mln_result(F) value;
+
+ /// Return type of read-only access.
+ typedef mln_result(F) rvalue;
+
+ /// Return type of read-write access.
+ typedef void lvalue; // FIXME
+
+ /// Value set associated type.
+ typedef mln::value::set_<mln_result(F)> vset;
+
+
+ /// Constructor.
+ fimage(const Function_p2v<F>& f, const Point_Set<S>& ps);
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ bool owns_(const psite& p) const;
+
+ /// Give the definition domain.
+ const S& domain() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ mln_result(F) operator()(const psite& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ void operator()(const psite& p);
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Change value type. FIXME!
+ template <typename U>
+ struct change_value
+ {
+ typedef void ret;
+ };
+
+ protected:
+ F f_;
+ S pset_;
+ };
+
+
+
+ template <typename F, typename S>
+ fimage<F,S>
+ operator | (const Function_p2v<F>& f, const Point_Set<S>& ps)
+ {
+ fimage<F,S> tmp(f, ps);
+ return tmp;
+ }
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F, typename S>
+ fimage<F,S>::fimage(const Function_p2v<F>& f, const Point_Set<S>& ps)
+ : f_(exact(f)),
+ pset_(exact(ps))
+ {
+ }
+
+ template <typename F, typename S>
+ bool fimage<F,S>::has_data() const
+ {
+ return true;
+ }
+
+ template <typename F, typename S>
+ bool fimage<F,S>::owns_(const psite& p) const
+ {
+ return pset_.has(p);
+ }
+
+ template <typename F, typename S>
+ const S&
+ fimage<F,S>::domain() const
+ {
+ return pset_;
+ }
+
+ template <typename F, typename S>
+ mln_result(F)
+ fimage<F,S>::operator()(const psite& p) const
+ {
+ mln_precondition(pset_.has(p));
+ return f_(p);
+ }
+
+ template <typename F, typename S>
+ void
+ fimage<F,S>::operator()(const psite& p)
+ {
+ mln_invariant(0); // FIXME: Turn into a compile-time error...
+ }
+
+ template <typename F, typename S>
+ const mln::value::set_<mln_result(F)>&
+ fimage<F,S>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_FIMAGE_HH
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh (revision 1033)
+++ mln/core/pixter2d_b.hh (working copy)
@@ -45,7 +45,8 @@
class fwd_pixter2d_b : public internal::pixel_iterator_base_< I, fwd_pixter2d_b<I> >
{
typedef internal::pixel_iterator_base_< I, fwd_pixter2d_b<I> > super_;
- typedef mln_value(super_) value_;
+ typedef typename super_::value_ value_;
+
public:
/*! \brief Constructor.
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh (revision 1033)
+++ mln/core/dpoints_pixter.hh (working copy)
@@ -55,11 +55,11 @@
class dpoints_fwd_pixter : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
public internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
{
- typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> > super;
+ typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> > super_;
public:
/// Using super value type.
- typedef mln_value(super) value;
+ typedef typename super_::value_ value_;
/*! \brief Constructor.
*
@@ -111,7 +111,7 @@
unsigned i_;
/// reference pixel / point in the image
- value** value_ref_;
+ value_** value_ref_;
// or:
const mln_point(I)* p_ref_;
@@ -135,7 +135,7 @@
dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
const Dps& dps,
const Generalized_Point<Pref>& p_ref)
- : super(image)
+ : super_(image)
{
mln_precondition(image.has_data());
p_ref_ = internal::force_exact<Pref>(p_ref).pointer_();
@@ -149,7 +149,7 @@
dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
const Dps& dps,
const Generalized_Pixel<Pref>& p_ref)
- : super(image)
+ : super_(image)
{
mln_precondition(image.has_data());
p_ref_ = 0;
Index: mln/core/internal/pixel_impl.hh
--- mln/core/internal/pixel_impl.hh (revision 1033)
+++ mln/core/internal/pixel_impl.hh (working copy)
@@ -62,6 +62,9 @@
/// Image rvalue type.
typedef mln_rvalue(I) rvalue;
+ /// Qualified value type.
+ typedef value value_;
+
/// pixel iterator value.
lvalue operator*();
@@ -105,13 +108,16 @@
/// Image rvalue type.
typedef mln_rvalue(I) rvalue;
+ /// Qualified value type.
+ typedef const value value_;
+
/// Get the pixel iterator value.
rvalue operator*() const;
/// Address of the current iterator value/pixel.
- value** address_() const;
+ const value** address_() const;
protected:
@@ -197,11 +203,11 @@
}
template <typename I, typename E>
- mln_value(I) **
+ const mln_value(I) **
pixel_impl_<const I, E>::address_() const
{
mln_precondition(is_valid_());
- return (value**)(& this->value_ptr_);
+ return (const value**)(& this->value_ptr_);
}
#endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/pixel_iterator_base.hh
--- mln/core/internal/pixel_iterator_base.hh (revision 1033)
+++ mln/core/internal/pixel_iterator_base.hh (working copy)
@@ -43,6 +43,22 @@
namespace internal
{
+
+ template <typename I>
+ struct qualified_value
+ {
+ typedef mln_value(I) ret;
+ };
+
+
+ template <typename I>
+ struct qualified_value< const I >
+ {
+ typedef const mln_value(I) ret;
+ };
+
+
+
/*! \brief A base class for pixel iterators.
*
*/
@@ -51,7 +67,6 @@
public internal::pixel_impl_<I, E>
{
typedef internal::pixel_impl_<I, E> super_;
- typedef mln_value(super_) value_;
public:
@@ -64,6 +79,9 @@
/// Test if the iterator is valid.
bool is_valid() const;
+ /// Qualified (const or not) value type.
+ typedef typename qualified_value<I>::ret value_;
+
protected:
/// Beginning of the image.
Index: mln/core/internal/image_adaptor.hh
--- mln/core/internal/image_adaptor.hh (revision 1033)
+++ mln/core/internal/image_adaptor.hh (working copy)
@@ -51,12 +51,16 @@
typename S = mln_pset(I) >
struct image_adaptor_ : public internal::image_base_< S, E >
{
+
/// Point_Site associated type.
typedef mln_psite(S) psite;
/// Point_Set associated type.
typedef S pset;
+ /// Value_Set associated type.
+ typedef mln_vset(I) vset;
+
/// Value associated type.
typedef mln_value(I) value;
@@ -66,6 +70,7 @@
/// Return type of read-write access.
typedef mln_lvalue(I) lvalue;
+
/// Test if this image has been initialized.
bool has_data() const;
@@ -75,12 +80,16 @@
/// Give the definition domain.
const S& domain() const;
+ /// Give the set of values.
+ const vset& values() const;
+
/// Read-only access of pixel value at point site \p p.
rvalue operator()(const psite& p) const;
/// Read-write access of pixel value at point site \p p.
lvalue operator()(const psite& p);
+
protected:
I& adaptee_;
@@ -116,6 +125,13 @@
}
template <typename I, typename E, typename S>
+ const mln_vset(I)&
+ image_adaptor_<I,E,S>::values() const
+ {
+ return adaptee_.values();
+ }
+
+ template <typename I, typename E, typename S>
typename image_adaptor_<I,E,S>::rvalue
image_adaptor_<I,E,S>::operator()(const psite& p) const
{
Index: mln/core/safe.hh
--- mln/core/safe.hh (revision 1031)
+++ mln/core/safe.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_SAFE_IMAGE_HH
-# define MLN_CORE_SAFE_IMAGE_HH
+#ifndef MLN_CORE_SAFE_HH
+# define MLN_CORE_SAFE_HH
# include <mln/core/internal/image_adaptor.hh>
@@ -34,6 +34,7 @@
namespace mln
{
+ // FIXME: Doc!
template <typename I>
struct safe_image : public internal::image_adaptor_< I, safe_image<I> >
@@ -100,4 +101,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_SAFE_IMAGE_HH
+#endif // ! MLN_CORE_SAFE_HH
Index: mln/core/concept/generalized_pixel.hh
--- mln/core/concept/generalized_pixel.hh (revision 1033)
+++ mln/core/concept/generalized_pixel.hh (working copy)
@@ -77,8 +77,9 @@
typedef mln_rvalue(E) rvalue;
rvalue (E::*m1)() const = & E::operator*;
m1 = 0;
- value** (E::*m2)() const = & E::address_;
- m2 = 0;
+ // FIXME: Activate (so add qualif_value):
+// value** (E::*m2)() const = & E::address_;
+// m2 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/pixel_iterator.hh
--- mln/core/concept/pixel_iterator.hh (revision 1033)
+++ mln/core/concept/pixel_iterator.hh (working copy)
@@ -54,8 +54,9 @@
public Generalized_Pixel<E>
{
/*
- typedef lvalue;
+ only if the iterator is constructed on a mutable image:
+ typedef lvalue;
lvalue operator*();
*/
protected:
@@ -68,9 +69,9 @@
template <typename E>
Pixel_Iterator<E>::Pixel_Iterator()
{
- typedef mln_lvalue(E) lvalue;
- lvalue (E::*m)() = & E::operator*;
- m = 0;
+// typedef mln_lvalue(E) lvalue;
+// lvalue (E::*m)() = & E::operator*;
+// m = 0;
}
#endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/fast_image.hh
--- mln/core/concept/fast_image.hh (revision 1033)
+++ mln/core/concept/fast_image.hh (working copy)
@@ -49,8 +49,8 @@
/*
unsigned border();
- int offset(const dpoint& dp);
- unsigned offset(const point& p);
+ int offset(const dpoint& dp) const;
+ unsigned offset(const point& p) const;
point point_at_offset(unsigned o) const;
const value* buffer() const;
@@ -75,9 +75,9 @@
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
- int (E::*m1)(const dpoint&) = & E::offset;
+ int (E::*m1)(const dpoint&) const = & E::offset;
m1 = 0;
- unsigned (E::*m2)(const point&) = & E::offset;
+ unsigned (E::*m2)(const point&) const = & E::offset;
m2 = 0;
point (E::*m3)(unsigned) const = & E::point_at_offset;
m3 = 0;
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 1033)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -41,6 +41,7 @@
template <typename E>
struct Image : public Object<E>
{
+
/*! \brief Value associated type.
*
* \invariant This type is neither qualified by const, nor by
@@ -61,6 +62,7 @@
*/
typedef void vset;
+
/*! \brief Test if the image have been initialized.
*/
bool has_data() const;
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1033)
+++ mln/core/image2d_b.hh (working copy)
@@ -190,10 +190,10 @@
/// Fast Image method
/// Give the offset corresponding to the delta-point \p dp.
- int offset(const dpoint2d& dp);
+ int offset(const dpoint2d& dp) const;
/// Give the offset corresponding to the point \p p.
- unsigned offset(const point2d& p);
+ unsigned offset(const point2d& p) const;
/// Give the point corresponding to the offset \p o.
point2d point_at_offset(unsigned o) const;
@@ -412,7 +412,7 @@
template <typename T>
int
- image2d_b<T>::offset(const dpoint2d& dp)
+ image2d_b<T>::offset(const dpoint2d& dp) const
{
mln_precondition(this->has_data());
int o = dp[0] * vb_.len(1) + dp[1];
@@ -421,7 +421,7 @@
template <typename T>
unsigned
- image2d_b<T>::offset(const point2d& p)
+ image2d_b<T>::offset(const point2d& p) const
{
mln_precondition(this->owns_(p));
unsigned o = & this->operator()(p) - this->buffer_;
@@ -535,6 +535,12 @@
};
template <typename T, typename W>
+ struct fwd_qixter< const image2d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image2d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
struct bkd_qixter< image2d_b<T>, W >
{
typedef internal::fixme ret;
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1031)
+++ mln/metal/vec.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_VEC_HH
-# define MLN_CORE_VEC_HH
+#ifndef MLN_CORE_METAL_VEC_HH
+# define MLN_CORE_METAL_VEC_HH
# include <mln/core/concept/object.hh>
@@ -34,6 +34,9 @@
namespace mln
{
+ namespace metal
+ {
+
template <unsigned n, typename T>
struct vec : public Object< vec<n,T> >
{
@@ -56,7 +59,9 @@
T coord_[n];
};
+ } // end of namespace mln::metal
+
} // end of namespace mln
-#endif // ! MLN_CORE_VEC_HH
+#endif // ! MLN_CORE_METAL_VEC_HH
Index: mln/level/assign.hh
--- mln/level/assign.hh (revision 0)
+++ mln/level/assign.hh (revision 0)
@@ -0,0 +1,103 @@
+// Copyright (C) 2007 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_LEVEL_ASSIGN_HH
+# define MLN_LEVEL_ASSIGN_HH
+
+/*! \file mln/level/assign.hh
+ *
+ * \brief Assignment between a couple of images.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ /*! Assignment of image \p target with image \p data.
+ *
+ * \param[out] output The image to be assigned.
+ * \param[in] data The auxiliary image.
+ *
+ * \pre target.domain = data.domain
+ *
+ * \todo Overload in impl:: for mixed (fast, non-fast).
+ *
+ * \todo Overload in impl:: for (fast, fast) if same value using memcpy.
+ */
+ template <typename L, typename R>
+ void assign(Image<L>& target, const Image<R>& data);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename L, typename R>
+ void assign(Image<L>& target_, const Image<R>& data_)
+ {
+ L& target = exact(target_);
+ const R& data = exact(data_);
+ mln_piter(L) p(target.domain());
+ for_all(p)
+ target(p) = data(p);
+ }
+
+ template <typename L, typename R>
+ void assign(Fast_Image<L>& target_, const Fast_Image<R>& data_)
+ {
+ L& target = exact(target_);
+ const R& data = exact(data_);
+ mln_pixter(L) lhs(target);
+ mln_pixter(const R) rhs(data);
+ for_all_2(lhs, rhs)
+ *lhs = *rhs;
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename L, typename R>
+ void assign(Image<L>& target, const Image<R>& data)
+ {
+ mln_precondition(exact(data).domain() = exact(target).domain());
+ impl::assign(exact(target), exact(data));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_ASSIGN_HH
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1033)
+++ mln/level/fast_median.hh (working copy)
@@ -54,7 +54,7 @@
* \pre \p input and \p output have to be initialized.
*/
template <typename I, typename W, typename O>
- void fast_median(Image<I>& input, const Window<W>& win,
+ void fast_median(const Image<I>& input, const Window<W>& win,
Image<O>& output);
@@ -65,7 +65,7 @@
{
template <typename I, typename W, typename O>
- void fast_median(I& input,
+ void fast_median(const I& input,
const W& win,
O& output)
{
@@ -90,14 +90,14 @@
point2d p = input.domain().pmin() + up;
- mln_qixter(I, window2d)
+ mln_qixter(const I, window2d)
q_fp(input, win_fwd_plus, p), q_fm(input, win_fwd_minus, p),
q_bp(input, win_bkd_plus, p), q_bm(input, win_bkd_minus, p),
q_top(input, win_top, p), q_bot(input, win_bot, p);
med.init();
{
- mln_qixter(I, W) q(input, win, p);
+ mln_qixter(const I, W) q(input, win, p);
for_all(q)
med.take(*q);
}
@@ -154,7 +154,7 @@
// facade
template <typename I, typename W, typename O>
- void fast_median(Image<I>& input, const Window<W>& win,
+ void fast_median(const Image<I>& input, const Window<W>& win,
Image<O>& output)
{
impl::fast_median(exact(input), exact(win), exact(output));
Index: mln/value/cast.hh
--- mln/value/cast.hh (revision 0)
+++ mln/value/cast.hh (revision 0)
@@ -0,0 +1,175 @@
+// Copyright (C) 2007 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_VALUE_CAST_HH
+# define MLN_VALUE_CAST_HH
+
+/*! \file mln/value/cast.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/value/set.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename T, typename I>
+ struct cast_image : public internal::image_base_< mln_pset(I), cast_image<T,I> >
+ {
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Point_Set associated type.
+ typedef mln_pset(I) pset;
+
+ /// Value associated type.
+ typedef T value;
+
+ /// Return type of read-only access.
+ typedef T rvalue;
+
+ /// Return type of read-write access.
+ typedef void lvalue; // FIXME
+
+ /// Value set associated type.
+ typedef mln::value::set_<T> vset;
+
+
+ /// Constructor.
+ cast_image(const Image<I>& ima);
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ bool owns_(const psite& p) const;
+
+ /// Give the definition domain.
+ const mln_pset(I)& domain() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ T operator()(const psite& p) const;
+
+ /// Read-write access of pixel value at point site \p p.
+ void operator()(const psite& p);
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Change value type.
+ template <typename U>
+ struct change_value
+ {
+ typedef mln_ch_value(I, U) ret;
+ };
+
+ protected:
+ const I& ima_;
+ };
+
+
+
+ template <typename T, typename I>
+ cast_image<T,I>
+ cast(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ cast_image<T,I> tmp(ima);
+ return tmp;
+ }
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename I>
+ cast_image<T,I>::cast_image(const Image<I>& ima)
+ : ima_(exact(ima))
+ {
+ mln_precondition(exact(ima).has_data());
+ }
+
+ template <typename T, typename I>
+ bool cast_image<T,I>::has_data() const
+ {
+ mln_invariant(ima_.has_data());
+ return true;
+ }
+
+ template <typename T, typename I>
+ bool cast_image<T,I>::owns_(const psite& p) const
+ {
+ return ima_.owns_(p);
+ }
+
+ template <typename T, typename I>
+ const mln_pset(I)&
+ cast_image<T,I>::domain() const
+ {
+ return ima_.domain();
+ }
+
+ template <typename T, typename I>
+ T
+ cast_image<T,I>::operator()(const psite& p) const
+ {
+ mln_precondition(ima_.owns_(p));
+ return ima_(p);
+ }
+
+ template <typename T, typename I>
+ void
+ cast_image<T,I>::operator()(const psite& p)
+ {
+ mln_invariant(0); // FIXME: Turn into a compile-time error...
+ }
+
+ template <typename T, typename I>
+ const mln::value::set_<T>&
+ cast_image<T,I>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_CAST_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some renaming and add phantom border routines.
* mln/pw: New directory.
* mln/fun/var.hh: Rename as...
* mln/pw/var.hh: ...this.
* mln/fun/val.hh: Rename as...
* mln/pw/cst.hh: ...this.
* mln/fun/pw_value.hh: Renameas ...
* mln/pw/value.hh: ...this.
* mln/core/concept/image.hh: .
* mln/core/concept/iterator.hh: .
* tests/erosion.cc,
* tests/pw_value.cc,
* TODO: Update.
* mln/convert/to_window.hh: Fix doc.
* mln/border/resize.hh: New.
* mln/border/fill.hh: New.
* mln/border/all.hh: New.
* mln/border/duplicate.hh: New.
* mln/border/mirror.hh: New.
TODO | 15 -------
mln/border/all.hh | 54 ++++++++++++++++++++++++++++
mln/border/duplicate.hh | 75 +++++++++++++++++++++++++++++++++++++++
mln/border/fill.hh | 76 ++++++++++++++++++++++++++++++++++++++++
mln/border/mirror.hh | 75 +++++++++++++++++++++++++++++++++++++++
mln/border/resize.hh | 81 +++++++++++++++++++++++++++++++++++++++++++
mln/convert/to_window.hh | 2 -
mln/core/concept/image.hh | 4 ++
mln/core/concept/iterator.hh | 6 +++
mln/pw/cst.hh | 41 ++++++++++++---------
mln/pw/value.hh | 57 ++++++++++++------------------
mln/pw/var.hh | 28 +++++++-------
tests/erosion.cc | 10 ++---
tests/pw_value.cc | 6 +--
14 files changed, 442 insertions(+), 88 deletions(-)
Index: tests/erosion.cc
--- tests/erosion.cc (revision 1030)
+++ tests/erosion.cc (working copy)
@@ -40,8 +40,8 @@
#include <mln/level/fill.hh>
#include <mln/morpho/erosion.hh>
-#include <mln/fun/pw_value.hh>
-#include <mln/fun/val.hh>
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
#include <mln/fun/ops.hh>
@@ -61,18 +61,16 @@
morpho::erosion(lena, rec, out);
io::save_pgm(out, "out.pgm");
- /*
{
image2d_b<bool> bin(lena.domain()), out(lena.domain());
- level::fill(bin, pw_value(1) > val(127));
+ level::fill(bin, pw::value(lena) > pw::cst(127));
morpho::erosion(bin, rec, out);
image2d_b<int_u8> test(lena.domain());
- image2d_b<int_u8>::piter p(lena.domain());
+ image2d_b<int_u8>::fwd_piter p(lena.domain());
for_all(p)
test(p) = out(p) ? 255 : 0;
io::save_pgm(test, "test.pgm");
}
- */
}
Index: tests/pw_value.cc
--- tests/pw_value.cc (revision 1030)
+++ tests/pw_value.cc (working copy)
@@ -31,9 +31,9 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/fun/pw_value.hh>
#include <mln/fun/ops.hh>
-#include <mln/fun/val.hh>
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
int main()
@@ -44,5 +44,5 @@
point2d p = make::point2d(1, 1);
ima(p) = 51;
- std::cout << (pw_value(ima) = val(51))(p) << std::endl;
+ mln_assertion( (pw::value(ima) = pw::cst(51))(p) = true );
}
Index: TODO
--- TODO (revision 1030)
+++ TODO (working copy)
@@ -31,12 +31,12 @@
* renaming
mlc into metal
-point-wise material: pw::value_of, pw::constant, and pw::variable
* clean-up
accu::histo and median: remove inheritance
+select_function in fun::internal::selector_p2? etc.
* processing routines
@@ -48,16 +48,3 @@
border::* and no-op versions if not fast image
arith::inplace_plus et al.
linear:: for convolutions
-
-
-svn mv genpoint.hh generalized_point.hh
-svn mv genpixel.hh generalized_pixel.hh
-svn mv psite.hh point_site.hh
-svn mv viter.hh value_iterator.hh
-svn mv piter.hh point_iterator.hh
-
-
-svn mv doc/genpoint.hh doc/generalized_point.hh
-svn mv doc/genpixel.hh doc/generalized_pixel.hh
-svn mv doc/viter.hh doc/value_iterator.hh
-svn mv doc/piter.hh doc/point_iterator.hh
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1030)
+++ mln/convert/to_window.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/convert/to_window.hh
*
- * \brief Convertions to mln::Image.
+ * \brief Convertions to mln::Window.
*/
# include <mln/core/concept/neighborhood.hh>
Index: mln/pw/var.hh
--- mln/pw/var.hh (revision 0)
+++ mln/pw/var.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_VAR_HH
-# define MLN_FUN_VAR_HH
+#ifndef MLN_PW_VAR_HH
+# define MLN_PW_VAR_HH
-/*! \file mln/fun/var.hh
+/*! \file mln/pw/var.hh
*
* \brief FIXME.
*/
@@ -41,31 +41,31 @@
// FIXME: Doc!
- namespace fun
+ namespace pw
{
template <typename V>
struct var_ : public Function_p2v< var_<V> >
{
typedef V result;
+
var_(const V& v);
+
template <typename P>
const V& operator()(const P&) const;
+
private:
const V& v_;
};
- } // end of namespace mln::fun
-
template <typename V>
- fun::var_<V> var(const V& v);
+ var_<V> var(const V& v);
# ifndef MLN_INCLUDE_ONLY
- namespace fun
- {
+ // pw::var_<V>
template <typename V>
var_<V>::var_(const V& v)
@@ -81,18 +81,20 @@
return v_;
}
- } // end of namespace mln::fun
+ // pw::var(v)
template <typename V>
- fun::var_<V> var(const V& v)
+ var_<V> var(const V& v)
{
- fun::var_<V> tmp(v);
+ var_<V> tmp(v);
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_VAR_HH
+#endif // ! MLN_PW_VAR_HH
Index: mln/pw/cst.hh
--- mln/pw/cst.hh (revision 0)
+++ mln/pw/cst.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_VAL_HH
-# define MLN_FUN_VAL_HH
+#ifndef MLN_PW_CST_HH
+# define MLN_PW_CST_HH
-/*! \file mln/fun/val.hh
+/*! \file mln/pw/cst.hh
*
* \brief FIXME.
*/
@@ -39,35 +39,38 @@
namespace mln
{
- // FIXME: Doc!
-
- namespace fun
+ namespace pw
{
+ // FIXME: Doc!
+
template <typename T>
- struct val_ : public Function_p2v< val_<T> >
+ struct cst_ : public Function_p2v< cst_<T> >
{
typedef T result;
- val_(T t);
+
+ cst_(T t);
+
template <typename P>
T operator()(const P&) const;
+
private:
T t_;
};
- } // end of namespace mln::fun
+
+ // FIXME: Doc!
template <typename T>
- fun::val_<T> val(T t);
+ cst_<T> cst(T t);
# ifndef MLN_INCLUDE_ONLY
- namespace fun
- {
+ // pw::cst_<T>
template <typename T>
- val_<T>::val_(T t)
+ cst_<T>::cst_(T t)
: t_(t)
{
}
@@ -75,23 +78,25 @@
template <typename T>
template <typename P>
T
- val_<T>::operator()(const P&) const
+ cst_<T>::operator()(const P&) const
{
return t_;
}
- } // end of namespace mln::fun
+ // pw::cst(t)
template <typename T>
- fun::val_<T> val(T t)
+ cst_<T> cst(T t)
{
- fun::val_<T> tmp(t);
+ cst_<T> tmp(t);
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_VAL_HH
+#endif // ! MLN_PW_CST_HH
Index: mln/pw/value.hh
--- mln/pw/value.hh (revision 0)
+++ mln/pw/value.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_PW_VALUE_HH
-# define MLN_FUN_PW_VALUE_HH
+#ifndef MLN_PW_VALUE_HH
+# define MLN_PW_VALUE_HH
-/*! \file mln/fun/pw_value.hh
+/*! \file mln/fun/pw/value.hh
*
* \brief FIXME.
*/
@@ -42,19 +42,7 @@
namespace mln
{
- // Fwd decl.
- namespace fun { template <typename I> struct pw_value; }
-
-
-
- // FIXME: Doc!
-
- template <typename I>
- fun::pw_value<I> pw_value(const Image<I>& ima);
-
-
-
- namespace fun
+ namespace pw
{
// FIXME: Move!
@@ -70,16 +58,16 @@
struct select_function_< value::binary_kind, E > : Function_p2b<E>
{};
- } // end of namespace mln::fun::internal
+ } // end of namespace mln::pw::internal
// FIXME: Doc!
template <typename I>
- struct pw_value : public internal::select_function_< mln_value_kind(I), pw_value<I> >
+ struct value_ : public internal::select_function_< mln_value_kind(I), value_<I> >
{
typedef mln_value(I) result;
- pw_value(const I& ima);
+ value_(const I& ima);
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
protected:
const I& ima_;
@@ -87,44 +75,47 @@
+ // FIXME: Doc!
+
+ template <typename I>
+ value_<I> value(const Image<I>& ima);
+
+
+
# ifndef MLN_INCLUDE_ONLY
- // fun::pw_value<I>
+ // pw::value_<I>
template <typename I>
- pw_value<I>::pw_value(const I& ima)
+ value_<I>::value_(const I& ima)
: ima_(ima)
{
}
template <typename I>
mln_rvalue(I)
- pw_value<I>::operator()(const mln_psite(I)& p) const
+ value_<I>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_.owns_(p));
return ima_(p);
}
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::fun
-
-# ifndef MLN_INCLUDE_ONLY
-
- // pw_value
+ // pw::value(ima)
template <typename I>
- fun::pw_value<I>
- pw_value(const Image<I>& ima)
+ value_<I>
+ value(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- fun::pw_value<I> tmp(exact(ima));
+ value_<I> tmp(exact(ima));
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::pw
+
} // end of namespace mln
-#endif // ! MLN_FUN_PW_VALUE_HH
+#endif // ! MLN_PW_VALUE_HH
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1030)
+++ mln/core/concept/image.hh (working copy)
@@ -134,6 +134,10 @@
m6 = 0;
lvalue (E::*m7)(const psite& p) = & E::operator();
m7 = 0;
+
+ typedef mln_vset(E) vset;
+ const vset& (E::*m8)() const = & E::values;
+ m8 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/iterator.hh
--- mln/core/concept/iterator.hh (revision 1030)
+++ mln/core/concept/iterator.hh (working copy)
@@ -40,6 +40,12 @@
# define for_all(x) for(x.start(); x.is_valid(); x.next())
+/*! \brief Loop to browse all the elements targetted by the couples of
+ * iterators \p x1 and \p x2.
+ */
+# define for_all_2(x1, x2) for(x1.start(),x2.start(); x1.is_valid(); x1.next(),x2.next())
+
+
/*! \brief Loop to browse all the remaining elements targetted by the
* iterator \p x.
*/
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 0)
+++ mln/border/resize.hh (revision 0)
@@ -0,0 +1,81 @@
+// Copyright (C) 2007 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_BORDER_RESIZE_HH
+# define MLN_BORDER_RESIZE_HH
+
+/*! \file mln/border/resize.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Resize the virtual (outer) border of image \p ima to at least
+ * \p thickness.
+ *
+ * \param[in,out] ima The image whose border is to be resized.
+ * \param[in] thickness The expected minimum border size.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \warning If the image border already has a size greater than \p
+ * thickness, this routine is a no-op.
+ *
+ * \todo Implement it.
+ */
+ template <typename I>
+ void resize(const Fast_Image<I>& ima, unsigned thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void resize(const Fast_Image<I>& ima_, unsigned thickness)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ if (ima.border() >= thickness)
+ return;
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_RESIZE_HH
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 0)
+++ mln/border/fill.hh (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (C) 2007 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_BORDER_FILL_HH
+# define MLN_BORDER_FILL_HH
+
+/*! \file mln/border/fill.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Fill the virtual (outer) border of image \p ima with the
+ * single value \p v.
+ *
+ * \param[in,out] ima The image whose border is to be filled.
+ * \param[in] v The value to assign to all border pixels.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memset if possible.
+ */
+ template <typename I>
+ void fill(const Fast_Image<I>& ima, const mln_value(I)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void fill(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_FILL_HH
Index: mln/border/all.hh
--- mln/border/all.hh (revision 0)
+++ mln/border/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 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_BORDER_ALL_HH
+# define MLN_BORDER_ALL_HH
+
+/*! \file mln/border/all.hh
+ *
+ * \brief File that includes all border-related routines.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace of routines related to image virtual (outer) border.
+ */
+ namespace border {}
+
+}
+
+
+# include <mln/border/duplicate.hh>
+# include <mln/border/fill.hh>
+# include <mln/border/mirror.hh>
+# include <mln/border/resize.hh>
+# include <mln/border/thickness.hh>
+
+
+#endif // ! MLN_BORDER_ALL_HH
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 0)
+++ mln/border/duplicate.hh (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 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_BORDER_DUPLICATE_HH
+# define MLN_BORDER_DUPLICATE_HH
+
+/*! \file mln/border/duplicate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Assign the virtual (outer) border of image \p ima with the
+ * dupplicate of the inner border of this image.
+ *
+ * \param[in,out] ima The image whose border is to be duplicated.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memcpy if possible.
+ */
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_DUPLICATE_HH
Index: mln/border/mirror.hh
--- mln/border/mirror.hh (revision 0)
+++ mln/border/mirror.hh (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 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_BORDER_MIRROR_HH
+# define MLN_BORDER_MIRROR_HH
+
+/*! \file mln/border/mirror.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Mirror the virtual (outer) border of image \p ima with the
+ * (inner) level contents of this image.
+ *
+ * \param[in,out] ima The image whose border is to be mirrored.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memset if possible.
+ */
+ template <typename I>
+ void mirror(const Fast_Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void mirror(const Fast_Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima_.has_data());
+ mln_invariant(0); // FIXME: NYI
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_MIRROR_HH
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Clean up stc/scoop.hxx a bit.
* stc/scoop.hxx: Add a copyright header.
Typos.
Re-indent some parts.
(helper_check): Fix documentation.
Actually use check_final_stm and check_delegatee_inherited as
described in the documentation.
(helper_find): Add some documentation.
scoop.hxx | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 53 insertions(+), 12 deletions(-)
Index: static/stc/scoop.hxx
--- static/stc/scoop.hxx (revision 1027)
+++ static/stc/scoop.hxx (working copy)
@@ -1,3 +1,29 @@
+// Copyright (C) 2005, 2006, 2007 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.
/* \file oln/stc/scoop.hxx
\brief To be included within a namespace to import SCOOP 2 equipment. */
@@ -102,7 +128,8 @@
/*
- FIXME: Inactivate since dummy code (many class are not Abstractions but abstraction<Exact>).
+ FIXME: Inactivate since dummy code (many class are not Abstractions
+ but abstraction<Exact>).
template <template <class> class abstraction, typename Exact>
struct super_trait_< abstraction<Exact> >
@@ -241,7 +268,7 @@
* Returns the statement for class 'from' corresponding to 'target'.
* This statement is either defined in 'vtypes' or in 'single_vtype'.
*
- * This routine is local; it does not recourse on superior classes.
+ * This routine is local; it does not recur on superior classes.
*
*/
@@ -308,7 +335,8 @@
};
template <typename orig, typename target, typename stm>
- struct check_no_final_inherited <orig, /* if curr == */ mlc::none, target, stm>
+ struct check_no_final_inherited <orig, /* if curr == */ mlc::none,
+ target, stm>
{
};
@@ -342,7 +370,7 @@
* check_delegatee_inherited
*/
- template <typename curr, typename target>
+ template <typename curr>
struct check_delegatee_inherited
: mlc::assert_< stc::is_found< typename first_stm<curr,
typedef_::delegatee>::ret::second_elt >,
@@ -422,7 +450,7 @@
* super = super(curr);
*
* if (stm == stc::abstract) {
- * check_no_stm_inherited(curr, super, target);
+ * check_no_stm_inherited((curr, abstract), super, target);
* return check(super, target);
* }
* if (stm == stc::final<T>) {
@@ -463,10 +491,8 @@
: check_no_final_inherited< mlc::pair_<curr, stc::final<T> >,
stc_super(curr),
target >
+ , check_final_stm< curr, target, T >
{
- /* FIXME:
- check_final_stm(T);
- */
typedef typename check<stc_super(curr), target>::ret ret;
};
@@ -476,10 +502,8 @@
: check_no_final_inherited< mlc::pair_<curr, stc::not_delegated>,
stc_super(curr),
target >
+ , check_delegatee_inherited< curr >
{
- /* FIXME:
- check_delegatee_inherited(curr);
- */
typedef typename check<stc_super(curr), target>::ret ret;
};
@@ -662,6 +686,7 @@
*
* delegator_find(from, target)
* {
+ * // FIXME: This precondition is not actually enforced in the algorithm.
* precondition(target != delegatee);
* delegatee = superior_find(from, delegatee);
* if (delegatee == mlc::not_found)
@@ -696,8 +721,23 @@
/*
* helper_find(from, target, where, res)
*
+ * FIXME: ...
*
- *
+ * helper_find(from, target, where, res)
+ * {
+ * if (res == mlc::not_found)
+ * return delegator_find(from, target)
+ * else if (res = stc::abstract)
+ * {
+ * res_d = delegator_find(source, target)
+ * assert(res_d != mlc::not_found,
+ * "<target> declared <where> but not defined at <from>")
+ * }
+ * else if (res = stc::not_delegated)
+ * return superior_find(from, target)
+ * else
+ * return res
+ * }
*/
template <typename from, typename target, typename where>
@@ -712,6 +752,7 @@
/* if res == */ stc::abstract >
{
typedef typename delegator_find<from, target>::ret res_d;
+ // FIXME: Might be shorten using mlc::assert_and_return_.
struct check_
: mlc::assert_< stc::is_found<res_d>,
ERROR::vtype_declared_but_not_defined