https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Parametrize histo::data by value types, Repair image1d.
* tests/core/other/pixter1d.cc,
* tests/core/image/image1d.cc: Replace npoints method by nsites.
* mln/histo/compute.spe.hh,
* mln/histo/compute.hh,
* tests/histo/compute.cc,
* tests/histo/to_image1d.cc: Change the histo::data parameter
* mln/histo/data.hh: Update data parameter.
* mln/core/site_set/p_line_graph_piter.hh: Fix compile errors.
* mln/core/image/image1d.hh: Repair image1d.
* mln/core/image/image3d.hh: Fix compile errors.
* mln/core/internal/check/image_fastest.hh: .
* mln/core/alias/dpoint1d.hh,
* mln/core/alias/dpoint3d.hh: Fix the dpoints coordinates type.
* mln/core/alias/point1d.hh,
* mln/core/alias/point3d.hh: Add specialization for subject_impl.
* mln/core/alias/point2d.hh: delete trailing whitespaces.
* mln/pw/image.hh,
* mln/value/stack.hh: Remove the values method.
* mln/convert/to_image.hh,
* mln/morpho/erosion.hh: Adapt to the histo::data changes.
mln/convert/to_image.hh | 6 -
mln/core/alias/dpoint1d.hh | 3
mln/core/alias/dpoint3d.hh | 4
mln/core/alias/point1d.hh | 95 ++++++++++++++++++
mln/core/alias/point3d.hh | 157 ++++++++++++++++++++++++++++++-
mln/core/image/image1d.hh | 75 +++++++-------
mln/core/image/image3d.hh | 26 +++--
mln/core/internal/check/image_fastest.hh | 2
mln/core/site_set/p_line_graph_piter.hh | 8 -
mln/histo/compute.hh | 12 +-
mln/histo/compute.spe.hh | 10 -
mln/histo/data.hh | 62 ++++++------
mln/pw/image.hh | 15 --
mln/value/stack.hh | 14 --
tests/core/image/image1d.cc | 6 -
tests/core/other/pixter1d.cc | 4
tests/histo/compute.cc | 6 -
tests/histo/to_image1d.cc | 4
18 files changed, 369 insertions(+), 140 deletions(-)
Index: tests/histo/compute.cc
--- tests/histo/compute.cc (revision 2208)
+++ tests/histo/compute.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -68,7 +68,7 @@
debug::iota(ima);
ima.at(0,0) = 2;
- histo::data< value::set<int_u8> > h = histo::compute(ima);
+ histo::data<int_u8> h = histo::compute(ima);
std::ostringstream oss;
oss << h;
mln_assertion(oss.str() == "2:2 3:1 4:1 5:1 6:1 7:1 8:1 9:1 ");
@@ -84,7 +84,7 @@
image2d<int_s5> ima(3, 3);
debug::iota(ima);
- histo::data< value::set<int_s5> > h = histo::compute(ima);
+ histo::data<int_s5> h = histo::compute(ima);
mln_assertion(h.vset().nvalues() == 31);
for (unsigned i = 0; i <= 15; ++i) // values from -15 to 0
Index: tests/histo/to_image1d.cc
--- tests/histo/to_image1d.cc (revision 2208)
+++ tests/histo/to_image1d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -68,7 +68,7 @@
debug::iota(ima);
ima(make::point2d(0,1)) = 255;
debug::println(ima);
- histo::data< value::set<int_u8> > h = histo::compute(ima);
+ histo::data<int_u8> h = histo::compute(ima);
std::cout << h << std::endl;
image1d<std::size_t> ima2 = convert::to_image(h);
Index: tests/core/other/pixter1d.cc
--- tests/core/other/pixter1d.cc (revision 2208)
+++ tests/core/other/pixter1d.cc (working copy)
@@ -64,7 +64,7 @@
p.next();
++i;
}
- mln_assertion(i == b.npoints());
+ mln_assertion(i == b.nsites());
}
{
@@ -80,7 +80,7 @@
p.next();
++i;
}
- mln_assertion(i == b.npoints());
+ mln_assertion(i == b.nsites());
}
}
}
Index: tests/core/image/image1d.cc
--- tests/core/image/image1d.cc (revision 2208)
+++ tests/core/image/image1d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,6 +43,6 @@
image1d<int> f(ninds, border);
- mln_assertion(f.npoints() == ninds);
- mln_assertion(f.ncells() == (ninds + 2 * border));
+ mln_assertion(f.nsites() == ninds);
+ mln_assertion(f.nelements() == (ninds + 2 * border));
}
Index: mln/histo/compute.spe.hh
--- mln/histo/compute.spe.hh (revision 2208)
+++ mln/histo/compute.spe.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -52,12 +52,12 @@
namespace generic
{
template <typename I>
- data<mln_vset(I)> compute_(const I& input);
+ data<mln_value(I)> compute_(const I& input);
}
template <typename I>
inline
- data<mln_vset(I)>
+ data<mln_value(I)>
compute_(trait::image::speed::any, const I& input)
{
return generic::compute_(input);
@@ -65,10 +65,10 @@
template <typename I>
inline
- data<mln_vset(I)>
+ data<mln_value(I)>
compute_(trait::image::speed::fastest, const I& input)
{
- data<mln_vset(I)> h(input.values());
+ data<mln_value(I)> h;
mln_pixter(const I) p(input);
for_all(p)
++h(p.val());
Index: mln/histo/data.hh
--- mln/histo/data.hh (revision 2208)
+++ mln/histo/data.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -36,7 +36,7 @@
# include <vector>
# include <algorithm>
-# include <mln/core/concept/value_set.hh>
+# include <mln/value/set.hh>
namespace mln
@@ -46,101 +46,101 @@
{
- /*! Generic histogram class over a value set with type \c S.
+ /*! Generic histogram class over a value set with type \c T.
*/
- template <typename S>
+ template <typename T>
struct data
{
- typedef mln_value(S) value;
+ typedef T value;
- data(const Value_Set<S>& s);
+ data();
void clear();
- std::size_t operator()(const value& v) const;
- std::size_t& operator()(const value& v);
+ std::size_t operator()(const T& v) const;
+ std::size_t& operator()(const T& v);
const std::vector<std::size_t>& vect() const;
- const S& vset() const;
+ const mln::value::set<T>& vset() const;
std::size_t operator[](unsigned i) const;
protected:
- const S& s_;
+ const mln::value::set<T>& s_;
std::vector<std::size_t> h_;
};
- template <typename S>
- std::ostream& operator<<(std::ostream& ostr, const data<S>&
h);
+ template <typename T>
+ std::ostream& operator<<(std::ostream& ostr, const data<T>&
h);
# ifndef MLN_INCLUDE_ONLY
- template <typename S>
+ template <typename T>
inline
- data<S>::data(const Value_Set<S>& s)
- : s_(exact(s)),
+ data<T>::data()
+ : s_(mln::value::set<T>::the()),
h_(s_.nvalues(), 0)
{
clear();
}
- template <typename S>
+ template <typename T>
inline
void
- data<S>::clear()
+ data<T>::clear()
{
std::fill(h_.begin(), h_.end(), 0);
}
- template <typename S>
+ template <typename T>
inline
std::size_t
- data<S>::operator()(const value& v) const
+ data<T>::operator()(const T& v) const
{
return h_[s_.index_of(v)];
}
- template <typename S>
+ template <typename T>
inline
std::size_t&
- data<S>::operator()(const value& v)
+ data<T>::operator()(const T& v)
{
return h_[s_.index_of(v)];
}
- template <typename S>
+ template <typename T>
inline
- const S&
- data<S>::vset() const
+ const mln::value::set<T>&
+ data<T>::vset() const
{
return s_;
}
- template <typename S>
+ template <typename T>
inline
std::size_t
- data<S>::operator[](unsigned i) const
+ data<T>::operator[](unsigned i) const
{
mln_precondition(i < s_.nvalues());
return h_[i];
}
- template <typename S>
+ template <typename T>
inline
const std::vector<std::size_t>&
- data<S>::vect() const
+ data<T>::vect() const
{
return h_;
}
- template <typename S>
+ template <typename T>
inline
- std::ostream& operator<<(std::ostream& ostr, const data<S>&
h)
+ std::ostream& operator<<(std::ostream& ostr, const data<T>&
h)
{
- mln_viter(S) v(h.vset());
+ mln_viter(mln::value::set<T>) v(h.vset());
for_all(v)
if (h(v) != 0)
ostr << v << ':' << h(v) << ' ';
Index: mln/histo/compute.hh
--- mln/histo/compute.hh (revision 2208)
+++ mln/histo/compute.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -49,7 +49,7 @@
/// Compute the histogram of image \p input.
template <typename I>
- data<mln_vset(I)> compute(const Image<I>& input);
+ data<mln_value(I)> compute(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
@@ -62,9 +62,9 @@
template <typename I>
inline
- data<mln_vset(I)> compute_(const I& input)
+ data<mln_value(I)> compute_(const I& input)
{
- data<mln_vset(I)> h(input.values());
+ data<mln_value(I)> h;
mln_piter(I) p(input.domain());
for_all(p)
++h(input(p));
@@ -78,13 +78,13 @@
template <typename I>
inline
- data<mln_vset(I)> compute(const Image<I>& input)
+ data<mln_value(I)> compute(const Image<I>& input)
{
trace::entering("histo::compute");
mlc_equal(mln_trait_image_quant(I), mln::trait::image::quant::low)::check();
mln_precondition(exact(input).has_data());
- data<mln_vset(I)> h = impl::compute_(mln_trait_image_speed(I)(),
+ data<mln_value(I)> h = impl::compute_(mln_trait_image_speed(I)(),
exact(input));
trace::exiting("histo::compute");
Index: mln/core/site_set/p_line_graph_piter.hh
--- mln/core/site_set/p_line_graph_piter.hh (revision 2208)
+++ mln/core/site_set/p_line_graph_piter.hh (working copy)
@@ -49,10 +49,10 @@
/// \brief Forward iterator on point sites of a mln::p_line_graph<P>.
template <typename P>
class p_line_graph_fwd_piter_
- : public internal::site_iterator_base_< P, p_line_graph_fwd_piter_<P> >
+ : public internal::site_iterator_base< P, p_line_graph_fwd_piter_<P> >
{
typedef p_line_graph_fwd_piter_<P> self_;
- typedef internal::site_iterator_base_< P, self_ > super_;
+ typedef internal::site_iterator_base< P, self_ > super_;
public:
// Make definitions from super class available.
@@ -129,10 +129,10 @@
/// \brief Backward iterator on point sites of a mln::p_line_graph<P>.
template <typename P>
class p_line_graph_bkd_piter_
- : public internal::site_iterator_base_< P, p_line_graph_bkd_piter_<P> >
+ : public internal::site_iterator_base< P, p_line_graph_bkd_piter_<P> >
{
typedef p_line_graph_bkd_piter_<P> self_;
- typedef internal::site_iterator_base_< P, self_ > super_;
+ typedef internal::site_iterator_base< P, self_ > super_;
public:
// Make definitions from super class available.
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2208)
+++ mln/core/image/image1d.hh (working copy)
@@ -169,9 +169,6 @@
/// Give the border thickness.
unsigned border() const;
- /// Give the number of cells (points including border ones).
- std::size_t ncells() const;
-
/// Read-only access to the image value located at point \p p.
const T& operator()(const point1d& p) const;
@@ -179,16 +176,10 @@
T& operator()(const point1d& p);
/// Read-only access to the image value located at offset \p o.
- const T& operator[](unsigned o) const;
+ const T& operator[](unsigned i) const;
/// Read-write access to the image value located at offset \p o.
- T& operator[](unsigned o);
-
- /// Read-only access to the image value located at (\p ind).
- const T& at(int ind) const;
-
- /// Read-write access to the image value located at (\p ind).
- T& at(int ind);
+ T& operator[](unsigned i);
/// Fast Image method
@@ -197,10 +188,10 @@
using super_::index_of_point;
/// Give the offset corresponding to the delta-point \p dp.
- int offset(const dpoint1d& dp) const;
+ int delta_index(const dpoint1d& dp) const;
/// Give the point corresponding to the offset \p o.
- point1d point_at_offset(unsigned o) const;
+ point1d point_at_index(unsigned i) const;
/// Give a hook to the value buffer.
const T* buffer() const;
@@ -208,6 +199,16 @@
/// Give a hook to the value buffer.
T* buffer();
+ /// Read-only access to the image value located at (\p ind).
+ const T& element(unsigned ind) const;
+
+ /// Read-write access to the image value located at (\p ind).
+ T& element(unsigned ind);
+
+ /// Give the number of cells (points including border ones).
+ std::size_t nelements() const;
+
+
/// Resize image border with new_border.
void resize_(unsigned new_border);
@@ -358,7 +359,7 @@
image1d<T>::domain() const
{
mln_precondition(this->has_data());
- return this->data->b_;
+ return this->data_->b_;
}
template <typename T>
@@ -367,7 +368,7 @@
image1d<T>::bbox() const
{
mln_precondition(this->has_data());
- return this->data->b_;
+ return this->data_->b_;
}
template <typename T>
@@ -376,16 +377,16 @@
image1d<T>::border() const
{
mln_precondition(this->has_data());
- return this->data->bdr_;
+ return this->data_->bdr_;
}
template <typename T>
inline
std::size_t
- image1d<T>::ncells() const
+ image1d<T>::nelements() const
{
mln_precondition(this->has_data());
- return this->data->vb_.npoints();
+ return this->data_->vb_.nsites();
}
template <typename T>
@@ -394,7 +395,7 @@
image1d<T>::has(const point1d& p) const
{
mln_precondition(this->has_data());
- return this->data->vb_.has(p);
+ return this->data_->vb_.has(p);
}
template <typename T>
@@ -403,7 +404,7 @@
image1d<T>::operator()(const point1d& p) const
{
mln_precondition(this->has(p));
- return this->data->array_[p.ind()];
+ return this->data_->array_[p.ind()];
}
template <typename T>
@@ -412,7 +413,7 @@
image1d<T>::operator()(const point1d& p)
{
mln_precondition(this->has(p));
- return this->data->array_[p.ind()];
+ return this->data_->array_[p.ind()];
}
template <typename T>
@@ -420,8 +421,8 @@
const T&
image1d<T>::operator[](unsigned o) const
{
- mln_precondition(o < ncells());
- return *(this->data->buffer_ + o);
+ mln_precondition(o < nelements());
+ return *(this->data_->buffer_ + o);
}
template <typename T>
@@ -429,26 +430,26 @@
T&
image1d<T>::operator[](unsigned o)
{
- mln_precondition(o < ncells());
- return *(this->data->buffer_ + o);
+ mln_precondition(o < nelements());
+ return *(this->data_->buffer_ + o);
}
template <typename T>
inline
const T&
- image1d<T>::at(int ind) const
+ image1d<T>::element(unsigned ind) const
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data->array_[ind];
+ return this->data_->array_[ind];
}
template <typename T>
inline
T&
- image1d<T>::at(int ind)
+ image1d<T>::element(unsigned ind)
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data->array_[ind];
+ return this->data_->array_[ind];
}
template <typename T>
@@ -457,7 +458,7 @@
image1d<T>::buffer() const
{
mln_precondition(this->has_data());
- return this->data->buffer_;
+ return this->data_->buffer_;
}
template <typename T>
@@ -466,13 +467,13 @@
image1d<T>::buffer()
{
mln_precondition(this->has_data());
- return this->data->buffer_;
+ return this->data_->buffer_;
}
template <typename T>
inline
int
- image1d<T>::offset(const dpoint1d& dp) const
+ image1d<T>::delta_index(const dpoint1d& dp) const
{
mln_precondition(this->has_data());
int o = dp[0];
@@ -482,11 +483,11 @@
template <typename T>
inline
point1d
- image1d<T>::point_at_offset(unsigned o) const
+ image1d<T>::point_at_index(unsigned i) const
{
- mln_precondition(o < ncells());
- point1d p = make::point1d(o + this->data->vb_.min_ind());
- mln_postcondition(& this->operator()(p) == this->data->buffer_ + o);
+ mln_precondition(i < nelements());
+ point1d p = make::point1d(i + this->data_->vb_.min_ind());
+ mln_postcondition(& this->operator()(p) == this->data_->buffer_ + i);
return p;
}
@@ -495,7 +496,7 @@
void
image1d<T>::resize_(unsigned new_border)
{
- this->data->reallocate_(new_border);
+ this->data_->reallocate_(new_border);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2208)
+++ mln/core/image/image3d.hh (working copy)
@@ -89,17 +89,25 @@
template <typename T>
struct image_< image3d<T> > : default_image_< T, image3d<T>
>
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::access::random access;
- typedef trait::image::space::three_d space;
+ typedef trait::image::speed::fastest speed;
typedef trait::image::size::regular size;
- typedef trait::image::support::aligned support;
- typedef trait::image::border::stored border;
- typedef trait::image::data::raw data;
- typedef trait::image::io::read_write io;
- typedef trait::image::speed::fastest speed;
+ // value
+ typedef trait::image::value_access::direct value_access;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_write value_io;
+
+ // site / domain
+ typedef trait::image::localization::basic_grid localization;
+ typedef trait::image::dimension::three_d dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::extendable ext_domain;
+ typedef trait::image::ext_value::multiple ext_value;
+ typedef trait::image::ext_io::read_write ext_io;
};
} // end of namespace mln::trait
@@ -127,7 +135,7 @@
/// Super type
- typedef internal::image_primary< box3d, image3d<T> > super_;
+ typedef internal::image_primary< T, box3d, image3d<T> > super_;
/// Value associated type.
typedef T value;
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 2208)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -38,7 +38,6 @@
# include <mln/core/internal/force_exact.hh>
-
namespace mln
{
@@ -90,6 +89,7 @@
typedef mln_psite(E) psite;
typedef mln_delta(psite) dpsite;
+
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
Index: mln/core/alias/dpoint1d.hh
--- mln/core/alias/dpoint1d.hh (revision 2208)
+++ mln/core/alias/dpoint1d.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/dpoint.hh>
# include <mln/core/grids.hh>
+# include <mln/core/def/coord.hh>
namespace mln
@@ -44,7 +45,7 @@
/*! \brief Type alias for a delta-point defined on the 1D square
* grid with integer coordinates.
*/
- typedef dpoint<mln::grid::tick, int> dpoint1d;
+ typedef dpoint<mln::grid::tick, def::coord> dpoint1d;
} // end of namespace mln
Index: mln/core/alias/dpoint3d.hh
--- mln/core/alias/dpoint3d.hh (revision 2208)
+++ mln/core/alias/dpoint3d.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/dpoint.hh>
# include <mln/core/grids.hh>
-
+# include <mln/core/def/coord.hh>
namespace mln
{
@@ -44,7 +44,7 @@
/*! \brief Type alias for a delta-point defined on the 3D square
* grid with integer coordinates.
*/
- typedef dpoint<mln::grid::cube, int> dpoint3d;
+ typedef dpoint<mln::grid::cube, def::coord> dpoint3d;
} // end of namespace mln
Index: mln/core/alias/point1d.hh
--- mln/core/alias/point1d.hh (revision 2208)
+++ mln/core/alias/point1d.hh (working copy)
@@ -35,7 +35,9 @@
*/
# include <mln/core/point.hh>
-
+// For site_const_impl and site_mutable_impl.
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/core/internal/force_exact.hh>
namespace mln
{
@@ -45,6 +47,97 @@
*/
typedef point<grid::tick, def::coord> point1d;
+ namespace internal
+ {
+
+ // Specialization.
+
+ template <typename C, typename E>
+ struct subject_impl< const point<grid::tick, C>, E >
+ {
+ typedef C coord;
+ enum { dim = 1 };
+
+ typedef const C& row_t;
+ const C& row() const;
+
+ const C& operator[](unsigned i) const;
+ const C& last_coord() const;
+ private:
+ const E& exact_() const;
+ };
+
+
+ // Specialization for point<M,C>.
+
+ template <typename C, typename E>
+ struct subject_impl< point<grid::tick, C>, E > :
+ subject_impl< const point<grid::tick, C>, E >
+ {
+ private:
+ typedef subject_impl< const point<grid::tick, C>, E > super_;
+ E& exact_();
+ public:
+ using super_::row;
+ C& row();
+ using super_::operator[];
+ C& operator[](unsigned i);
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::tick, C>, E >::row() const
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::tick, C>, E >::operator[](unsigned i)
const
+ {
+ mln_precondition(i < 1);
+ return exact_().get_subject()[i];
+ }
+
+ template <typename C, typename E>
+ inline
+ const E&
+ subject_impl< const point<grid::tick, C>, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::tick, C>, E >::row()
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::tick, C>, E >::operator[](unsigned i)
+ {
+ mln_precondition(i < 2);
+ return exact_().get_subject()[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
} // end of namespace mln
Index: mln/core/alias/point2d.hh
Index: mln/core/alias/point3d.hh
--- mln/core/alias/point3d.hh (revision 2208)
+++ mln/core/alias/point3d.hh (working copy)
@@ -35,7 +35,9 @@
*/
# include <mln/core/point.hh>
-
+// For site_const_impl and site_mutable_impl:
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/core/internal/force_exact.hh>
namespace mln
{
@@ -45,6 +47,159 @@
*/
typedef point<grid::cube, def::coord> point3d;
+ namespace internal
+ {
+
+ // Specialization.
+
+ template <typename C, typename E>
+ struct subject_impl< const point<grid::cube, C>, E >
+ {
+ typedef C coord;
+ enum { dim = 3 };
+
+ typedef const C& row_t;
+ const C& row() const;
+
+ typedef const C& col_t;
+ const C& col() const;
+
+ typedef const C& sli_t;
+ const C& sli() const;
+
+ const C& operator[](unsigned i) const;
+ const C& last_coord() const;
+ private:
+ const E& exact_() const;
+ };
+
+
+ // Specialization for point<M,C>.
+
+ template <typename C, typename E>
+ struct subject_impl< point<grid::cube, C>, E > :
+ subject_impl< const point<grid::cube, C>, E >
+ {
+ private:
+ typedef subject_impl< const point<grid::cube, C>, E > super_;
+ E& exact_();
+ public:
+
+ using super_::row;
+ C& row();
+
+ using super_::col;
+ C& col();
+
+ using super_::sli;
+ C& sli();
+
+ using super_::operator[];
+ C& operator[](unsigned i);
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::row() const
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::col() const
+ {
+ return exact_().get_subject().col();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::sli() const
+ {
+ return exact_().get_subject().sli();
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::operator[](unsigned i)
const
+ {
+ mln_precondition(i < 3);
+ return exact_().get_subject()[i];
+ }
+
+ template <typename C, typename E>
+ inline
+ const C&
+ subject_impl< const point<grid::cube, C>, E >::last_coord() const
+ {
+ return this->col();
+ }
+
+ template <typename C, typename E>
+ inline
+ const E&
+ subject_impl< const point<grid::cube, C>, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ // subject_impl
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::row()
+ {
+ return exact_().get_subject().row();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::col()
+ {
+ return exact_().get_subject().col();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::sli()
+ {
+ return exact_().get_subject().sli();
+ }
+
+ template <typename C, typename E>
+ inline
+ C&
+ subject_impl< point<grid::cube, C>, E >::operator[](unsigned i)
+ {
+ mln_precondition(i < 3);
+ return exact_().get_subject()[i];
+ }
+
+ template <typename C, typename E>
+ inline
+ E&
+ subject_impl< point<grid::cube, C>, E >::exact_()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
} // end of namespace mln
Index: mln/value/stack.hh
--- mln/value/stack.hh (revision 2208)
+++ mln/value/stack.hh (working copy)
@@ -166,9 +166,6 @@
/// Return type of read-write access.
typedef typename internal::helper_stack_image_lvalue_<n,I>::ret lvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
/// Skeleton.
typedef stack_image< n, tag::image_<I> > skeleton;
@@ -191,9 +188,6 @@
/// Read-write access of pixel value at point site \p p.
lvalue operator()(const psite&);
void write_(const psite& p, const value& v);
-
- /// Give the set of values of the image.
- const vset& values() const;
};
@@ -296,14 +290,6 @@
return internal::helper_stack_image_lvalue_<n,I>::make(*this, p);
}
- template <unsigned n, typename I>
- inline
- const mln::value::set< algebra::vec<n, mln_value(I)> >&
- stack_image<n,I>::values() const
- {
- return vset::the();
- }
-
// stack(..)
template <typename I>
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 2208)
+++ mln/convert/to_image.hh (working copy)
@@ -187,11 +187,11 @@
return ima;
}
- template <typename S>
+ template <typename T>
inline
- image1d<std::size_t> to_image(const histo::data<S>& h)
+ image1d<std::size_t> to_image(const histo::data<T>& h)
{
- mln_value(S)
+ mln_value(histo::data<T>)
v_min = h.vset()[0],
v_max = h.vset()[h.vset().nvalues() - 1];
image1d<std::size_t> ima(make::box1d(v_min, v_max));
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 2208)
+++ mln/pw/image.hh (working copy)
@@ -130,10 +130,6 @@
/// Return type of read-write access.
typedef void lvalue; // FIXME
- /// Value set associated type.
- typedef mln::value::set<mln_result(F)> vset;
-
-
/// Constructor without argument.
image();
@@ -150,9 +146,6 @@
/// Read-write access is present but disabled.
void operator()(const mln_psite(S)&);
-
- /// Give the set of values of the image.
- const vset& values() const;
};
} // end of namespace mln::pw
@@ -230,14 +223,6 @@
mln_invariant(0); // FIXME: Turn into a compile-time error...
}
- template <typename F, typename S>
- inline
- const mln::value::set<mln_result(F)>&
- image<F,S>::values() const
- {
- return vset::the();
- }
-
} // end of namespace mln::pw
# endif // ! MLN_INCLUDE_ONLY
Index: mln/morpho/erosion.hh