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