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

Add type of ''image restricted_to a subset''.

	* tests/core/subset.cc: New.
	* tests/core/Makefile.am: Update.
	* oln/debug/println.hh: New.
	* oln/core/internal/op_image_restricted_to_pset.hh: New.
	* oln/debug/print.hh: Fix copyright.
	* oln/core/concept/image.hh (bbox): Provide a final impl.
	* oln/core/rle/rle_image.hh,
	* oln/core/concept/image_identity.hh,
	* oln/core/sparse/sparse_image.hh,
	* oln/core/1d/image1d.hh
	* oln/core/1d/image1d_b.hh
	* oln/core/2d/image2d.hh
	* oln/core/2d/image2d_b.hh: Update.
	* oln/core/concept/neighborhood.hh (oln_decl_op_plus): Move to...
	* oln/core/gen/neighb.hh: ...this file.
	* oln/core/gen/op.hh (oln_decl_op_restricted_to, restricted_to):
	New.
	* oln/core/internal/point_set_base.hh (category): New.
	* oln/core/internal/op_image_plus_nbh.hh: Add static assert.
	* oln/core/internal/image_base.hh (include): Add
	op_image_restricted_to_pset.hh.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@877 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c65f3791
2007-03-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add type of ''image restricted_to a subset''.
* tests/core/subset.cc: New.
* tests/core/Makefile.am: Update.
* oln/debug/println.hh: New.
* oln/core/internal/op_image_restricted_to_pset.hh: New.
* oln/debug/print.hh: Fix copyright.
* oln/core/concept/image.hh (bbox): Provide a final impl.
* oln/core/rle/rle_image.hh,
* oln/core/concept/image_identity.hh,
* oln/core/sparse/sparse_image.hh,
* oln/core/1d/image1d.hh
* oln/core/1d/image1d_b.hh
* oln/core/2d/image2d.hh
* oln/core/2d/image2d_b.hh: Update.
* oln/core/concept/neighborhood.hh (oln_decl_op_plus): Move to...
* oln/core/gen/neighb.hh: ...this file.
* oln/core/gen/op.hh (oln_decl_op_restricted_to, restricted_to):
New.
* oln/core/internal/point_set_base.hh (category): New.
* oln/core/internal/op_image_plus_nbh.hh: Add static assert.
* oln/core/internal/image_base.hh (include): Add
op_image_restricted_to_pset.hh.
2007-03-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add external initialization through ''init(target, with, data)''.
......
......@@ -97,7 +97,6 @@ namespace oln
std::size_t impl_npoints() const;
box1d impl_bbox() const;
box1d impl_points() const;
};
......@@ -176,19 +175,13 @@ namespace oln
}
template <typename T>
box1d image1d<T>::impl_bbox() const
box1d image1d<T>::impl_points() const
{
assert(this->has_data());
box1d b(this->data_->imin(), this->data_->imax());
return b;
}
template <typename T>
box1d image1d<T>::impl_points() const
{
return this->bbox();
}
# endif
......
......@@ -105,7 +105,6 @@ namespace oln
std::size_t impl_npoints() const;
box1d impl_bbox() const;
box1d impl_points() const;
unsigned border() const;
......@@ -183,13 +182,6 @@ namespace oln
return this->data_->first[i];
}
template <typename T>
box1d image1d_b<T>::impl_bbox() const
{
assert(this->has_data());
return this->data_->third;
}
template <typename T>
box1d image1d_b<T>::impl_points() const
{
......
......@@ -100,7 +100,6 @@ namespace oln
std::size_t impl_npoints() const;
box2d impl_bbox() const;
box2d impl_points() const;
};
......@@ -203,7 +202,7 @@ namespace oln
}
template <typename T>
box2d image2d<T>::impl_bbox() const
box2d image2d<T>::impl_points() const
{
assert(this->has_data());
point2d
......@@ -213,12 +212,6 @@ namespace oln
return b;
}
template <typename T>
box2d image2d<T>::impl_points() const
{
return this->bbox();
}
template <typename T, typename D>
bool init_(image2d<T>* this_, const D& dat)
{
......
......@@ -146,7 +146,6 @@ namespace oln
std::size_t impl_npoints() const;
box2d impl_bbox() const;
box2d impl_points() const;
unsigned border() const;
......@@ -243,13 +242,6 @@ namespace oln
return this->data_->array(row, col);
}
template <typename T>
box2d image2d_b<T>::impl_bbox() const
{
assert(this->has_data());
return this->data_->box;
}
template <typename T>
box2d image2d_b<T>::impl_points() const
{
......
......@@ -132,11 +132,13 @@ namespace oln
stc_typename(plain);
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
rvalue operator()(const psite& p) const;
box bbox() const;
pset points() const;
// With final impl:
box bbox() const;
protected:
Image();
};
......@@ -357,7 +359,7 @@ namespace oln
typename Image<Exact>::box
Image<Exact>::bbox() const
{
return exact(this)->impl_bbox();
return this->points().bbox(); // Final impl.
}
template <typename Exact>
......@@ -551,8 +553,7 @@ namespace oln
{
}
# endif
# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
......
......@@ -54,7 +54,6 @@ namespace oln
bool impl_owns_(const psite& p) const;
rvalue impl_read(const psite& p) const;
box impl_bbox() const;
pset impl_points() const;
};
......@@ -192,13 +191,6 @@ namespace oln
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
......
......@@ -29,8 +29,6 @@
# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# include <oln/core/equipment.hh>
# include <oln/core/internal/op_image_plus_nbh.hh>
......@@ -52,8 +50,6 @@ namespace oln
}; // end of oln::Neighborhood<Exact>
oln_decl_op_plus(Image, Neighborhood);
# ifndef OLN_INCLUDE_ONLY
......
......@@ -31,12 +31,18 @@
# include <oln/core/internal/dpoints_impl.hh>
# include <oln/core/internal/neighborhood_base.hh>
# include <oln/core/internal/op_image_plus_nbh.hh>
namespace oln
{
// Op.
oln_decl_op_plus(Image, Neighborhood);
// Fwd decl.
template <typename Dp> class neighb_;
......
......@@ -71,8 +71,9 @@
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_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_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to, Lconcept, |, Rconcept)
// ...
......@@ -104,6 +105,7 @@ namespace oln
struct plus;
struct such_as;
struct restricted_to;
/// \}
......
......@@ -461,8 +461,21 @@ namespace oln
} // end of namespace oln
// FIXME: Bad!
/// \{
/// FIXME: Bad!
# include <oln/core/internal/f_ch_value.hh>
# include <oln/core/internal/op_image_restricted_to_pset.hh>
namespace oln
{
oln_decl_op_restricted_to(Image, Point_Set);
} // end of namespace oln
/// \}
......
......@@ -84,7 +84,8 @@ namespace oln
template <typename I, typename N>
class special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
:
public internal::image_extension_< op_<I, plus, N> >
public internal::image_extension_< op_<I, plus, N> >,
private mlc::assert_< mlc_is_not_a(I, Image_with_Nbh) > // FIXME: Add err msg.
{
typedef internal::image_extension_< op_<I, plus, N> > super;
public:
......@@ -167,8 +168,6 @@ namespace oln
// init
// FIXME: N is nbh?
template <typename I, typename N, typename D>
bool init_(internal::current* this_, const D& dat)
{
......
// 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_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
# define OLN_CORE_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
# include <oln/core/internal/image_base.hh>
# include <oln/core/concept/point_set.hh>
# include <oln/core/gen/op.hh>
namespace oln
{
# define current \
special_op_< stc::is<Image>, I, restricted_to, stc::is<Point_Set>, S >
// /// Fwd decls.
// template <typename Exact> struct Image;
// template <typename Exact> struct Point_Set;
/// Super type.
template <typename I, typename S>
struct super_trait_< internal::current >
{
typedef internal::image_extension_< op_<I, restricted_to, S> > ret;
};
/// Virtual types.
template <typename I, typename S>
struct vtypes< internal::current >
{
typedef op_<I, restricted_to, S> Exact;
typedef stc_type(I, point) point__;
typedef I delegatee;
typedef internal::pair<I,S> data;
typedef S pset;
typedef op_<oln_plain(I), restricted_to, S> plain;
typedef op_<pl::rec<I>, restricted_to, S> skeleton;
};
namespace internal
{
/// Implementation class the result of "Image I | Point_Set S".
template <typename I, typename S>
class special_op_< stc::is<Image>, I, restricted_to, stc::is<Point_Set>, S >
:
public internal::image_extension_< op_<I, restricted_to, S> >
{
typedef internal::image_extension_< op_<I, restricted_to, S> > super;
public:
stc_using(pset);
stc_using(box);
stc_using(data);
stc_using(delegatee);
delegatee& impl_image();
const delegatee& impl_image() const;
pset impl_points() const;
protected:
special_op_();
special_op_(I& ima, S& subset);
};
} // end of namespace oln::internal
// init
template <typename I, typename S, typename D>
bool init_(internal::current* target, const D& dat);
template <typename S, typename I>
bool init(Point_Set<S>& target,
with_t,
const internal::current& dat);
template <typename I, typename S>
bool init(Image<I>& target,
with_t,
const internal::current& dat);
# ifndef OLN_INCLUDE_ONLY
namespace internal
{
template <typename I, typename S>
current::special_op_()
{
}
template <typename I, typename S>
current::special_op_(I& ima, S& subset)
{
this->data_ = new data(ima, subset);
}
template <typename I, typename S>
typename current::delegatee&
current::impl_image()
{
assert(this->has_data());
return this->data_->first;
}
template <typename I, typename S>
const typename current::delegatee&
current::impl_image() const
{
assert(this->has_data());
return this->data_->first;
}
template <typename I, typename S>
typename current::pset
current::impl_points() const
{
assert(this->has_data());
return this->data_->second;
}
} // end of namespace oln::internal
// init
template <typename I, typename S, typename D>
bool init_(internal::current* this_, const D& dat)
{
precondition(not this_->has_data());
this_->data__() = new typename op_<I, restricted_to, S>::data;
bool image_ok = init(this_->data__()->first, with, dat);
bool subset_ok = init(this_->data__()->second, with, dat);
postcondition(image_ok);
postcondition(subset_ok);
return image_ok and subset_ok;
}
template <typename S, typename I>
bool init_(Point_Set<S>* this_,
const internal::current& data)
{
*this_ = data.points();
return true;
}
template <typename I, typename S>
bool init(Image<I>* this_,
const internal::current& data)
{
*this_ = data.image();
return true;
}
# endif // OLN_INCLUDE_ONLY
# undef current
} // end of namespace oln
#endif // ! OLN_CORE_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
......@@ -58,6 +58,8 @@ namespace oln
typedef stc_deferred(point) point__;
typedef stc_deferred(fwd_piter) fwd_piter__;
typedef stc::final< stc::is<Point_Set> > category;
typedef stc::final< box_<point__> > box;
typedef stc::final<stc_type(point__, grid)> grid;
typedef stc::final<fwd_piter__> piter;
......
......@@ -80,7 +80,6 @@ namespace oln
**
** method:
** pset impl_points() const : return image pset
** box impl_bbox() const : return image bbox
** bool impl_has(const point& p) const : rle_image has p?
** bool impl_owns_(const psite& p) const : same has impl_has
** void insert(const point& p, unsigned len, value val) : insert a new range on the image
......@@ -105,7 +104,6 @@ namespace oln
rle_image();
pset impl_points() const;
box impl_bbox() const;
bool impl_has(const point& p) const;
bool impl_owns_(const psite& p) const;
void insert(const point& p, unsigned len, value val);
......@@ -129,13 +127,6 @@ namespace oln
return this->data_->first;
}
template <typename P, typename T>
typename rle_image<P, T>::box
rle_image<P, T>::impl_bbox() const
{
return this->data_->first.bbox();
}
template <typename P, typename T>
bool
rle_image<P, T>::impl_has(const typename rle_image<P, T>::point& p) const
......
......@@ -83,7 +83,6 @@ namespace oln
sparse_image();
pset impl_points() const;
box impl_bbox() const;
bool impl_has(const point& p) const;
bool impl_owns_(const psite& p) const;
void insert(const point& p, unsigned len, const std::vector<value>& val);
......@@ -108,13 +107,6 @@ namespace oln
return this->data_->first;
}
template <typename P, typename T>
typename sparse_image<P, T>::box
sparse_image<P, T>::impl_bbox() const
{
return this->data_->first.bbox();
}
template <typename P, typename T>
bool
sparse_image<P, T>::impl_has(const typename sparse_image<P, T>::point& p) const
......
// Copyright (C) 2006 EPITA Research and Development Laboratory
// Copyright (C) 2006, 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
......
// 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_DEBUG_PRINTLN_HH
# define OLN_DEBUG_PRINTLN_HH
# include <oln/debug/print.hh>
namespace oln
{
namespace debug
{
template <typename I>
void println(const Image<I>& input, std::ostream& ostr = std::cout);
# ifndef OLN_INCLUDE_ONLY
template <typename I>
void println(const Image<I>& input, std::ostream& ostr)
{
print(exact(input), ostr);
ostr << std::endl;
}
# endif // ! OLN_INCLUDE_ONLY