https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update image2d with new image properties.
* doc/tutorial/examples/image2d.cc: New.
* mln/trait/image/props.hh (localization): Fix missing types.
(space_from_point): Update.
* mln/trait/image/print.hh: Fix missing brackets.
* mln/trait/images.hh: Update macros.
(mln_trait_image_io_from_): Update.
(mln_trait_image_data_from_): Remove; obsolete.
* mln/core/macros.hh (mln_dpsite, mln_dpsite_): New.
* mln/core/internal/image_base.hh
(dpoint, coord, bbox): Remove cause not general.
(owns_): Remove; it is obsolete/replaced by 'has'.
* mln/core/internal/check/image_fastest.hh
(offset_at): Return std::size_t; now accept more types for
the p argument.
(image_fastest_): Update ctor.
* mln/core/concept/image.hh: Layout doc.
(mln_point, point): Rename as...
(mln_site, site): ...these.
(coord, dpoint): Remove; obsolete.
* mln/core/image2d.hh: Likewise.
(image_): Update traits.
(owns_): Rename as...
(has): ...this.
doc/tutorial/examples/image2d.cc | 10 ++++
mln/core/concept/image.hh | 66 +++++++++++++------------------
mln/core/image2d.hh | 45 +++++++++++++--------
mln/core/internal/check/image_fastest.hh | 24 +++++------
mln/core/internal/image_base.hh | 24 -----------
mln/core/macros.hh | 6 ++
mln/trait/image/print.hh | 30 +++++++-------
mln/trait/image/props.hh | 13 ++++--
mln/trait/images.hh | 53 +++++++-----------------
9 files changed, 128 insertions(+), 143 deletions(-)
Index: doc/tutorial/examples/image2d.cc
--- doc/tutorial/examples/image2d.cc (revision 0)
+++ doc/tutorial/examples/image2d.cc (revision 0)
@@ -0,0 +1,10 @@
+# include <mln/core/image2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<char> ima(2, 3);
+ mln_invariant(ima.nsites() == 6);
+}
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 2010)
+++ mln/trait/image/props.hh (working copy)
@@ -379,8 +379,15 @@
struct none : any { std::string name() const { return "localization::none"; }
};
struct space : any { std::string name() const { return "localization::space";
} };
struct grid : space { protected: grid() {} };
+ struct isotropic_grid
+ : grid { std::string name() const { return "localization::isotropic_grid"; }
};
+ struct basic_grid
+ : isotropic_grid { std::string name() const { return
"localization::basic_grid"; } };
+ struct anisotropic_grid
+ : grid { std::string name() const { return "localization::anisotropic_grid";
} };
};
+
// dimension: /any/
// |
// + -- none
@@ -566,15 +573,15 @@
template <>
struct space_from_point<point1d>
- { typedef trait::image::space::one_d ret; };
+ { typedef trait::image::dimension::one_d ret; };
template <>
struct space_from_point<point2d>
- { typedef trait::image::space::two_d ret; };
+ { typedef trait::image::dimension::two_d ret; };
template <>
struct space_from_point<point3d>
- { typedef trait::image::space::three_d ret; };
+ { typedef trait::image::dimension::three_d ret; };
/// \}
} // end of namespace mln::trait::image
Index: mln/trait/image/print.hh
--- mln/trait/image/print.hh (revision 2010)
+++ mln/trait/image/print.hh (working copy)
@@ -68,21 +68,21 @@
mlc_is_a(I, Image)::check();
typedef mln::trait::image_<I> the;
ostr << "{ "
- << typename the::category.name() << ", "
- << typename the::speed.name() << ", "
- << typename the::size.name() << ", "
- << typename the::value_access.name() << ", "
- << typename the::value_storage.name() << ", "
- << typename the::value_browsing.name() << ", "
- << typename the::value_io.name() << ", "
- << typename the::localization.name() << ", "
- << typename the::dimension.name() << ", "
- << typename the::ext_domain.name() << ", "
- << typename the::ext_value.name() << ", "
- << typename the::ext_io.name() << ", "
- << typename the::kind.name() << ", "
- << typename the::nature.name() << ", "
- << typename the::quant.name() << " }" << std::endl;
+ << typename the::category().name() << ", "
+ << typename the::speed().name() << ", "
+ << typename the::size().name() << ", "
+ << typename the::value_access().name() << ", "
+ << typename the::value_storage().name() << ", "
+ << typename the::value_browsing().name() << ", "
+ << typename the::value_io().name() << ", "
+ << typename the::localization().name() << ", "
+ << typename the::dimension().name() << ", "
+ << typename the::ext_domain().name() << ", "
+ << typename the::ext_value().name() << ", "
+ << typename the::ext_io().name() << ", "
+ << typename the::kind().name() << ", "
+ << typename the::nature().name() << ", "
+ << typename the::quant().name() << " }" << std::endl;
}
template <typename I>
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 2010)
+++ mln/trait/images.hh (working copy)
@@ -47,52 +47,33 @@
# include <mln/metal/if.hh>
# include <mln/metal/is_const.hh>
-// category
-// speed
-// size
-// value_access
-// value_storage
-// value_browsing
-// value_io
-// localization
-// dimension
-// ext_domain
-// ext_value
-// ext_io
-// kind
-// nature
-// quant
+
# define mln_trait_image_category(I) typename mln::trait::image_< I >::category
+# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
+# define mln_trait_image_size(I) typename mln::trait::image_< I >::size
+
+# define mln_trait_image_value_access(I) typename mln::trait::image_< I
>::value_access
+# define mln_trait_image_value_storage(I) typename mln::trait::image_< I
>::value_storage
+# define mln_trait_image_value_browsing(I) typename mln::trait::image_< I
>::value_browsing
+# define mln_trait_image_value_io(I) typename mln::trait::image_< I
>::value_io
+
+# define mln_trait_image_localization(I) typename mln::trait::image_< I
>::localization
+# define mln_trait_image_dimension(I) typename mln::trait::image_< I
>::dimension
+
+# define mln_trait_image_ext_domain(I) typename mln::trait::image_< I
>::ext_domain
+# define mln_trait_image_ext_value(I) typename mln::trait::image_< I >::ext_value
+# define mln_trait_image_ext_io(I) typename mln::trait::image_< I >::ext_io
# define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind
+# define mln_trait_image_nature(I) typename mln::trait::image_< I >::nature
# define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant
-# define mln_trait_image_value(I) typename mln::trait::image_< I >::value
-
-# define mln_trait_image_access(I) typename mln::trait::image_< I >::access
-# define mln_trait_image_space(I) typename mln::trait::image_< I >::space
-# define mln_trait_image_size(I) typename mln::trait::image_< I >::size
-# define mln_trait_image_support(I) typename mln::trait::image_< I >::support
-
-# define mln_trait_image_border(I) typename mln::trait::image_< I >::border
-# define mln_trait_image_neighb(I) typename mln::trait::image_< I >::neighb
-# define mln_trait_image_data(I) typename mln::trait::image_< I >::data
-# define mln_trait_image_io(I) typename mln::trait::image_< I >::io
-# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
// for io: I const => read_only, otherwise like I
# define mln_trait_image_io_from_(I) \
-mlc_if( mlc_is_const(I), mln::trait::image::io::read_only, mln_trait_image_io(I) )
+mlc_if( mlc_is_const(I), mln::trait::image::value_io::read_only,
mln_trait_image_value_io(I) )
-// for data: if raw or linear => stored, otherwise like I (i.e., either stored or
computed)
-#define mln_trait_image_data_from_(I) typename \
-mln::metal::if_< mln::metal::or_< mlc_equal( mln_trait_image_data(I), \
- mln::trait::image::data::raw), \
- mlc_equal( mln_trait_image_data(I), \
- mln::trait::image::data::linear) >, \
- mln::trait::image::data::stored, \
- mln_trait_image_data(I) >::ret
namespace mln
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2010)
+++ mln/core/macros.hh (working copy)
@@ -94,6 +94,12 @@
# define mln_dpoint_(T) T::dpoint
/// \}
+/// Shortcuts to access the dpsite type associated to T.
+/// \{
+# define mln_dpsite(T) typename T::dpsite
+# define mln_dpsite_(T) T::dpsite
+/// \}
+
// e
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 2010)
+++ mln/core/internal/image_base.hh (working copy)
@@ -106,13 +106,6 @@
/// Point associated type.
typedef mln_site(S) site;
- /// Dpoint associated type.
- typedef mln_dpoint(site) dpoint;
-
- /// Coordinate associated type.
- typedef mln_coord(site) coord;
-
-
/// Forward Site_Iterator associated type.
typedef mln_fwd_piter(S) fwd_piter;
@@ -123,12 +116,6 @@
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
- // FIXME: Keep this default (owns_ is based on has)?
- bool owns_(const psite& p) const;
-
- /// Give a bounding box of the image domain.
- const box_<site>& bbox() const;
-
/// Give the number of sites of the image domain.
std::size_t nsites() const;
@@ -208,18 +195,11 @@
template <typename S, typename E>
inline
- bool
- image_base_<S,E>::owns_(const psite& p) const
- {
- mln_precondition(exact(this)->has_data());
- return exact(this)->has(p);
- }
-
- template <typename S, typename E>
- inline
std::size_t
image_base_<S,E>::nsites() const
{
+ mlc_equal(mln_trait_site_set_nsites(S),
+ mln::trait::site_set::nsites::known)::check();
mln_precondition(exact(this)->has_data());
return exact(this)->domain().nsites();
}
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 2010)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -32,6 +32,8 @@
*
* \brief Class that statically checks the interface of fastest
* images.
+ *
+ * \todo Check and convert p in offset_at towards E::psite.
*/
# include <mln/core/internal/force_exact.hh>
@@ -52,9 +54,9 @@
struct image_fastest_
{
- /*! \brief Give the offset of the point \p p.
+ /*! \brief Give the offset of the site \p p.
*
- * \param[in] p A generalized point.
+ * \param[in] p A site.
*
* \warning This method is final.
*
@@ -62,8 +64,8 @@
* \post p == point_at_offset(result)
*/
template <typename P>
- unsigned
- offset_at(const Point_Site<P>& p) const;
+ std::size_t
+ offset_at(const P& p) const;
protected:
image_fastest_();
@@ -84,15 +86,15 @@
inline
image_fastest_<E,B>::image_fastest_()
{
- typedef mln_point(E) point;
- typedef mln_dpoint(E) dpoint;
+ typedef mln_site(E) site;
+ typedef mln_dpsite(E) dpsite;
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
- int (E::*m1)(const dpoint&) const = & E::offset;
+ int (E::*m1)(const dpsite&) const = & E::offset;
m1 = 0;
- point (E::*m2)(unsigned) const = & E::point_at_offset;
+ site (E::*m2)(unsigned) const = & E::point_at_offset;
m2 = 0;
unsigned (E::*m3)() const = & E::border;
m3 = 0;
@@ -121,12 +123,10 @@
template <typename E, typename B>
template <typename P>
inline
- unsigned // FIXME: std::size_t?
- image_fastest_<E,B>::offset_at(const Point_Site<P>& p_) const
+ std::size_t
+ image_fastest_<E,B>::offset_at(const P& p) const
{
- // FIXME: check that P is mln_point(E)
const E* this_ = & internal::force_exact<E>(*this);
- const P& p = exact(p_);
mln_precondition(this_->has_data());
mln_precondition(this_->owns_(p));
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2010)
+++ mln/core/concept/image.hh (working copy)
@@ -73,42 +73,35 @@
typedef Image<void> category;
/*
- // to be provided in concrete image classes:
-
- typedef mesh;
-
- typedef value;
- typedef rvalue;
- typedef lvalue;
- typedef vset;
-
- const vset& values() const;
-
- bool owns_(const psite& p) const;
- const pset& domain() const;
-
- rvalue operator()(const psite& p) const;
- lvalue operator()(const psite& p);
-
- typedef skeleton;
-
-
// provided by internal::image_base_:
typedef pset;
- typedef point;
+ typedef site;
typedef psite;
- typedef coord;
- typedef dpoint;
-
typedef fwd_piter;
typedef bkd_piter;
bool has(const psite& p) const;
- std::size_t nsites() const;
+ std::size_t nsites() const; // If relevant.
bool has_data() const;
+
+ // to be provided in concrete image classes:
+
+ typedef value;
+
+ typedef vset;
+ const vset& values() const;
+
+ typedef rvalue;
+ typedef lvalue;
+ rvalue operator()(const psite& p) const;
+ lvalue operator()(const psite& p);
+
+ const pset& domain() const;
+
+ typedef skeleton;
*/
protected:
@@ -125,17 +118,18 @@
// provided by internal::image_base_:
typedef mln_pset(E) pset;
- typedef mln_point(E) point;
+ typedef mln_site(E) site;
typedef mln_psite(E) psite;
- typedef mln_coord(E) coord;
- typedef mln_dpoint(E) dpoint;
-
typedef mln_fwd_piter(E) fwd_piter;
typedef mln_bkd_piter(E) bkd_piter;
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
+ std::size_t (E::*m2)() const = & E::nsites;
+ m2 = 0;
+ bool (E::*m3)() const = & E::has_data;
+ m3 = 0;
// to be provided in concrete image classes:
@@ -143,13 +137,8 @@
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
- typedef typename E::skeleton skeleton;
-
- bool (E::*m3)() const = & E::has_data;
- m3 = 0;
- bool (E::*m4)(const psite& p) const = & E::owns_;
- m4 = 0;
- const pset& (E::*m5)() const = & E::domain;
+ typedef mln_vset(E) vset;
+ const vset& (E::*m5)() const = & E::values;
m5 = 0;
rvalue (E::*m6)(const psite& p) const = & E::operator();
@@ -157,9 +146,10 @@
lvalue (E::*m7)(const psite& p) = & E::operator();
m7 = 0;
- typedef mln_vset(E) vset;
- const vset& (E::*m8)() const = & E::values;
+ const pset& (E::*m8)() const = & E::domain;
m8 = 0;
+
+ typedef typename E::skeleton skeleton;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image2d.hh
--- mln/core/image2d.hh (revision 2010)
+++ mln/core/image2d.hh (working copy)
@@ -88,17 +88,25 @@
template <typename T>
struct image_< image2d<T> > : default_image_< T, image2d<T>
>
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::access::random access;
- typedef trait::image::space::two_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::two_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
@@ -116,12 +124,15 @@
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
+
typedef point2d psite;
- typedef point2d point;
- typedef dpoint2d dpoint;
+ typedef point2d site;
+ typedef dpoint2d dpsite;
+
typedef mln_fwd_piter(box2d) fwd_piter;
typedef mln_bkd_piter(box2d) bkd_piter;
- typedef line_piter_<point> line_piter;
+
+ typedef line_piter_<point2d> line_piter;
// End of warning.
@@ -160,7 +171,7 @@
/// Test if \p p is valid.
- bool owns_(const point2d& p) const;
+ bool has(const point2d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -422,7 +433,7 @@
template <typename T>
inline
bool
- image2d<T>::owns_(const point2d& p) const
+ image2d<T>::has(const point2d& p) const
{
mln_precondition(this->has_data());
return this->data_->vb_.has(p);
@@ -433,7 +444,7 @@
const T&
image2d<T>::operator()(const point2d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.row()][p.col()];
}
@@ -442,7 +453,7 @@
T&
image2d<T>::operator()(const point2d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.row()][p.col()];
}
@@ -469,7 +480,7 @@
const T&
image2d<T>::at(int row, int col) const
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
return this->data_->array_[row][col];
}
@@ -478,7 +489,7 @@
T&
image2d<T>::at(int row, int col)
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
return this->data_->array_[row][col];
}