Commit 3814dc0f authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-09-26 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add mapimage type and update.
	
	* oln/core/gen/mapimage.hh: New.
	* oln/automatic/image_being_random_accessible.hh: New.
	* oln/core/abstract/topology_having_bbox.hh
	(bbox): New; mutable version.
	* oln/core/abstract/image.hh (has): Remove; this method
	is now specific to a sub-abstraction.
	* oln/core/abstract/image/mutability/hierarchy.hh
	(lvalue_t, psite_t): Update.
	(~image_being_mutable): Fix typo.
	(using): New; it allows disambiguation of overloading
	thru inheritance.
	* oln/core/abstract/image/accessibility/hierarchy.hh
	(has, has_large): Update.
	(include): Update.
	* oln/core/abstract/image/bbox/hierarchy.hh
	(bbox_t, point_t): Update.
	(bbox): Change return signature.
	(pmin, pmax): New.
	* oln/core/gen/topo_bbox.hh (impl_bbox): New.
	* oln/Makefile.am (nobase_oln_HEADERS): Update.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@575 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent e6708a33
2006-09-26 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add mapimage type and update.
* oln/core/gen/mapimage.hh: New.
* oln/automatic/image_being_random_accessible.hh: New.
* oln/core/abstract/topology_having_bbox.hh
(bbox): New; mutable version.
* oln/core/abstract/image.hh (has): Remove; this method
is now specific to a sub-abstraction.
* oln/core/abstract/image/mutability/hierarchy.hh
(lvalue_t, psite_t): Update.
(~image_being_mutable): Fix typo.
(using): New; it allows disambiguation of overloading
thru inheritance.
* oln/core/abstract/image/accessibility/hierarchy.hh
(has, has_large): Update.
(include): Update.
* oln/core/abstract/image/bbox/hierarchy.hh
(bbox_t, point_t): Update.
(bbox): Change return signature.
(pmin, pmax): New.
* oln/core/gen/topo_bbox.hh (impl_bbox): New.
* oln/Makefile.am (nobase_oln_HEADERS): Update.
2006-09-26 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add some abstract image sub-hierarchies.
......
......@@ -5,6 +5,9 @@ olndir = $(includedir)/oln
nobase_oln_HEADERS = \
\
automatic/image.hh \
automatic/image_being_mutable.hh \
automatic/image_being_random_accessible.hh \
automatic/image_having_neighborhood.hh \
automatic/image_having_neighborhood.hh \
automatic/topology_being_random_accessible.hh \
automatic/topology_having_bbox.hh \
......@@ -30,11 +33,14 @@ nobase_oln_HEADERS = \
core/abstract/entry.hh \
core/abstract/grid.hh \
core/abstract/image.hh \
core/abstract/image/accessibility/hierarchy.hh \
core/abstract/image/bbox/hierarchy.hh \
core/abstract/image/dimension/1d.hh \
core/abstract/image/dimension/2d.hh \
core/abstract/image/dimension/3d.hh \
core/abstract/image/dimension/hierarchy.hh \
core/abstract/image/hierarchies.hh \
core/abstract/image/mutability/hierarchy.hh \
core/abstract/image/neighborhood/hierarchy.hh \
core/abstract/image/type/binary.hh \
core/abstract/image/type/color.hh \
......@@ -62,9 +68,13 @@ nobase_oln_HEADERS = \
core/gen/bbox.hh \
core/gen/bbox_bkd_piter.hh \
core/gen/bbox_fwd_piter.hh \
core/gen/bkd_piter_bbox.hh \
core/gen/fwd_piter_bbox.hh \
core/gen/mapimage.hh \
core/gen/neighb.hh \
core/gen/topo_add_nbh.hh \
core/gen/topo_bbox.hh \
core/gen/topo_lbbox.hh \
\
core/internal/bbox_bkd_piter.hh \
core/internal/bbox_fwd_piter.hh \
......
// Copyright (C) 2006 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 OLENA_AUTOMATIC_IMAGE_BEING_RANDOM_ACCESSIBLE_HH
# define OLENA_AUTOMATIC_IMAGE_BEING_RANDOM_ACCESSIBLE_HH
# include <oln/core/typedefs.hh>
# include <oln/morpher/tags.hh>
namespace oln
{
// Forward declaration.
namespace abstract
{
template <typename E> class image_being_random_accessible;
} // end of namespace oln::abstract
namespace automatic
{
/// Default implementation corresponding to the interface
/// oln::abstract::image_being_random_accessible.
template <typename E, typename M>
class impl< abstract::image_being_random_accessible, M, E> :
public virtual stc::any__simple<E>
{
private:
typedef oln_type_of(E, point) point_t;
public:
bool impl_has(const point_t& p) const
{
return this->exact().topo().has(p);
}
bool impl_has_large(const point_t& p) const
{
return this->exact().has(p);
}
};
/// Implementation corresponding to the interface
/// oln::abstract::image_being_random_accessible for an identity morpher.
template <typename E>
class impl< abstract::image_being_random_accessible, morpher::tag::identity, E> :
public virtual stc::any__simple<E>
{
private:
typedef oln_type_of(E, point) point_t;
public:
bool impl_has(const point_t& p) const
{
return this->exact().delegate().has(p);
}
bool impl_has_large(const point_t& p) const
{
return this->exact().delegate().has_large(p);
}
};
} // end of namespace oln::automatic
} // end of namespace oln
#endif // ! OLENA_AUTOMATIC_IMAGE_BEING_RANDOM_ACCESSIBLE_HH
......@@ -123,23 +123,6 @@ namespace oln
return this->exact().impl_op_read(p);
}
/*! \brief Test if the point \a p belongs to the current image.
** Please note that a point of the outer boundary of an image
** does NOT belong to the image.
**
** \return True if p belongs to the current image, false otherwise.
**
** \see hold_large
*/
bool has(const psite_t& p) const
{
return this->exact().impl_has(p);
}
// FIXME: has should *not* be defined for all image classes.
protected:
/*! \brief Constructor (protected, empty).
......
......@@ -29,6 +29,7 @@
# define OLENA_CORE_ABSTRACT_IMAGE_ACCESSIBILITY_HIERARCHY_HH
# include <oln/core/abstract/image.hh>
# include <oln/automatic/image_being_random_accessible.hh>
......@@ -52,16 +53,16 @@ namespace oln
public:
// Concrete method.
// Abstract method.
bool has(const point_t& p) const
{
return this->topo().has(p);
return this->exact().impl_has(p);
}
// Concrete method.
// Abstract method.
bool has_large(const point_t& p) const
{
return this->topo().has_large(p);
return this->exact().impl_has_large(p);
}
protected:
......
......@@ -48,7 +48,9 @@ namespace oln
public automatic::impl< image_having_bbox, oln_type_of(E, morpher), E >
{
private:
typedef oln_type_of(E, bbox) bbox_t;
typedef oln_check_type_of(E, bbox) bbox_t;
typedef oln_check_type_of(E, point) point_t;
public:
......@@ -57,11 +59,23 @@ namespace oln
};
// Concrete method.
bbox_t bbox() const
const bbox_t& bbox() const
{
return this->topo().bbox();
}
// Concrete method.
const point_t& pmin() const
{
return this->topo().bbox().pmin();
}
// Concrete method.
const point_t& pmax() const
{
return this->topo().bbox().pmax();
}
protected:
/// Constructor (protected, empty).
......
......@@ -53,8 +53,8 @@ namespace oln
{
private:
typedef oln_type_of(E, lvalue) lvalue_t;
typedef oln_type_of(E, psite) psite_t;
typedef oln_check_type_of(E, lvalue) lvalue_t;
typedef oln_check_type_of(E, psite) psite_t;
public:
......@@ -66,7 +66,9 @@ namespace oln
** the current image.
*/
lvalue_t& operator()(const psite_t& p) const
using image<E>::operator();
lvalue_t& operator()(const psite_t& p)
{
return this->exact().impl_op_readwrite(p);
}
......@@ -77,7 +79,7 @@ namespace oln
image_being_mutable() {}
/// Destructor (protected).
image_being_mutable() { decl(); }
~image_being_mutable() { decl(); }
};
......
......@@ -56,6 +56,12 @@ namespace oln
return this->exact().impl_bbox();
}
// abstract
bbox_t& bbox()
{
return this->exact().impl_bbox();
}
// concrete
operator bbox_t() const
{
......
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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 OLENA_CORE_GEN_MAPIMAGE_HH
# define OLENA_CORE_GEN_MAPIMAGE_HH
# include <oln/core/image_entry.hh>
# include <oln/core/gen/topo_bbox.hh>
# include <map>
namespace oln
{
// Forward declaration.
template <typename point_t, typename value_t> class mapimage;
/// Virtual types associated to oln::mapimage<>.
template <typename point_t, typename value_t>
struct vtypes< mapimage<point_t, value_t> >
{
typedef topo_bbox_<point_t> topo_type;
typedef oln_type_of(point_t, grid) grid_type;
typedef point_t point_type;
typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
typedef value_t value_type;
typedef mlc::true_ is_mutable_type;
typedef value_t lvalue_type;
typedef void real_type; // FIXME
};
/// Super type declaration.
template <typename point_t, typename value_t>
struct set_super_type< mapimage<point_t, value_t> >
{
typedef mapimage<point_t, value_t> self_t;
typedef image_entry<self_t> ret;
};
/// General 2D image class.
template <typename point_t, typename value_t>
class mapimage : public image_entry< mapimage<point_t, value_t> >
{
typedef mapimage<point_t, value_t> self_t;
typedef oln_type_of(self_t, topo) topo_t;
public:
/// Ctor.
mapimage(const value_t& val)
: val_(val)
{
}
const topo_t& impl_topo() const
{
return topo_;
}
value_t impl_op_read(const point_t& p) const
{
if (not has(p))
return val_;
return data_[p];
}
value_t& impl_op_readwrite(const point_t& p)
{
topo_.bbox().take(p);
return data_[p];
}
bool impl_has(const point_t& p) const
{
return data_.find(p) != data_.end();
}
private:
value_t val_;
mutable topo_t topo_;
mutable std::map<point_t, value_t> data_;
};
} // end of namespace oln
#endif // ! OLENA_CORE_GEN_MAPIMAGE_HH
......@@ -64,6 +64,8 @@ namespace oln
template <typename point>
class topo_bbox_ : public topology_entry< topo_bbox_<point> >
{
typedef topo_bbox_<point> self_t;
typedef topology_entry<self_t> super_t;
typedef bbox_<point> bbox_t;
public:
......@@ -82,6 +84,11 @@ namespace oln
return bb_;
}
bbox_t& impl_bbox()
{
return bb_;
}
bool impl_has(const point& p) const
{
return bb_.has(p);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment