https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add oln::image1d and associated types.
* oln/core/1d/image1d.hh, oln/core/1d/array1d.hh,
* oln/core/1d/point1d.hh, oln/core/1d/dpoint1d.hh,
* oln/core/1d/neighb1d.hh, oln/core/1d/aliases.hh,
* oln/basics1d.hh: New.
* oln/core/abstract/point_set_being_connected.hh
(oln::abstract::point_set_being_1d_connected): New class.
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 1>): Handle
the 1-dimension case, and move the 2-dimension case...
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 2>): ...here
(new).
* tests/image1d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image1d.
(image1d_SOURCES): New.
oln/basics1d.hh | 62 ++++++++++++
oln/core/1d/aliases.hh | 69 +++++++++++++
oln/core/1d/array1d.hh | 117 +++++++++++++++++++++++
oln/core/1d/dpoint1d.hh | 98 +++++++++++++++++++
oln/core/1d/image1d.hh | 127 +++++++++++++++++++++++++
oln/core/1d/neighb1d.hh | 54 ++++++++++
oln/core/1d/point1d.hh | 108 +++++++++++++++++++++
oln/core/abstract/point_set_being_connected.hh | 39 +++++++
tests/Makefile.am | 2
tests/image1d.cc | 63 ++++++++++++
10 files changed, 737 insertions(+), 2 deletions(-)
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 0)
+++ oln/core/1d/image1d.hh (revision 0)
@@ -0,0 +1,127 @@
+// 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 OLN_CORE_1D_IMAGE1D_HH
+# define OLN_CORE_1D_IMAGE1D_HH
+
+# include <oln/core/image_entry.hh>
+# include <oln/core/1d/array1d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ template <typename T> class image1d;
+
+
+ /// Virtual types associated to oln::image1d<T>.
+ template <typename T>
+ struct vtypes< image1d<T> >
+ {
+ typedef topo_lbbox_<point1d> topo_type;
+ typedef grid1d grid_type;
+
+ typedef point1d point_type;
+
+ typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
+ typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
+
+ typedef T value_type;
+ typedef T lvalue_type;
+ typedef mlc::true_ is_mutable_type;
+
+ typedef image1d<T> real_type;
+ };
+
+
+ /// Super type declaration.
+ template <typename T>
+ struct set_super_type< image1d<T> >
+ {
+ typedef image1d<T> self_t;
+ typedef image_entry<self_t> ret;
+ };
+
+
+ /// General 1D image class.
+ template <typename T>
+ class image1d : public image_entry< image1d<T> >
+ {
+ typedef image1d<T> self_t;
+ typedef array1d<T> array_t;
+
+ public:
+
+ /// Ctor using sizes.
+ image1d(unsigned nindices, unsigned border = 2)
+ : topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
+ data_(new array_t(0 - border,
+ nindices - 1 + border))
+ {
+ }
+
+ /// Ctor using an existing topology.
+ image1d(const topo1d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().index(),
+ topo.bbox().pmax().index()))
+ {
+ }
+
+ const topo1d& impl_topo() const
+ {
+ return topo_;
+ }
+
+ T impl_op_read(const point1d& p) const
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.index());
+ }
+
+ T& impl_op_readwrite(const point1d& p)
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.index());
+ }
+
+ private:
+
+ topo1d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_IMAGE1D_HH
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 0)
+++ oln/core/1d/array1d.hh (revision 0)
@@ -0,0 +1,117 @@
+// Copyright (C) 2001, 2003, 2004, 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 OLN_CORE_1D_ARRAY1D_HH
+# define OLN_CORE_1D_ARRAY1D_HH
+
+# include <cstdlib>
+# include <mlc/contract.hh>
+
+
+namespace oln
+{
+
+ /// General 1D array class.
+ template <typename value_t, typename coord_t = int>
+ class array1d
+ {
+ public:
+
+ /// Ctor.
+ array1d(coord_t min, coord_t max) :
+ min_(min), max_(max)
+ {
+ precondition(max >= min);
+ len_ = max - min + 1;
+ allocate_();
+ }
+
+ /// Ctor.
+ array1d(coord_t len) :
+ min_(0), len_(len)
+ {
+ precondition(len > 0);
+ max_ = min_ + len_;
+ allocate_();
+ }
+
+ /// Dtor.
+ ~array1d()
+ {
+ deallocate_();
+ }
+
+ value_t operator()(coord_t i) const
+ {
+ precondition(has(i));
+ return buffer_[i - min_];
+ }
+
+ value_t& operator()(coord_t i)
+ {
+ precondition(has(i));
+ return buffer_[i - min_];
+ }
+
+ bool has(coord_t i) const
+ {
+ return
+ i >= min_ and i <= max_;
+ }
+
+ size_t memsize() const
+ {
+ return size_t(len_) * sizeof(value_t);
+ }
+
+ protected:
+
+ coord_t min_, max_;
+ coord_t len_;
+ value_t* buffer_;
+
+ private:
+
+ void allocate_()
+ {
+ buffer_ = new value_t[size_t(len_)];
+ }
+
+ void deallocate_()
+ {
+ precondition(buffer_ != 0);
+ delete[] buffer_;
+ buffer_ = 0; // safety
+ }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_ARRAY1D_HH
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 0)
+++ oln/core/1d/point1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 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 OLN_CORE_1D_POINT1D_HH
+# define OLN_CORE_1D_POINT1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/internal/point_nd.hh>
+
+
+namespace oln
+{
+
+ /* FIXME: Is this the right place for these functions (on types)?
+ In particular, the function on dpoint1d should be near the
+ definition of dpoint1d, not point1d's. */
+ /// Specializations of functions point and dpoint :
+ /// \f$(n, coord) \rightarrow type\f$ for \f$n = 1\f$.
+ /// \{
+ template <typename C> struct point_ <1, C> { typedef point1d_<C> ret; };
+ template <typename C> struct dpoint_ <1, C> { typedef dpoint1d_<C> ret; };
+ /// \}
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< point1d_<C> >
+ {
+ typedef internal::point_nd< point1d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::point1d_<C>.
+ template <typename C>
+ struct vtypes< point1d_<C> >
+ {
+ typedef grid1d grid_type;
+ typedef dpoint1d dpoint_type;
+ typedef C coord_type;
+ typedef mlc::uint_<1> dim_type;
+ };
+
+
+ /// General 1D point class.
+ template <typename C>
+ class point1d_ : public stc_get_supers(point1d_<C>)
+ {
+ typedef point1d_<C> self_t;
+ typedef stc_get_super(point1d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ point1d_()
+ {
+ }
+
+ /// Ctor.
+ point1d_(coord_t index)
+ : super_t (xtd::mk_vec(index))
+ {
+ }
+
+ /// Ctor.
+ point1d_(const xtd::vec<1,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ coord_t index() const { return v_[0]; }
+ coord_t& index() { return v_[0]; }
+ };
+
+
+} // end of namespace oln
+
+# include <oln/core/1d/dpoint1d.hh>
+
+
+#endif // ! OLN_CORE_1D_POINT1D_HH
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 0)
+++ oln/core/1d/dpoint1d.hh (revision 0)
@@ -0,0 +1,98 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 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 OLN_CORE_1D_DPOINT1D_HH
+# define OLN_CORE_1D_DPOINT1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/1d/point1d.hh>
+# include <oln/core/internal/dpoint_nd.hh>
+
+
+namespace oln
+{
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< dpoint1d_<C> >
+ {
+ typedef internal::dpoint_nd< dpoint1d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::dpoint1d_<C>.
+ template <typename C>
+ struct vtypes< dpoint1d_<C> >
+ {
+ typedef grid1d grid_type;
+ typedef point1d point_type;
+ typedef C coord_type;
+ typedef mlc::uint_<1> dim_type;
+ };
+
+
+ /// General 1D dpoint class.
+ template <typename C>
+ class dpoint1d_
+ : public stc_get_supers(dpoint1d_<C>)
+ {
+ typedef dpoint1d_<C> self_t;
+ typedef stc_get_super(dpoint1d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ dpoint1d_()
+ {
+ }
+
+ /// Ctor.
+ dpoint1d_(const xtd::vec<1,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ /// Ctor.
+ dpoint1d_(coord_t index)
+ : super_t(xtd::mk_vec(index))
+ {
+ }
+
+ coord_t index() const { return v_[0]; }
+ coord_t& index() { return v_[0]; }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 0)
+++ oln/core/1d/neighb1d.hh (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 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 OLN_CORE_1D_NEIGHB1D_HH
+# define OLN_CORE_1D_NEIGHB1D_HH
+
+# include <oln/core/gen/neighb.hh>
+# include <oln/core/1d/aliases.hh>
+
+
+namespace oln
+{
+
+ neighb1d c2()
+ {
+ static bool flower = true;
+ static neighb1d the_;
+ if (flower)
+ {
+ the_.add(dpoint1d(1));
+ flower = false;
+ }
+ return the_;
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_NEIGHB1D_HH
Index: oln/core/1d/aliases.hh
--- oln/core/1d/aliases.hh (revision 0)
+++ oln/core/1d/aliases.hh (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (C) 2001, 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 OLN_CORE_1D_ALIASES_HH
+# define OLN_CORE_1D_ALIASES_HH
+
+
+namespace oln
+{
+
+ /// \{
+ /// Forward declarations.
+ template <typename C> class point1d_;
+ template <typename C> class dpoint1d_;
+ template <typename D> class neighb_;
+ template <typename P> class bbox_;
+ template <typename P> class topo_lbbox_;
+ template <typename T> class fwd_piter_bbox_;
+ template <typename T> class bkd_piter_bbox_;
+ class grid1d;
+ /// \}
+
+
+ /// \{
+ /// Alliases.
+ typedef point1d_<int> point1d;
+ typedef dpoint1d_<int> dpoint1d;
+
+ typedef neighb_<dpoint1d> neighb1d;
+
+ typedef bbox_<point1d> bbox1d;
+ typedef topo_lbbox_<point1d> topo1d;
+ typedef fwd_piter_bbox_<topo1d> fwd_piter1d;
+ typedef bkd_piter_bbox_<topo1d> bkd_piter1d;
+
+ typedef point1d_<float> point1df;
+ typedef dpoint1d_<float> dpoint1df;
+ /// \}
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_ALIASES_HH
Index: oln/basics1d.hh
--- oln/basics1d.hh (revision 0)
+++ oln/basics1d.hh (revision 0)
@@ -0,0 +1,62 @@
+// 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 OLN_BASICS1D_HH
+# define OLN_BASICS1D_HH
+
+
+# include <oln/core/1d/aliases.hh>
+
+# include <oln/core/1d/grid1d.hh>
+
+# include <oln/core/1d/point1d.hh>
+namespace oln { template class point1d_<int>; }
+
+# include <oln/core/1d/dpoint1d.hh>
+namespace oln { template class dpoint1d_<int>; }
+
+# include <oln/core/gen/bbox.hh>
+namespace oln { template class bbox_<point1d>; }
+
+# include <oln/core/gen/topo_lbbox.hh>
+namespace oln { template class topo_lbbox_<point1d>; }
+
+# include <oln/core/gen/fwd_piter_bbox.hh>
+namespace oln { template class fwd_piter_bbox_<topo1d>; }
+
+# include <oln/core/gen/bkd_piter_bbox.hh>
+namespace oln { template class bkd_piter_bbox_<topo1d>; }
+
+# include <oln/core/gen/neighb.hh>
+namespace oln { template class neighb_<dpoint1d>; }
+# include <oln/core/1d/neighb1d.hh>
+
+# include <oln/core/1d/image1d.hh>
+
+
+#endif // ! OLN_BASICS1D_HH
Index: oln/core/abstract/point_set_being_connected.hh
--- oln/core/abstract/point_set_being_connected.hh (revision 603)
+++ oln/core/abstract/point_set_being_connected.hh (working copy)
@@ -39,6 +39,24 @@
template <typename E>
+ class point_set_being_1d_connected : public virtual abstract::point_set<E>
+ {
+ public:
+
+ unsigned nindices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ protected:
+
+ point_set_being_1d_connected()
+ {}
+ };
+
+
+ template <typename E>
class point_set_being_2d_connected : public virtual abstract::point_set<E>
{
public:
@@ -65,12 +83,29 @@
} // end of namespace oln::abstract
+ // Forward declarations.
+ class grid1d;
+ class grid2d;
+
template <typename E>
struct case_ < point_set_hierarchy_wrt_connectivity, E, 1 >
- : where_< mlc::and_list_< mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ : where_< mlc::and_list_<
+ mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ mlc::eq_< oln_type_of(E, is_connected), mlc::true_ >,
+ mlc::eq_< oln_type_of(E, grid), grid1d >
+ > >
+ {
+ typedef abstract::point_set_being_1d_connected<E> ret;
+ };
+
+ template <typename E>
+ struct case_ < point_set_hierarchy_wrt_connectivity, E, 2 >
+ : where_< mlc::and_list_<
+ mlc::neq_< oln_type_of(E, bbox), mlc::none >,
mlc::eq_< oln_type_of(E, is_connected), mlc::true_ >,
- mlc::eq_< oln_type_of(E, grid), grid2d > > >
+ mlc::eq_< oln_type_of(E, grid), grid2d >
+ > >
{
typedef abstract::point_set_being_2d_connected<E> ret;
};
Index: tests/image1d.cc
--- tests/image1d.cc (revision 0)
+++ tests/image1d.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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.
+
+/// Test oln::image1d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics1d.hh, but
+// oln/core/1d/image1d.hh (and oln/core/1d/neigh1d.hh ?).
+#include <oln/basics1d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 1-d image using its iterator.
+ oln::image1d<char> ima1(3);
+ oln_type_of_(oln::image1d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 1-d image using a classic loop.
+ oln::image1d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ ima2(oln::point1d(i)) = 2;
+
+ // Fill a 1-d image using the routine oln::level::fill.
+ oln::image1d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image1d<long> sum(ima1.topo());
+ oln_type_of_(oln::image1d<long>, piter) p(sum.topo());
+ for_all(p)
+ sum(p) = ima1(p) + ima2(p) + ima3(p);
+ // And check the sum.
+ for_all(p)
+ assert(sum(p) == 6);
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 603)
+++ tests/Makefile.am (working copy)
@@ -20,6 +20,7 @@
point2d \
grid \
image_entry \
+ image1d \
image2d \
npoints \
\
@@ -34,6 +35,7 @@
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
+image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
npoints_SOURCES = npoints.cc
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add simple tests for point2d and dpoint2d.
* tests/dpoint2d.cc, tests/point2d.cc: New tests.
* tests/image_entry.cc: Fix comments.
* tests/Makefile.am (check_PROGRAMS): Add dpoint2d and point2d.
(dpoint2d_SOURCES, point2d_SOURCES): New.
Makefile.am | 4 ++++
dpoint2d.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
image_entry.cc | 6 ++----
point2d.cc | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 4 deletions(-)
Index: tests/point2d.cc
--- tests/point2d.cc (revision 0)
+++ tests/point2d.cc (revision 0)
@@ -0,0 +1,43 @@
+// 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.
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+// FIXME: Don't include oln/basics2d.hh, which is too big.
+// (Fix.)
+#include <oln/basics2d.hh>
+
+
+int
+main()
+{
+ typedef oln::point2d_<int> point2d;
+ typedef oln:: stc_get_supers(point2d) point2d_super_type;
+ mlc::assert_<
+ mlc_eq( point2d_super_type, oln::internal::point_nd< point2d > )
+ >::check();
+}
Index: tests/image_entry.cc
--- tests/image_entry.cc (revision 600)
+++ tests/image_entry.cc (working copy)
@@ -25,15 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// Test oln::abstract::image_entry.
+/// Test oln::image_entry.
-// FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to
-// stress image_typeness.hh. This might be done in another test, of
-// course.
#include <oln/basics2d.hh>
#include <oln/core/image_entry.hh>
+
namespace my
{
// Forward declaration.
Index: tests/dpoint2d.cc
--- tests/dpoint2d.cc (revision 0)
+++ tests/dpoint2d.cc (revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+/// Test oln::image_entry.
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+// // FIXME: Fix oln/basics2d.hh!
+// #include <oln/core/2d/point2d.hh>
+// namespace oln { template class point2d_<int>; }
+// #include <oln/core/2d/dpoint2d.hh>
+#include <oln/basics2d.hh>
+
+
+int
+main()
+{
+ typedef oln::dpoint2d_<int> dpoint2d;
+ typedef oln:: stc_get_supers(dpoint2d) dpoint2d_super_type;
+ mlc::assert_<
+ mlc_eq( dpoint2d_super_type, oln::internal::dpoint_nd< dpoint2d > )
+ >::check();
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 600)
+++ tests/Makefile.am (working copy)
@@ -16,6 +16,8 @@
check_PROGRAMS = \
+ dpoint2d \
+ point2d \
grid \
image_entry \
image2d \
@@ -28,6 +30,8 @@
fill
# Images and auxiliary structures.
+dpoint2d_SOURCES = dpoint2d.cc
+point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
image2d_SOURCES = image2d.cc
2006-10-02 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add isubset image morpher and subsequent tools.
* oln/core/gen/piter_isubset.hh: New.
* oln/core/gen/topo_add_isubset.hh: New.
* oln/morpher/add_isubset.hh: New.
* oln/debug/print.hh (println): New.
* oln/core/typedefs.hh (isubset): New.
* oln/core/automatic/image_being_random_accessible.hh
(set_impl): Remove; cause error-prone.
* oln/core/abstract/image/type/hierarchy.hh
(where_): Rely on xtd_is_binary instead of an hard-coded test.
(include): Update.
* oln/core/gen/fwd_piter_bbox.hh (topo_type): new.
(topo_): Change ref into plain type so it is more secure.
* oln/core/gen/bkd_piter_bbox.hh (topo_type): new.
(topo_): Change ref into plain type so it is more secure.
* oln/core/gen/topo_add_nbh.hh (operator topo_t): New.
* oln/core/internal/topology_morpher.hh
(delegated_type): New.
Index: oln/debug/print.hh
===================================================================
--- oln/debug/print.hh (revision 596)
+++ oln/debug/print.hh (working copy)
@@ -80,6 +80,7 @@
} // end of namespace oln::debug::impl
+
/// Facade.
template <typename I>
void print(const abstract::image<I>& input, std::ostream& ostr)
@@ -88,6 +89,15 @@
}
+ /// Facade.
+ template <typename I>
+ void println(const abstract::image<I>& input, std::ostream& ostr)
+ {
+ print(input, ostr);
+ ostr << std::endl;
+ }
+
+
} // end of namespace oln::debug
} // end of namespace oln
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 596)
+++ oln/core/typedefs.hh (working copy)
@@ -134,6 +134,7 @@
mlc_decl_typedef(dpoint_type);
mlc_decl_typedef(neighborhood_type);
+ mlc_decl_typedef(isubset);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
@@ -152,6 +153,7 @@
// mlc_decl_typedef(window_type);
// --------------------------------------------------------------------
+
// ------------------------------ //
// Extension in image_operators. //
// ------------------------------ //
Index: oln/core/automatic/image_being_random_accessible.hh
===================================================================
--- oln/core/automatic/image_being_random_accessible.hh (revision 596)
+++ oln/core/automatic/image_being_random_accessible.hh (working copy)
@@ -72,33 +72,6 @@
};
- /// Implementation corresponding to the interface
- /// oln::abstract::image_being_random_accessible for an identity morpher.
-
- template <typename E>
- class set_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
Index: oln/core/abstract/image/type/hierarchy.hh
===================================================================
--- oln/core/abstract/image/type/hierarchy.hh (revision 596)
+++ oln/core/abstract/image/type/hierarchy.hh (working copy)
@@ -28,6 +28,7 @@
#ifndef OLN_CORE_ABSTRACT_IMAGE_TYPE_HIERARCHY_HH
# define OLN_CORE_ABSTRACT_IMAGE_TYPE_HIERARCHY_HH
+# include <xtd/valtraits.hh>
# include <oln/core/abstract/image.hh>
@@ -105,7 +106,7 @@
/// Binary case.
template <typename E>
struct case_< image_hierarchy_wrt_type, E, 1 > :
- where_< mlc::eq_< oln_type_of(E, value), bool > >
+ where_< xtd_is_binary(oln_type_of(E, value)) >
{
// Definition of the super class corresponding to this case.
typedef abstract::binary_image<E> ret;
Index: oln/core/gen/piter_isubset.hh
===================================================================
--- oln/core/gen/piter_isubset.hh (revision 0)
+++ oln/core/gen/piter_isubset.hh (revision 0)
@@ -0,0 +1,141 @@
+// 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 OLN_CORE_GEN_PITER_ISUBSET_HH
+# define OLN_CORE_GEN_PITER_ISUBSET_HH
+
+# include <oln/core/abstract/topology.hh>
+# include <oln/core/abstract/iterator_on_points.hh>
+
+
+namespace oln
+{
+
+
+ // Forward declaration.
+ template <typename piter_t, typename isubset_t> class piter_isubset_;
+
+
+ // Super type declaration.
+ template <typename piter_t, typename isubset_t>
+ struct set_super_type< piter_isubset_<piter_t, isubset_t> >
+ {
+ typedef piter_isubset_<piter_t, isubset_t> self_t;
+ typedef abstract::iterator_on_points<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::piter_isubset_<piter_t, isubset_t>.
+ template <typename piter_t, typename isubset_t>
+ struct vtypes< piter_isubset_<piter_t, isubset_t> >
+ {
+ typedef oln_type_of(piter_t, point) point_type;
+ typedef oln_type_of(piter_t, grid) grid_type;
+
+ typedef topo_add_isubset<oln_type_of(piter_t, topo), isubset_t> topo_type;
+ };
+
+
+
+ /// Abstract forward point iterator class.
+ template <typename piter_t, typename isubset_t>
+ class piter_isubset_ : public abstract::iterator_on_points< piter_isubset_<piter_t, isubset_t> >
+ {
+ typedef piter_isubset_<piter_t, isubset_t> self_t;
+ typedef abstract::iterator_on_points<self_t> super_t;
+
+ typedef oln_type_of(self_t, point) topo_t;
+ typedef oln_type_of(piter_t, point) point_t;
+
+ public:
+
+ template <typename T>
+ piter_isubset_(const abstract::topology<T>& topo)
+ : p_(topo),
+ isubset_(topo.exact().isubset())
+ {
+ }
+
+ void impl_start()
+ {
+ p_.start();
+ while (p_.is_valid() and isubset_(p_) == false)
+ p_.next();
+ }
+
+ void impl_next()
+ {
+ do
+ p_.next();
+ while (p_.is_valid() and isubset_(p_) == false);
+ }
+
+ void impl_invalidate()
+ {
+ p_.invalidate();
+ }
+
+ bool impl_is_valid() const
+ {
+ return p_.is_valid();
+ }
+
+ point_t impl_to_point() const
+ {
+ return p_.to_point();
+ }
+
+ const point_t* impl_point_adr() const
+ {
+ return p_.point_adr();
+ }
+
+ const topo_t& topo() const
+ {
+ topo_t tmp(p_.topo(), isubset_);
+ return tmp;
+ }
+
+ template <typename new_topo_t>
+ struct change_topology_
+ {
+ typedef typename piter_t::template change_topology_<new_topo_t>::ret new_piter_t;
+ typedef piter_isubset_<new_piter_t, isubset_t> ret;
+ };
+
+ protected:
+
+ piter_t p_;
+ const isubset_t& isubset_;
+
+ }; // end of class oln::piter_isubset_<point>
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_PITER_ISUBSET_HH
Index: oln/core/gen/topo_add_isubset.hh
===================================================================
--- oln/core/gen/topo_add_isubset.hh (revision 0)
+++ oln/core/gen/topo_add_isubset.hh (revision 0)
@@ -0,0 +1,115 @@
+// 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 OLN_CORE_GEN_TOPO_ADD_ISUBSET_HH
+# define OLN_CORE_GEN_TOPO_ADD_ISUBSET_HH
+
+# include <oln/core/internal/topology_morpher.hh>
+
+
+
+namespace oln
+{
+
+
+ // Forward declarations.
+ template <typename topo, typename isubset> class topo_add_isubset;
+
+
+ // Super type declaration.
+ template <typename topo, typename isubset>
+ struct set_super_type< topo_add_isubset<topo, isubset> >
+ {
+ typedef topo_add_isubset<topo, isubset> self_t;
+ typedef internal::topology_morpher<topo, self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::bbox_<point>.
+ template <typename topo, typename isubset>
+ struct vtypes< topo_add_isubset<topo, isubset> >
+ {
+ typedef isubset isubset_type;
+ };
+
+
+ /// Bounding box topology based on a point class.
+ template <typename topo_t, typename isubset_t>
+ class topo_add_isubset
+ : public internal::topology_morpher<topo_t, topo_add_isubset<topo_t, isubset_t> >
+ {
+ typedef topo_add_isubset<topo_t, isubset_t> self_t;
+ typedef oln_type_of(self_t, point) point_t;
+
+ public:
+
+ topo_add_isubset()
+ {
+ }
+
+ topo_add_isubset(const topo_t& topo, const isubset_t& isubset)
+ : topo_(topo),
+ isubset_(isubset)
+ {
+ }
+
+ bool impl_has(const point_t& p) const
+ {
+ return topo_.has(p) and isubset_(p) == true;
+ }
+
+ bool impl_has_large(const point_t& p) const
+ {
+ return topo_.has(p) and isubset_(p) == true;
+ }
+
+ const topo_t& delegate() const
+ {
+ return topo_;
+ }
+
+ const isubset_t& isubset() const
+ {
+ return isubset_;
+ }
+
+ operator topo_t() const
+ {
+ return topo_;
+ }
+
+ protected:
+
+ topo_t topo_;
+ isubset_t isubset_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_TOPO_ADD_ISUBSET_HH
Index: oln/core/gen/fwd_piter_bbox.hh
===================================================================
--- oln/core/gen/fwd_piter_bbox.hh (revision 596)
+++ oln/core/gen/fwd_piter_bbox.hh (working copy)
@@ -56,6 +56,7 @@
{
typedef oln_type_of(topo, point) point_type;
typedef oln_type_of(topo, grid) grid_type;
+ typedef topo topo_type;
};
@@ -103,7 +104,7 @@
protected:
- const topo_t& topo_;
+ const topo_t topo_;
}; // end of class oln::fwd_piter_bbox_<point>
Index: oln/core/gen/bkd_piter_bbox.hh
===================================================================
--- oln/core/gen/bkd_piter_bbox.hh (revision 596)
+++ oln/core/gen/bkd_piter_bbox.hh (working copy)
@@ -56,6 +56,7 @@
{
typedef oln_type_of(topo, point) point_type;
typedef oln_type_of(topo, grid) grid_type;
+ typedef topo topo_type;
};
@@ -103,7 +104,7 @@
protected:
- const topo_t& topo_;
+ const topo_t topo_;
}; // end of class oln::bkd_piter_bbox_<point>
Index: oln/core/gen/topo_add_nbh.hh
===================================================================
--- oln/core/gen/topo_add_nbh.hh (revision 596)
+++ oln/core/gen/topo_add_nbh.hh (working copy)
@@ -89,6 +89,11 @@
return topo_;
}
+ operator topo_t() const
+ {
+ return topo_;
+ }
+
protected:
topo_t topo_;
Index: oln/core/internal/topology_morpher.hh
===================================================================
--- oln/core/internal/topology_morpher.hh (revision 596)
+++ oln/core/internal/topology_morpher.hh (working copy)
@@ -54,7 +54,13 @@
typedef morpher::tag::identity ret;
};
+ template <typename Topo, typename E>
+ struct single_vtype< internal::topology_morpher<Topo, E>, typedef_::delegated_type >
+ {
+ typedef Topo ret;
+ };
+
namespace internal
{
Index: oln/morpher/add_isubset.hh
===================================================================
--- oln/morpher/add_isubset.hh (revision 0)
+++ oln/morpher/add_isubset.hh (revision 0)
@@ -0,0 +1,125 @@
+// 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 OLN_MORPHER_ADD_ISUBSET
+# define OLN_MORPHER_ADD_ISUBSET
+
+# include <oln/morpher/internal/image_extension.hh>
+# include <oln/morpher/tags.hh>
+# include <oln/core/gen/topo_add_isubset.hh>
+# include <oln/core/gen/piter_isubset.hh>
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <typename Image, typename Isubset> struct add_isubset;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <typename Image, typename Isubset>
+ struct set_super_type< morpher::add_isubset<Image, Isubset> >
+ {
+ typedef morpher::add_isubset<Image, Isubset> self_t;
+ typedef morpher::internal::image_extension<Image, self_t> ret;
+ };
+
+ template <typename Image, typename Isubset>
+ struct vtypes< morpher::add_isubset<Image, Isubset> >
+ {
+ // Topology type.
+ typedef topo_add_isubset< oln_type_of(Image, topo), Isubset > topo_type;
+
+ // Piter types.
+ typedef piter_isubset_<oln_type_of(Image, fwd_piter), Isubset> fwd_piter_type;
+ typedef piter_isubset_<oln_type_of(Image, bkd_piter), Isubset> bkd_piter_type;
+
+ // Isubset type.
+ typedef Isubset subset_type;
+ };
+
+
+ namespace morpher
+ {
+ /// Isubset addition morpher.
+ template <typename Image, typename Isubset>
+ class add_isubset : public stc_get_supers(mlc_comma_1(add_isubset<Image, Isubset>))
+ {
+ private:
+
+ typedef add_isubset<Image, Isubset> self_t;
+ typedef stc_get_nth_super(self_t, 1) super_t;
+ typedef oln_type_of(self_t, topo) topo_t;
+
+ public:
+
+ // FIXME: Handle the constness.
+
+ add_isubset(const Image& image, const Isubset& isubset) :
+ super_t(image),
+ topo_(image.topo(), isubset)
+ {
+ mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Isubset, grid)>::check();
+ // FIXME: check that Image is without a isubset
+ }
+
+ const topo_t& impl_topo() const
+ {
+ return topo_;
+ }
+
+ protected:
+ topo_t topo_;
+ };
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I, typename S>
+ morpher::add_isubset<I, S>
+ operator | (const abstract::image<I>& image,
+ const abstract::binary_image<S>& isubset)
+ {
+ mlc::assert_equal_<oln_type_of(I, grid), oln_type_of(S, grid)>::check();
+ // FIXME: check that Image does not have yet a subset
+ morpher::add_isubset<I, S> tmp(image.exact(), isubset.exact());
+ return tmp;
+ }
+
+ // FIXME: Register this operator.
+ // FIXME: Add mutable version.
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_ADD_ISUBSET