https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Reorganize and fix oln/core/3d/.
* oln/core/3d/aliases.hh (oln::fwd_piter3d, oln::bkd_piter3d): Fix
their definitions.
* oln/core/3d/neighb3d.hh (c6, c18, c26)
(c4_slice, c8_slice, c4_row, c8_row, c4_col, c8_col): Rename as...
(mk_c6, mk_c18, mk_c26, mk_c4_slice, mk_c8_slice)
(mk_c4_row, mk_c8_row, mk_c4_col, mk_c8_col): ...these.
(c6, c18, c26, c4_slice, c8_slice, c4_row, c8_row)
(c4_col, c8_col): New objects.
* oln/core/3d/array3d.hh, oln/core/3d/dpoint3d.hh,
* oln/core/3d/image3d.hh, oln/core/3d/neighb3d.hh,
* oln/core/3d/point3d.hh: Separate the interface of the methods
and functions from their implementation.
* oln/core/3d/image3d.hh (oln::vtypes< image3d<T> >): Set
topo_type to topo3d.
(bbox_<point3d>): Move explicit instantiation...
* oln/basics3d.hh: ...here
(oln/core/fwd_piter.hh): Include it.
* oln/core/3d/image3d.hh: Move the definition of the virtual types
fwd_piter and bkd_piter of oln::image3d...
* oln/core/fwd_piter.hh: ...here.
* oln/core/abstract/image/hybrid/classical.hh
(oln::abstract:classical_3d_image): New.
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 3>): Rename
as...
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 4>): ...this.
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 3>): New.
Handle 3D case.
basics3d.hh | 4 -
core/3d/aliases.hh | 4 -
core/3d/array3d.hh | 81 ++++++++++++++++++++++----------
core/3d/dpoint3d.hh | 57 ++++++++++++++++------
core/3d/image3d.hh | 66 ++++++++++++++++++++------
core/3d/neighb3d.hh | 65 +++++++++++++++++++++----
core/3d/point3d.hh | 58 ++++++++++++++++------
core/abstract/image/hybrid/classical.hh | 31 +++++++++++-
core/abstract/point.hh | 1
core/fwd_piter.hh | 15 +++++
10 files changed, 297 insertions(+), 85 deletions(-)
Index: oln/core/fwd_piter.hh
--- oln/core/fwd_piter.hh (revision 626)
+++ oln/core/fwd_piter.hh (working copy)
@@ -144,10 +144,21 @@
typedef bkd_piter2d ret;
};
+
+ // image3d<T>
+
+ template <typename T> class image3d;
+
+ template <typename T>
+ struct single_vtype< image3d<T>, typedef_::fwd_piter_type >
+ {
+ typedef fwd_piter3d ret;
+ };
+
template <typename T>
- struct single_vtype< image2d<T>, typedef_::fwd_qiter_type >
+ struct single_vtype< image3d<T>, typedef_::bkd_piter_type >
{
- typedef fwd_qiter2d ret;
+ typedef bkd_piter3d ret;
};
Index: oln/core/abstract/image/hybrid/classical.hh
--- oln/core/abstract/image/hybrid/classical.hh (revision 626)
+++ oln/core/abstract/image/hybrid/classical.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/abstract/image/dimension/1d.hh>
# include <oln/core/abstract/image/dimension/2d.hh>
+# include <oln/core/abstract/image/dimension/3d.hh>
# include <oln/core/abstract/image/bbox/hierarchy.hh>
# include <oln/core/abstract/image/accessibility/hierarchy.hh>
@@ -70,6 +71,15 @@
classical_2d_image();
};
+ template <typename E>
+ struct classical_3d_image
+ : public virtual abstract::classical_image<E>,
+ public virtual abstract::image3d<E>
+ {
+ protected:
+ classical_3d_image();
+ };
+
# ifndef OLN_INCLUDE_ONLY
@@ -88,6 +98,11 @@
{
}
+ template <typename E>
+ classical_3d_image<E>::classical_3d_image()
+ {
+ }
+
# endif
} // end of namespace oln::abstract
@@ -96,6 +111,7 @@
// Fwd. decl.
class grid1d;
class grid2d;
+ class grid3d;
/// 1D case.
@@ -124,9 +140,22 @@
};
- /// General case.
+ /// 3D case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 3 > :
+ where_< mlc::and_list_< mlc::eq_< oln_type_of(E, grid), oln::grid3d >,
+ mlc::eq_< oln_deduce_type_of(E, topo, is_random_accessible), mlc::true_ >,
+ mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
+
+ >
+ {
+ typedef abstract::classical_3d_image<E> ret;
+ };
+
+
+ /// General case.
+ template <typename E>
+ struct case_< image_hybrid_hierarchy_wrt_classical, E, 4 > :
where_< mlc::and_< mlc::eq_< oln_deduce_type_of(E, topo,
is_random_accessible), mlc::true_ >,
mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
Index: oln/core/abstract/point.hh
--- oln/core/abstract/point.hh (revision 626)
+++ oln/core/abstract/point.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/traits_id.hh>
# include <oln/core/abstract/dpoint.hh>
+# include <xtd/vec.hh>
Index: oln/core/3d/aliases.hh
--- oln/core/3d/aliases.hh (revision 626)
+++ oln/core/3d/aliases.hh (working copy)
@@ -55,8 +55,8 @@
typedef bbox_<point3d> bbox3d;
typedef topo_lbbox_<point3d> topo3d;
- typedef fwd_piter_bbox_<topo3d> fwd_piter3d;
- typedef bkd_piter_bbox_<topo3d> bkd_piter3d;
+ typedef fwd_piter_bbox_<point3d> fwd_piter3d;
+ typedef bkd_piter_bbox_<point3d> bkd_piter3d;
typedef point3d_<float> point3df;
typedef dpoint3d_<float> dpoint3df;
Index: oln/core/3d/neighb3d.hh
--- oln/core/3d/neighb3d.hh (revision 626)
+++ oln/core/3d/neighb3d.hh (working copy)
@@ -36,8 +36,23 @@
namespace oln
{
+ namespace internal
+ {
+
+ neighb3d mk_c6();
+ neighb3d mk_c18();
+ neighb3d mk_c26();
+ neighb3d mk_c4_slice();
+ neighb3d mk_c8_slice();
+ neighb3d mk_c4_row();
+ neighb3d mk_c8_row();
+ neighb3d mk_c4_col();
+ neighb3d mk_c8_col();
+
+
+# ifndef OLN_INCLUDE_ONLY
- neighb3d c6()
+ neighb3d mk_c6()
{
static bool flower = true;
static neighb3d the_;
@@ -53,7 +68,7 @@
}
- neighb3d c18()
+ neighb3d mk_c18()
{
static bool flower = true;
static neighb3d the_;
@@ -75,7 +90,7 @@
}
- neighb3d c26()
+ neighb3d mk_c26()
{
static bool flower = true;
static neighb3d the_;
@@ -101,7 +116,7 @@
}
- neighb3d c4_slice()
+ neighb3d mk_c4_slice()
{
static bool flower = true;
static neighb3d the_;
@@ -116,7 +131,7 @@
}
- neighb3d c8_slice()
+ neighb3d mk_c8_slice()
{
static bool flower = true;
static neighb3d the_;
@@ -133,7 +148,7 @@
}
- neighb3d c4_row()
+ neighb3d mk_c4_row()
{
static bool flower = true;
static neighb3d the_;
@@ -148,7 +163,7 @@
}
- neighb3d c8_row()
+ neighb3d mk_c8_row()
{
static bool flower = true;
static neighb3d the_;
@@ -165,7 +180,7 @@
}
- neighb3d c4_col()
+ neighb3d mk_c4_col()
{
static bool flower = true;
static neighb3d the_;
@@ -180,7 +195,7 @@
}
- neighb3d c8_col()
+ neighb3d mk_c8_col()
{
static bool flower = true;
static neighb3d the_;
@@ -196,9 +211,39 @@
return the_;
}
+# endif
-} // end of namespace oln
+ } // end of namespace oln::internal
+
+
+ extern const neighb3d c6;
+ extern const neighb3d c18;
+ extern const neighb3d c26;
+ extern const neighb3d c4_slice;
+ extern const neighb3d c8_slice;
+ extern const neighb3d c4_row;
+ extern const neighb3d c8_row;
+ extern const neighb3d c4_col;
+ extern const neighb3d c8_col;
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ const neighb3d c6 = internal::mk_c6();
+ const neighb3d c18 = internal::mk_c18();
+ const neighb3d c26 = internal::mk_c26();
+
+ const neighb3d c4_slice = internal::mk_c4_slice();
+ const neighb3d c8_slice = internal::mk_c8_slice();
+ const neighb3d c4_row = internal::mk_c4_row();
+ const neighb3d c8_row = internal::mk_c8_row();
+ const neighb3d c4_col = internal::mk_c4_col();
+ const neighb3d c8_col = internal::mk_c8_col();
+
+# endif
+
+} // end of namespace oln
#endif // ! OLN_CORE_3D_NEIGHB3D_HH
Index: oln/core/3d/dpoint3d.hh
--- oln/core/3d/dpoint3d.hh (revision 626)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -70,38 +70,67 @@
{
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_()
+ dpoint3d_();
+
+ /// Ctor.
+ dpoint3d_(const xtd::vec<3,C>& v);
+
+ /// Ctor.
+ dpoint3d_(C slice, C row, C col);
+
+ C slice() const;
+ C& slice();
+
+ C row() const;
+ C& row();
+
+ C col() const;
+ C& col();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename C>
+ dpoint3d_<C>::dpoint3d_()
{
}
- /// Ctor.
- dpoint3d_(const xtd::vec<3,coord_t>& v)
+ template <typename C>
+ dpoint3d_<C>::dpoint3d_(const xtd::vec<3,C>& v)
: super_t(v)
{
}
- /// Ctor.
- dpoint3d_(coord_t slice, coord_t row, coord_t col)
+ template <typename C>
+ dpoint3d_<C>::dpoint3d_(C slice, C row, C col)
: super_t(xtd::mk_vec(slice, row, col))
{
}
- coord_t slice() const { return v_[0]; }
- coord_t& slice() { return v_[0]; }
+ template <typename C>
+ C dpoint3d_<C>::slice() const { return v_[0]; }
+ template <typename C>
+ C& dpoint3d_<C>::slice() { return v_[0]; }
+
+ template <typename C>
+ C dpoint3d_<C>::row() const { return v_[1]; }
+ template <typename C>
+ C& dpoint3d_<C>::row() { return v_[1]; }
+
+ template <typename C>
+ C dpoint3d_<C>::col() const { return v_[2]; }
+ template <typename C>
+ C& dpoint3d_<C>::col() { return v_[2]; }
- 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]; }
- };
+# endif
} // end of namespace oln
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 626)
+++ oln/core/3d/array3d.hh (working copy)
@@ -44,8 +44,42 @@
/// 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),
+ coord_t imax, coord_t jmax, coord_t kmax);
+ /// Ctor.
+ array3d(coord_t ilen, coord_t jlen, coord_t klen);
+
+ /// Dtor.
+ ~array3d();
+
+ value_t operator()(coord_t i, coord_t j, coord_t k) const;
+ value_t& operator()(coord_t i, coord_t j, coord_t k);
+
+ bool has(coord_t i, coord_t j, coord_t k) const;
+
+ size_t memsize() const;
+
+ 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_();
+ void deallocate_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename value_t, typename coord_t>
+ array3d<value_t, coord_t>::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);
@@ -55,9 +89,9 @@
allocate_();
}
- /// Ctor.
- array3d(coord_t ilen, coord_t jlen, coord_t klen) :
- imin_(0), jmin_(0), kmin_(0),
+ template <typename value_t, typename coord_t>
+ array3d<value_t, coord_t>::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);
@@ -67,25 +101,30 @@
allocate_();
}
- /// Dtor.
- ~array3d()
+ template <typename value_t, typename coord_t>
+ array3d<value_t, coord_t>::~array3d()
{
deallocate_();
}
- value_t operator()(coord_t i, coord_t j, coord_t k) const
+ template <typename value_t, typename coord_t>
+ value_t
+ array3d<value_t, coord_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)
+ template <typename value_t, typename coord_t>
+ value_t&
+ array3d<value_t, coord_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
+ template <typename value_t, typename coord_t>
+ bool array3d<value_t, coord_t>::has(coord_t i, coord_t j, coord_t k) const
{
return
i >= imin_ and i <= imax_ and
@@ -93,7 +132,8 @@
k >= kmin_ and k <= kmax_;
}
- size_t memsize() const
+ template <typename value_t, typename coord_t>
+ size_t array3d<value_t, coord_t>::memsize() const
{
return
// buffer_
@@ -106,17 +146,8 @@
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_()
+ template <typename value_t, typename coord_t>
+ void array3d<value_t, coord_t>::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_)];
@@ -135,7 +166,8 @@
array_1st_dim_ -= imin_;
}
- void deallocate_()
+ template <typename value_t, typename coord_t>
+ void array3d<value_t, coord_t>::deallocate_()
{
precondition(buffer_ != 0 and
array_2nd_dim_ != 0 and
@@ -148,7 +180,8 @@
delete[] array_1st_dim_;
array_1st_dim_ = 0; // safety
}
- };
+
+# endif
} // end of namespace oln
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 626)
+++ oln/core/3d/image3d.hh (working copy)
@@ -53,15 +53,11 @@
template <typename T>
struct vtypes< image3d<T> >
{
- // FIXME: or `typedef topo3d topo_type;' ?
- typedef topo_lbbox_<point3d> topo_type;
+ typedef topo3d 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;
@@ -90,7 +86,32 @@
/// Ctor using sizes.
image3d(unsigned nslices, unsigned nrows, unsigned ncols,
- unsigned border = 2)
+ unsigned border = 2);
+
+ /// Ctor using an existing topology.
+ image3d(const topo3d& topo);
+
+ const topo3d& impl_topo() const;
+
+ T impl_op_read(const point3d& p) const;
+ T& impl_op_readwrite(const point3d& p);
+
+ T* adr_at(int slice, int row, int col);
+ const T* adr_at(int slice, int row, int col) const;
+
+ private:
+
+ topo3d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image3d<T>::image3d(unsigned nslices, unsigned nrows, unsigned ncols,
+ unsigned border)
: topo_(bbox3d(point3d(0, 0, 0 ),
point3d(nslices - 1, nrows - 1, ncols - 1)),
border),
@@ -103,8 +124,8 @@
{
}
- /// Ctor using an existing topology.
- image3d(const topo3d& topo)
+ template <typename T>
+ image3d<T>::image3d(const topo3d& topo)
: topo_(topo),
data_(new array_t(topo.bbox().pmin().slice(),
topo.bbox().pmin().row(),
@@ -115,30 +136,45 @@
{
}
- const topo3d& impl_topo() const
+ template <typename T>
+ const topo3d& image3d<T>::impl_topo() const
{
return topo_;
}
- T impl_op_read(const point3d& p) const
+ template <typename T>
+ T image3d<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)
+ template <typename T>
+ T& image3d<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:
+ template <typename T>
+ T* image3d<T>::adr_at(int slice, int row, int col)
+ {
+ precondition(data_ != 0);
+ precondition(data_->has(slice, row, col));
+ return &(data_->operator()(slice, row, col));
+ }
- topo3d topo_;
- internal::tracked_ptr<array_t> data_;
- };
+ template <typename T>
+ const T* image3d<T>::adr_at(int slice, int row, int col) const
+ {
+ precondition(data_ != 0);
+ precondition(data_->has(slice, row, col));
+ return &(data_->operator()(slice, row, col));
+ }
+
+# endif
} // end of namespace oln
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 626)
+++ oln/core/3d/point3d.hh (working copy)
@@ -78,39 +78,67 @@
{
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_()
+ point3d_();
+
+ /// Ctor.
+ point3d_(C slice, C row, C col);
+
+ /// Ctor.
+ point3d_(const xtd::vec<3,C>& v);
+
+ C slice() const;
+ C& slice();
+
+ C row() const;
+ C& row();
+
+ C col() const;
+ C& col();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename C>
+ point3d_<C>::point3d_()
{
}
- /// Ctor.
- point3d_(coord_t slice, coord_t row, coord_t col)
+ template <typename C>
+ point3d_<C>::point3d_(C slice, C row, C col)
: super_t (xtd::mk_vec(slice, row, col))
{
}
- /// Ctor.
- point3d_(const xtd::vec<3,coord_t>& v)
+ template <typename C>
+ point3d_<C>::point3d_(const xtd::vec<3,C>& 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]; }
- };
+ template <typename C>
+ C point3d_<C>::slice() const { return v_[0]; }
+ template <typename C>
+ C& point3d_<C>::slice() { return v_[0]; }
+
+ template <typename C>
+ C point3d_<C>::row() const { return v_[1]; }
+ template <typename C>
+ C& point3d_<C>::row() { return v_[1]; }
+
+ template <typename C>
+ C point3d_<C>::col() const { return v_[2]; }
+ template <typename C>
+ C& point3d_<C>::col() { return v_[2]; }
+# endif
} // end of namespace oln
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 626)
+++ oln/basics3d.hh (working copy)
@@ -35,7 +35,6 @@
# include <oln/core/3d/grid3d.hh>
# include <oln/core/3d/point3d.hh>
-
# include <oln/core/3d/dpoint3d.hh>
# include <oln/core/gen/bbox.hh>
@@ -43,7 +42,6 @@
# include <oln/core/3d/bbox3d.hh>
# include <oln/core/gen/fwd_piter_bbox.hh>
-
# include <oln/core/gen/bkd_piter_bbox.hh>
# include <oln/core/gen/neighb.hh>
@@ -51,6 +49,8 @@
# include <oln/core/3d/image3d.hh>
+# include <oln/core/fwd_piter.hh>
+
# include <oln/core/spe/slice.hh>
# include <oln/core/spe/row.hh>
# include <oln/core/spe/col.hh>