https://svn.lrde.epita.fr/svn/oln/trunk/olena
I'm currently working on a ``slice'' morpher; this is why I added 1-d
and 3-d images.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add oln::image3d and associated types.
* oln/core/3d/image3d.hh, oln/core/3d/array3d.hh,
* oln/core/3d/point3d.hh, oln/core/3d/dpoint3d.hh,
* oln/core/3d/neighb3d.hh, oln/core/3d/aliases.hh,
* oln/basics3d.hh: New.
* oln/core/abstract/point_set_being_connected.hh
(oln::abstract::point_set_being_3d_connected): New class.
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 3>): New
case.
* tests/image3d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image3d.
(image3d_SOURCES): New.
oln/basics3d.hh | 62 +++++++
oln/core/3d/aliases.hh | 69 ++++++++
oln/core/3d/array3d.hh | 157 +++++++++++++++++++
oln/core/3d/dpoint3d.hh | 104 ++++++++++++
oln/core/3d/image3d.hh | 139 +++++++++++++++++
oln/core/3d/neighb3d.hh | 204 +++++++++++++++++++++++++
oln/core/3d/point3d.hh | 114 +++++++++++++
oln/core/abstract/point_set_being_connected.hh | 41 +++++
tests/Makefile.am | 2
tests/image3d.cc | 65 +++++++
10 files changed, 957 insertions(+)
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 0)
+++ oln/core/3d/image3d.hh (revision 0)
@@ -0,0 +1,139 @@
+// 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_3D_IMAGE3D_HH
+# define OLN_CORE_3D_IMAGE3D_HH
+
+# include <oln/core/image_entry.hh>
+# include <oln/core/3d/array3d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ template <typename T> class image3d;
+
+
+ /// Virtual types associated to oln::image3d<T>.
+ template <typename T>
+ struct vtypes< image3d<T> >
+ {
+ // FIXME: or `typedef topo3d topo_type;' ?
+ typedef topo_lbbox_<point3d> topo_type;
+ typedef grid3d grid_type;
+
+ typedef point3d 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 image3d<T> real_type;
+ };
+
+
+ /// Super type declaration.
+ template <typename T>
+ struct set_super_type< image3d<T> >
+ {
+ typedef image3d<T> self_t;
+ typedef image_entry<self_t> ret;
+ };
+
+
+ /// General 3D image class.
+ template <typename T>
+ class image3d : public image_entry< image3d<T> >
+ {
+ typedef image3d<T> self_t;
+ typedef array3d<T> array_t;
+
+ public:
+
+ /// Ctor using sizes.
+ image3d(unsigned nslices, unsigned nrows, unsigned ncols,
+ unsigned border = 2)
+ : topo_(bbox3d(point3d(0, 0, 0 ),
+ point3d(nslices - 1, nrows - 1, ncols - 1)),
+ border),
+ data_(new array_t(0 - border,
+ 0 - border,
+ 0 - border,
+ nslices - 1 + border,
+ nrows - 1 + border,
+ ncols - 1 + border))
+ {
+ }
+
+ /// Ctor using an existing topology.
+ image3d(const topo3d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().slice(),
+ topo.bbox().pmin().row(),
+ topo.bbox().pmin().col(),
+ topo.bbox().pmax().slice(),
+ topo.bbox().pmax().row(),
+ topo.bbox().pmax().col()))
+ {
+ }
+
+ const topo3d& impl_topo() const
+ {
+ return topo_;
+ }
+
+ T impl_op_read(const point3d& p) const
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.slice(), p.row(), p.col());
+ }
+
+ T& impl_op_readwrite(const point3d& p)
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.slice(), p.row(), p.col());
+ }
+
+ private:
+
+ topo3d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_IMAGE3D_HH
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 0)
+++ oln/core/3d/array3d.hh (revision 0)
@@ -0,0 +1,157 @@
+// 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_3D_ARRAY3D_HH
+# define OLN_CORE_3D_ARRAY3D_HH
+
+# include <cstdlib>
+# include <mlc/contract.hh>
+
+
+namespace oln
+{
+
+ /// General 3D array class.
+ template <typename value_t, typename coord_t = int>
+ class array3d
+ {
+ public:
+
+ /// Ctor.
+ array3d(coord_t imin, coord_t jmin, coord_t kmin,
+ coord_t imax, coord_t jmax, coord_t kmax) :
+ imin_(imin), jmin_(jmin), kmin_(kmin),
+ imax_(imax), jmax_(jmax), kmax_(kmax)
+ {
+ precondition(imax >= imin and jmax >= jmin and kmax >= kmin);
+ ilen_ = imax - imin + 1;
+ jlen_ = jmax - jmin + 1;
+ klen_ = kmax - kmin + 1;
+ allocate_();
+ }
+
+ /// Ctor.
+ array3d(coord_t ilen, coord_t jlen, coord_t klen) :
+ imin_(0), jmin_(0), kmin_(0),
+ ilen_(ilen), jlen_(jlen), klen_(klen)
+ {
+ precondition(ilen > 0 and jlen > 0 and klen > 0);
+ imax_ = imin_ + ilen_;
+ jmax_ = jmin_ + ilen_;
+ kmax_ = kmin_ + klen_;
+ allocate_();
+ }
+
+ /// Dtor.
+ ~array3d()
+ {
+ deallocate_();
+ }
+
+ value_t operator()(coord_t i, coord_t j, coord_t k) const
+ {
+ precondition(has(i, j, k));
+ return array_1st_dim_[i][j][k];
+ }
+
+ value_t& operator()(coord_t i, coord_t j, coord_t k)
+ {
+ precondition(has(i, j, k));
+ return array_1st_dim_[i][j][k];
+ }
+
+ bool has(coord_t i, coord_t j, coord_t k) const
+ {
+ return
+ i >= imin_ and i <= imax_ and
+ j >= jmin_ and j <= jmax_ and
+ k >= kmin_ and k <= kmax_;
+ }
+
+ size_t memsize() const
+ {
+ return
+ // buffer_
+ size_t(ilen_) * size_t(jlen_) * size_t(klen_) * sizeof(value_t)
+ +
+ // array_2nd_dim_
+ size_t(ilen_) * size_t(jlen_) * sizeof(value_t*)
+ +
+ // array_1st_dim_
+ size_t(ilen_) * sizeof(value_t*);
+ }
+
+ protected:
+
+ coord_t imin_, jmin_, kmin_, imax_, jmax_, kmax_;
+ coord_t ilen_, jlen_, klen_;
+ value_t* buffer_;
+ value_t** array_2nd_dim_;
+ value_t*** array_1st_dim_;
+
+ private:
+
+ void allocate_()
+ {
+ buffer_ = new value_t[size_t(ilen_) * size_t(jlen_) * size_t(klen_)];
+ array_2nd_dim_ = new value_t*[size_t(ilen_) * size_t(jlen_)];
+ array_1st_dim_ = new value_t**[size_t(ilen_)];
+ value_t* buf = buffer_ - kmin_;
+ for (coord_t i = 0; i < ilen_; ++i)
+ {
+ value_t** nth_array_2nd_dim = array_2nd_dim_ + i * jlen_;
+ array_1st_dim_[i] = nth_array_2nd_dim - jmin_;
+ for (coord_t j = 0; j < jlen_; ++j)
+ {
+ nth_array_2nd_dim[j] = buf;
+ buf += klen_;
+ }
+ }
+ array_1st_dim_ -= imin_;
+ }
+
+ void deallocate_()
+ {
+ precondition(buffer_ != 0 and
+ array_2nd_dim_ != 0 and
+ array_1st_dim_ != 0);
+ delete[] buffer_;
+ buffer_ = 0; // safety
+ delete[] array_2nd_dim_;
+ array_2nd_dim_ = 0; // safety
+ array_1st_dim_ += imin_;
+ delete[] array_1st_dim_;
+ array_1st_dim_ = 0; // safety
+ }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_ARRAY3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 0)
+++ oln/core/3d/point3d.hh (revision 0)
@@ -0,0 +1,114 @@
+// 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_3D_POINT3D_HH
+# define OLN_CORE_3D_POINT3D_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 dpoint3d should be near the
+ definition of dpoint3d, not point3d's. */
+ /// Specializations of functions point and dpoint :
+ /// \f$(n, coord) \rightarrow type\f$ for \f$n = 3\f$.
+ /// \{
+ template <typename C> struct point_ <3, C> { typedef point3d_<C>
ret; };
+ template <typename C> struct dpoint_ <3, C> { typedef dpoint3d_<C>
ret; };
+ /// \}
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< point3d_<C> >
+ {
+ typedef internal::point_nd< point3d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::point3d_<C>.
+ template <typename C>
+ struct vtypes< point3d_<C> >
+ {
+ typedef grid3d grid_type;
+ typedef dpoint3d dpoint_type;
+ typedef C coord_type;
+ typedef mlc::uint_<3> dim_type;
+ };
+
+
+ /// General 3D point class.
+ template <typename C>
+ class point3d_ : public stc_get_supers(point3d_<C>)
+ {
+ typedef point3d_<C> self_t;
+ typedef stc_get_super(point3d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ point3d_()
+ {
+ }
+
+ /// Ctor.
+ point3d_(coord_t slice, coord_t row, coord_t col)
+ : super_t (xtd::mk_vec(slice, row, col))
+ {
+ }
+
+ /// Ctor.
+ point3d_(const xtd::vec<3,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ coord_t slice() const { return v_[0]; }
+ coord_t& slice() { return v_[0]; }
+
+ coord_t row() const { return v_[1]; }
+ coord_t& row() { return v_[1]; }
+
+ coord_t col() const { return v_[2]; }
+ coord_t& col() { return v_[2]; }
+ };
+
+
+} // end of namespace oln
+
+# include <oln/core/3d/dpoint3d.hh>
+
+
+#endif // ! OLN_CORE_3D_POINT3D_HH
Index: oln/core/3d/dpoint3d.hh
--- oln/core/3d/dpoint3d.hh (revision 0)
+++ oln/core/3d/dpoint3d.hh (revision 0)
@@ -0,0 +1,104 @@
+// 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_3D_DPOINT3D_HH
+# define OLN_CORE_3D_DPOINT3D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/internal/dpoint_nd.hh>
+
+
+namespace oln
+{
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< dpoint3d_<C> >
+ {
+ typedef internal::dpoint_nd< dpoint3d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::dpoint3d_<C>.
+ template <typename C>
+ struct vtypes< dpoint3d_<C> >
+ {
+ typedef grid3d grid_type;
+ typedef point3d point_type;
+ typedef C coord_type;
+ typedef mlc::uint_<3> dim_type;
+ };
+
+
+ /// General 3D dpoint class.
+ template <typename C>
+ class dpoint3d_
+ : public stc_get_supers(dpoint3d_<C>)
+ {
+ typedef dpoint3d_<C> self_t;
+ typedef stc_get_super(dpoint3d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ dpoint3d_()
+ {
+ }
+
+ /// Ctor.
+ dpoint3d_(const xtd::vec<3,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ /// Ctor.
+ dpoint3d_(coord_t slice, coord_t row, coord_t col)
+ : super_t(xtd::mk_vec(slice, row, col))
+ {
+ }
+
+ coord_t slice() const { return v_[0]; }
+ coord_t& slice() { return v_[0]; }
+
+ coord_t row() const { return v_[1]; }
+ coord_t& row() { return v_[1]; }
+
+ coord_t col() const { return v_[2]; }
+ coord_t& col() { return v_[2]; }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_DPOINT3D_HH
Index: oln/core/3d/neighb3d.hh
--- oln/core/3d/neighb3d.hh (revision 0)
+++ oln/core/3d/neighb3d.hh (revision 0)
@@ -0,0 +1,204 @@
+// 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_3D_NEIGHB3D_HH
+# define OLN_CORE_3D_NEIGHB3D_HH
+
+# include <oln/core/gen/neighb.hh>
+# include <oln/core/3d/aliases.hh>
+
+
+namespace oln
+{
+
+
+ neighb3d c6()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c18()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1))
+ .add(dpoint3d(1, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c26()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1))
+ .add(dpoint3d(1, -1, -1))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, -1, 1))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1))
+ .add(dpoint3d(1, 1, -1))
+ .add(dpoint3d(1, 1, 0))
+ .add(dpoint3d(1, 1, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_slice()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_slice()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_row()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_row()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_col()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_col()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_CORE_3D_NEIGHB3D_HH
Index: oln/core/3d/aliases.hh
--- oln/core/3d/aliases.hh (revision 0)
+++ oln/core/3d/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_3D_ALIASES_HH
+# define OLN_CORE_3D_ALIASES_HH
+
+
+namespace oln
+{
+
+ /// \{
+ /// Forward declarations.
+ template <typename C> class point3d_;
+ template <typename C> class dpoint3d_;
+ 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 grid3d;
+ /// \}
+
+
+ /// \{
+ /// Alliases.
+ typedef point3d_<int> point3d;
+ typedef dpoint3d_<int> dpoint3d;
+
+ typedef neighb_<dpoint3d> neighb3d;
+
+ typedef bbox_<point3d> bbox3d;
+ typedef topo_lbbox_<point3d> topo3d;
+ typedef fwd_piter_bbox_<topo3d> fwd_piter3d;
+ typedef bkd_piter_bbox_<topo3d> bkd_piter3d;
+
+ typedef point3d_<float> point3df;
+ typedef dpoint3d_<float> dpoint3df;
+ /// \}
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_ALIASES_HH
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 0)
+++ oln/basics3d.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_BASICS3D_HH
+# define OLN_BASICS3D_HH
+
+
+# include <oln/core/3d/aliases.hh>
+
+# include <oln/core/3d/grid3d.hh>
+
+# include <oln/core/3d/point3d.hh>
+namespace oln { template class point3d_<int>; }
+
+# include <oln/core/3d/dpoint3d.hh>
+namespace oln { template class dpoint3d_<int>; }
+
+# include <oln/core/gen/bbox.hh>
+namespace oln { template class bbox_<point3d>; }
+
+# include <oln/core/gen/topo_lbbox.hh>
+namespace oln { template class topo_lbbox_<point3d>; }
+
+# include <oln/core/gen/fwd_piter_bbox.hh>
+namespace oln { template class fwd_piter_bbox_<topo3d>; }
+
+# include <oln/core/gen/bkd_piter_bbox.hh>
+namespace oln { template class bkd_piter_bbox_<topo3d>; }
+
+# include <oln/core/gen/neighb.hh>
+namespace oln { template class neighb_<dpoint3d>; }
+# include <oln/core/3d/neighb3d.hh>
+
+# include <oln/core/3d/image3d.hh>
+
+
+#endif // ! OLN_BASICS3D_HH
Index: oln/core/abstract/point_set_being_connected.hh
--- oln/core/abstract/point_set_being_connected.hh (revision 604)
+++ oln/core/abstract/point_set_being_connected.hh (working copy)
@@ -79,6 +79,35 @@
{}
};
+ template <typename E>
+ class point_set_being_3d_connected : public virtual abstract::point_set<E>
+ {
+ public:
+
+ unsigned nslices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ unsigned nrows() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(1);
+ }
+
+ unsigned ncols() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(2);
+ }
+
+ protected:
+
+ point_set_being_3d_connected()
+ {}
+ };
+
} // end of namespace oln::abstract
@@ -86,6 +115,7 @@
// Forward declarations.
class grid1d;
class grid2d;
+ class grid3d;
template <typename E>
@@ -110,6 +140,17 @@
typedef abstract::point_set_being_2d_connected<E> ret;
};
+ template <typename E>
+ struct case_ < point_set_hierarchy_wrt_connectivity, E, 3 >
+ : 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), grid3d >
+ > >
+ {
+ typedef abstract::point_set_being_3d_connected<E> ret;
+ };
+
} // end of namespace oln
Index: tests/Makefile.am
--- tests/Makefile.am (revision 604)
+++ tests/Makefile.am (working copy)
@@ -22,6 +22,7 @@
image_entry \
image1d \
image2d \
+ image3d \
npoints \
\
identity_morpher \
@@ -37,6 +38,7 @@
image_entry_SOURCES = image_entry.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
+image3d_SOURCES = image3d.cc
npoints_SOURCES = npoints.cc
# Morphers.
Index: tests/image3d.cc
--- tests/image3d.cc (revision 0)
+++ tests/image3d.cc (revision 0)
@@ -0,0 +1,65 @@
+// 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::image3d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics3d.hh, but
+// oln/core/3d/image3d.hh (and oln/core/3d/neigh3d.hh ?).
+#include <oln/basics3d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 3-d image using its iterator.
+ oln::image3d<char> ima1(3, 3, 3);
+ oln_type_of_(oln::image3d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 3-d image using a classic loop.
+ oln::image3d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ for (unsigned j = 0; j < 3; ++j)
+ for (unsigned k = 0; k < 3; ++k)
+ ima2(oln::point3d(i, j, k)) = 2;
+
+ // Fill a 3-d image using the routine oln::level::fill.
+ oln::image3d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image3d<long> sum(ima1.topo());
+ oln_type_of_(oln::image3d<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);
+}