Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2006
- 3 participants
- 108 discussions
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
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Clean up morphers.
* oln/morpher/identity.hh
(oln::vtypes< morpher::identity<Image> >): Remove (was useless).
(oln/morpher/tags.hh): Move header inclusion...
* oln/morpher/internal/image_extension.hh: ...here
* oln/morpher/add_neighborhood.hh, oln/morpher/add_isubset.hh
(oln/morpher/tags.hh): No longer include it.
* oln/morpher/tags.hh (oln::morpher::tag::add_neighborhood):
Remove (was useless).
(oln::morpher::tag::identity): Adjust documentation.
add_isubset.hh | 1 -
add_neighborhood.hh | 1 -
identity.hh | 11 -----------
internal/image_extension.hh | 1 +
tags.hh | 4 +---
5 files changed, 2 insertions(+), 16 deletions(-)
Index: oln/morpher/identity.hh
--- oln/morpher/identity.hh (revision 602)
+++ oln/morpher/identity.hh (working copy)
@@ -29,7 +29,6 @@
# define OLN_MORPHER_IDENTITY
# include <oln/morpher/internal/image_extension.hh>
-# include <oln/morpher/tags.hh>
namespace oln
@@ -52,16 +51,6 @@
};
- /// New virtual types associated with oln::morpher::identity.
- /// \{
- template <typename Image>
- struct vtypes< morpher::identity<Image> >
- {
- typedef oln::morpher::tag::identity morpher_type;
- };
- /// \}
-
-
namespace morpher
{
/// Identity morpher.
Index: oln/morpher/internal/image_extension.hh
--- oln/morpher/internal/image_extension.hh (revision 602)
+++ oln/morpher/internal/image_extension.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_MORPHER_INTERNAL_IMAGE_EXTENSION
# include <oln/core/image_entry.hh>
+# include <oln/morpher/tags.hh>
namespace oln
Index: oln/morpher/add_neighborhood.hh
--- oln/morpher/add_neighborhood.hh (revision 602)
+++ oln/morpher/add_neighborhood.hh (working copy)
@@ -29,7 +29,6 @@
# define OLN_MORPHER_ADD_NEIGHBORHOOD
# include <oln/morpher/internal/image_extension.hh>
-# include <oln/morpher/tags.hh>
# include <oln/core/gen/topo_add_nbh.hh>
Index: oln/morpher/add_isubset.hh
--- oln/morpher/add_isubset.hh (revision 602)
+++ oln/morpher/add_isubset.hh (working copy)
@@ -29,7 +29,6 @@
# 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>
Index: oln/morpher/tags.hh
--- oln/morpher/tags.hh (revision 602)
+++ oln/morpher/tags.hh (working copy)
@@ -35,10 +35,8 @@
{
namespace tag
{
- /// Tag associated to oln::morpher::identity.
+ /// Tag associated to oln::morpher::image_extension.
struct identity;
- /// Tag associated to oln::morpher::add_neighborhood.
- struct add_neighborhood;
} // end of namespace oln::morpher::tag
1
0
03 Oct '06
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Take borders into account in data allocation of image2d.
* oln/core/2d/image2d.hh (image2d(unsigned, unsigned, unsigned)):
Allocate space for the border in the array.
* oln/core/2d/point2d.hh, oln/core/typedefs.hh: Add FIXMEs.
* oln/core/2d/neighb2d.hh, oln/core/2d/dpoint2d.hh,
* oln/core/internal/point_nd.hh: Aesthetic changes.
2d/dpoint2d.hh | 2 --
2d/image2d.hh | 3 ++-
2d/neighb2d.hh | 3 ++-
2d/point2d.hh | 4 +++-
internal/point_nd.hh | 3 ++-
typedefs.hh | 1 +
6 files changed, 10 insertions(+), 6 deletions(-)
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 601)
+++ oln/core/2d/image2d.hh (working copy)
@@ -85,7 +85,8 @@
: topo_(bbox2d(point2d(0, 0),
point2d(nrows-1, ncols-1)),
border),
- data_(new array_t(0, 0, nrows-1, ncols-1))
+ data_(new array_t(0 - border, 0 - border,
+ nrows - 1 + border, ncols - 1 + border))
{
}
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 601)
+++ oln/core/2d/point2d.hh (working copy)
@@ -36,7 +36,9 @@
namespace oln
{
-
+ /* FIXME: Is this the right place for these functions (on types)?
+ In particular, the function on dpoint2d should be near the
+ definition of dpoint2d, not point2d's. */
/// Specializations of functions point and dpoint :
/// \f$(n, coord) \rightarrow type\f$ for \f$n = 2\f$.
/// \{
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh (revision 601)
+++ oln/core/typedefs.hh (working copy)
@@ -172,6 +172,7 @@
| category::grid. |
`-----------------*/
+ // FIXME: Merge with dim_type?
mlc_decl_typedef(dimvalue_type);
mlc_decl_typedef(coord_type);
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 601)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and Development Laboratory
+// 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
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 601)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -95,8 +95,6 @@
};
-
-
} // end of namespace oln
Index: oln/core/internal/point_nd.hh
--- oln/core/internal/point_nd.hh (revision 601)
+++ oln/core/internal/point_nd.hh (working copy)
@@ -41,7 +41,8 @@
{
- /// Function "point_ : (n, coord) -> point type".
+ /// Function \f$point : (n, coord) \rightarrow point type\f$.
+
template <unsigned n, typename C>
struct point_
{
1
0
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
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Separate tracked_ptr from array2d.
* oln/core/2d/array2d.hh (oln::tracked_ptr): Move...
* oln/core/internal/tracked_ptr.hh: ...here (new file).
* oln/core/2d/image2d.hh (oln::image2d::data_): Adjust type.
(oln::image2d(const topo2d&)): New ctor.
* tests/image2d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image2d.
(image2d_SOURCES): New.
oln/core/2d/array2d.hh | 169 ------------------------------
oln/core/2d/image2d.hh | 16 ++
oln/core/internal/tracked_ptr.hh | 213 +++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 2
tests/image2d.cc | 64 +++++++++++
5 files changed, 293 insertions(+), 171 deletions(-)
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 599)
+++ oln/core/2d/array2d.hh (working copy)
@@ -30,181 +30,12 @@
# define OLN_CORE_2D_ARRAY2D_HH
# include <cstdlib>
-# include <set>
# include <mlc/contract.hh>
namespace oln
{
- template <typename T>
- struct tracked_ptr
- {
- typedef tracked_ptr<T> self_t;
- typedef std::set<self_t*> holders_t;
-
- T* ptr_;
- holders_t* holders_;
-
- /// Coercion towards Boolean (for arithmetical tests).
- operator bool() const
- {
- invariant_();
- return ptr_ != 0;
- }
-
- /// Negation (for arithmetical tests).
- bool operator not() const
- {
- invariant_();
- return not bool(*this);
- }
-
- /*! \brief Mimics the behavior of op-> for a pointer in the const case.
- **
- ** \invariant Pointer proxy exists.
- */
- const T*const operator->() const
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
-
- /*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
- **
- ** \invariant Pointer proxy exists.
- */
- T*const operator->()
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
-
- /// Ctor.
- tracked_ptr() :
- ptr_(0),
- holders_(0)
- {
- invariant_();
- }
-
- /// Ctor.
- tracked_ptr(T* ptr) :
- ptr_(ptr)
- {
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- invariant_();
- }
-
- /// Cpy ctor.
- tracked_ptr(const self_t& rhs) :
- ptr_(rhs.ptr_),
- holders_(rhs.holders_)
- {
- rhs.invariant_();
- if (ptr_ != 0)
- holders_->insert(this);
- invariant_();
- }
-
- /// Assignment.
- self_t& operator=(const self_t& rhs)
- {
- invariant_();
- rhs.invariant_();
- if (&rhs == this or rhs.ptr_ == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = rhs.ptr_;
- holders_ = rhs.holders_;
- holders_->insert(this);
- return *this;
- }
-
- /// Assignment.
- self_t& operator=(T* ptr)
- {
- invariant_();
- if (ptr == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = ptr;
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- return *this;
- }
-
- /// Dtor.
- ~tracked_ptr()
- {
- clean_();
- }
-
- void invariant_() const
- {
- invariant((ptr_ and holders_) or (not ptr_ and not holders_));
- if (ptr_ == 0)
- return;
- invariant(holders_->size() > 0);
- self_t* this_ = const_cast<self_t*>(this);
- invariant(holders_->find(this_) != holders_->end());
- typename holders_t::const_iterator i;
- for (i = holders_->begin(); i != holders_->end(); ++i)
- invariant((*i)->ptr_ == ptr_);
- }
-
- void clean_()
- {
- invariant_();
- if (ptr_ == 0)
- // no-op
- return;
- if (holders_->size() == 1)
- {
- delete ptr_;
- delete holders_;
- }
- else
- holders_->erase(this);
- ptr_ = 0;
- holders_ = 0;
- invariant_();
- }
-
- friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp)
- {
- ostr << "tracked_ptr @ " << (&tp)
- << " { ptr = " << tp.ptr_
- << " / holders = ";
- if (tp.holders_ == 0)
- ostr << "0";
- else
- {
- typename holders_t::const_iterator i;
- for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
- ostr << (*i) << ' ';
- }
- ostr << " }";
- return ostr;
- }
- };
-
-
/// General 2D array class.
template <typename value_t, typename coord_t = int>
class array2d
Index: oln/core/internal/tracked_ptr.hh
--- oln/core/internal/tracked_ptr.hh (revision 0)
+++ oln/core/internal/tracked_ptr.hh (revision 0)
@@ -0,0 +1,213 @@
+// 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_INTERNAL_TRACKED_PTR_HH
+# define OLN_CORE_INTERNAL_TRACKED_PTR_HH
+
+# include <set>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct tracked_ptr
+ {
+ typedef tracked_ptr<T> self_t;
+ typedef std::set<self_t*> holders_t;
+
+ T* ptr_;
+ holders_t* holders_;
+
+ /// Coercion towards Boolean (for arithmetical tests).
+ operator bool() const
+ {
+ invariant_();
+ return ptr_ != 0;
+ }
+
+ /// Negation (for arithmetical tests).
+ bool operator not() const
+ {
+ invariant_();
+ return not bool(*this);
+ }
+
+ /*! \brief Mimics the behavior of op-> for a pointer in the const case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ const T*const operator->() const
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ /*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ T*const operator->()
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ /// Ctor.
+ tracked_ptr() :
+ ptr_(0),
+ holders_(0)
+ {
+ invariant_();
+ }
+
+ /// Ctor.
+ tracked_ptr(T* ptr) :
+ ptr_(ptr)
+ {
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ invariant_();
+ }
+
+ /// Cpy ctor.
+ tracked_ptr(const self_t& rhs) :
+ ptr_(rhs.ptr_),
+ holders_(rhs.holders_)
+ {
+ rhs.invariant_();
+ if (ptr_ != 0)
+ holders_->insert(this);
+ invariant_();
+ }
+
+ /// Assignment.
+ self_t& operator=(const self_t& rhs)
+ {
+ invariant_();
+ rhs.invariant_();
+ if (&rhs == this or rhs.ptr_ == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = rhs.ptr_;
+ holders_ = rhs.holders_;
+ holders_->insert(this);
+ return *this;
+ }
+
+ /// Assignment.
+ self_t& operator=(T* ptr)
+ {
+ invariant_();
+ if (ptr == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = ptr;
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ return *this;
+ }
+
+ /// Dtor.
+ ~tracked_ptr()
+ {
+ clean_();
+ }
+
+ void invariant_() const
+ {
+ invariant((ptr_ and holders_) or (not ptr_ and not holders_));
+ if (ptr_ == 0)
+ return;
+ invariant(holders_->size() > 0);
+ self_t* this_ = const_cast<self_t*>(this);
+ invariant(holders_->find(this_) != holders_->end());
+ typename holders_t::const_iterator i;
+ for (i = holders_->begin(); i != holders_->end(); ++i)
+ invariant((*i)->ptr_ == ptr_);
+ }
+
+ void clean_()
+ {
+ invariant_();
+ if (ptr_ == 0)
+ // no-op
+ return;
+ if (holders_->size() == 1)
+ {
+ delete ptr_;
+ delete holders_;
+ }
+ else
+ holders_->erase(this);
+ ptr_ = 0;
+ holders_ = 0;
+ invariant_();
+ }
+
+ friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp)
+ {
+ ostr << "tracked_ptr @ " << (&tp)
+ << " { ptr = " << tp.ptr_
+ << " / holders = ";
+ if (tp.holders_ == 0)
+ ostr << "0";
+ else
+ {
+ typename holders_t::const_iterator i;
+ for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
+ ostr << (*i) << ' ';
+ }
+ ostr << " }";
+ return ostr;
+ }
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_TRACKED_PTR_HH
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 599)
+++ oln/core/2d/image2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/image_entry.hh>
# include <oln/core/2d/array2d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
namespace oln
@@ -44,6 +45,7 @@
template <typename T>
struct vtypes< image2d<T> >
{
+ // FIXME: or `typedef topo2d topo_type;' ?
typedef topo_lbbox_<point2d> topo_type;
typedef grid2d grid_type;
@@ -78,7 +80,7 @@
public:
- /// Ctor.
+ /// Ctor using sizes.
image2d(unsigned nrows, unsigned ncols, unsigned border = 2)
: topo_(bbox2d(point2d(0, 0),
point2d(nrows-1, ncols-1)),
@@ -87,6 +89,16 @@
{
}
+ /// Ctor using an existing topology.
+ image2d(const topo2d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().row(),
+ topo.bbox().pmin().col(),
+ topo.bbox().pmax().row(),
+ topo.bbox().pmax().col()))
+ {
+ }
+
const topo2d& impl_topo() const
{
return topo_;
@@ -109,7 +121,7 @@
private:
topo2d topo_;
- tracked_ptr<array_t> data_;
+ internal::tracked_ptr<array_t> data_;
};
Index: tests/image2d.cc
--- tests/image2d.cc (revision 0)
+++ tests/image2d.cc (revision 0)
@@ -0,0 +1,64 @@
+// 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::image2d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics2d.hh, but
+// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?).
+#include <oln/basics2d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 2-d image using its iterator.
+ oln::image2d<char> ima1(3, 3);
+ oln_type_of_(oln::image2d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 2-d image using a classic loop.
+ oln::image2d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ for (unsigned j = 0; j < 3; ++j)
+ ima2(oln::point2d(i, j)) = 2;
+
+ // Fill a 2-d image using the routine oln::level::fill.
+ oln::image2d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image2d<long> sum(ima1.topo());
+ oln_type_of_(oln::image2d<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 599)
+++ tests/Makefile.am (working copy)
@@ -18,6 +18,7 @@
check_PROGRAMS = \
grid \
image_entry \
+ image2d \
npoints \
\
identity_morpher \
@@ -29,6 +30,7 @@
# Images and auxiliary structures.
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
+image2d_SOURCES = image2d.cc
npoints_SOURCES = npoints.cc
# Morphers.
1
0
Oops.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 598)
+++ ChangeLog (revision 599)
@@ -13,11 +13,6 @@
(oln::dpoint2d_): Use stc_get_supers to set the base class.
(oln::dpoint2d_::super_t): Use stc_get_super to define it.
-2006-10-02 Roland Levillain <roland(a)lrde.epita.fr>
-
- * oln/core/2d/array2d.hh (oln::tracked_ptr): Move...
- * oln/core/internal/tracked_ptr.hh: ...here (new file).
-
2006-10-02 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add isubset image morpher and subsequent tools.
1
0
02 Oct '06
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix the inheritance of oln::point2d_ and oln::dpoint2d_.
* oln/core/2d/point2d.hh (oln::set_super_type< point2d_<C> >):
New.
(oln::point2d_): Use stc_get_supers to set the base class.
(oln::point2d_::super_t): Use stc_get_super to define it.
(oln::point2d_::point2d_(coord_t, coord_t)): Use xtd::mk_vec
to initialize the base class.
* oln/core/2d/dpoint2d.hh (oln::set_super_type< dpoint2d_<C> >):
Re-enable it.
(oln::dpoint2d_): Use stc_get_supers to set the base class.
(oln::dpoint2d_::super_t): Use stc_get_super to define it.
dpoint2d.hh | 24 +++++++++++++-----------
point2d.hh | 25 ++++++++++++++++---------
2 files changed, 29 insertions(+), 20 deletions(-)
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 597)
+++ oln/core/2d/point2d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and Development Laboratory
+// 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
@@ -36,13 +37,22 @@
{
+ /// Specializations of functions point and dpoint :
+ /// \f$(n, coord) \rightarrow type\f$ for \f$n = 2\f$.
/// \{
- /// Specializations of functions point and dpoint : (n,coord) -> type for n = 2.
template <typename C> struct point_ <2, C> { typedef point2d_<C> ret; };
template <typename C> struct dpoint_ <2, C> { typedef dpoint2d_<C> ret; };
/// \}
+ /// Super type.
+ template<typename C>
+ struct set_super_type< point2d_<C> >
+ {
+ typedef internal::point_nd< point2d_<C> > ret;
+ };
+
+
/// Virtual types associated to oln::point2d_<C>.
template <typename C>
struct vtypes< point2d_<C> >
@@ -56,18 +66,16 @@
/// General 2D point class.
template <typename C>
- class point2d_ : public internal::point_nd< point2d_<C> > // FIXME: stc_get_super_(point2d_<C>)
+ class point2d_ : public stc_get_supers(point2d_<C>)
{
typedef point2d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
+ typedef stc_get_super(point2d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
public:
- // Cf. BUG! typedef oln_type_of(self_t, grid) grid_t;
- typedef oln_type_of(self_t, coord) coord_t;
-
/// Ctor.
point2d_()
{
@@ -75,9 +83,8 @@
/// Ctor.
point2d_(coord_t row, coord_t col)
+ : super_t (xtd::mk_vec(row, col))
{
- v_[0] = row;
- v_[1] = col;
}
/// Ctor.
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 597)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and Development Laboratory
+// 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
@@ -37,12 +38,12 @@
{
-// /// Super type.
-// template<typename C>
-// struct set_super_type< dpoint2d_<C> >
-// {
-// typedef abstract::dpoint< dpoint2d_<C> > ret;
-// };
+ /// Super type.
+ template<typename C>
+ struct set_super_type< dpoint2d_<C> >
+ {
+ typedef internal::dpoint_nd< dpoint2d_<C> > ret;
+ };
/// Virtual types associated to oln::dpoint2d_<C>.
@@ -58,10 +59,11 @@
/// General 2D dpoint class.
template <typename C>
- class dpoint2d_ : public internal::dpoint_nd< dpoint2d_<C> > // FIXME: stc_get_super_(dpoint2d_<C>)
+ class dpoint2d_
+ : public stc_get_supers(dpoint2d_<C>)
{
typedef dpoint2d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t; // FIXME: stc_get_super(self_t)
+ typedef stc_get_super(dpoint2d_<C>) super_t;
typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
@@ -74,8 +76,8 @@
}
/// Ctor.
- dpoint2d_(const xtd::vec<2,coord_t>& v) :
- super_t(v)
+ dpoint2d_(const xtd::vec<2,coord_t>& v)
+ : super_t(v)
{
}
1
0
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
1
0