Commit 3e355fbd authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Update site set concepts and generic box.

	* mln/trait/site_set/print.hh (ostr): Add default.
	* mln/core/macros.hh (mln_site, mln_site_): New.
	* mln/core/internal/point_set_base.hh
	(mesh, dpoint): Remove.
	(point): Rename as...
	(site): ...this.
	Update.
	* mln/core/box.hh: Likewise.
	(trait::site_set_): New.
	* mln/core/concept/box.hh (point): Rename as...
	(site): ...this.
	* mln/core/concept/point_set.hh: Likewise.
	Remove npoints and bbox from comments.
	(point_set): Add props check in ctor.
	(operator==, operator <=): Remove test over npoints.
	(operator <): Rely on != instead of npoints.
	* mln/core/concept/doc/box.hh (point): Rename as...
	(site): ...this.
	* mln/core/concept/doc/point_set.hh: Likewise.
	(bbox, npoints): Remove.
	* tests/core/box2d.cc: Add print props test.
	
	* mln/core/pset_array.hh,
	* mln/core/p_priority_queue_fast.hh,
	* mln/core/p_priority_queue_fast_with_array.hh,
	* mln/core/p_queue_fast.hh,
	* mln/core/p_image2d.hh,
	* mln/core/p_line_graph.hh,
	* mln/core/p_queue.hh,
	* mln/core/p_graph.hh,
	* mln/core/p_priority_queue.hh,
	* mln/core/p_set.hh,
	* mln/core/line2d.hh,
	* mln/core/p_bgraph.hh,
	* mln/core/p_run.hh,
	* mln/core/pset_if.hh,
	* mln/core/p_array.hh,
	* mln/core/p_runs.hh (point_set_base_): Rename as...
	(site_set_base_): ...this.
	
	* mln/metal/not_equal.hh: New.
	* mln/metal/all.hh: Include not_equal.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008@1951 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 73876aa4
2008-05-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Update site set concepts and generic box.
* mln/trait/site_set/print.hh (ostr): Add default.
* mln/core/macros.hh (mln_site, mln_site_): New.
* mln/core/internal/point_set_base.hh
(mesh, dpoint): Remove.
(point): Rename as...
(site): ...this.
Update.
* mln/core/box.hh: Likewise.
(trait::site_set_): New.
* mln/core/concept/box.hh (point): Rename as...
(site): ...this.
* mln/core/concept/point_set.hh: Likewise.
Remove npoints and bbox from comments.
(point_set): Add props check in ctor.
(operator==, operator <=): Remove test over npoints.
(operator <): Rely on != instead of npoints.
* mln/core/concept/doc/box.hh (point): Rename as...
(site): ...this.
* mln/core/concept/doc/point_set.hh: Likewise.
(bbox, npoints): Remove.
* tests/core/box2d.cc: Add print props test.
* mln/core/pset_array.hh,
* mln/core/p_priority_queue_fast.hh,
* mln/core/p_priority_queue_fast_with_array.hh,
* mln/core/p_queue_fast.hh,
* mln/core/p_image2d.hh,
* mln/core/p_line_graph.hh,
* mln/core/p_queue.hh,
* mln/core/p_graph.hh,
* mln/core/p_priority_queue.hh,
* mln/core/p_set.hh,
* mln/core/line2d.hh,
* mln/core/p_bgraph.hh,
* mln/core/p_run.hh,
* mln/core/pset_if.hh,
* mln/core/p_array.hh,
* mln/core/p_runs.hh (point_set_base_): Rename as...
(site_set_base_): ...this.
* mln/metal/not_equal.hh: New.
* mln/metal/all.hh: Include not_equal.
2008-05-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Rename Point_Set as Site_Set.
......
......@@ -42,12 +42,29 @@
namespace mln
{
// fwd decl
// Fwd decls.
template <typename P> struct box_;
template <typename P> struct box_fwd_piter_;
template <typename P> struct box_bkd_piter_;
/*! \brief Generic box class.
namespace trait
{
template <typename P>
struct site_set_< box_<P> >
{
typedef trait::site_set::nsites::known nsites;
typedef trait::site_set::bbox::straight bbox;
typedef trait::site_set::contents::fixed contents;
typedef trait::site_set::arity::unique arity;
};
} // end of namespace trait
/*! \brief Generic box class: site set containing points of a
* regular grid.
*
* Parameter \c P is the corresponding type of point.
*/
......@@ -58,22 +75,16 @@ namespace mln
/// Dimension.
enum { dim = P::dim };
/// Mesh associated type.
typedef mln_mesh(P) mesh;
/// Point_Site associated type.
/// PSite associated type.
typedef P psite;
/// Point associated type.
typedef P point;
/// Dpoint associated type.
typedef mln_dpoint(P) dpoint;
/// Site associated type.
typedef P site;
/// Forward Point_Iterator associated type.
/// Forward Site_Iterator associated type.
typedef box_fwd_piter_<P> fwd_piter;
/// Backward Point_Iterator associated type.
/// Backward Site_Iterator associated type.
typedef box_bkd_piter_<P> bkd_piter;
/// Minimum point.
......@@ -92,7 +103,7 @@ namespace mln
box_();
/// Constructor of a box going from \p pmin to \p pmax.
box_(const point& pmin, const point& pmax);
box_(const site& pmin, const site& pmax);
/// \{ Constructors with different numbers of arguments
/// (sizes) w.r.t. the dimension.
......@@ -173,7 +184,7 @@ namespace mln
template <typename P>
inline
box_<P>::box_(const point& pmin, const point& pmax)
box_<P>::box_(const site& pmin, const site& pmax)
: pmin_(pmin),
pmax_(pmax)
{
......
// 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
......@@ -29,6 +29,7 @@
# define MLN_CORE_CONCEPT_BOX_HH
/*! \file mln/core/concept/box.hh
*
* \brief Definition of the concept of mln::Box.
*/
......@@ -40,8 +41,8 @@ namespace mln
/*! \brief Base class for implementation classes of boxes.
*
* Boxes are particular point sets useful to bound any set of
* points.
* Boxes are particular site sets useful to bound any set of
* sites defined on a regular grid.
*
* \see mln::doc::Box for a complete documentation of this class
* contents.
......@@ -50,35 +51,35 @@ namespace mln
struct Box : public Site_Set<E>
{
/*
const point& pmin() const;
const point& pmax() const;
const site& pmin() const;
const site& pmax() const;
*/
/*! \brief Give the length of the \p i-th side of the box.
*
* \pre i < point::dim
* \pre i < site::dim
*
* \warning This method is final for all box classes.
*/
unsigned len(unsigned i) const;
/*! \brief Give the bounding box of this point set.
/*! \brief Give the bounding box of this site set.
*
* Return the bounding box of this point set, so that is itself.
* Return the bounding box of this site set, so that is itself.
* This method is declared by the mln::Site_Set concept.
*
* \warning This method is final for all box classes.
*/
const E& bbox() const;
/*! \brief Give the number of points of this box.
/*! \brief Give the number of sites of this box.
*
* Return the number of points of this box. This method is
* Return the number of sites of this box. This method is
* declared by the mln::Site_Set concept.
*
* \warning This method is final for all box classes.
*/
std::size_t npoints() const;
std::size_t nsites() const;
protected:
Box();
......@@ -144,20 +145,20 @@ namespace mln
inline
Box<E>::Box()
{
typedef mln_point(E) point;
point (E::*m1)() const = & E::pmin;
typedef mln_site(E) site;
site (E::*m1)() const = & E::pmin;
m1 = 0;
point (E::*m2)() const = & E::pmax;
site (E::*m2)() const = & E::pmax;
m2 = 0;
}
template <typename E>
inline
std::size_t
Box<E>::npoints() const
Box<E>::nsites() const
{
std::size_t count = 1;
typedef mln_point(E) P; // helps g++-3.3.5
typedef mln_site(E) P; // helps g++-3.3.5
for (unsigned i = 0; i < P::dim; ++i)
count *= exact(this)->len(i);
return count;
......@@ -183,7 +184,7 @@ namespace mln
// FIXME: Same grid!
const Bl& lhs = exact(lhs_);
const Br& rhs = exact(rhs_);
typedef mln_point(Bl) P;
typedef mln_site(Bl) P;
for (unsigned i = 0; i < P::dim; ++i)
if (lhs.pmin()[i] < rhs.pmin()[i] ||
lhs.pmax()[i] > rhs.pmax()[i])
......
// 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
......@@ -26,6 +26,7 @@
// Public License.
/*! \file mln/core/concept/doc/box.hh
*
* \brief This file documents the concept of mln::Box.
*/
......@@ -47,7 +48,7 @@ namespace mln
* For instance, with mln::box2d, this minimum is the top left
* point of the box.
*/
const point& pmin() const;
const site& pmin() const;
/*! \brief Give the box "maximum" point.
*
......@@ -55,7 +56,7 @@ namespace mln
* For instance, with mln::box2d, this maximum is the bottom
* right point of the box.
*/
const point& pmax() const;
const site& pmax() const;
/*! \brief Return the bounding box of this point set.
*
......@@ -73,7 +74,7 @@ namespace mln
*
* \warning This method is final for all box classes.
*/
std::size_t npoints() const;
std::size_t nsites() const;
};
} // end of namespace mln::doc
......
......@@ -42,36 +42,28 @@ namespace mln
template <typename E>
struct Site_Set : public Object<E>
{
/*! \brief Point associated type.
/*! \brief Site associated type.
*/
typedef void point;
typedef void site;
/*! \brief Point_Site associated type.
/*! \brief PSite associated type.
*/
typedef void psite;
/*! \brief Forward Point_Iterator associated type.
/*! \brief Forward Site_Iterator associated type.
*/
typedef void fwd_piter;
/*! \brief Backward Point_Iterator associated type.
/*! \brief Backward Site_Iterator associated type.
*/
typedef void bkd_piter;
/*! \brief Test if \p p belongs to this point set.
/*! \brief Test if \p p belongs to this site set.
*
* \param[in] p A point site.
* \return True if \p p is an element of the point set.
* \param[in] p A psite.
* \return True if \p p is an element of the site set.
*/
bool has(const psite& p) const;
/*! \brief Give the bounding box of this point set.
*/
const box_<point>& bbox() const;
/*! \brief Give the number of points of this point set.
*/
std::size_t npoints() const;
};
} // end of namespace mln::doc
......
......@@ -32,14 +32,13 @@
*
* \brief Definition of the concept of mln::Site_Set.
*
* \todo Think about adding an 'insert' method (not so easy because of
* pset_if...)
*
* \todo Move out the ops.
*/
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/point_iterator.hh>
# include <mln/trait/site_sets.hh>
# include <mln/metal/not_equal.hh>
namespace mln
......@@ -57,7 +56,7 @@ namespace mln
};
/*! \brief Base class for implementation classes of point sets.
/*! \brief Base class for implementation classes of site sets.
*
* \see mln::doc::Site_Set for a complete documentation of this
* class contents.
......@@ -68,19 +67,13 @@ namespace mln
typedef Site_Set<void> category;
/*
typedef mesh;
typedef point;
typedef site;
typedef psite;
typedef fwd_piter;
typedef bkd_piter;
bool has(const psite& p) const;
std::size_t npoints() const;
// FIXME: No longer required (at least, not this way).
const box_<point>& bbox() const;
*/
protected:
......@@ -88,10 +81,10 @@ namespace mln
};
/*! \brief Equality test between point sets \p lhs and \p rhs.
/*! \brief Equality test between site sets \p lhs and \p rhs.
*
* \param[in] lhs A point set.
* \param[in] rhs Another point set.
* \param[in] lhs A site set.
* \param[in] rhs Another site set.
*
* \relates mln::Site_Set
*/
......@@ -100,10 +93,10 @@ namespace mln
/*! \brief Inclusion test between point sets \p lhs and \p rhs.
/*! \brief Inclusion test between site sets \p lhs and \p rhs.
*
* \param[in] lhs A point set (included?).
* \param[in] rhs Another point set (includer?).
* \param[in] lhs A site set (included?).
* \param[in] rhs Another site set (includer?).
*
* \relates mln::Site_Set
*/
......@@ -112,11 +105,11 @@ namespace mln
/*! \brief Strict inclusion test between point sets \p lhs and \p
/*! \brief Strict inclusion test between site sets \p lhs and \p
* rhs.
*
* \param[in] lhs A point set (strictly included?).
* \param[in] rhs Another point set (includer?).
* \param[in] lhs A site set (strictly included?).
* \param[in] rhs Another site set (includer?).
*
* \relates mln::Site_Set
*/
......@@ -125,18 +118,18 @@ namespace mln
/*! \brief Print a point set \p pset into the output stream \p
/*! \brief Print a site set \p set into the output stream \p
* ostr.
*
* \param[in,out] ostr An output stream.
* \param[in] pset A point set.
* \param[in] set A site set.
*
* \return The modified output stream \p ostr.
*
* \relates mln::Site_Set
*/
template <typename S>
std::ostream& operator<<(std::ostream& ostr, const Site_Set<S>& pset);
std::ostream& operator<<(std::ostream& ostr, const Site_Set<S>& set);
......@@ -149,21 +142,21 @@ namespace mln
inline
Site_Set<E>::Site_Set()
{
typedef mln_mesh(E) mesh;
typedef mln_point(E) point;
// Check properties.
mlc_not_equal( mln_trait_site_set_nsites(E), mln::trait::undef )::check();
mlc_not_equal( mln_trait_site_set_bbox(E), mln::trait::undef )::check();
mlc_not_equal( mln_trait_site_set_contents(E), mln::trait::undef )::check();
mlc_not_equal( mln_trait_site_set_arity(E), mln::trait::undef )::check();
// Check associated types.
typedef mln_site(E) site;
typedef mln_psite(E) psite;
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;
// FIXME: No longer required (at least, not this way).
// const box_<point>& (E::*m2)() const = & E::bbox;
// m2 = 0;
std::size_t (E::*m3)() const = & E::npoints;
m3 = 0;
// Check methods.
bool (E::*m)(const psite& p) const = & E::has;
m = 0;
}
......@@ -178,10 +171,6 @@ namespace mln
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
// easy test:
if (lhs.npoints() != rhs.npoints())
return false;
// exhaustive test:
mln_fwd_piter(Sl) pl(lhs);
mln_fwd_piter(Sr) pr(rhs);
......@@ -205,10 +194,6 @@ namespace mln
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
// easy test:
if (lhs.npoints() > rhs.npoints())
return false;
// exhaustive test:
mln_piter(Sl) pl(lhs);
for_all(pl)
......@@ -226,17 +211,17 @@ namespace mln
// FIXME: Same grid!
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
return lhs <= rhs && lhs.npoints() != rhs.npoints();
return lhs <= rhs && lhs != rhs;
}
template <typename S>
inline
std::ostream& operator<<(std::ostream& ostr, const Site_Set<S>& pset_)
std::ostream& operator<<(std::ostream& ostr, const Site_Set<S>& set_)
{
const S& pset = exact(pset_);
const S& set = exact(set_);
ostr << '{';
mln_piter(S) p(pset);
mln_piter(S) p(set);
for_all(p)
ostr << p;
return ostr << '}';
......
......@@ -30,7 +30,7 @@
/*! \file mln/core/internal/point_set_base.hh
*
* \brief Definition of a base class for point set classes.
* \brief Definition of a base class for site set classes.
*/
# include <mln/core/concept/point_set.hh>
......@@ -43,26 +43,20 @@ namespace mln
namespace internal
{
/*! \internal A base class for point set classes.
* \p P is a point site type.
/*! \internal A base class for site set classes.
* \p P is a psite type.
*/
template <typename P, typename E>
struct point_set_base_ : public Site_Set<E>
struct site_set_base_ : public Site_Set<E>
{
/// Point_Site associated type.
/// PSite associated type.
typedef P psite;
/// Mesh associated type.
typedef mln_mesh(P) mesh;
/// Point associated type.
typedef mln_point(P) point;
/// Dpoint associated type.
typedef mln_dpoint(point) dpoint;
/// Site associated type.
typedef mln_site(P) site;
protected:
point_set_base_();
site_set_base_();
};
......@@ -70,7 +64,7 @@ namespace mln
template <typename S, typename E>
inline
point_set_base_<S,E>::point_set_base_()
site_set_base_<S,E>::site_set_base_()
{
}
......
......@@ -47,7 +47,7 @@ namespace mln
/*! \brief 2D line point set class.
*/
class line2d : public internal::point_set_base_< point2d, line2d >
class line2d : public internal::site_set_base_< point2d, line2d >
{
public:
......
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -242,6 +243,15 @@
/// \}
// s
/// Shortcuts to access the site type associated to T.
/// \{
# define mln_site(T) typename T::site
# define mln_site_(T) T::site
/// \}
// v
/// Shortcuts to access the value type associated to T.
......
......@@ -57,7 +57,7 @@ namespace mln
* \todo Make it work with P being a Point_Site.
*/
template <typename P>
class p_array : public internal::point_set_base_< P, p_array<P> >
class p_array : public internal::site_set_base_< P, p_array<P> >
{
public:
/// The associated psite type.
......
......@@ -49,7 +49,7 @@ namespace mln
template<typename P>
struct p_bgraph
: public internal::point_set_base_< graph_psite<P>, p_bgraph<P> >
: public internal::site_set_base_< graph_psite<P>, p_bgraph<P> >
{
typedef util::internal::boost_graph<P, util::empty> graph;
......
......@@ -47,7 +47,7 @@ namespace mln
template<typename P>
struct p_graph
: public internal::point_set_base_< graph_psite<P>, p_graph<P> >
: public internal::site_set_base_< graph_psite<P>, p_graph<P> >
{
typedef util::graph<P> graph;
......
......@@ -55,7 +55,7 @@ namespace mln
template <typename P> struct p_image2d_bkd_piter_;
template <typename P>
class p_image2d : public internal::point_set_base_<P, p_image2d<P> >
class p_image2d : public internal::site_set_base_<P, p_image2d<P> >
{
public:
......
......@@ -53,7 +53,7 @@ namespace mln
template<typename P>
struct p_line_graph
: public internal::point_set_base_< line_graph_psite<P>, p_line_graph<P> >