Commit ae69f455 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Add the notion of image plus neighborhood and the underlying

	mechanism.
	
	* oln/debug/print_nbh.hh,
	* oln/debug/iota.hh,
	* oln/core/concept/image_identity.hh,
	* oln/core/gen/op.hh,
	* oln/core/internal/op_image_plus_nbh.hh,
	* oln/core/internal/special_op.hh: New.
	* oln/core/concept/image.hh (fwd_niter, bkd_niter, niter): New.
	* oln/core/concept/neighborhood.hh (category): New.
	(include): Add op_image_plus_nbh.hh.
	(oln_decl_op_plus): New.  Handle "Image + Neighborhood".
	* oln/core/equipment.hh (left, right, oper, tag): New.
	* oln/core/gen/single_value_image.hh: Fix.
	* oln/core/internal/neighborhood_base.hh (category): New.
	(neighborhood_base_): Fix inheritance.
	* oln/core/internal/image_base.hh (image_extension_): New.
	(image_base_): Add dpoint.
	* oln/stc/scoop.hxx (vtypes, super_trait_): Add specialization
	for const types.
	(super_trait_): Handle error when not user-defined.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@859 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 8bd6feca
2007-03-08 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add the notion of image plus neighborhood and the underlying
mechanism.
* oln/debug/print_nbh.hh,
* oln/debug/iota.hh,
* oln/core/concept/image_identity.hh,
* oln/core/gen/op.hh,
* oln/core/internal/op_image_plus_nbh.hh,
* oln/core/internal/special_op.hh: New.
* oln/core/concept/image.hh (fwd_niter, bkd_niter, niter): New.
* oln/core/concept/neighborhood.hh (category): New.
(include): Add op_image_plus_nbh.hh.
(oln_decl_op_plus): New. Handle "Image + Neighborhood".
* oln/core/equipment.hh (left, right, oper, tag): New.
* oln/core/gen/single_value_image.hh: Fix.
* oln/core/internal/neighborhood_base.hh (category): New.
(neighborhood_base_): Fix inheritance.
* oln/core/internal/image_base.hh (image_extension_): New.
(image_base_): Add dpoint.
* oln/stc/scoop.hxx (vtypes, super_trait_): Add specialization
for const types.
(super_trait_): Handle error when not user-defined.
2007-03-08 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Move the responsibility of iteration on window points from
......
......@@ -142,6 +142,11 @@ namespace oln
public automatic::get_impl<Image_with_Nbh, Exact>
{
stc_typename(nbh);
stc_typename(fwd_niter);
stc_typename(bkd_niter);
typedef fwd_niter niter;
nbh nbhood() const;
protected:
......
// 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 OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
# define OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
# include <oln/core/concept/image.hh>
namespace oln
{
namespace behavior { struct identity; }
namespace automatic
{
/// Concept-class "Image".
template <typename Exact>
struct set_impl< Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(psite);
stc_typename(rvalue);
stc_typename(box);
stc_typename(pset);
bool impl_owns_(const psite& p) const;
rvalue impl_read(const psite& p) const;
box impl_bbox() const;
pset impl_points() const;
};
/// Concept-class "Image_with_Nbh".
template <typename Exact>
struct set_impl< Image_with_Nbh, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(nbh);
nbh impl_nbhood() const;
};
/// Concept-class "Mutable_Image".
template <typename Exact>
struct set_impl< Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(psite);
stc_typename(lvalue);
lvalue impl_read_write(const psite& p);
};
/// Concept-class "Fast_Image".
template <typename Exact>
struct set_impl< Fast_Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(rvalue);
stc_typename(lvalue);
stc_typename(index);
rvalue impl_index_read(index i) const;
lvalue impl_index_read_write(index i);
std::size_t impl_npoints() const;
};
/// Concept-class "Point_Wise_Accessible_Image".
template <typename Exact>
struct set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(point);
bool impl_has(const point& p) const;
};
/// Concept-class "Value_Wise_Accessible_Image".
template <typename Exact>
struct set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(vsite);
stc_typename(rvaluep);
rvaluep impl_value_read(const vsite& v) const;
};
/// Concept-class "Value_Wise_Mutable_Image".
template <typename Exact>
struct set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
{
stc_typename(vsite);
stc_typename(lvaluep);
lvaluep impl_value_read_write(const vsite& v);
};
/// Concept-class "Image_1D".
template <typename Exact>
struct set_impl< Image_1D, behavior::identity, Exact > : public virtual Any<Exact>
{
};
/// Concept-class "Image_2D".
template <typename Exact>
struct set_impl< Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
{
};
/// Concept-class "Image_3D".
template <typename Exact>
struct set_impl< Image_3D, behavior::identity, Exact > : public virtual Any<Exact>
{
};
/// Concept-class "Point_Wise_Accessible_Image_2D".
template <typename Exact>
struct set_impl< Point_Wise_Accessible_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
{
// default code is provided in Point_Wise_Accessible_Image_2D<Exact>
};
/// Concept-class "Point_Wise_Mutable_Image_2D".
template <typename Exact>
struct set_impl< Point_Wise_Mutable_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
{
// default code is provided in Point_Wise_Mutable_Image_2D<Exact>
};
# ifndef OLN_INCLUDE_ONLY
/// Concept-class "Image".
template <typename Exact>
bool
set_impl< Image, behavior::identity, Exact >::impl_owns_(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
{
return exact(this)->image().owns_(p);
}
template <typename Exact>
typename set_impl< Image, behavior::identity, Exact >::rvalue
set_impl< Image, behavior::identity, Exact >::impl_read(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
{
return exact(this)->image()(p);
}
template <typename Exact>
typename set_impl< Image, behavior::identity, Exact >::box
set_impl< Image, behavior::identity, Exact >::impl_bbox() const
{
return exact(this)->image().bbox();
}
template <typename Exact>
typename set_impl< Image, behavior::identity, Exact >::pset
set_impl< Image, behavior::identity, Exact >::impl_points() const
{
return exact(this)->image().points();
}
/// Concept-class "Image_with_Nbh".
template <typename Exact>
typename set_impl< Image_with_Nbh, behavior::identity, Exact >::nbh
set_impl< Image_with_Nbh, behavior::identity, Exact >::impl_nbhood() const
{
return exact(this)->image().nbhood();
}
/// Concept-class "Mutable_Image".
template <typename Exact>
typename set_impl< Mutable_Image, behavior::identity, Exact >::lvalue
set_impl< Mutable_Image, behavior::identity, Exact >::impl_read_write(const typename set_impl< Mutable_Image, behavior::identity, Exact >::psite& p)
{
return exact(this)->image().operator()(p);
}
/// Concept-class "Fast_Image".
template <typename Exact>
typename set_impl< Fast_Image, behavior::identity, Exact >::rvalue
set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read(typename set_impl< Fast_Image, behavior::identity, Exact >::index i) const
{
return exact(this)->image()[i];
}
template <typename Exact>
typename set_impl< Fast_Image, behavior::identity, Exact >::lvalue
set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read_write(typename set_impl< Fast_Image, behavior::identity, Exact >::index i)
{
return exact(this)->image()[i];
}
template <typename Exact>
std::size_t
set_impl< Fast_Image, behavior::identity, Exact >::impl_npoints() const
{
return exact(this)->image().npoints();
}
/// Concept-class "Point_Wise_Accessible_Image".
template <typename Exact>
bool
set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::impl_has(const typename set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::point& p) const
{
return exact(this)->image().has(p);
}
/// Concept-class "Value_Wise_Accessible_Image".
template <typename Exact>
typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::rvaluep
set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::impl_value_read(const typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::vsite& v) const
{
return exact(this)->image().value(v);
}
/// Concept-class "Value_Wise_Mutable_Image".
template <typename Exact>
typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::lvaluep
set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::impl_value_read_write(const typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::vsite& v)
{
return exact(this)->image().value(v);
}
# endif
} // end of namespace oln::automatic
} // end of namespace oln
#endif // ! OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
......@@ -29,6 +29,9 @@
# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# include <oln/core/equipment.hh>
# include <oln/core/internal/op_image_plus_nbh.hh>
namespace oln
......@@ -41,6 +44,7 @@ namespace oln
{
stc_typename(grid);
stc_typename(point);
stc_typename(category);
protected:
Neighborhood();
......@@ -48,6 +52,8 @@ namespace oln
}; // end of oln::Neighborhood<Exact>
oln_decl_op_plus(Image, Neighborhood);
# ifndef OLN_INCLUDE_ONLY
......
......@@ -66,6 +66,7 @@ namespace oln
stc_decl_associated_type( index );
// l
stc_decl_associated_type( left );
stc_decl_associated_type( lvalue );
stc_decl_associated_type( lvaluep );
......@@ -75,6 +76,7 @@ namespace oln
stc_decl_associated_type( niter );
// o
stc_decl_associated_type( oper );
stc_decl_associated_type( output );
// p
......@@ -87,12 +89,16 @@ namespace oln
stc_decl_associated_type( qiter );
// r
stc_decl_associated_type( right );
stc_decl_associated_type( rvalue );
stc_decl_associated_type( rvaluep );
// s
stc_decl_associated_type( std_container );
// t
stc_decl_associated_type( tag );
// v
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
......
// 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 OLN_CORE_GEN_OP_HH
# define OLN_CORE_GEN_OP_HH
# include <oln/core/internal/special_op.hh>
// Macro.
# define oln_decl_op_(OpName, Lconcept, OpSym, Rconcept) \
\
template <typename L, typename R> \
op_<L, OpName, R> \
operator OpSym (Lconcept<L>& lhs, Rconcept<R>& rhs) \
{ \
op_<L, OpName, R> tmp(exact(lhs), exact(rhs)); \
return tmp; \
} \
\
template <typename L, typename R> \
op_<L, OpName, const R> \
operator OpSym (Lconcept<L>& lhs, const Rconcept<R>& rhs) \
{ \
op_<L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
return tmp; \
} \
\
template <typename L, typename R> \
op_<const L, OpName, R> \
operator OpSym (const Lconcept<L>& lhs, Rconcept<R>& rhs) \
{ \
op_<const L, OpName, R> tmp(exact(lhs), exact(rhs)); \
return tmp; \
} \
\
template <typename L, typename R> \
op_<const L, OpName, const R> \
operator OpSym (const Lconcept<L>& lhs, const Rconcept<R>& rhs) \
{ \
op_<const L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
return tmp; \
} \
\
struct e_n_d___w_i_t_h___a___s_e_m_i___c_o_l_u_m_n
# define oln_decl_op_plus(Lconcept, Rconcept) oln_decl_op_(plus, Lconcept, +, Rconcept)
# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_(such_as, Lconcept, |, Rconcept)
// ...
# define oln_category_of_(Type) typename oln::internal::category_of_<Type>::ret
namespace oln
{
namespace internal
{
template <typename T>
struct category_of_
{
typedef stc_type(T, category) ret;
};
// ...
} // end of namespace oln::internal
/// \{
/// Operator Names.
struct plus;
struct such_as;
/// \}
// Fwd decl.
template <typename L, typename OpName, typename R> class op_;
/// Virtual types.
template <typename L, typename OpName, typename R>
struct vtypes< op_<L, OpName, R> >
{
};
/// Super type.
# define super \
internal::special_op_< oln_category_of_(L), L, OpName, oln_category_of_(R), R >
template <typename L, typename OpName, typename R>
struct super_trait_< op_<L, OpName, R> >
{
typedef super ret;
};
/// Class for result of "L op R".
template <typename L, typename OpName, typename R>
class op_ : public super
{
public:
op_(L& l, R& r);
}; // end of op_<L, OpName, R>
# ifndef OLN_INCLUDE_ONLY
template <typename L, typename OpName, typename R>
op_<L, OpName, R>::op_(L& l, R& r)
: super (l, r)
{
}
# endif
# undef super
} // end of namespace oln
#endif // ! OLN_CORE_GEN_OP_HH
......@@ -54,11 +54,6 @@ namespace oln
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
// FIXME: To be defined...
typedef mlc::none qiter;
typedef mlc::none fwd_qiter;
typedef mlc::none bkd_qiter;
};
......
......@@ -29,10 +29,11 @@
# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
# include <oln/core/internal/image_selectors.hh>
# include <oln/core/concept/image_identity.hh>
# include <oln/core/internal/tracked_ptr.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
......@@ -50,6 +51,7 @@ namespace oln
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
template <typename Exact> struct image_extension_;
template <typename Exact> struct multiple_image_morpher_;
}
......@@ -86,6 +88,12 @@ namespace oln
typedef internal::image_morpher_<Exact> ret;
};
template <typename Exact>
struct super_trait_< internal::image_extension_<Exact> >
{
typedef internal::single_image_morpher_<Exact> ret;
};
template <typename Exact>
struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
......@@ -122,6 +130,7 @@ namespace oln
typedef stc::final< stc::is<Image> > category;
typedef stc::final< box_<point__> > box;
typedef stc::final< stc_type(point__, grid) > grid;
typedef stc::final< stc_type(point__, dpoint) > dpoint;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
typedef fwd_piter piter;
......@@ -145,6 +154,7 @@ namespace oln
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
typedef stc::abstract behavior;
typedef stc::not_delegated data;
};
......@@ -153,6 +163,12 @@ namespace oln
{
};
template <typename Exact>
struct vtypes< internal::image_extension_<Exact> >
{