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
March 2007
- 7 participants
- 73 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add type of 2d images with border.
* tests/core/Makefile.am (check_PROGRAMS): Add neighb2d.
* oln/debug/print.hh: Update.
* oln/core/2d/array2d.hh (operator[], blen_): New.
* oln/core/2d/image2d.hh (npoints): Fix; rename as...
(impl_npoints): ...this.
(operator[]): Update.
* oln/core/2d/image2d_b.hh: Update.
* oln/core/2d/grid2d.hh (OLN_ENV_2D): New.
* oln/core/equipment.hh (oln_coord): New.
* oln/core/gen/dpoints_piter.hh (dps_): Change type.
* oln/core/internal/image_base.hh (impl_npoints): New; default impl.
* oln/core/internal/point_set_std_based.hh: Fix.
oln/core/2d/array2d.hh | 27 +++
oln/core/2d/grid2d.hh | 4
oln/core/2d/image2d.hh | 9 -
oln/core/2d/image2d_b.hh | 213 ++++++++++++++++++++-----------
oln/core/equipment.hh | 2
oln/core/gen/dpoints_piter.hh | 9 -
oln/core/internal/image_base.hh | 9 +
oln/core/internal/point_set_std_based.hh | 2
oln/debug/print.hh | 55 +++++---
tests/core/Makefile.am | 2
10 files changed, 231 insertions(+), 101 deletions(-)
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 863)
+++ tests/core/Makefile.am (working copy)
@@ -23,6 +23,7 @@
point2d \
grid \
image2d \
+ neighb2d \
npoints \
neighb2d \
window2d \
@@ -33,6 +34,7 @@
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image2d_SOURCES = image2d.cc
+neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
window2d_SOURCES = window2d.cc
neighb2d_SOURCES = neighb2d.cc
Index: oln/debug/print.hh
--- oln/debug/print.hh (revision 863)
+++ oln/debug/print.hh (working copy)
@@ -29,11 +29,7 @@
# define OLN_DEBUG_PRINT_HH
# include <iostream>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/hybrid/classical.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/spe/row.hh>
-# include <oln/core/spe/col.hh>
+# include <oln/core/concept/image.hh>
# ifdef OLN_ENV_2D
# include <oln/core/2d/point2d.hh>
@@ -49,7 +45,7 @@
/// Fwd decl.
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr = std::cout);
+ void print(const Image<I>& input, std::ostream& ostr = std::cout);
# ifndef OLN_INCLUDE_ONLY
@@ -70,30 +66,47 @@
/// Generic version.
+
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr)
+ void print_Gen(const Image<I>& input, std::ostream& ostr)
{
- oln_vtype(I, fwd_piter) p(input.topo());
+ oln_fwd_piter(I) p(input.points());
for_all(p)
ostr << p.to_point() << ':' << format(input(p)) << ' ';
}
+ template <typename I>
+ void print(const Image<I>& input, std::ostream& ostr)
+ {
+ print_Gen(input, ostr);
+ }
+
+
# ifdef OLN_ENV_2D
+ /// Default version.
+
+ template <typename I>
+ void print_2D(const Image<I>&, const I& input, std::ostream& ostr)
+ {
+ print_Gen(input, ostr);
+ }
+
/// Version for classical 2D images.
+
template <typename I>
- void print(const abstract::classical_2d_image<I>& input,
+ void print_2D(const Point_Wise_Accessible_Image<I>&, const I& input,
std::ostream& ostr)
{
const oln_coord(I)
- min_row = oln::min_row(input),
- max_row = oln::max_row(input);
+ min_row = input.bbox().pmin().row(),
+ max_row = input.bbox().pmax().row();
+ const oln_coord(I)
+ min_col = input.bbox().pmin().col(),
+ max_col = input.bbox().pmax().col();
for (oln_coord(I) row = min_row; row <= max_row; ++row)
{
- const oln_coord(I)
- min_col = oln::min_col(input),
- max_col = oln::max_col(input);
for (oln_coord(I) col = min_col; col <= max_col; ++col)
{
point2d p(row, col);
@@ -107,7 +120,13 @@
}
}
-# endif
+ template <typename I>
+ void print(const Image_2D<I>& input, std::ostream& ostr)
+ {
+ impl::print_2D(exact(input), exact(input), ostr);
+ }
+
+# endif // OLN_ENV_2D
} // end of namespace oln::debug::impl
@@ -115,13 +134,15 @@
/// Facade.
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr)
+ void print(const Image<I>& input, std::ostream& ostr)
{
- impl::print(input.exact(), ostr);
+ impl::print(exact(input), ostr);
}
+
# endif // ! OLN_INCLUDE_ONLY
+
} // end of namespace oln::debug
} // end of namespace oln
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 863)
+++ oln/core/2d/array2d.hh (working copy)
@@ -55,6 +55,9 @@
const T& operator()(C i, C j) const;
T& operator()(C i, C j);
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
+
bool has(C i, C j) const;
std::size_t memsize() const;
@@ -72,6 +75,7 @@
C imin_, jmin_, imax_, jmax_;
C ilen_, jlen_;
+ std::size_t blen_;
T* buffer_;
T** array_;
@@ -132,6 +136,22 @@
}
template <typename T, typename C>
+ const T& array2d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array2d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
bool array2d_<T, C>::has(C i, C j) const
{
return
@@ -179,7 +199,7 @@
template <typename T, typename C>
std::size_t array2d_<T, C>::ncells() const
{
- return std::size_t(ilen_) * std::size_t(jlen_);
+ return blen_;
}
template <typename T, typename C>
@@ -187,7 +207,7 @@
{
return
// buffer_
- std::size_t(ilen_) * std::size_t(jlen_) * sizeof(T)
+ blen_ * sizeof(T)
+
// array_
std::size_t(ilen_) * sizeof(T*);
@@ -196,7 +216,8 @@
template <typename T, typename C>
void array2d_<T, C>::allocate_()
{
- buffer_ = new T[std::size_t(ilen_) * std::size_t(jlen_)];
+ blen_ = std::size_t(ilen_) * std::size_t(jlen_);
+ buffer_ = new T[blen_];
array_ = new T*[std::size_t(ilen_)];
T* buf = buffer_ - jmin_;
for (C i = 0; i < ilen_; ++i)
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 863)
+++ oln/core/2d/image2d.hh (working copy)
@@ -95,7 +95,7 @@
T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- std::size_t npoints() const;
+ std::size_t impl_npoints() const;
box2d impl_bbox() const;
box2d impl_points() const;
@@ -157,7 +157,7 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->buffer()[i];
+ return this->data_->operator[](i);
}
template <typename T>
@@ -179,7 +179,7 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->buffer()[i];
+ return this->data_->operator[](i);
}
template <typename T>
@@ -190,8 +190,9 @@
}
template <typename T>
- std::size_t image2d<T>::npoints() const
+ std::size_t image2d<T>::impl_npoints() const
{
+ // faster than the default code given by primitive_image_
assert(this->has_data());
return this->data_->ncells();
}
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 863)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -29,79 +29,124 @@
#ifndef OLN_CORE_2D_IMAGE2D_B_HH
# define OLN_CORE_2D_IMAGE2D_B_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/topo2d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/2d/box2d.hh>
namespace oln
{
- // Forward declaration.
+
+ // FIXME: Move it!
+
+ namespace internal
+ {
+
+
+ template <typename P, typename T>
+ struct f_point_value_to_array_;
+
+ template <typename T>
+ struct f_point_value_to_array_< point2d, T >
+ {
+ typedef array2d_<T, int> ret;
+ };
+
+
+ template <typename P, typename T>
+ struct array_b_
+ {
+ typedef typename f_point_value_to_array_<P, T>::ret array_t;
+ typedef typename P::coord coord;
+
+ array_b_(const P& pmin, const P& pmax, unsigned border)
+ : array(pmin.row() - border, pmin.col() - border,
+ pmax.row() + border, pmax.col() + border),
+ border(border),
+ box(pmin, pmax)
+ {
+ }
+
+ array_t array;
+ unsigned border;
+ box_<P> box;
+ };
+
+
+ } // end of namespace oln::internal
+
+
+ // end of FIXME
+
+
+
+ // Fwd decl.
template <typename T> class image2d_b;
- /// Virtual types associated to oln::image2d_b<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image2d_b<T> >
{
- typedef topo2d topo_type;
+ typedef point2d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
- typedef point2d point_type;
+ typedef box2d pset;
+ typedef internal::array_b_<point2d, T> data;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ // FIXME: wrong qiter!!!
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image2d_b<T> >
+ struct super_trait_< image2d_b<T> >
{
- typedef image2d_b<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image2d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 2D image class.
+
template <typename T>
- class image2d_b : public image_entry< image2d_b<T> >
+ class image2d_b : public internal::plain_primitive_image_< image2d_b<T> >
{
- typedef image2d_b<T> self_t;
- typedef array2d<T> array_t;
-
+ typedef image2d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
public:
+ stc_using(data);
- /// Ctor without info.
image2d_b();
-
- /// Ctor using sizes.
+ image2d_b(const box2d& b, unsigned border = 2);
image2d_b(unsigned nrows, unsigned ncols, unsigned border = 2);
- /// Ctor using an existing topology.
- image2d_b(const topo2d& topo);
+ bool impl_owns_(const point2d& p) const;
- const topo2d& impl_topo() const;
+ bool impl_has(const point2d& p) const;
+ bool impl_has_at(int row, int col) const;
- T impl_op_read(const point2d& p) const;
- T impl_at(int row, int col) const;
+ const T& impl_read(const point2d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int row, int col) const;
- T& impl_op_readwrite(const point2d& p);
+ T& impl_read_write(const point2d& p);
+ T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- T* adr_at(int row, int col);
- const T* adr_at(int row, int col) const;
+ std::size_t impl_npoints() const;
- private:
+ box2d impl_bbox() const;
+ box2d impl_points() const;
- topo2d topo_;
- internal::tracked_ptr<array_t> data_;
+ unsigned border() const;
};
@@ -110,86 +155,108 @@
template <typename T>
image2d_b<T>::image2d_b()
- : topo_(),
- data_()
{
}
template <typename T>
+ image2d_b<T>::image2d_b(const box2d& b, unsigned border)
+ {
+ this->data_ = new data(b.pmin(), b.pmax(), border);
+ }
+
+ template <typename T>
image2d_b<T>::image2d_b(unsigned nrows, unsigned ncols, unsigned border)
- : topo_(bbox2d(point2d(0, 0 ),
- point2d(nrows - 1, ncols - 1)),
- border),
- data_(new array_t(0 - border, 0 - border,
- nrows - 1 + border, ncols - 1 + border))
{
+ precondition(nrows != 0 and ncols != 0);
+ this->data_ = new data(point2d(0, 0),
+ point2d(nrows - 1, ncols - 1),
+ border);
}
template <typename T>
- image2d_b<T>::image2d_b(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()))
+ bool image2d_b<T>::impl_owns_(const point2d& p) const
{
+ assert(this->has_data());
+ return this->data_->array.has(p.row(), p.col());
}
+ template <typename T>
+ bool image2d_b<T>::impl_has(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->box.has(p);
+ }
template <typename T>
- const topo2d& image2d_b<T>::impl_topo() const
+ bool image2d_b<T>::impl_has_at(int row, int col) const
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->box.has(point2d(row, col));
}
+ template <typename T>
+ const T& image2d_b<T>::impl_read(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->array(p.row(), p.col());
+ }
template <typename T>
- T image2d_b<T>::impl_op_read(const point2d& p) const
+ const T& image2d_b<T>::impl_index_read(unsigned i) const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->array[i];
}
template <typename T>
- T image2d_b<T>::impl_at(int row, int col) const
+ const T& image2d_b<T>::impl_at(int row, int col) const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->array(row, col);
}
+ template <typename T>
+ T& image2d_b<T>::impl_read_write(const point2d& p)
+ {
+ assert(this->has_data());
+ return this->data_->array(p.row(), p.col());
+ }
template <typename T>
- T& image2d_b<T>::impl_op_readwrite(const point2d& p)
+ T& image2d_b<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->array[i];
}
template <typename T>
T& image2d_b<T>::impl_at(int row, int col)
{
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->array(row, col);
}
+ template <typename T>
+ box2d image2d_b<T>::impl_bbox() const
+ {
+ assert(this->has_data());
+ return this->data_->box;
+ }
template <typename T>
- T* image2d_b<T>::adr_at(int row, int col)
+ box2d image2d_b<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ return this->data_->box;
}
template <typename T>
- const T* image2d_b<T>::adr_at(int row, int col) const
+ unsigned image2d_b<T>::border() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ return this->data_->border;
}
# endif
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 863)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -32,6 +32,10 @@
# include <oln/core/concept/grid.hh>
+# define OLN_ENV_2D
+
+
+
namespace oln
{
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 863)
+++ oln/core/equipment.hh (working copy)
@@ -55,6 +55,8 @@
stc_decl_associated_type( coord );
stc_decl_associated_type( ch_value );
+# define oln_coord(T) oln_typename_shortcut__(T, coord)
+
// d
stc_decl_associated_type( data );
stc_decl_associated_type( dim );
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 863)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -80,6 +80,9 @@
{
public:
+ dpoints_piter_impl_(const dpoints_piter_impl_&);
+ void operator=(const dpoints_piter_impl_&);
+
void impl_invalidate();
bool impl_is_valid() const;
@@ -91,7 +94,7 @@
protected:
const P* p_ref_;
- const std::vector<typename P::dpoint>* dps_;
+ std::vector<typename P::dpoint> dps_;
unsigned n_, i_;
P p_;
@@ -168,7 +171,7 @@
const internal::dpoints_impl_<typename P::dpoint>& data)
{
p_ref_ = point_adr_(ref);
- dps_ = &(data.dpoints());
+ dps_ = data.dpoints();
n_ = data.size();
i_ = n_;
postcondition(n_ != 0);
@@ -206,7 +209,7 @@
void
dpoints_piter_impl_<P>::update_p_()
{
- p_ = *p_ref_+ (*dps_)[i_];
+ p_ = *p_ref_+ dps_[i_];
}
} // end of namespace oln::internal
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 863)
+++ oln/core/internal/image_base.hh (working copy)
@@ -208,6 +208,8 @@
template <typename Exact>
class primitive_image_ : public image_base_<Exact>
{
+ public:
+ std::size_t impl_npoints() const;
protected:
primitive_image_();
};
@@ -309,6 +311,13 @@
{
}
+ template <typename Exact>
+ std::size_t primitive_image_<Exact>::impl_npoints() const
+ {
+ precondition(this->has_data());
+ return this->pset().npoints();
+ }
+
/// plain_primitive_image_<Exact>
template <typename Exact>
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 863)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -153,7 +153,7 @@
const typename point_set_std_based_<Exact>::std_container&
point_set_std_based_<Exact>::con() const
{
- this->con_;
+ return this->con_;
}
# endif
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update tests.
* tests/core/image_entry.cc: Remove; obsolete.
* tests/core/window2d.cc,
* tests/core/point2d.cc,
* tests/core/dpoint2d.cc,
* tests/core/at.cc,
* tests/core/Makefile.am,
* tests/core/grid.cc,
* tests/core/image2d.cc,
* tests/core/npoints.cc,
* oln/debug/print_nbh.hh,
* oln/level/fill.hh: Update.
oln/core/concept/image.hh | 12 +--
oln/core/equipment.hh | 23 +++++-
oln/debug/print_nbh.hh | 6 +
oln/level/fill.hh | 164 ++++++++++++++++------------------------------
tests/core/Makefile.am | 9 --
tests/core/at.cc | 19 ++---
tests/core/dpoint2d.cc | 10 +-
tests/core/grid.cc | 18 ++---
tests/core/image2d.cc | 16 ++--
tests/core/npoints.cc | 8 +-
tests/core/point2d.cc | 9 --
tests/core/window2d.cc | 54 ++++-----------
12 files changed, 145 insertions(+), 203 deletions(-)
Index: tests/core/window2d.cc
--- tests/core/window2d.cc (revision 859)
+++ tests/core/window2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -27,40 +27,25 @@
/// Test oln::window2d.
-#include <oln/basics2d.hh>
-#include <oln/debug/print.hh>
-#include <oln/io/pnm.hh>
-#include <oln/morpher/add_neighborhood.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/window2d.hh>
-#include "data.hh"
namespace test
{
template <typename I, typename W>
- void run(const oln::abstract::image<I>& ima,
- const oln::abstract::window<W>& win)
+ unsigned run(const oln::Point_Wise_Accessible_Image<I>& input,
+ const oln::Window<W>& win)
{
- oln_piter(I) p(ima.topo());
- oln_qiter(I) q(p, win);
+ oln_piter(I) p(input.points());
+ oln_qiter(W) q(p, win);
+ unsigned count = 0;
for_all(p)
- {
-#if 0
- // Disable the display to speed up the test.
- std::cout << unsigned(ima(p)) << ": ";
-#endif
for_all(q)
- {
-#if 0
- // Likewise.
- std::cout << unsigned(ima(q)) << " ";
-#endif
- }
-#if 0
- // Likewise.
- std::cout << std::endl;
-#endif
- }
+ if (input.has(q))
+ ++count;
+ return count;
}
}
@@ -70,16 +55,9 @@
{
using namespace oln;
- image2d<unsigned char> ima = io::load_pgm(rdata("lena32.pgm"));
-#if 0
- // Disable the display to speed up the test.
- debug::println(ima);
-#endif
-
- window2d win;
- win
- .add(dpoint2d(-1, 0))
- .add(dpoint2d(-2, 0));
-
- test::run(ima, win);
+ image2d<bool> ima(3, 3);
+ // 4 + 6 + 4 +
+ // 6 + 9 + 6 +
+ // 4 + 6 + 4 = 49
+ assert(test::run(ima, win3x3) = 49);
}
Index: tests/core/point2d.cc
--- tests/core/point2d.cc (revision 859)
+++ tests/core/point2d.cc (working copy)
@@ -25,19 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#include <mlc/assert.hh>
-#include <mlc/is_a.hh>
-// FIXME: There is an inter-dependency between point2d and dpoint2d.
-// Maybe we'll solve this with the interface/implementation separation?
#include <oln/core/2d/point2d.hh>
-#include <oln/core/2d/dpoint2d.hh>
int
main()
{
- typedef oln::point2d_<int> point_t;
+ typedef oln::point2d point_t;
mlc::assert_<
- mlc_is_a_( point_t, oln::internal::point_nd )
+ mlc_is_a_( point_t, oln::Point )
>::check();
}
Index: tests/core/dpoint2d.cc
--- tests/core/dpoint2d.cc (revision 859)
+++ tests/core/dpoint2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -29,17 +29,17 @@
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
-#include <oln/basics2d.hh>
+#include <oln/core/2d/dpoint2d.hh>
int
main()
{
- typedef oln::dpoint2d_<int> dpoint_t;
+ typedef oln::dpoint2d dpoint_t;
mlc::assert_<
- mlc_is_a_( dpoint_t, oln::internal::dpoint_nd )
+ mlc_is_a_( dpoint_t, oln::Dpoint )
>::check();
- typedef oln_vtype_(dpoint_t, vec) vec_t;
+ typedef dpoint_t::vec_t vec_t;
mlc::assert_< mlc_is_a_( vec_t, mlc_comma_1(xtd::vec< 2u, int >) ) >::check();
}
Index: tests/core/at.cc
--- tests/core/at.cc (revision 859)
+++ tests/core/at.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -26,11 +26,9 @@
// Public License.
#include <cassert>
-// FIXME: Don't include oln/basics2d.hh, which is too big.
-// (Fix.)
-#include <oln/basics1d.hh>
-#include <oln/basics2d.hh>
-#include <oln/morpher/add_neighborhood.hh>
+// FIXME: Disabled #include <oln/basics1d.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/neighb2d.hh>
int
@@ -46,8 +44,9 @@
assert(ima(p) = 51);
- image1d<int> sig(1);
- point1d i(0);
- (sig + c2).at(0) = 51;
- assert(sig(i) = 51);
+ // FIXME: Disabled
+// image1d<int> sig(1);
+// point1d i(0);
+// (sig + c2).at(0) = 51;
+// assert(sig(i) = 51);
}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 859)
+++ tests/core/Makefile.am (working copy)
@@ -22,26 +22,17 @@
dpoint2d \
point2d \
grid \
- image_entry \
- image1d \
image2d \
- image3d \
npoints \
- pw_value \
window2d \
- \
at
# Images and auxiliary structures.
dpoint2d_SOURCES = dpoint2d.cc
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
-image_entry_SOURCES = image_entry.cc
-image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
-image3d_SOURCES = image3d.cc
npoints_SOURCES = npoints.cc
-pw_value_SOURCES = pw_value.cc
window2d_SOURCES = window2d.cc
# Methods.
Index: tests/core/grid.cc
--- tests/core/grid.cc (revision 859)
+++ tests/core/grid.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -28,10 +28,11 @@
/// Test grids.
#include <cassert>
-#include <oln/core/1d/aliases.hh>
-#include <oln/core/2d/aliases.hh>
-#include <oln/core/3d/aliases.hh>
-#include <oln/core/gen/grid.hh>
+#include <oln/core/2d/grid2d.hh>
+// FIXME: Disabled.
+// #include <oln/core/1d/aliases.hh>
+// #include <oln/core/3d/aliases.hh>
+
int
main()
@@ -39,7 +40,8 @@
// The extra pairs of parenthesis around mlc_value are needed to
// prevent the assert macro from interpreting the arguments of
// mlc_value as its own.
- assert((mlc_value(oln_vtype_(oln::grid1d, dimvalue))) = 1);
- assert((mlc_value(oln_vtype_(oln::grid2d, dimvalue))) = 2);
- assert((mlc_value(oln_vtype_(oln::grid3d, dimvalue))) = 3);
+ assert((mlc_value(oln::grid2d::dim)) = 2);
+ // FIXME: Disabled.
+// assert((mlc_value(oln::grid1d::dim)) = 1);
+// assert((mlc_value(oln::grid3d::dim)) = 3);
}
Index: tests/core/image2d.cc
--- tests/core/image2d.cc (revision 859)
+++ tests/core/image2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -30,7 +30,7 @@
#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/core/2d/image2d.hh>
#include <oln/level/fill.hh>
int
@@ -38,24 +38,24 @@
{
// Fill a 2D image using its iterator.
oln::image2d<char> ima1(3, 3);
- oln_vtype_(oln::image2d<char>, piter) p1(ima1.topo());
+ oln::image2d<char>::piter p1(ima1.points());
for_all(p1)
ima1(p1) = 1;
// Fill a 2D image using a classic loop.
- oln::image2d<int> ima2(ima1.topo());
+ oln::image2d<int> ima2(ima1.points());
for (unsigned i = 0; i < 3; ++i)
for (unsigned j = 0; j < 3; ++j)
- ima2(oln::point2d(i, j)) = 2;
+ ima2.at(i, j) = 2;
// Fill a 2D image using the routine oln::level::fill.
- oln::image2d<long> ima3(ima1.topo());
+ oln::image2d<long> ima3(ima1.points());
oln::level::fill(ima3, 3);
// Add the three images.
- oln::image2d<long> sum(ima1.topo());
- oln_vtype_(oln::image2d<long>, piter) p(sum.topo());
+ oln::image2d<long> sum(ima1.points());
+ oln::image2d<long>::piter p(sum.points());
for_all(p)
sum(p) = ima1(p) + ima2(p) + ima3(p);
// And check the sum.
Index: tests/core/npoints.cc
--- tests/core/npoints.cc (revision 859)
+++ tests/core/npoints.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -28,13 +28,13 @@
/// Test image2d.
#include <cassert>
-#include <oln/basics2d.hh>
+#include <oln/core/2d/image2d.hh>
template <typename I>
-unsigned npoints(const oln::abstract::image<I>& input)
+unsigned npoints(const oln::Image<I>& input)
{
- oln_vtype(I, piter) p(input.topo());
+ typename I::piter p(input.points());
unsigned count = 0;
for_all(p)
++count;
Index: oln/debug/print_nbh.hh
--- oln/debug/print_nbh.hh (revision 859)
+++ oln/debug/print_nbh.hh (working copy)
@@ -49,7 +49,8 @@
// Image
template <typename I>
- void print_nbh(const Image<I>&, const I& input, std::ostream& ostr)
+ void print_nbh(const Image<I>&,
+ const I& input, std::ostream& ostr)
{
typename I::fwd_piter p(input.points());
typename I::fwd_niter n(p, input.nbhood());
@@ -67,7 +68,8 @@
// Point_Wise_Accessible_Image
template <typename I>
- void print_nbh(const Point_Wise_Accessible_Image<I>&,const I& input, std::ostream& ostr)
+ void print_nbh(const Point_Wise_Accessible_Image<I>&,
+ const I& input, std::ostream& ostr)
{
typename I::fwd_piter p(input.points());
typename I::fwd_niter n(p, input.nbhood());
Index: oln/level/fill.hh
--- oln/level/fill.hh (revision 859)
+++ oln/level/fill.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
@@ -29,12 +29,8 @@
#ifndef OLN_LEVEL_FILL_HH
# define OLN_LEVEL_FILL_HH
-# include <iostream>
-
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/value_wise_accessibility/hierarchy.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/functions.hh>
+# include <oln/core/concept/image.hh>
+// # include <oln/core/concept/function.hh>
namespace oln
@@ -46,159 +42,119 @@
}
- /// Fwd decl.
- template <typename I, typename V>
- I& operator<<(abstract::mutable_image<I>& input, const V values[]);
-
- /// Fwd decl.
- template <typename I>
- I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value);
-
-
namespace level
{
- /// Fwd decl.
+ /// Fwd decls.
+
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value);
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value);
- /// Fwd decl.
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[]);
+ void fill(Mutable_Image<I>& input, const V values[]);
- /// Fwd decl.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&));
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&));
- /// Fwd decl.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun);
- /// Fwd decl.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value);
+
+ // FIXME: Inactivated.
+
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun);
+
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value);
# ifndef OLN_INCLUDE_ONLY
+
namespace impl
{
- /// Generic version.
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value)
{
- oln_piter(I) p(input.topo());
+ oln_piter(I) p(input.points());
for_all(p)
input(p) = value;
}
- /// Generic version.
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input,
+// const oln_value(I)& value)
+// {
+// oln_viter(I) v(input);
+// for_all(v)
+// input.value_(v) = value;
+// }
+
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[])
+ void fill(Mutable_Image<I>& input, const V values[])
{
- oln_piter(I) p(input.topo());
+ oln_piter(I) p(input.points());
unsigned i = 0;
for_all(p)
input(p) = values[i++];
}
- /// Generic version.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&))
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&))
{
- oln_piter(I) p(input.topo());
- unsigned i = 0;
+ oln_piter(I) p(input.points());
for_all(p)
input(p) = fun(p);
}
- /// Generic version.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun)
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun.exact()(p);
- }
-
- /// Version specialized for mutable images being value-wise
- /// random accessible.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value)
- {
- // FIXME: We should not need to call exact() here.
- oln_viter(I) v(input.exact());
- for_all(v)
- input.value(v) = value;
- }
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun)
+// {
+// oln_piter(I) p(input.points());
+// for_all(p)
+// input(p) = fun.exact()(p);
+// }
} // end of namespace oln::level::impl
- /// Facade.
+
+ /// Facades.
+
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value)
{
- impl::fill(input.exact(), value);
+ impl::fill(exact(input), value);
}
- /// Facade.
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[])
+ void fill(Mutable_Image<I>& input, const V values[])
{
- return impl::fill(input.exact(), values);
+ impl::fill(exact(input), values);
}
- /// Facade.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&))
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&))
{
- return impl::fill(input.exact(), fun);
+ impl::fill(exact(input), fun);
}
- /// Facade.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun)
- {
- return impl::fill(input.exact(), fun);
- }
-
- /// Facade.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value)
- {
- return impl::fill(input.exact(), value);
- }
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun)
+// {
+// impl::fill(exact(input), fun);
+// }
+
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value)
+// {
+// impl::fill(exact(input), value);
+// }
# endif
} // end of namespace oln::level
-
-# ifndef OLN_INCLUDE_ONLY
-
- /// Fwd decl.
- template <typename I, typename V>
- I& operator<<(abstract::mutable_image<I>& input, const V values[])
- {
- level::fill(input, values);
- return input.exact();
- }
-
- /// Fwd decl.
- template <typename I>
- I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value)
- {
- level::fill(input, value);
- return input.exact();
- }
-
-# endif
-
} // end of namespace oln
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 859)
+++ oln/core/concept/image.hh (working copy)
@@ -215,7 +215,7 @@
{
stc_typename(vsite);
stc_typename(rvaluep);
- rvaluep value(const vsite& v) const;
+ rvaluep value_(const vsite& v) const;
protected:
Value_Wise_Accessible_Image();
@@ -232,7 +232,7 @@
using Value_Wise_Accessible_Image<Exact>::value;
stc_typename(lvaluep);
- lvaluep value(const vsite& v);
+ lvaluep value_(const vsite& v);
protected:
Value_Wise_Mutable_Image();
@@ -440,7 +440,7 @@
template <typename Exact>
typename Value_Wise_Accessible_Image<Exact>::rvaluep
- Value_Wise_Accessible_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
+ Value_Wise_Accessible_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
{
return exact(this)->impl_value_read(v);
}
@@ -454,7 +454,7 @@
template <typename Exact>
typename Value_Wise_Mutable_Image<Exact>::lvaluep
- Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
+ Value_Wise_Mutable_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
return exact(this)->impl_value_read_write(v);
}
@@ -514,7 +514,7 @@
Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
{
typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
- return this->at(p);
+ return this->operator()(p);
}
template <typename Exact>
@@ -536,7 +536,7 @@
Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
typename Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
- return this->at(p);
+ return this->operator()(p);
}
template <typename Exact>
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 859)
+++ oln/core/equipment.hh (working copy)
@@ -28,12 +28,14 @@
#ifndef OLN_CORE_EQUIPMENT_HH
# define OLN_CORE_EQUIPMENT_HH
-# include <cassert>
-# include <mlc/value.hh>
# include <mlc/contract.hh>
# include <oln/stc/scoop.hh> // FIXME: Remove "oln/" later.
+# define oln_typename_shortcut__(Type, Alias) typename Type::Alias
+
+
+
namespace oln
{
@@ -45,6 +47,10 @@
stc_decl_associated_type( bkd_qiter );
stc_decl_associated_type( box );
+# define oln_bkd_niter(T) oln_typename_shortcut__(T, bkd_niter)
+# define oln_bkd_piter(T) oln_typename_shortcut__(T, bkd_piter)
+# define oln_bkd_qiter(T) oln_typename_shortcut__(T, bkd_qiter)
+
// c
stc_decl_associated_type( coord );
stc_decl_associated_type( ch_value );
@@ -59,6 +65,10 @@
stc_decl_associated_type( fwd_piter );
stc_decl_associated_type( fwd_qiter );
+# define oln_fwd_niter(T) oln_typename_shortcut__(T, fwd_niter)
+# define oln_fwd_piter(T) oln_typename_shortcut__(T, fwd_piter)
+# define oln_fwd_qiter(T) oln_typename_shortcut__(T, fwd_qiter)
+
// g
stc_decl_associated_type( grid );
@@ -75,6 +85,8 @@
stc_decl_associated_type( nbh );
stc_decl_associated_type( niter );
+# define oln_niter(T) oln_typename_shortcut__(T, niter)
+
// o
stc_decl_associated_type( oper );
stc_decl_associated_type( output );
@@ -85,9 +97,14 @@
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
+# define oln_piter(T) oln_typename_shortcut__(T, piter)
+# define oln_point(T) oln_typename_shortcut__(T, point)
+
// q
stc_decl_associated_type( qiter );
+# define oln_qiter(T) oln_typename_shortcut__(T, qiter)
+
// r
stc_decl_associated_type( right );
stc_decl_associated_type( rvalue );
@@ -103,6 +120,8 @@
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
+# define oln_value(T) oln_typename_shortcut__(T, value)
+
} // end of namespace oln
1
0
859: Add the notion of image plus neighborhood and the underlying mechanism.
by Thierry Geraud 08 Mar '07
by Thierry Geraud 08 Mar '07
08 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the notion of image plus neighborhood and the underlying
mechanism.
* oln/debug/print_nbh.hh,
* oln/debug/iota.hh,
* oln/core/concept/image_identity.hh,
* oln/core/gen/op.hh,
* oln/core/internal/op_image_plus_nbh.hh,
* oln/core/internal/special_op.hh: New.
* oln/core/concept/image.hh (fwd_niter, bkd_niter, niter): New.
* oln/core/concept/neighborhood.hh (category): New.
(include): Add op_image_plus_nbh.hh.
(oln_decl_op_plus): New. Handle "Image + Neighborhood".
* oln/core/equipment.hh (left, right, oper, tag): New.
* oln/core/gen/single_value_image.hh: Fix.
* oln/core/internal/neighborhood_base.hh (category): New.
(neighborhood_base_): Fix inheritance.
* oln/core/internal/image_base.hh (image_extension_): New.
(image_base_): Add dpoint.
* oln/stc/scoop.hxx (vtypes, super_trait_): Add specialization
for const types.
(super_trait_): Handle error when not user-defined.
core/concept/image.hh | 5
core/concept/image_identity.hh | 292 +++++++++++++++++++++++++++++++++++++
core/concept/neighborhood.hh | 6
core/equipment.hh | 6
core/gen/op.hh | 162 ++++++++++++++++++++
core/gen/single_value_image.hh | 5
core/internal/image_base.hh | 35 ++++
core/internal/neighborhood_base.hh | 3
core/internal/op_image_plus_nbh.hh | 102 ++++++++++++
core/internal/special_op.hh | 76 +++++++++
debug/iota.hh | 56 +++++++
debug/print_nbh.hh | 101 ++++++++++++
stc/scoop.hxx | 21 ++
13 files changed, 863 insertions(+), 7 deletions(-)
Index: oln/debug/print_nbh.hh
--- oln/debug/print_nbh.hh (revision 0)
+++ oln/debug/print_nbh.hh (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007 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_DEBUG_PRINT_NBH_HH
+# define OLN_DEBUG_PRINT_NBH_HH
+
+# include <iostream>
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+ // fwd decl
+ template <typename I>
+ void print_nbh(const Image_with_Nbh<I>& input, std::ostream& ostr = std::cout);
+
+
+ namespace impl
+ {
+
+ // Image
+
+ template <typename I>
+ void print_nbh(const Image<I>&, const I& input, std::ostream& ostr)
+ {
+ typename I::fwd_piter p(input.points());
+ typename I::fwd_niter n(p, input.nbhood());
+ for_all(p)
+ {
+ ostr << input(p) << ": ";
+ for_all(n)
+ if (input.owns_(n))
+ ostr << input(n) << " ";
+ ostr << std::endl;
+ }
+ }
+
+
+ // Point_Wise_Accessible_Image
+
+ template <typename I>
+ void print_nbh(const Point_Wise_Accessible_Image<I>&,const I& input, std::ostream& ostr)
+ {
+ typename I::fwd_piter p(input.points());
+ typename I::fwd_niter n(p, input.nbhood());
+ for_all(p)
+ {
+ ostr << input(p) << ": ";
+ for_all(n)
+ if (input.has(n))
+ ostr << input(n) << " ";
+ ostr << std::endl;
+ }
+ }
+
+ } // end of namespace oln::debug::impl
+
+
+ // facade
+ template <typename I>
+ void print_nbh(const Image_with_Nbh<I>& input, std::ostream& ostr)
+ {
+ impl::print_nbh(exact(input), exact(input), ostr);
+ }
+
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_PRINT_NBH_HH
Index: oln/debug/iota.hh
--- oln/debug/iota.hh (revision 0)
+++ oln/debug/iota.hh (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 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_DEBUG_IOTA_HH
+# define OLN_DEBUG_IOTA_HH
+
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+
+ template <typename I>
+ void iota(Mutable_Image<I>& in_out)
+ {
+ typename I::value v = 0;
+ typename I::fwd_piter p(in_out.points());
+ for_all(p)
+ in_out(p) = v++;
+ }
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_IOTA_HH
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 858)
+++ oln/core/concept/image.hh (working copy)
@@ -142,6 +142,11 @@
public automatic::get_impl<Image_with_Nbh, Exact>
{
stc_typename(nbh);
+
+ stc_typename(fwd_niter);
+ stc_typename(bkd_niter);
+ typedef fwd_niter niter;
+
nbh nbhood() const;
protected:
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 858)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -29,6 +29,9 @@
# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# include <oln/core/equipment.hh>
+# include <oln/core/internal/op_image_plus_nbh.hh>
+
+
namespace oln
@@ -41,6 +44,7 @@
{
stc_typename(grid);
stc_typename(point);
+ stc_typename(category);
protected:
Neighborhood();
@@ -48,6 +52,8 @@
}; // end of oln::Neighborhood<Exact>
+ oln_decl_op_plus(Image, Neighborhood);
+
# ifndef OLN_INCLUDE_ONLY
Index: oln/core/concept/image_identity.hh
--- oln/core/concept/image_identity.hh (revision 0)
+++ oln/core/concept/image_identity.hh (revision 0)
@@ -0,0 +1,292 @@
+// Copyright (C) 2007 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_CONCEPT_IMAGE_IDENTITY_HH
+# define OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
+
+# include <oln/core/concept/image.hh>
+
+
+
+namespace oln
+{
+
+ namespace behavior { struct identity; }
+
+
+ namespace automatic
+ {
+
+
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ struct set_impl< Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(psite);
+ stc_typename(rvalue);
+ stc_typename(box);
+ stc_typename(pset);
+
+ bool impl_owns_(const psite& p) const;
+ rvalue impl_read(const psite& p) const;
+ box impl_bbox() const;
+ pset impl_points() const;
+ };
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ struct set_impl< Image_with_Nbh, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(nbh);
+ nbh impl_nbhood() const;
+ };
+
+
+ /// Concept-class "Mutable_Image".
+
+ template <typename Exact>
+ struct set_impl< Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(psite);
+ stc_typename(lvalue);
+ lvalue impl_read_write(const psite& p);
+ };
+
+
+ /// Concept-class "Fast_Image".
+
+ template <typename Exact>
+ struct set_impl< Fast_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(rvalue);
+ stc_typename(lvalue);
+ stc_typename(index);
+
+ rvalue impl_index_read(index i) const;
+ lvalue impl_index_read_write(index i);
+ std::size_t impl_npoints() const;
+ };
+
+
+ /// Concept-class "Point_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(point);
+ bool impl_has(const point& p) const;
+ };
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(rvaluep);
+ rvaluep impl_value_read(const vsite& v) const;
+ };
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ struct set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(lvaluep);
+ lvaluep impl_value_read_write(const vsite& v);
+ };
+
+
+ /// Concept-class "Image_1D".
+
+ template <typename Exact>
+ struct set_impl< Image_1D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Image_3D".
+
+ template <typename Exact>
+ struct set_impl< Image_3D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Point_Wise_Accessible_Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Accessible_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ // default code is provided in Point_Wise_Accessible_Image_2D<Exact>
+ };
+
+
+ /// Concept-class "Point_Wise_Mutable_Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Mutable_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ // default code is provided in Point_Wise_Mutable_Image_2D<Exact>
+ };
+
+
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ bool
+ set_impl< Image, behavior::identity, Exact >::impl_owns_(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
+ {
+ return exact(this)->image().owns_(p);
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::rvalue
+ set_impl< Image, behavior::identity, Exact >::impl_read(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
+ {
+ return exact(this)->image()(p);
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::box
+ set_impl< Image, behavior::identity, Exact >::impl_bbox() const
+ {
+ return exact(this)->image().bbox();
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::pset
+ set_impl< Image, behavior::identity, Exact >::impl_points() const
+ {
+ return exact(this)->image().points();
+ }
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ typename set_impl< Image_with_Nbh, behavior::identity, Exact >::nbh
+ set_impl< Image_with_Nbh, behavior::identity, Exact >::impl_nbhood() const
+ {
+ return exact(this)->image().nbhood();
+ }
+
+
+ /// Concept-class "Mutable_Image".
+
+ template <typename Exact>
+ typename set_impl< Mutable_Image, behavior::identity, Exact >::lvalue
+ set_impl< Mutable_Image, behavior::identity, Exact >::impl_read_write(const typename set_impl< Mutable_Image, behavior::identity, Exact >::psite& p)
+ {
+ return exact(this)->image().operator()(p);
+ }
+
+
+ /// Concept-class "Fast_Image".
+
+ template <typename Exact>
+ typename set_impl< Fast_Image, behavior::identity, Exact >::rvalue
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read(typename set_impl< Fast_Image, behavior::identity, Exact >::index i) const
+ {
+ return exact(this)->image()[i];
+ }
+
+ template <typename Exact>
+ typename set_impl< Fast_Image, behavior::identity, Exact >::lvalue
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read_write(typename set_impl< Fast_Image, behavior::identity, Exact >::index i)
+ {
+ return exact(this)->image()[i];
+ }
+
+ template <typename Exact>
+ std::size_t
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_npoints() const
+ {
+ return exact(this)->image().npoints();
+ }
+
+
+ /// Concept-class "Point_Wise_Accessible_Image".
+
+ template <typename Exact>
+ bool
+ set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::impl_has(const typename set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::point& p) const
+ {
+ return exact(this)->image().has(p);
+ }
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::rvaluep
+ set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::impl_value_read(const typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::vsite& v) const
+ {
+ return exact(this)->image().value(v);
+ }
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::lvaluep
+ set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::impl_value_read_write(const typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::vsite& v)
+ {
+ return exact(this)->image().value(v);
+ }
+
+
+# endif
+
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 858)
+++ oln/core/equipment.hh (working copy)
@@ -66,6 +66,7 @@
stc_decl_associated_type( index );
// l
+ stc_decl_associated_type( left );
stc_decl_associated_type( lvalue );
stc_decl_associated_type( lvaluep );
@@ -75,6 +76,7 @@
stc_decl_associated_type( niter );
// o
+ stc_decl_associated_type( oper );
stc_decl_associated_type( output );
// p
@@ -87,12 +89,16 @@
stc_decl_associated_type( qiter );
// r
+ stc_decl_associated_type( right );
stc_decl_associated_type( rvalue );
stc_decl_associated_type( rvaluep );
// s
stc_decl_associated_type( std_container );
+ // t
+ stc_decl_associated_type( tag );
+
// v
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 0)
+++ oln/core/gen/op.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 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_OP_HH
+# define OLN_CORE_GEN_OP_HH
+
+# include <oln/core/internal/special_op.hh>
+
+
+
+// Macro.
+
+# define oln_decl_op_(OpName, Lconcept, OpSym, Rconcept) \
+ \
+ template <typename L, typename R> \
+ op_<L, OpName, R> \
+ operator OpSym (Lconcept<L>& lhs, Rconcept<R>& rhs) \
+ { \
+ op_<L, OpName, R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<L, OpName, const R> \
+ operator OpSym (Lconcept<L>& lhs, const Rconcept<R>& rhs) \
+ { \
+ op_<L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<const L, OpName, R> \
+ operator OpSym (const Lconcept<L>& lhs, Rconcept<R>& rhs) \
+ { \
+ op_<const L, OpName, R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<const L, OpName, const R> \
+ operator OpSym (const Lconcept<L>& lhs, const Rconcept<R>& rhs) \
+ { \
+ op_<const L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d___w_i_t_h___a___s_e_m_i___c_o_l_u_m_n
+
+
+# define oln_decl_op_plus(Lconcept, Rconcept) oln_decl_op_(plus, Lconcept, +, Rconcept)
+# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_(such_as, Lconcept, |, Rconcept)
+// ...
+
+
+
+
+# define oln_category_of_(Type) typename oln::internal::category_of_<Type>::ret
+
+
+namespace oln
+{
+
+
+ namespace internal
+ {
+ template <typename T>
+ struct category_of_
+ {
+ typedef stc_type(T, category) ret;
+ };
+
+ // ...
+
+ } // end of namespace oln::internal
+
+
+
+ /// \{
+ /// Operator Names.
+
+ struct plus;
+ struct such_as;
+
+ /// \}
+
+
+
+ // Fwd decl.
+ template <typename L, typename OpName, typename R> class op_;
+
+
+ /// Virtual types.
+ template <typename L, typename OpName, typename R>
+ struct vtypes< op_<L, OpName, R> >
+ {
+ };
+
+
+ /// Super type.
+
+# define super \
+ internal::special_op_< oln_category_of_(L), L, OpName, oln_category_of_(R), R >
+
+ template <typename L, typename OpName, typename R>
+ struct super_trait_< op_<L, OpName, R> >
+ {
+ typedef super ret;
+ };
+
+
+ /// Class for result of "L op R".
+
+ template <typename L, typename OpName, typename R>
+ class op_ : public super
+ {
+ public:
+ op_(L& l, R& r);
+
+ }; // end of op_<L, OpName, R>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename L, typename OpName, typename R>
+ op_<L, OpName, R>::op_(L& l, R& r)
+ : super (l, r)
+ {
+ }
+
+# endif
+
+# undef super
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_OP_HH
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 858)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -54,11 +54,6 @@
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
-
- // FIXME: To be defined...
- typedef mlc::none qiter;
- typedef mlc::none fwd_qiter;
- typedef mlc::none bkd_qiter;
};
Index: oln/core/internal/neighborhood_base.hh
--- oln/core/internal/neighborhood_base.hh (revision 858)
+++ oln/core/internal/neighborhood_base.hh (working copy)
@@ -56,6 +56,7 @@
typedef stc_deferred(point) point__;
typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< stc::is<Neighborhood> > category;
};
@@ -65,7 +66,7 @@
/// Base class for implementation of neighborhoods class.
template <typename Exact>
- class neighborhood_base_ : public Neighborhood< neighb_<Exact> >
+ class neighborhood_base_ : public Neighborhood<Exact>
{
protected:
neighborhood_base_();
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 0)
+++ oln/core/internal/op_image_plus_nbh.hh (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (C) 2007 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_OP_IMAGE_PLUS_NBH_HH
+# define OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
+
+# include <oln/core/gen/op.hh>
+# include <oln/core/gen/dpoints_piter.hh>
+# include <oln/core/internal/image_base.hh>
+
+
+namespace oln
+{
+
+ /// Fwd decls.
+ template <typename Exact> struct Image;
+ template <typename Exact> struct Neighborhood;
+
+
+ /// Super type.
+ template <typename I, typename N>
+ struct super_trait_< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ {
+ typedef internal::image_extension_< op_<I, plus, N> > ret;
+ };
+
+
+ /// Virtual types.
+ template <typename I, typename N>
+ struct vtypes< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ {
+ typedef op_<I, plus, N> Exact;
+ typedef stc_type(I, point) point__;
+
+ typedef I delegatee;
+ typedef internal::pair<I,N> data;
+
+ typedef N nbh;
+ typedef dpoints_fwd_piter_<point__> fwd_niter;
+ typedef dpoints_bkd_piter_<point__> bkd_niter;
+ };
+
+
+ namespace internal
+ {
+
+ /// Implementation class the result of "Image I + Neighborhood N".
+
+ template <typename I, typename N>
+ class special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+ :
+ public internal::image_extension_< op_<I, plus, N> >
+ {
+ typedef internal::image_extension_< op_<I, plus, N> > super;
+ public:
+ stc_using(nbh);
+ stc_using(data);
+ stc_using(delegatee);
+
+ delegatee& impl_image() { assert(this->has_data()); return this->data_->value1; }
+ const delegatee& impl_image() const { assert(this->has_data()); return this->data_->value1; }
+
+ nbh impl_nbhood() const { assert(this->has_data()); return this->data_->value2; }
+
+ protected:
+ special_op_(I& ima, N& n)
+ {
+ this->data_ = new data(ima, n);
+ }
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 858)
+++ oln/core/internal/image_base.hh (working copy)
@@ -29,10 +29,11 @@
# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
# include <oln/core/internal/image_selectors.hh>
+# include <oln/core/concept/image_identity.hh>
+
# include <oln/core/internal/tracked_ptr.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
-# include <oln/core/gen/image_pset_piter.hh>
@@ -50,6 +51,7 @@
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
+ template <typename Exact> struct image_extension_;
template <typename Exact> struct multiple_image_morpher_;
}
@@ -87,6 +89,12 @@
};
template <typename Exact>
+ struct super_trait_< internal::image_extension_<Exact> >
+ {
+ typedef internal::single_image_morpher_<Exact> ret;
+ };
+
+ template <typename Exact>
struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
typedef internal::image_morpher_<Exact> ret;
@@ -122,6 +130,7 @@
typedef stc::final< stc::is<Image> > category;
typedef stc::final< box_<point__> > box;
typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< stc_type(point__, dpoint) > dpoint;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
typedef fwd_piter piter;
@@ -145,6 +154,7 @@
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
+ typedef stc::abstract behavior;
typedef stc::not_delegated data;
};
@@ -154,6 +164,12 @@
};
template <typename Exact>
+ struct vtypes< internal::image_extension_<Exact> >
+ {
+ typedef stc::final< behavior::identity > behavior;
+ };
+
+ template <typename Exact>
struct vtypes< internal::multiple_image_morpher_<Exact> >
{
typedef stc::abstract n;
@@ -239,6 +255,16 @@
};
+ /// image_extension_<Exact>
+
+ template <typename Exact>
+ class image_extension_ : public single_image_morpher_<Exact>
+ {
+ protected:
+ image_extension_();
+ };
+
+
/// multiple_image_morpher_<Exact>
template <typename Exact>
@@ -320,6 +346,13 @@
{
}
+ // image_extension_<Exact>
+
+ template <typename Exact>
+ image_extension_<Exact>::image_extension_()
+ {
+ }
+
// multiple_image_morpher_<Exact>
template <typename Exact>
Index: oln/core/internal/special_op.hh
--- oln/core/internal/special_op.hh (revision 0)
+++ oln/core/internal/special_op.hh (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (C) 2007 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_SPECIAL_OP_HH
+# define OLN_CORE_INTERNAL_SPECIAL_OP_HH
+
+# include <oln/core/internal/image_base.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decls.
+ namespace internal {
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ class special_op_;
+ }
+ template <typename L, typename OpName, typename R> class op_;
+
+
+ /// Virtual types.
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ struct vtypes< internal::special_op_<Lcat, L, OpName, Rcat, R> >
+ /* undefined; to be specialized... */
+ ;
+
+
+ /// Super type.
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ struct super_trait_< internal::special_op_<Lcat, L, OpName, Rcat, R> >
+ /* undefined; to be specialized... */
+ ;
+
+
+ namespace internal
+ {
+
+ /// Class for result of "L op R".
+
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ class special_op_;
+ /* undefined; to be specialized... */
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_SPECIAL_OP_HH
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 858)
+++ oln/stc/scoop.hxx (working copy)
@@ -56,6 +56,9 @@
struct no_delegatee_declared_;
+ template <typename T>
+ struct super_trait_not_defined_for_;
+
} /* end of namespace ERROR */
@@ -69,6 +72,11 @@
{
};
+template <typename from_type>
+struct vtypes <const from_type> : public vtypes <from_type>
+{
+};
+
template <typename from_type, typename type>
struct single_vtype
{
@@ -77,17 +85,30 @@
+/* super_trait_ */
template <typename from_type>
struct super_trait_;
+template <typename from_type>
+struct super_trait_ <const from_type> : super_trait_<from_type>
+{
+};
+
template <template <class> class abstraction, typename Exact>
struct super_trait_< abstraction<Exact> >
{
typedef mlc::none ret;
};
+template <typename from_type>
+struct super_trait_ :
+ mlc::abort_< ERROR::super_trait_not_defined_for_<from_type> >
+{
+ typedef mlc::none ret;
+};
+
1
0
858: Move the responsibility of iteration on window points from images to windows.
by Thierry Geraud 08 Mar '07
by Thierry Geraud 08 Mar '07
08 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move the responsibility of iteration on window points from
images to windows.
* ChangeLog: Add missing former entry.
* core/concept/image.hh (value): Add missing code.
(qiter, fwd_qiter, bkd_qiter): Move to...
* core/concept/window.hh: ...here.
(point): New virtual type.
* core/concept/neighborhood.hh (point): Likewise.
* core/2d/aliases.hh,
* core/2d/neighb2d.hh,
* core/2d/dpoint2d.hh,
* core/2d/window2d.hh,
* core/2d/box2d.hh: Update.
* core/gen/dpoints_piter.hh (include): Remove useless ones.
* oln/core/internal/neighborhood_base.hh: New.
* core/gen/neighb.hh: Update inheritance.
* oln/core/internal/window_base.hh: New.
* core/gen/window.hh: Update inheritance.
(vtypes): Update.
* core/internal/point_set_std_based.hh: Fix missing return.
* core/internal/image_base.hh: Update.
* core/internal/point2d.hh: Fix wrong visibility.
2d/aliases.hh | 35 ++++++++------
2d/box2d.hh | 3 -
2d/dpoint2d.hh | 4 +
2d/neighb2d.hh | 3 -
2d/point2d.hh | 4 +
2d/window2d.hh | 5 +-
concept/image.hh | 4 -
concept/neighborhood.hh | 1
concept/window.hh | 6 ++
gen/dpoints_piter.hh | 6 --
gen/neighb.hh | 8 +--
gen/single_value_image.hh | 2
gen/window.hh | 11 ++--
internal/image_base.hh | 4 -
internal/neighborhood_base.hh | 92 ++++++++++++++++++++++++++++++++++++++
internal/point2d.hh | 2
internal/point_set_std_based.hh | 1
internal/window_base.hh | 96 ++++++++++++++++++++++++++++++++++++++++
18 files changed, 249 insertions(+), 38 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 857)
+++ oln/core/concept/image.hh (working copy)
@@ -195,9 +195,6 @@
{
stc_using_from(Image, point);
- stc_typename(qiter);
- stc_typename(fwd_qiter);
- stc_typename(bkd_qiter);
bool has(const point& p) const;
protected:
@@ -454,6 +451,7 @@
typename Value_Wise_Mutable_Image<Exact>::lvaluep
Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
+ return exact(this)->impl_value_read_write(v);
}
template <typename Exact>
Index: oln/core/concept/window.hh
--- oln/core/concept/window.hh (revision 857)
+++ oln/core/concept/window.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_CONCEPT_WINDOW_HH
# include <oln/core/equipment.hh>
+# include <oln/core/concept/point.hh>
namespace oln
@@ -40,6 +41,11 @@
struct Window : public Any<Exact>
{
stc_typename(grid);
+ stc_typename(point);
+
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
protected:
Window();
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 857)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -40,6 +40,7 @@
struct Neighborhood : public Any<Exact>
{
stc_typename(grid);
+ stc_typename(point);
protected:
Neighborhood();
Index: oln/core/2d/aliases.hh
--- oln/core/2d/aliases.hh (revision 857)
+++ oln/core/2d/aliases.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -35,29 +35,36 @@
/// Forward declarations.
/// \{
+
+ template <typename P> class box_;
+ template <typename P> class box_fwd_piter_;
+ template <typename P> class box_bkd_piter_;
+
template <typename D> class neighb_;
template <typename D> class window_;
- template <typename P> class topo_lbbox_;
- template <typename P> class fwd_piter_bbox_;
- template <typename P> class bkd_piter_bbox_;
- template <typename P> class fwd_qiter_win_;
- template <typename P> class bkd_qiter_win_;
+ template <typename P> class dpoints_fwd_piter_;
+ template <typename P> class dpoints_bkd_piter_;
+
/// \}
/// Aliases.
/// \{
- typedef neighb_<dpoint2d> neighb2d;
- typedef window_<dpoint2d> window2d;
-
- typedef topo_lbbox_<point2d> topo2d;
+ typedef box_<point2d> box2d;
+ typedef box_fwd_piter_<point2d> piter2d;
+ typedef box_fwd_piter_<point2d> fwd_piter2d;
+ typedef box_bkd_piter_<point2d> bkd_piter2d;
- typedef fwd_piter_bbox_<point2d> fwd_piter2d;
- typedef bkd_piter_bbox_<point2d> bkd_piter2d;
+ typedef neighb_<dpoint2d> neighb2d;
+ typedef dpoints_fwd_piter_<point2d> niter2d;
+ typedef dpoints_fwd_piter_<point2d> fwd_niter2d;
+ typedef dpoints_bkd_piter_<point2d> bkd_niter2d;
- typedef fwd_qiter_win_<point2d> fwd_qiter2d;
- typedef bkd_qiter_win_<point2d> bkd_qiter2d;
+ typedef window_<dpoint2d> window2d;
+ typedef dpoints_fwd_piter_<point2d> qiter2d;
+ typedef dpoints_fwd_piter_<point2d> fwd_qiter2d;
+ typedef dpoints_bkd_piter_<point2d> bkd_qiter2d;
/// \}
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 857)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -31,12 +31,13 @@
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef neighb_<dpoint2d> neighb2d;
+ // FIXME: neighb2d should be an actual type, not an alias...
namespace internal
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 857)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -88,4 +88,8 @@
} // end of namespace oln
+// dpoint2d goes with point2d so:
+# include <oln/core/2d/point2d.hh>
+
+
#endif // ! OLN_CORE_2D_DPOINT2D_HH
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 857)
+++ oln/core/2d/window2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -30,12 +30,13 @@
# include <oln/core/gen/window.hh>
# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef window_<dpoint2d> window2d;
+ // FIXME: window2d should be an actual type, not an alias...
window2d mk_square(unsigned odd_len);
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 857)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,12 +30,13 @@
# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef box_<point2d> box2d;
+ // FIXME: box2d should be an actual type, not an alias...
} // end of namespace oln
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 857)
+++ oln/core/2d/point2d.hh (working copy)
@@ -88,4 +88,8 @@
} // end of namespace oln
+// point2d goes with dpoint2d so:
+# include <oln/core/2d/dpoint2d.hh>
+
+
#endif // ! OLN_CORE_2D_POINT2D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 857)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -29,8 +29,6 @@
# define OLN_CORE_GEN_DPOINTS_PITER_HH
# include <oln/core/concept/iterator_on_points.hh>
-# include <oln/core/concept/window.hh>
-# include <oln/core/concept/neighborhood.hh>
# include <oln/core/internal/dpoints_impl.hh>
@@ -39,8 +37,8 @@
/// Fwd decls.
- template <typename P> struct dpoints_fwd_piter_;
- template <typename P> struct dpoints_bkd_piter_;
+ template <typename P> class dpoints_fwd_piter_;
+ template <typename P> class dpoints_bkd_piter_;
// Super types.
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 857)
+++ oln/core/gen/neighb.hh (working copy)
@@ -30,7 +30,7 @@
# define OLN_CORE_GEN_NEIGHB_HH
# include <oln/core/internal/dpoints_impl.hh>
-# include <oln/core/concept/neighborhood.hh>
+# include <oln/core/internal/neighborhood_base.hh>
namespace oln
@@ -46,7 +46,7 @@
struct super_trait_< neighb_<Dp> >
{
typedef neighb_<Dp> current__;
- typedef Neighborhood<current__> ret;
+ typedef internal::neighborhood_base_<current__> ret;
};
@@ -54,14 +54,14 @@
template <typename Dp>
struct vtypes< neighb_<Dp> >
{
- typedef stc_type(Dp, grid) grid;
+ typedef stc_type(Dp, point) point;
};
/// Generic classical neighborhood class.
template <typename Dp>
- class neighb_ : public Neighborhood< neighb_<Dp> >,
+ class neighb_ : public internal::neighborhood_base_< neighb_<Dp> >,
public internal::dpoints_impl_<Dp>
{
public:
Index: oln/core/gen/window.hh
--- oln/core/gen/window.hh (revision 857)
+++ oln/core/gen/window.hh (working copy)
@@ -28,8 +28,9 @@
#ifndef OLN_CORE_GEN_WINDOW_HH
# define OLN_CORE_GEN_WINDOW_HH
+# include <oln/core/internal/window_base.hh>
# include <oln/core/internal/dpoints_impl.hh>
-# include <oln/core/concept/window.hh>
+# include <oln/core/gen/dpoints_piter.hh>
namespace oln
@@ -45,7 +46,7 @@
struct super_trait_< window_<Dp> >
{
typedef window_<Dp> current__;
- typedef Window<current__> ret;
+ typedef internal::window_base_<current__> ret;
};
@@ -53,14 +54,16 @@
template <typename Dp>
struct vtypes< window_<Dp> >
{
- typedef stc_type(Dp, grid) grid;
+ typedef stc_type(Dp, point) point;
+ typedef dpoints_fwd_piter_<point> fwd_qiter;
+ typedef dpoints_bkd_piter_<point> bkd_qiter;
};
/// Generic classical windoworhood class.
template <typename Dp>
- class window_ : public Window< window_<Dp> >,
+ class window_ : public internal::window_base_< window_<Dp> >,
public internal::dpoints_impl_<Dp>
{
public:
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 857)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -48,6 +48,8 @@
typedef point psite;
typedef Ps pset;
+ typedef typename point::coord coord;
+
typedef T value;
typedef const T& rvalue;
Index: oln/core/internal/window_base.hh
--- oln/core/internal/window_base.hh (revision 0)
+++ oln/core/internal/window_base.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 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_WINDOW_BASE_HH
+# define OLN_CORE_INTERNAL_WINDOW_BASE_HH
+
+# include <oln/core/concept/window.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class window_base_; }
+
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::window_base_<Exact> >
+ {
+ typedef Window<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::window_base_<Exact> >
+ {
+ typedef stc::abstract point;
+ typedef stc::abstract fwd_qiter;
+ typedef stc::abstract bkd_qiter;
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(fwd_qiter) fwd_qiter__;
+
+ typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< fwd_qiter__ > qiter;
+ };
+
+
+ namespace internal
+ {
+
+ /// Base class for implementation of windows class.
+
+ template <typename Exact>
+ class window_base_ : public Window<Exact>
+ {
+ protected:
+ window_base_();
+
+ }; // end of class oln::window_base_<Exact>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ window_base_<Exact>::window_base_()
+ {
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_WINDOW_BASE_HH
Index: oln/core/internal/neighborhood_base.hh
--- oln/core/internal/neighborhood_base.hh (revision 0)
+++ oln/core/internal/neighborhood_base.hh (revision 0)
@@ -0,0 +1,92 @@
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 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_NEIGHBORHOOD_BASE_HH
+# define OLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
+
+# include <oln/core/concept/neighborhood.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class neighborhood_base_; }
+
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::neighborhood_base_<Exact> >
+ {
+ typedef Neighborhood<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::neighborhood_base_<Exact> >
+ {
+ typedef stc::abstract point;
+
+ typedef stc_deferred(point) point__;
+ typedef stc::final< stc_type(point__, grid) > grid;
+ };
+
+
+ namespace internal
+ {
+
+ /// Base class for implementation of neighborhoods class.
+
+ template <typename Exact>
+ class neighborhood_base_ : public Neighborhood< neighb_<Exact> >
+ {
+ protected:
+ neighborhood_base_();
+
+ }; // end of class oln::neighborhood_base_<Exact>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ neighborhood_base_<Exact>::neighborhood_base_()
+ {
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 857)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -109,6 +109,7 @@
for_all(i)
ostr << i.to_point() << ' ';
ostr << "}";
+ return ostr;
}
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 857)
+++ oln/core/internal/image_base.hh (working copy)
@@ -33,7 +33,6 @@
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
-# include <oln/core/gen/dpoints_piter.hh>
@@ -140,9 +139,6 @@
typedef stc_deferred(point) point__;
typedef stc::final< point__ > psite;
- typedef stc::final< dpoints_fwd_piter_<point__> > fwd_qiter;
- typedef stc::final< dpoints_bkd_piter_<point__> > bkd_qiter;
- typedef fwd_qiter qiter;
};
template <typename Exact>
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 857)
+++ oln/core/internal/point2d.hh (working copy)
@@ -64,9 +64,9 @@
class point2d_ : public point_base_<Exact>
{
typedef point_base_<Exact> super;
- stc_using(coord);
public:
+ stc_using(coord);
coord row() const;
coord& row();
1
0
Ce patch permet � g++ 4.1 de compiler le code enregistr� par Th�o hier
(qui devait compiler avec g++ 3.3). Il y a a probablement d'autres endroits
� modifier de la sorte dans Olena, car le test qui a permis de rep�rer ces
erreurs �tait relativement petit.
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix name lookup for attribute of super classes.
* olena/oln/core/concept/image.hh,
* olena/oln/core/gen/dpoints_piter.hh,
* olena/oln/core/internal/point_base.hh,
* olena/oln/core/internal/dpoint_base.hh: Fix name lookup
for attribute of super classes.
concept/image.hh | 13 ++++++-------
gen/dpoints_piter.hh | 12 ++++++------
internal/dpoint_base.hh | 2 ++
internal/point_base.hh | 2 ++
4 files changed, 16 insertions(+), 13 deletions(-)
Index: olena/oln/core/concept/image.hh
--- olena/oln/core/concept/image.hh (revision 856)
+++ olena/oln/core/concept/image.hh (working copy)
@@ -412,21 +412,21 @@
typename Fast_Image<Exact>::rvalue
Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i) const
{
- return exact(this)->impl_index_read(p);
+ return exact(this)->impl_index_read(i);
}
template <typename Exact>
typename Fast_Image<Exact>::lvalue
Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i)
{
- return exact(this)->impl_index_read_write(p);
+ return exact(this)->impl_index_read_write(i);
}
template <typename Exact>
std::size_t
Fast_Image<Exact>::npoints() const
{
- return exact(this)->impl_npoints(p);
+ return exact(this)->impl_npoints();
}
template <typename Exact>
@@ -454,7 +454,6 @@
typename Value_Wise_Mutable_Image<Exact>::lvaluep
Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
- return exact(this)->impl_value_read_write(p);
}
template <typename Exact>
@@ -503,7 +502,7 @@
bool
Point_Wise_Accessible_Image_2D<Exact>::impl_has_at(coord row, coord col) const
{
- Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
return this->has(p);
}
@@ -511,7 +510,7 @@
typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
{
- Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
return this->at(p);
}
@@ -533,7 +532,7 @@
typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
- Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
return this->at(p);
}
Index: olena/oln/core/gen/dpoints_piter.hh
--- olena/oln/core/gen/dpoints_piter.hh (revision 856)
+++ olena/oln/core/gen/dpoints_piter.hh (working copy)
@@ -228,7 +228,7 @@
void
dpoints_fwd_piter_<P>::impl_start()
{
- i_ = 0;
+ this->i_ = 0;
this->update_p_();
}
@@ -236,7 +236,7 @@
void
dpoints_fwd_piter_<P>::impl_next()
{
- if (++i_ == n_)
+ if (++this->i_ == this->n_)
return;
this->update_p_();
}
@@ -256,7 +256,7 @@
void
dpoints_bkd_piter_<P>::impl_start()
{
- i_ = n_ - 1;
+ this->i_ = this->n_ - 1;
this->update_p_();
}
@@ -264,12 +264,12 @@
void
dpoints_bkd_piter_<P>::impl_next()
{
- if (i_ == 0)
+ if (this->i_ == 0)
{
- i_ = n_;
+ this->i_ = this->n_;
return;
}
- --i_;
+ --this->i_;
this->update_p_();
}
Index: olena/oln/core/internal/point_base.hh
--- olena/oln/core/internal/point_base.hh (revision 856)
+++ olena/oln/core/internal/point_base.hh (working copy)
@@ -75,6 +75,8 @@
stc_using(dim);
stc_using(dpoint);
+ using super::n;
+
coord operator[](unsigned i) const;
coord& operator[](unsigned i);
Index: olena/oln/core/internal/dpoint_base.hh
--- olena/oln/core/internal/dpoint_base.hh (revision 856)
+++ olena/oln/core/internal/dpoint_base.hh (working copy)
@@ -76,6 +76,8 @@
stc_using(dim);
stc_using(point);
+ using super::n;
+
coord operator[](unsigned i) const;
coord& operator[](unsigned i);
1
0
06 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update windows and neighborhoods + remove obsolete files.
* oln/core/abstract/window.hh: Rename as...
* oln/core/concept/window.hh: ...this and update.
* oln/core/abstract/neighborhood.hh: Rename as...
* oln/core/concept/neighborhood.hh: ...this and update.
* oln/core/gen/fwd_qiter_win.hh: Rename as...
* oln/core/gen/dpoints_piter.hh: ...this and update.
* oln/core/internal/dpoints_impl.hh: New.
* oln/core/2d/neighb2d.hh: Update.
* oln/core/internal/image_base.hh (plain_primitive_image_): New.
* oln/core/2d/image2d.hh (image2d): Inherit from plain_primitive_image_.
* oln/core/2d/window2d.hh: Update
(mk_square): New.
* oln/core/gen/neighb.hh: Update.
* oln/core/internal/image_selectors.hh: Fix.
* oln/core/internal/dpoint_base.hh (include): Fix.
* oln/core/type.hh,
* oln/core/typedefs.hh,
* oln/core/macros.hh,
* oln/core/neighborhood_entry.hh,
* oln/core/gen/bkd_qiter_win.hh,
* oln/core/gen/grid.hh,
* oln/core/gen/topo_add_isubset.hh,
* oln/core/gen/topo_bbox.hh,
* oln/core/gen/fwd_niter_neighb.hh,
* oln/core/gen/topo_lbbox.hh,
* oln/core/gen/bkd_niter_neighb.hh,
* oln/core/gen/topo_add_nbh.hh,
* oln/core/internal/topology_morpher.hh: Remove.
2d/image2d.hh | 7 -
2d/neighb2d.hh | 42 +++---
2d/window2d.hh | 47 +++++++
concept/neighborhood.hh | 66 ++--------
concept/window.hh | 71 ++---------
gen/dpoints_piter.hh | 267 +++++++++++++++++++++++++++++---------------
gen/neighb.hh | 106 ++++-------------
gen/window.hh | 117 ++++++-------------
internal/dpoint_base.hh | 1
internal/dpoints_impl.hh | 125 ++++++++------------
internal/image_base.hh | 47 ++++++-
internal/image_selectors.hh | 2
12 files changed, 431 insertions(+), 467 deletions(-)
Index: oln/core/concept/window.hh
--- oln/core/concept/window.hh (revision 854)
+++ oln/core/concept/window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,84 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_WINDOW_HH
-# define OLN_CORE_ABSTRACT_WINDOW_HH
+#ifndef OLN_CORE_CONCEPT_WINDOW_HH
+# define OLN_CORE_CONCEPT_WINDOW_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract { template <typename E> class window; }
+ /// Concept-class "Window".
-
- template <typename E>
- struct set_super_type< abstract::window<E> >
- {
- typedef mlc::none ret;
- };
-
-
- namespace abstract
- {
-
-
- /// Abstract window class.
- template <typename E>
- class window : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
-
- struct decl
+ template <typename Exact>
+ struct Window : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Window();
- window();
- ~window();
-
- }; // end of class oln::abstract::window<E>
+ }; // end of oln::Window<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool window<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- window<E>::window()
- {
- }
-
- template <typename E>
- window<E>::~window()
- {
- decl();
- }
-
- template <typename E>
- window<E>::decl::decl()
+ template <typename Exact>
+ Window<Exact>::Window()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_WINDOW_HH
+#endif // ! OLN_CORE_CONCEPT_WINDOW_HH
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 854)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,79 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
-# define OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#ifndef OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
+# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract
- {
-
-
- /// Abstract neighborhood class.
- template <typename E>
- class neighborhood : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
+ /// Concept-class "Neighborhood".
- struct decl
+ template <typename Exact>
+ struct Neighborhood : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Neighborhood();
- neighborhood();
- ~neighborhood();
-
- }; // end of class oln::abstract::neighborhood<E>
+ }; // end of oln::Neighborhood<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool neighborhood<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- neighborhood<E>::neighborhood()
- {
- }
-
- template <typename E>
- neighborhood<E>::~neighborhood()
- {
- decl();
- }
-
- template <typename E>
- neighborhood<E>::decl::decl()
+ template <typename Exact>
+ Neighborhood<Exact>::Neighborhood()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-
-// # include <oln/core/abstract/neighborhood_hierarchies.hh>
-
-
-
-#endif // ! OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#endif // ! OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 854)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -52,38 +52,38 @@
neighb2d mk_c4()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1, 0));
+ return tmp;
}
neighb2d mk_c8()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1,-1))
- .add(dpoint2d(1, 0))
- .add(dpoint2d(1, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1,-1))
+ .take(dpoint2d(1, 0))
+ .take(dpoint2d(1, 1));
+ return tmp;
}
neighb2d mk_c2_row()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1));
+ return tmp;
}
neighb2d mk_c2_col()
{
- neighb2d the_;
- the_
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(1, 0));
+ return tmp;
}
# endif
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 854)
+++ oln/core/2d/image2d.hh (working copy)
@@ -46,7 +46,6 @@
struct vtypes< image2d<T> >
{
typedef point2d point;
- typedef point psite;
typedef int coord;
typedef unsigned index;
@@ -65,17 +64,17 @@
struct super_trait_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> ret;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 2D image class.
template <typename T>
- class image2d : public internal::image_base_< image2d<T> >
+ class image2d : public internal::plain_primitive_image_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> super;
+ typedef internal::plain_primitive_image_<current> super;
public:
stc_using(data);
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 854)
+++ oln/core/2d/window2d.hh (working copy)
@@ -28,10 +28,49 @@
#ifndef OLN_CORE_2D_WINDOW2D_HH
# define OLN_CORE_2D_WINDOW2D_HH
-// Headers required for the complete definition of oln::window2d
-// (i.e., oln::window_<dpoint2d>).
-# include <oln/core/2d/aliases.hh>
-# include <oln/core/2d/dpoint2d.hh>
# include <oln/core/gen/window.hh>
+# include <oln/core/2d/dpoint2d.hh>
+
+
+namespace oln
+{
+
+ typedef window_<dpoint2d> window2d;
+
+
+ window2d mk_square(unsigned odd_len);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ window2d mk_square(unsigned odd_len)
+ {
+ precondition(odd_len % 2 = 1);
+ window2d tmp;
+ int half_len = odd_len / 2;
+ for (int drow = - half_len; drow <= half_len; ++drow)
+ for (int dcol = - half_len; dcol <= half_len; ++dcol)
+ tmp.take(dpoint2d(drow, dcol));
+ return tmp;
+ }
+
+# endif
+
+
+ extern const window2d win3x3;
+ extern const window2d win5x5;
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ const window2d win3x3 = mk_square(3);
+ const window2d win5x5 = mk_square(5);
+
+# endif
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_2D_WINDOW2D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 854)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,154 +25,252 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_FWD_QITER_WIN_HH
-# define OLN_CORE_GEN_FWD_QITER_WIN_HH
+#ifndef OLN_CORE_GEN_DPOINTS_PITER_HH
+# define OLN_CORE_GEN_DPOINTS_PITER_HH
-# include <oln/core/abstract/iterator_on_points.hh>
-# include <oln/core/abstract/window.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/window.hh>
+# include <oln/core/concept/neighborhood.hh>
+# include <oln/core/internal/dpoints_impl.hh>
namespace oln
{
- // Forward declaration.
- template <typename point_t> class fwd_qiter_win_;
+ /// Fwd decls.
+ template <typename P> struct dpoints_fwd_piter_;
+ template <typename P> struct dpoints_bkd_piter_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< fwd_qiter_win_<point_t> >
+ // Super types.
+ template <typename P>
+ struct super_trait_< dpoints_fwd_piter_<P> >
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> ret;
+ typedef dpoints_fwd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+ template <typename P>
+ struct super_trait_< dpoints_bkd_piter_<P> >
+ {
+ typedef dpoints_bkd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
};
- /// Virtual types associated to oln::fwd_qiter_win_<point_t>.
- template <typename point_t>
- struct vtypes< fwd_qiter_win_<point_t> >
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< dpoints_fwd_piter_<P> >
{
- typedef point_t point_type;
- typedef oln_grid(point_t) grid_type;
+ typedef P point;
+ };
+ template <typename P>
+ struct vtypes< dpoints_bkd_piter_<P> >
+ {
+ typedef P point;
};
- /// Abstract forward point iterator class.
- template <typename point_t>
- class fwd_qiter_win_ : public abstract::iterator_on_points< fwd_qiter_win_<point_t> >
+ namespace internal
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> super_t;
- typedef oln_dpoint(point_t) dpoint_t;
+ /// Class to factor some code.
+
+ template <typename P>
+ class dpoints_piter_impl_ : private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+
+ void impl_invalidate();
+
+ bool impl_is_valid() const;
+
+ P impl_to_point() const;
+
+ const P* impl_point_adr() const;
+
+ protected:
+
+ const P* p_ref_;
+ const std::vector<typename P::dpoint>* dps_;
+ unsigned n_, i_;
+ P p_;
+
+ // Ctor.
+ template <typename Pl>
+ dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data);
+
+ void update_p_();
+ };
+
+ } // end of namespace oln::internal
+
+
+ /// Forward point iterator class on a set of dpoints.
+
+ template <typename P>
+ class dpoints_fwd_piter_ : public Iterator_on_Points< dpoints_fwd_piter_<P> >,
+ public internal::dpoints_piter_impl_<P>
+ {
public:
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win);
-
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win);
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_(const Pl& p, const X& win_or_nbh);
void impl_start();
void impl_next();
- void impl_invalidate();
+ }; // end of class oln::dpoints_fwd_piter_<P>
- bool impl_is_valid() const;
- point_t impl_to_point() const;
- const point_t* impl_point_adr() const;
+ /// Backward point iterator class on a set of dpoints.
- protected:
+ template <typename P>
+ class dpoints_bkd_piter_ : public Iterator_on_Points< dpoints_bkd_piter_<P> >,
+ public internal::dpoints_piter_impl_<P>
+ {
+ public:
+
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_(const Pl& p, const X& win_or_nbh);
- const point_t* p_ref_;
- window_<dpoint_t> win_;
- int i_;
- point_t p_;
+ void impl_start();
+
+ void impl_next();
- }; // end of class oln::fwd_qiter_win_<point_t>
+ }; // end of class oln::dpoints_bkd_piter_<P>
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win)
- : p_ref_(it.point_adr()),
- win_(win.exact())
+ namespace internal
{
- precondition(win_.card() > 0);
- this->invalidate();
+
+ template <typename Pl>
+ const Pl* point_adr_(const Point<Pl>& p)
+ {
+ return exact(&p);
}
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win)
- : p_ref_(&(p.exact())),
- win_(win.exact())
+ template <typename Pl>
+ const typename Pl::point* point_adr_(const Iterator_on_Points<Pl>& p)
{
- precondition(win_.card() > 0);
- this->invalidate();
+ return p.point_adr();
+ }
+
+ template <typename P>
+ template <typename Pl>
+ dpoints_piter_impl_<P>::dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data)
+ {
+ p_ref_ = point_adr_(ref);
+ dps_ = &(data.dpoints());
+ n_ = data.size();
+ i_ = n_;
+ postcondition(n_ != 0);
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_start()
+ dpoints_piter_impl_<P>::impl_invalidate()
{
- i_ = 0;
- p_ = *p_ref_+ win_.dp(i_);
+ i_ = n_;
+ }
+
+ template <typename P>
+ bool
+ dpoints_piter_impl_<P>::impl_is_valid() const
+ {
+ return i_ != n_;
+ }
+
+ template <typename P>
+ P
+ dpoints_piter_impl_<P>::impl_to_point() const
+ {
+ return p_;
}
- template <typename point_t>
+ template <typename P>
+ const P*
+ dpoints_piter_impl_<P>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_next()
+ dpoints_piter_impl_<P>::update_p_()
{
- ++i_;
- if (i_ = int(win_.card()))
+ p_ = *p_ref_+ (*dps_)[i_];
+ }
+
+ } // end of namespace oln::internal
+
+
+ // fwd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_<P>::dpoints_fwd_piter_(const Pl& p, const X& win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- this->invalidate();
- return;
}
- p_ = *p_ref_ + win_.dp(i_);
+
+ template <typename P>
+ void
+ dpoints_fwd_piter_<P>::impl_start()
+ {
+ i_ = 0;
+ this->update_p_();
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_invalidate()
+ dpoints_fwd_piter_<P>::impl_next()
{
- i_ = -1;
+ if (++i_ = n_)
+ return;
+ this->update_p_();
}
- template <typename point_t>
- bool
- fwd_qiter_win_<point_t>::impl_is_valid() const
+
+ // bkd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_<P>::dpoints_bkd_piter_(const Pl& p, const X& win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- return i_ != -1;
}
- template <typename point_t>
- point_t
- fwd_qiter_win_<point_t>::impl_to_point() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_start()
{
- return p_;
+ i_ = n_ - 1;
+ this->update_p_();
}
- template <typename point_t>
- const point_t*
- fwd_qiter_win_<point_t>::impl_point_adr() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_next()
{
- return &p_;
+ if (i_ = 0)
+ {
+ i_ = n_;
+ return;
+ }
+ --i_;
+ this->update_p_();
}
# endif
@@ -180,5 +278,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_FWD_QITER_WIN_HH
-
+#endif // ! OLN_CORE_GEN_DPOINTS_PITER_HH
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 854)
+++ oln/core/gen/neighb.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,120 +29,66 @@
#ifndef OLN_CORE_GEN_NEIGHB_HH
# define OLN_CORE_GEN_NEIGHB_HH
-# include <set>
-# include <vector>
-# include <oln/core/neighborhood_entry.hh>
-# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/neighborhood.hh>
namespace oln
{
- // Forward declaration.
- template <typename dpoint> class neighb_;
+ // Fwd decl.
+ template <typename Dp> class neighb_;
- // Super type declaration.
- template <typename dpoint>
- struct set_super_type< neighb_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< neighb_<Dp> >
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> ret;
+ typedef neighb_<Dp> current__;
+ typedef Neighborhood<current__> ret;
};
- /// Virtual types associated to oln::neighb_<dpoint>.
- template <typename dpoint>
- struct vtypes< neighb_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< neighb_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- struct FIXME_ERR;
+ /// Generic classical neighborhood class.
-
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class neighb_ : public neighborhood_entry< neighb_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint), FIXME_ERR >
+ template <typename Dp>
+ class neighb_ : public Neighborhood< neighb_<Dp> >,
+ public internal::dpoints_impl_<Dp>
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> super_t;
-
public:
neighb_();
- neighb_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- neighb_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- unsigned card() const;
-
- dpoint dp(unsigned i) const;
-
- // void print(std::ostream& ostr) const;
- // friend std::ostream& operator<<(std::ostream& ostr, const neighb_<dpoint>& nbh);
+ neighb_<Dp>& take(const Dp& dp);
- protected:
-
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::neighb_<dpoint>
+ }; // end of class oln::neighb_<Dp>
# ifndef OLN_INCLUDE_ONLY
-
- template <typename dpoint>
- neighb_<dpoint>::neighb_()
+ template <typename Dp>
+ neighb_<Dp>::neighb_()
{
}
- template <typename dpoint>
- neighb_<dpoint>& neighb_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ neighb_<Dp>& neighb_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- s_.insert(-dp);
- update_();
+ this->take_( dp);
+ this->take_(-dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- neighb_<dpoint>& neighb_<dpoint>::add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned neighb_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint neighb_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- void neighb_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
- }
-
# endif
Index: oln/core/gen/window.hh
--- oln/core/gen/window.hh (revision 854)
+++ oln/core/gen/window.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2007 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
@@ -29,123 +28,81 @@
#ifndef OLN_CORE_GEN_WINDOW_HH
# define OLN_CORE_GEN_WINDOW_HH
-# include <set>
-# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/window.hh>
namespace oln
{
+
// Fwd decl.
- template <typename dpoint> class window_;
+ template <typename Dp> class window_;
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< window_<Dp> >
{
- typedef abstract::window< window_<dpoint> > ret;
+ typedef window_<Dp> current__;
+ typedef Window<current__> ret;
};
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< window_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
- {
- typedef window_<dpoint> self_t;
+ /// Generic classical windoworhood class.
+ template <typename Dp>
+ class window_ : public Window< window_<Dp> >,
+ public internal::dpoints_impl_<Dp>
+ {
public:
window_();
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ window_<Dp>& take(const Dp& dp);
- bool impl_is_valid() const;
+ window_<Dp> impl_op_unary_minus_() const;
- protected:
+ }; // end of class oln::window_<Dp>
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::window_<dpoint>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
+ template <typename Dp>
+ window_<Dp>::window_()
{
}
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ window_<Dp>&
+ window_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- update_();
+ this->take_( dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
- {
- return v_.size() != 0;
- }
-
- template <typename dpoint>
- void
- window_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ template <typename Dp>
+ window_<Dp>
+ window_<Dp>::impl_op_unary_minus_() const
+ {
+ window_<Dp> tmp;
+ for (unsigned i = 0; i < this->size(); ++i)
+ tmp.take(- this->v_[i]);
+ return tmp;
}
# endif
+
} // end of namespace oln
Index: oln/core/internal/dpoints_impl.hh
--- oln/core/internal/dpoints_impl.hh (revision 854)
+++ oln/core/internal/dpoints_impl.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,127 +26,104 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_WINDOW_HH
-# define OLN_CORE_GEN_WINDOW_HH
+#ifndef OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
+# define OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
# include <set>
# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <iterator>
+# include <oln/core/concept/dpoint.hh>
namespace oln
{
- // Fwd decl.
- template <typename dpoint> class window_;
-
-
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
- {
- typedef abstract::window< window_<dpoint> > ret;
- };
-
-
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ namespace internal
{
- typedef oln_vtype(dpoint, grid) grid_type;
- };
+ /// Implementation for classes storing a set of dpoints.
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
+ template <typename Dp>
+ class dpoints_impl_
+ : private mlc::assert_< mlc_is_a(Dp, Dpoint) >
{
- typedef window_<dpoint> self_t;
-
public:
- window_();
-
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
+ unsigned size() const;
+ const Dp& operator[](unsigned i) const;
+ const std::vector<Dp>& dpoints() const;
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ protected:
- bool impl_is_valid() const;
+ dpoints_impl_();
+ void take_(const Dp& dp);
- protected:
+ std::vector<Dp> v_;
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
+ private:
void update_();
+ std::set<Dp> s_;
- }; // end of class oln::window_<dpoint>
+ }; // end of class oln::internal::dpoints_impl_<Dp>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
- {
- }
+ // public:
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ unsigned
+ dpoints_impl_<Dp>::size() const
{
- s_.insert(dp);
- update_();
- return *this;
+ return v_.size();
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
+ template <typename Dp>
+ const Dp&
+ dpoints_impl_<Dp>::operator[](unsigned i) const
{
- return this->add(dp.exact());
+ precondition(i < v_.size());
+ return v_[i];
}
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
+ template <typename Dp>
+ const std::vector<Dp>&
+ dpoints_impl_<Dp>::dpoints() const
{
- return v_.size();
+ return v_;
}
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
+ // protected:
+
+ template <typename Dp>
+ dpoints_impl_<Dp>::dpoints_impl_()
{
- precondition(i < v_.size());
- return v_[i];
}
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
+ template <typename Dp>
+ void
+ dpoints_impl_<Dp>::take_(const Dp& dp)
{
- return v_.size() != 0;
+ s_.insert(dp);
+ update_();
}
- template <typename dpoint>
+ // private:
+
+ template <typename Dp>
void
- window_<dpoint>::update_()
+ dpoints_impl_<Dp>::update_()
{
v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
}
# endif
+ } // end of namespace oln::internal
+
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_WINDOW_HH
+#endif // ! OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 854)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -102,7 +102,7 @@
// FIXME: ...
template <typename Exact>
- struct default_case_< Image_pw_accessibility, Exact >
+ struct case_< Image_pw_accessibility, Exact, 3 >
:
where_< mlc::eq_< stc_get_type(psite), stc_get_type(point) > >
{
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 854)
+++ oln/core/internal/dpoint_base.hh (working copy)
@@ -31,6 +31,7 @@
# include <xtd/vec.hh>
# include <mlc/int.hh>
+# include <oln/core/internal/point_base.hh>
# include <oln/core/concept/dpoint.hh>
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 854)
+++ oln/core/internal/image_base.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
+# include <oln/core/gen/dpoints_piter.hh>
@@ -44,7 +45,10 @@
namespace internal
{
template <typename Exact> struct image_base_;
+
template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct plain_primitive_image_;
+
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
template <typename Exact> struct multiple_image_morpher_;
@@ -66,6 +70,12 @@
};
template <typename Exact>
+ struct super_trait_< internal::plain_primitive_image_<Exact> >
+ {
+ typedef internal::primitive_image_<Exact> ret;
+ };
+
+ template <typename Exact>
struct super_trait_< internal::image_morpher_<Exact> >
{
typedef internal::image_base_<Exact> ret;
@@ -100,12 +110,8 @@
// FIXME: Uncomment below!
// typedef stc::abstract output;
- typedef stc::abstract data;
- // FIXME: Temporary hack:
- typedef mlc::none qiter;
- typedef mlc::none fwd_qiter;
- typedef mlc::none bkd_qiter;
+ typedef stc::abstract data;
// Deferred.
@@ -119,8 +125,7 @@
typedef stc::final< stc_type(point__, grid) > grid;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
- typedef stc::final< fwd_piter > piter;
-
+ typedef fwd_piter piter;
};
@@ -130,6 +135,17 @@
};
template <typename Exact>
+ struct vtypes< internal::plain_primitive_image_<Exact> >
+ {
+ typedef stc_deferred(point) point__;
+
+ typedef stc::final< point__ > psite;
+ typedef stc::final< dpoints_fwd_piter_<point__> > fwd_qiter;
+ typedef stc::final< dpoints_bkd_piter_<point__> > bkd_qiter;
+ typedef fwd_qiter qiter;
+ };
+
+ template <typename Exact>
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
@@ -185,6 +201,16 @@
};
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ class plain_primitive_image_ : public primitive_image_<Exact>
+ {
+ protected:
+ plain_primitive_image_();
+ };
+
+
/// image_morpher_<Exact>
template <typename Exact>
@@ -261,6 +287,13 @@
{
}
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ plain_primitive_image_<Exact>::plain_primitive_image_()
+ {
+ }
+
// image_morpher_<Exact>
template <typename Exact>
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Extend image selectors and add image2d type.
* core/concept/image.hh (doc): New.
(Fast_Image): New.
(Random_Accessible_Image, Random_Mutable_Image): Merge into
Fast_Image.
* core/concept/point_set.hh (include): Update.
* core/concept/point.hh: Likewise.
* core/2d/array2d.hh (include): Remove abstract/array.
(array2d): Rename as...
(array2d_): ...this.
(imin, jmin, imax, jmax, buffer, ncells): New methods.
* core/2d/image2d.hh: Update.
* core/2d/image2d_b.hh: New.
* core/2d/grid2d.hh (Grid_2D): New.
(grid2d_rec, grid2d_hex, grid2d_tri): New.
* core/equipment.hh (ch_value, output): New.
* core/gen/box.hh: Fix.
* core/internal/image_selectors.hh: Update.
* core/internal/image_base.hh (qiter, fwd_qiter, bkd_qiter): New.
* stc/scoop.hh (stc_get_type_, stc_get_type, stc_is_a): New.
core/2d/array2d.hh | 132 ++++++++++++++++++++--------
core/2d/grid2d.hh | 75 +++++++++++++---
core/2d/image2d.hh | 178 +++++++++++++++++++++------------------
core/2d/image2d_b.hh | 50 +++++-----
core/concept/image.hh | 141 +++++++++++++++++++++---------
core/concept/point.hh | 1
core/concept/point_set.hh | 3
core/equipment.hh | 4
core/gen/box.hh | 4
core/internal/image_base.hh | 7 +
core/internal/image_selectors.hh | 72 ++++++++++++++-
stc/scoop.hh | 11 ++
12 files changed, 471 insertions(+), 207 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 853)
+++ oln/core/concept/image.hh (working copy)
@@ -29,9 +29,74 @@
#ifndef OLN_CORE_CONCEPT_IMAGE_HH
# define OLN_CORE_CONCEPT_IMAGE_HH
+# include <cstddef>
# include <oln/core/equipment.hh>
+/*
+
+
+Image
+ |
+ |
+ |
+ o -- Mutable_Image
+ | |
+ | + -- Fast_Image
+ |
+ |
+ |
+ o -- + -- Image_1D
+ | |
+ | + -- Image_2D
+ | | |
+ | | + -- Image_2D_rec
+ | | |
+ | | + -- Image_2D_hex
+ | | |
+ | | + -- Image_2D_tri
+ | |
+ | + -- Image_3D
+ |
+ |
+ |
+ o -- Point_Wise_Accessible_Image
+ | |
+ | | Image_2D
+ | | |
+ | | |
+ | + -- Point_Wise_Accessible_Image_2D
+ | | |
+ | | | Mutable_Image
+ | | | |
+ | | | |
+ | | + -- Point_Wise_Mutable_Image_2D
+ | |
+ | + ...
+ |
+ |
+ |
+ o -- + -- Gray_Level_Image
+ | |
+ | + -- Color_Image
+ | |
+ | + -- Label_Image
+ | | |
+ | | + -- Binary_Image
+ | | |
+ | | + -- String_Image
+ | |
+ | + -- Deformation_Field_Image
+ | |
+ | + -- Data_Image
+ |
+ |
+ |
+ ...
+
+*/
+
+
namespace oln
{
@@ -57,6 +122,8 @@
stc_typename(box);
stc_typename(pset);
+ // stc_typename(output); // FIXME: Uncomment!
+
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
@@ -99,55 +166,42 @@
};
- /// Concept-class "Point_Wise_Accessible_Image".
+ /// Concept-class "Fast_Image".
template <typename Exact>
- struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
- public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
- {
- stc_using_from(Image, point);
-
- stc_typename(qiter);
- stc_typename(fwd_qiter);
- stc_typename(bkd_qiter);
- bool has(const point& p) const;
-
- protected:
- Point_Wise_Accessible_Image();
- };
-
-
- /// Concept-class "Random_Accessible_Image".
-
- template <typename Exact>
- struct Random_Accessible_Image : public virtual Image<Exact>,
- public automatic::get_impl<Random_Accessible_Image, Exact>
+ struct Fast_Image : public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Fast_Image, Exact>
{
stc_using_from(Image, rvalue);
+ stc_using_from(Image, lvalue);
stc_typename(index);
+
rvalue operator[](index i) const;
+ lvalue operator[](index i);
+ std::size_t npoints() const;
+ // FIXME: ...
protected:
- Random_Accessible_Image();
+ Fast_Image();
};
- /// Concept-class "Random_Mutable_Image".
+ /// Concept-class "Point_Wise_Accessible_Image".
template <typename Exact>
- struct Random_Mutable_Image : public virtual Random_Accessible_Image<Exact>,
- public virtual Mutable_Image<Exact>,
- public automatic::get_impl<Random_Mutable_Image, Exact>
+ struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
{
- stc_using_from(Random_Accessible_Image, index);
- stc_using_from(Mutable_Image, lvalue);
- using Random_Accessible_Image<Exact>::operator[];
+ stc_using_from(Image, point);
- lvalue operator[](index i);
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
+ bool has(const point& p) const;
protected:
- Random_Mutable_Image();
+ Point_Wise_Accessible_Image();
};
@@ -352,31 +406,31 @@
{
}
- // ----------------------------------- Random_Accessible_Image<Exact>
+ // ----------------------------------- Fast_Image<Exact>
template <typename Exact>
- typename Random_Accessible_Image<Exact>::rvalue
- Random_Accessible_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i) const
+ typename Fast_Image<Exact>::rvalue
+ Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i) const
{
return exact(this)->impl_index_read(p);
}
template <typename Exact>
- Random_Accessible_Image<Exact>::Random_Accessible_Image()
+ typename Fast_Image<Exact>::lvalue
+ Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i)
{
+ return exact(this)->impl_index_read_write(p);
}
- // ----------------------------------- Random_Mutable_Image<Exact>
-
template <typename Exact>
- typename Random_Mutable_Image<Exact>::lvalue
- Random_Mutable_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i)
+ std::size_t
+ Fast_Image<Exact>::npoints() const
{
- return exact(this)->impl_index_read_write(p);
+ return exact(this)->impl_npoints(p);
}
template <typename Exact>
- Random_Mutable_Image<Exact>::Random_Mutable_Image()
+ Fast_Image<Exact>::Fast_Image()
{
}
@@ -483,6 +537,11 @@
return this->at(p);
}
+ template <typename Exact>
+ Point_Wise_Mutable_Image_2D<Exact>::Point_Wise_Mutable_Image_2D()
+ {
+ }
+
# endif
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 853)
+++ oln/core/concept/point_set.hh (working copy)
@@ -29,8 +29,7 @@
# define OLN_CORE_CONCEPT_POINT_SET_HH
# include <ostream>
-# include <oln/core/equipment.hh>
-# include <oln/core/point.hh>
+# include <oln/core/concept/point.hh>
namespace oln
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 853)
+++ oln/core/concept/point.hh (working copy)
@@ -30,7 +30,6 @@
# define OLN_CORE_CONCEPT_POINT_HH
# include <mlc/value.hh>
-# include <oln/core/equipment.hh>
# include <oln/core/concept/operators.hh>
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 853)
+++ oln/core/2d/array2d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 2007 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
@@ -31,39 +31,49 @@
# include <cstddef>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 2D array class.
- template <typename value_t, typename coord_t = int>
- class array2d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array2d_
{
public:
/// Ctor.
- array2d(coord_t imin, coord_t jmin, coord_t imax, coord_t jmax);
+ array2d_(C imin, C jmin, C imax, C jmax);
+
/// Ctor.
- array2d(coord_t ilen, coord_t jlen);
+ array2d_(C ilen, C jlen);
/// Dtor.
- ~array2d();
+ ~array2d_();
- value_t operator()(coord_t i, coord_t j) const;
- value_t& operator()(coord_t i, coord_t j);
+ const T& operator()(C i, C j) const;
+ T& operator()(C i, C j);
- bool has(coord_t i, coord_t j) const;
+ bool has(C i, C j) const;
std::size_t memsize() const;
+ std::size_t ncells() const;
+
+ C imin() const;
+ C jmin() const;
+ C imax() const;
+ C jmax() const;
+
+ const T* buffer() const;
+ T* buffer();
protected:
- coord_t imin_, jmin_, imax_, jmax_;
- coord_t ilen_, jlen_;
- value_t* buffer_;
- value_t** array_;
+ C imin_, jmin_, imax_, jmax_;
+ C ilen_, jlen_;
+ T* buffer_;
+ T** array_;
private:
@@ -75,9 +85,8 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::array2d(coord_t imin, coord_t jmin,
- coord_t imax, coord_t jmax) :
+ template <typename T, typename C>
+ array2d_<T, C>::array2d_(C imin, C jmin, C imax, C jmax) :
imin_(imin),
jmin_(jmin),
imax_(imax),
@@ -89,8 +98,8 @@
allocate_();
}
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::array2d(coord_t ilen, coord_t jlen) :
+ template <typename T, typename C>
+ array2d_<T, C>::array2d_(C ilen, C jlen) :
imin_(0),
jmin_(0),
ilen_(ilen),
@@ -102,52 +111,95 @@
allocate_();
}
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::~array2d()
+ template <typename T, typename C>
+ array2d_<T, C>::~array2d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t array2d<value_t, coord_t>::operator()(coord_t i, coord_t j) const
+ template <typename T, typename C>
+ const T& array2d_<T, C>::operator()(C i, C j) const
{
precondition(has(i, j));
return array_[i][j];
}
- template <typename value_t, typename coord_t>
- value_t& array2d<value_t, coord_t>::operator()(coord_t i, coord_t j)
+ template <typename T, typename C>
+ T& array2d_<T, C>::operator()(C i, C j)
{
precondition(has(i, j));
return array_[i][j];
}
- template <typename value_t, typename coord_t>
- bool array2d<value_t, coord_t>::has(coord_t i, coord_t j) const
+ template <typename T, typename C>
+ bool array2d_<T, C>::has(C i, C j) const
{
return
i >= imin_ and i <= imax_ and
j >= jmin_ and j <= jmax_;
}
- template <typename value_t, typename coord_t>
- size_t array2d<value_t, coord_t>::memsize() const
+
+ template <typename T, typename C>
+ C array2d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::jmin() const
+ {
+ return jmin_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::jmax() const
+ {
+ return jmax_;
+ }
+
+ template <typename T, typename C>
+ const T* array2d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array2d_<T, C>::buffer()
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ std::size_t array2d_<T, C>::ncells() const
+ {
+ return std::size_t(ilen_) * std::size_t(jlen_);
+ }
+
+ template <typename T, typename C>
+ std::size_t array2d_<T, C>::memsize() const
{
return
// buffer_
- size_t(ilen_) * size_t(jlen_) * sizeof(value_t)
+ std::size_t(ilen_) * std::size_t(jlen_) * sizeof(T)
+
// array_
- size_t(ilen_) * sizeof(value_t*);
+ std::size_t(ilen_) * sizeof(T*);
}
- template <typename value_t, typename coord_t>
- void array2d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array2d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)];
- array_ = new value_t*[size_t(ilen_)];
- value_t* buf = buffer_ - jmin_;
- for (coord_t i = 0; i < ilen_; ++i)
+ buffer_ = new T[std::size_t(ilen_) * std::size_t(jlen_)];
+ array_ = new T*[std::size_t(ilen_)];
+ T* buf = buffer_ - jmin_;
+ for (C i = 0; i < ilen_; ++i)
{
array_[i] = buf;
buf += jlen_;
@@ -155,8 +207,8 @@
array_ -= imin_;
}
- template <typename value_t, typename coord_t>
- void array2d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array2d_<T, C>::deallocate_()
{
precondition(buffer_ != 0 and array_ != 0);
delete[] buffer_;
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 853)
+++ oln/core/2d/image2d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
@@ -29,79 +29,77 @@
#ifndef OLN_CORE_2D_IMAGE2D_HH
# define OLN_CORE_2D_IMAGE2D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/topo2d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/2d/box2d.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image2d;
- /// Virtual types associated to oln::image2d<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image2d<T> >
{
- typedef topo2d topo_type;
+ typedef point2d point;
+ typedef point psite;
- typedef point2d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box2d pset;
+ typedef array2d_<value, coord> data;
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image2d<T> >
+ struct super_trait_< image2d<T> >
{
- typedef image2d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image2d<T> current;
+ typedef internal::image_base_<current> ret;
};
/// General 2D image class.
+
template <typename T>
- class image2d : public image_entry< image2d<T> >
+ class image2d : public internal::image_base_< image2d<T> >
{
- typedef image2d<T> self_t;
- typedef array2d<T> array_t;
-
+ typedef image2d<T> current;
+ typedef internal::image_base_<current> super;
public:
+ stc_using(data);
- /// Ctor without info.
image2d();
+ image2d(const box2d& b);
+ image2d(unsigned nrows, unsigned ncols);
- /// Ctor using sizes.
- image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
+ bool impl_owns_(const point2d& p) const;
- /// Ctor using an existing topology.
- image2d(const topo2d& topo);
+ bool impl_has(const point2d& p) const;
+ bool impl_has_at(int row, int col) const;
- const topo2d& impl_topo() const;
+ const T& impl_read(const point2d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int row, int col) const;
- T impl_op_read(const point2d& p) const;
- T impl_at(int row, int col) const;
-
- T& impl_op_readwrite(const point2d& p);
+ T& impl_read_write(const point2d& p);
+ T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- T* adr_at(int row, int col);
- const T* adr_at(int row, int col) const;
-
- private:
+ std::size_t npoints() const;
- topo2d topo_;
- internal::tracked_ptr<array_t> data_;
+ box2d impl_bbox() const;
+ box2d impl_points() const;
};
@@ -110,86 +108,110 @@
template <typename T>
image2d<T>::image2d()
- : topo_(),
- data_()
{
}
template <typename T>
- image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border)
- : topo_(bbox2d(point2d(0, 0 ),
- point2d(nrows - 1, ncols - 1)),
- border),
- data_(new array_t(0 - border, 0 - border,
- nrows - 1 + border, ncols - 1 + border))
+ image2d<T>::image2d(const box2d& b)
{
+ this->data_ = new data(b.pmin().row(), b.pmin().col(),
+ b.pmax().row(), b.pmax().col());
}
template <typename T>
- image2d<T>::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()))
+ image2d<T>::image2d(unsigned nrows, unsigned ncols)
{
+ precondition(nrows != 0 and ncols != 0);
+ this->data_ = new data(0, 0, nrows - 1, ncols - 1);
}
+ template <typename T>
+ bool image2d<T>::impl_owns_(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.row(), p.col());
+ }
template <typename T>
- const topo2d& image2d<T>::impl_topo() const
+ bool image2d<T>::impl_has(const point2d& p) const
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->has(p.row(), p.col());
}
+ template <typename T>
+ bool image2d<T>::impl_has_at(int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->has(row, col);
+ }
template <typename T>
- T image2d<T>::impl_op_read(const point2d& p) const
+ const T& image2d<T>::impl_read(const point2d& p) const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ return this->data_->operator()(p.row(), p.col());
}
template <typename T>
- T image2d<T>::impl_at(int row, int col) const
+ const T& image2d<T>::impl_index_read(unsigned i) const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->buffer()[i];
}
+ template <typename T>
+ const T& image2d<T>::impl_at(int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->operator()(row, col);
+ }
+
+ template <typename T>
+ T& image2d<T>::impl_read_write(const point2d& p)
+ {
+ assert(this->has_data());
+ return this->data_->operator()(p.row(), p.col());
+ }
template <typename T>
- T& image2d<T>::impl_op_readwrite(const point2d& p)
+ T& image2d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->buffer()[i];
}
template <typename T>
T& image2d<T>::impl_at(int row, int col)
{
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->operator()(row, col);
}
+ template <typename T>
+ std::size_t image2d<T>::npoints() const
+ {
+ assert(this->has_data());
+ return this->data_->ncells();
+ }
template <typename T>
- T* image2d<T>::adr_at(int row, int col)
+ box2d image2d<T>::impl_bbox() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ point2d
+ pmin(this->data_->imin(), this->data_->jmin()),
+ pmax(this->data_->imax(), this->data_->jmax());
+ box2d b(pmin, pmax);
+ return b;
}
template <typename T>
- const T* image2d<T>::adr_at(int row, int col) const
+ box2d image2d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ return this->bbox();
}
# endif
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 850)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_2D_IMAGE2D_HH
-# define OLN_CORE_2D_IMAGE2D_HH
+#ifndef OLN_CORE_2D_IMAGE2D_B_HH
+# define OLN_CORE_2D_IMAGE2D_B_HH
# include <oln/core/image_entry.hh>
# include <oln/core/gen/grid.hh>
@@ -43,12 +43,12 @@
{
// Forward declaration.
- template <typename T> class image2d;
+ template <typename T> class image2d_b;
- /// Virtual types associated to oln::image2d<T>.
+ /// Virtual types associated to oln::image2d_b<T>.
template <typename T>
- struct vtypes< image2d<T> >
+ struct vtypes< image2d_b<T> >
{
typedef topo2d topo_type;
@@ -62,30 +62,30 @@
/// Super type declaration.
template <typename T>
- struct set_super_type< image2d<T> >
+ struct set_super_type< image2d_b<T> >
{
- typedef image2d<T> self_t;
+ typedef image2d_b<T> self_t;
typedef image_entry<self_t> ret;
};
/// General 2D image class.
template <typename T>
- class image2d : public image_entry< image2d<T> >
+ class image2d_b : public image_entry< image2d_b<T> >
{
- typedef image2d<T> self_t;
+ typedef image2d_b<T> self_t;
typedef array2d<T> array_t;
public:
/// Ctor without info.
- image2d();
+ image2d_b();
/// Ctor using sizes.
- image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
+ image2d_b(unsigned nrows, unsigned ncols, unsigned border = 2);
/// Ctor using an existing topology.
- image2d(const topo2d& topo);
+ image2d_b(const topo2d& topo);
const topo2d& impl_topo() const;
@@ -109,14 +109,14 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image2d<T>::image2d()
+ image2d_b<T>::image2d_b()
: topo_(),
data_()
{
}
template <typename T>
- image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border)
+ image2d_b<T>::image2d_b(unsigned nrows, unsigned ncols, unsigned border)
: topo_(bbox2d(point2d(0, 0 ),
point2d(nrows - 1, ncols - 1)),
border),
@@ -126,7 +126,7 @@
}
template <typename T>
- image2d<T>::image2d(const topo2d& topo)
+ image2d_b<T>::image2d_b(const topo2d& topo)
: topo_(topo),
data_(new array_t(topo.bbox().pmin().row(),
topo.bbox().pmin().col(),
@@ -137,14 +137,14 @@
template <typename T>
- const topo2d& image2d<T>::impl_topo() const
+ const topo2d& image2d_b<T>::impl_topo() const
{
return topo_;
}
template <typename T>
- T image2d<T>::impl_op_read(const point2d& p) const
+ T image2d_b<T>::impl_op_read(const point2d& p) const
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
@@ -152,7 +152,7 @@
}
template <typename T>
- T image2d<T>::impl_at(int row, int col) const
+ T image2d_b<T>::impl_at(int row, int col) const
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -161,7 +161,7 @@
template <typename T>
- T& image2d<T>::impl_op_readwrite(const point2d& p)
+ T& image2d_b<T>::impl_op_readwrite(const point2d& p)
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
@@ -169,7 +169,7 @@
}
template <typename T>
- T& image2d<T>::impl_at(int row, int col)
+ T& image2d_b<T>::impl_at(int row, int col)
{
precondition(data_->has(row, col));
return data_->operator()(row, col);
@@ -177,7 +177,7 @@
template <typename T>
- T* image2d<T>::adr_at(int row, int col)
+ T* image2d_b<T>::adr_at(int row, int col)
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -185,7 +185,7 @@
}
template <typename T>
- const T* image2d<T>::adr_at(int row, int col) const
+ const T* image2d_b<T>::adr_at(int row, int col) const
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -198,4 +198,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_2D_IMAGE2D_HH
+#endif // ! OLN_CORE_2D_IMAGE2D_B_HH
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 853)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -35,33 +35,82 @@
namespace oln
{
- struct grid2d;
+ /// \{
+ /// Fwd decls.
- /// Super type.
- template<>
- struct super_trait_< grid2d >
+ template <typename Exact> struct Grid_2D;
+ struct grid2d_rec;
+ struct grid2d_hex;
+ struct grid2d_tri;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_2D.
+
+ template <typename Exact>
+ struct vtypes< Grid_2D<Exact> >
{
- typedef Grid< grid2d > ret;
+ typedef mlc::uint_<2> dim;
};
+ template <typename Exact>
+ struct Grid_2D : public Grid<Exact>
+ {
+ protected:
+ Grid_2D() {}
+ };
+
+ /// \}
+
+
+ /// \{
+ /// Super types.
- /// Virtual types.
template <>
- struct vtypes< grid2d >
+ struct super_trait_< grid2d_rec >
{
- typedef mlc::uint_<2> dim;
+ typedef Grid_2D< grid2d_rec > ret;
};
+ template<>
+ struct super_trait_< grid2d_hex >
+ {
+ typedef Grid_2D< grid2d_hex > ret;
+ };
- /// Rectangular grid class.
- class grid2d : public Grid< grid2d >
+ template<>
+ struct super_trait_< grid2d_tri >
{
- public:
- /// Ctor.
- grid2d() {}
+ typedef Grid_2D< grid2d_tri > ret;
};
+ /// \}
+
+
+
+
+ /// Rectangular grid struct.
+
+ struct grid2d_rec : public Grid_2D< grid2d_rec >
+ {};
+
+ typedef grid2d_rec grid2d; // for short
+
+
+ /// Hexagonal grid struct.
+
+ struct grid2d_hex : public Grid_2D< grid2d_hex >
+ {};
+
+
+ /// Triangular grid struct.
+
+ struct grid2d_tri : public Grid_2D< grid2d_tri >
+ {};
+
} // end of namespace oln
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 853)
+++ oln/core/equipment.hh (working copy)
@@ -47,6 +47,7 @@
// c
stc_decl_associated_type( coord );
+ stc_decl_associated_type( ch_value );
// d
stc_decl_associated_type( data );
@@ -73,6 +74,9 @@
stc_decl_associated_type( nbh );
stc_decl_associated_type( niter );
+ // o
+ stc_decl_associated_type( output );
+
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( point );
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 853)
+++ oln/core/gen/box.hh (working copy)
@@ -240,7 +240,7 @@
box_<P>::pmin() const
{
for (unsigned i = 0; i < n; ++i)
- invariant(pmin[i] <= pmax[i]);
+ invariant(this->pmin_[i] <= this->pmax_[i]);
return this->pmin_;
}
@@ -249,7 +249,7 @@
box_<P>::pmax() const
{
for (unsigned i = 0; i < n; ++i)
- invariant(pmax[i] >= pmin[i]);
+ invariant(this->pmax_[i] >= this->pmin_[i]);
return this->pmax_;
}
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 853)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
# include <oln/core/concept/image.hh>
+# include <oln/core/2d/grid2d.hh>
namespace oln
@@ -43,24 +44,85 @@
typedef selector<Image, 1> Image_mutability;
template <typename Exact>
- struct case_< Image_mutability, Exact, 1 > : where_< stc_type_is_found(lvalue) >
+ struct case_< Image_mutability, Exact, 1 >
+ :
+ where_< stc_type_is_found(lvalue) >
{
typedef Mutable_Image<Exact> ret;
};
+ template <typename Exact>
+ struct case_< Image_mutability, Exact, 2 >
+ :
+ where_< mlc::and_< stc_type_is_found(lvalue),
+ stc_type_is_found(index) > >
+ {
+ typedef Fast_Image<Exact> ret;
+ };
+
+
+ // 2. dimension
+
+ typedef selector<Image, 2> Image_dimension;
+
+ template <typename Exact>
+ struct case_< Image_dimension, Exact, 1 >
+ :
+ where_< stc_is_a(grid, Grid_2D) >
+ {
+ typedef Image_2D<Exact> ret;
+ };
+
+ // FIXME: ...
+
+
+ // 3. point-wise accessibility
+
+ typedef selector<Image, 3> Image_pw_accessibility;
- // 2. point-wise accessibility
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 1 >
+ :
+ where_< mlc::and_list_< mlc::eq_< stc_get_type(psite), stc_get_type(point) >,
+ stc_type_is_found(lvalue),
+ stc_is_a(grid, Grid_2D) > >
+ {
+ typedef Point_Wise_Mutable_Image_2D<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 2 >
+ :
+ where_< mlc::and_< mlc::eq_< stc_get_type(psite), stc_get_type(point) >,
+ stc_is_a(grid, Grid_2D) > >
+ {
+ typedef Point_Wise_Accessible_Image_2D<Exact> ret;
+ };
- typedef selector<Image, 2> Image_pw_accessibility;
+ // FIXME: ...
template <typename Exact>
- struct case_< Image_pw_accessibility, Exact, 1 > : where_< mlc::eq_< stc_type(Exact, psite),
- stc_type(Exact, point) > >
+ struct default_case_< Image_pw_accessibility, Exact >
+ :
+ where_< mlc::eq_< stc_get_type(psite), stc_get_type(point) > >
{
typedef Point_Wise_Accessible_Image<Exact> ret;
};
+ // 4. nbh
+
+ typedef selector<Image, 4> Image_nbh;
+
+ template <typename Exact>
+ struct case_< Image_nbh, Exact, 1 >
+ :
+ where_< stc_type_is_found(nbh) >
+ {
+ typedef Image_with_Nbh<Exact> ret;
+ };
+
+
} // end of namespace oln::internal
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 853)
+++ oln/core/internal/image_base.hh (working copy)
@@ -98,8 +98,15 @@
typedef stc::abstract value;
typedef stc::abstract rvalue;
+ // FIXME: Uncomment below!
+ // typedef stc::abstract output;
typedef stc::abstract data;
+ // FIXME: Temporary hack:
+ typedef mlc::none qiter;
+ typedef mlc::none fwd_qiter;
+ typedef mlc::none bkd_qiter;
+
// Deferred.
typedef stc_deferred(point) point__;
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 853)
+++ oln/stc/scoop.hh (working copy)
@@ -99,6 +99,11 @@
# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
# define stc_type(From, Type) typename stc_type_(From, Type)
+# define stc_get_type_(Type) vtype<Exact, typedef_::Type>::ret
+# define stc_get_type(Type) typename stc_get_type_(Type)
+
+// FIXME: Swap name of stc_type and stc_get_type?
+
// below the more tolerant version is used, namely stc_deferred,
// yet it sometimes can be replaced by "stc_find_type(E, Name)"
@@ -111,6 +116,11 @@
+# define stc_is_a(T, U) \
+mlc::wrap_< \
+ typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< typename mlc::basic_< stc_deferred(T) >::ret, U > \
+>
+
@@ -134,6 +144,7 @@
+
// the macro below was called stc_prop which was ambiguous
// (that lets us think that it is true_ or false_) but the
// result is a mlc::bexpr_!
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update image concepts and add single_value_image.
* core/abstract/image.hh: Rename as...
* core/concept/image.hh: ...this.
Update.
Add some code from files in core/abstract/image/.
* core/image_entry.hh: Rename as...
* core/internal/image_base.hh: ...this.
Update.
Add some code from files in core/internal/.
* core/gen/image_pset_piter.hh,
* core/gen/single_value_image.hh,
* core/internal/utils.hh,
* core/internal/image_selectors.hh: New.
* core/topology_entry.hh: Remove this residue.
* core/concept/point_set.hh (has): Fix typo.
* core/concept/point.hh (oln/core/concept/operators):
Include.
* core/equipment.hh: Update.
* stc/scoop.hxx (internal::top): Rename as...
(internal::top__): ...this to disambiguate.
core/concept/image.hh | 498 +++++++++++++++++++++++++++++----------
core/concept/point.hh | 1
core/concept/point_set.hh | 3
core/equipment.hh | 23 +
core/gen/image_pset_piter.hh | 252 +++++++++++++++++++
core/gen/single_value_image.hh | 162 ++++++++++++
core/internal/image_base.hh | 297 +++++++++++++++++++----
core/internal/image_selectors.hh | 70 +++++
core/internal/utils.hh | 74 +++++
stc/scoop.hxx | 14 -
10 files changed, 1222 insertions(+), 172 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 845)
+++ oln/core/concept/image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,197 +26,461 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_IMAGE_HH
-# define OLN_CORE_ABSTRACT_IMAGE_HH
+#ifndef OLN_CORE_CONCEPT_IMAGE_HH
+# define OLN_CORE_CONCEPT_IMAGE_HH
-# include <cstddef>
-
-# include <oln/core/typedefs.hh>
-# include <oln/core/abstract/fwd_decls.hh>
-# include <oln/core/automatic/image/image.hh>
-# include <oln/debug/track.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- // Fwd decl.
- static unsigned& current_image_id();
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ struct Image : public virtual Any<Exact>,
+ public automatic::get_impl<Image, Exact>
+ {
+ stc_typename(grid);
+
+ stc_typename(point);
+ stc_typename(psite);
+
+ stc_typename(value);
+ stc_typename(rvalue);
+
+ stc_typename(piter);
+ stc_typename(fwd_piter);
+ stc_typename(bkd_piter);
+
+ stc_typename(box);
+ stc_typename(pset);
+
+ bool owns_(const psite& p) const;
+ rvalue operator()(const psite& p) const;
+
+ box bbox() const;
+ pset points() const;
+
+ protected:
+ Image();
+ };
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ struct Image_with_Nbh : public virtual Image<Exact>,
+ public automatic::get_impl<Image_with_Nbh, Exact>
+ {
+ stc_typename(nbh);
+ nbh nbhood() const;
+
+ protected:
+ Image_with_Nbh();
+ };
+
+ /// Concept-class "Mutable_Image".
+ template <typename Exact>
+ struct Mutable_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Mutable_Image, Exact>
+ {
+ stc_using_from(Image, psite);
+ using Image<Exact>::operator();
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
+ stc_typename(lvalue);
+ lvalue operator()(const psite& p);
+
+ protected:
+ Mutable_Image();
+ };
- /*! \class abstract::image<E>
- **
- ** The abstract::image class is the base class from whom derives
- ** every concrete image class. Basically, an image is a set of
- ** points and a set of values associated with those points.
- **
- ** Parameter E is the exact type of image.
- */
+ /// Concept-class "Point_Wise_Accessible_Image".
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
+ {
+ stc_using_from(Image, point);
+
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
+ bool has(const point& p) const;
- template <typename E>
- struct image : public virtual stc::any__simple<E>,
- public virtual oln::type,
- public automatic::get_impl<image, E>
+ protected:
+ Point_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Random_Accessible_Image".
+
+ template <typename Exact>
+ struct Random_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Random_Accessible_Image, Exact>
{
+ stc_using_from(Image, rvalue);
+
+ stc_typename(index);
+ rvalue operator[](index i) const;
+
+ protected:
+ Random_Accessible_Image();
+ };
+
- public:
+ /// Concept-class "Random_Mutable_Image".
- struct decl
+ template <typename Exact>
+ struct Random_Mutable_Image : public virtual Random_Accessible_Image<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Random_Mutable_Image, Exact>
+ {
+ stc_using_from(Random_Accessible_Image, index);
+ stc_using_from(Mutable_Image, lvalue);
+ using Random_Accessible_Image<Exact>::operator[];
+
+ lvalue operator[](index i);
+
+ protected:
+ Random_Mutable_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Value_Wise_Accessible_Image, Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(rvaluep);
+ rvaluep value(const vsite& v) const;
+
+ protected:
+ Value_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Mutable_Image : public virtual Value_Wise_Accessible_Image<Exact>,
+ public automatic::get_impl<Value_Wise_Mutable_Image, Exact>
{
- oln_virtual_typedef(topo);
- oln_virtual_typedef(grid);
- oln_virtual_typedef(coord);
- oln_virtual_typedef(psite);
- oln_virtual_typedef(point);
+ stc_using_from(Value_Wise_Accessible_Image, vsite);
+ using Value_Wise_Accessible_Image<Exact>::value;
+
+ stc_typename(lvaluep);
+ lvaluep value(const vsite& v);
+
+ protected:
+ Value_Wise_Mutable_Image();
+ };
- // FIXME: Rec?
- oln_virtual_typedef(fwd_piter);
- oln_virtual_typedef(bkd_piter);
- oln_virtual_typedef(is_computed);
- oln_virtual_typedef(value);
- oln_virtual_typedef(rvalue);
+ /// Concept-class "Image_1D".
- oln_virtual_typedef(morpher);
+ template <typename Exact>
+ struct Image_1D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_1D, Exact>
+ {
+ stc_typename(coord);
- decl();
+ protected:
+ Image_1D();
};
- public:
- /*------------------*
- ! abstract methods !
- *------------------*/
+ /// Concept-class "Image_2D".
- /*! \brief Return the topological information about the current
- ** image. Nota bene: this method is abstract-like.it is a
- ** pseudo-abstract method.
- **
- ** \return An object deriving from abstract::topo. Ex: if the
- ** image is an image2d<something>, the returned object is a
- ** topo2d.
- */
+ template <typename Exact>
+ struct Image_2D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_2D, Exact>
+ {
+ stc_typename(coord);
- const oln_topo(E)& topo() const;
+ protected:
+ Image_2D();
+ };
- /*! \brief Gives access to the value stored at \a p in the
- ** current image.
- */
+ /// Concept-class "Image_3D".
- oln_rvalue(E) operator()(const oln_psite(E)& p) const;
+ template <typename Exact>
+ struct Image_3D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_3D, Exact>
+ {
+ stc_typename(coord);
+
+ protected:
+ Image_3D();
+ };
- unsigned id() const;
+
+ /// Concept-class "Point_Wise_Accessible_Image_2D".
+
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image_2D : public virtual Point_Wise_Accessible_Image<Exact>,
+ public virtual Image_2D<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image, point);
+ stc_using_from(Point_Wise_Accessible_Image, rvalue);
+ stc_using_from(Image_2D, coord);
+
+ bool has_at(coord row, coord col) const;
+ rvalue at(coord row, coord col) const;
+
+ // default
+ bool impl_has_at(coord row, coord col) const;
+ rvalue impl_at(coord row, coord col) const;
protected:
+ Point_Wise_Accessible_Image_2D();
+ };
+
- /*! \brief Constructors (protected).
- */
- image();
- image(const image& rhs);
+ /// Concept-class "Point_Wise_Mutable_Image_2D".
- /*! \brief Assignment (protected).
- */
- E& operator=(const image& rhs);
+ template <typename Exact>
+ struct Point_Wise_Mutable_Image_2D : public virtual Point_Wise_Accessible_Image_2D<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Point_Wise_Mutable_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image_2D, point);
+ stc_using_from(Point_Wise_Accessible_Image_2D, coord);
+ stc_using_from(Mutable_Image, lvalue);
+ using Point_Wise_Accessible_Image_2D<Exact>::at;
- /*! \brief Destructor.
- */
- virtual ~image();
+ lvalue at(coord row, coord col);
- private:
+ // default
+ lvalue impl_at(coord row, coord col);
- unsigned id_;
+ protected:
+ Point_Wise_Mutable_Image_2D();
};
+
+
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image<E>::decl::decl()
+ // ----------------------------------- Image<Exact>
+
+ template <typename Exact>
+ bool
+ Image<Exact>::owns_(const typename Image<Exact>::psite& p) const
{
- // FIXME: Rec?
- mlc::assert_< mlc_is_a(topo, abstract::topology) >::check();
- mlc::assert_< mlc_is_a(grid, abstract::grid) >::check();
- mlc::assert_< mlc_is_a(point, abstract::point) >::check();
- mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check();
- mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check();
+ return exact(this)->impl_owns_(p);
+ }
- // FIXME: Rec?
- // mlc::assert_< mlc_is_a(plain, abstract::image) >::check();
+ template <typename Exact>
+ typename Image<Exact>::rvalue
+ Image<Exact>::operator()(const typename Image<Exact>::psite& p) const
+ {
+ precondition(this->owns_(p));
+ return exact(this)->impl_read(p);
}
- template <typename E>
- image<E>::image()
- : id_(++current_image_id())
+ template <typename Exact>
+ typename Image<Exact>::box
+ Image<Exact>::bbox() const
{
- ++debug::n_images;
+ return exact(this)->impl_bbox();
}
- template <typename E>
- image<E>::image(const image& rhs)
- : id_(rhs.id_)
+ template <typename Exact>
+ typename Image<Exact>::pset
+ Image<Exact>::points() const
{
- ++debug::n_images;
+ return exact(this)->impl_points();
}
- template <typename E>
- E& image<E>::operator=(const image<E>& rhs)
+ template <typename Exact>
+ Image<Exact>::Image()
{
- this->id_ = rhs.id_;
- return this->exact();
}
- template <typename E>
- image<E>::~image()
+ // ----------------------------------- Image_with_Nbh<Exact>
+
+ template <typename Exact>
+ typename Image_with_Nbh<Exact>::nbh
+ Image_with_Nbh<Exact>::nbhood() const
{
- decl();
- --debug::n_images;
+ return exact(this)->impl_nbhood();
}
- template <typename E>
- unsigned
- image<E>::id() const
+ template <typename Exact>
+ Image_with_Nbh<Exact>::Image_with_Nbh()
{
- return id_;
}
- template <typename E>
- const oln_topo(E)&
- image<E>::topo() const
+ // ----------------------------------- Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Mutable_Image<Exact>::lvalue
+ Mutable_Image<Exact>::operator()(const typename Mutable_Image<Exact>::psite& p)
{
- return this->exact().impl_topo();
+ precondition(this->owns_(p));
+ return exact(this)->impl_read_write(p);
}
- template <typename E>
- oln_rvalue(E)
- image<E>::operator()(const oln_psite(E)& p) const
+ template <typename Exact>
+ Mutable_Image<Exact>::Mutable_Image()
{
- return this->exact().impl_op_read(p);
}
-# endif
+ // ----------------------------------- Point_Wise_Accessible_Image<Exact>
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image<Exact>::has(const typename Point_Wise_Accessible_Image<Exact>::point& p) const
+ {
+ return exact(this)->impl_has(p);
+ }
+ template <typename Exact>
+ Point_Wise_Accessible_Image<Exact>::Point_Wise_Accessible_Image()
+ {
+ }
- } // end of namespace oln::abstract
+ // ----------------------------------- Random_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Random_Accessible_Image<Exact>::rvalue
+ Random_Accessible_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i) const
+ {
+ return exact(this)->impl_index_read(p);
+ }
+ template <typename Exact>
+ Random_Accessible_Image<Exact>::Random_Accessible_Image()
+ {
+ }
+ // ----------------------------------- Random_Mutable_Image<Exact>
-# ifndef OLN_INCLUDE_ONLY
+ template <typename Exact>
+ typename Random_Mutable_Image<Exact>::lvalue
+ Random_Mutable_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i)
+ {
+ return exact(this)->impl_index_read_write(p);
+ }
+
+ template <typename Exact>
+ Random_Mutable_Image<Exact>::Random_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Accessible_Image<Exact>::rvaluep
+ Value_Wise_Accessible_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
+ {
+ return exact(this)->impl_value_read(v);
+ }
+
+ template <typename Exact>
+ Value_Wise_Accessible_Image<Exact>::Value_Wise_Accessible_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Mutable_Image<Exact>::lvaluep
+ Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
+ {
+ return exact(this)->impl_value_read_write(p);
+ }
+
+ template <typename Exact>
+ Value_Wise_Mutable_Image<Exact>::Value_Wise_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Image_1D<Exact>
+
+ template <typename Exact>
+ Image_1D<Exact>::Image_1D()
+ {
+ }
+
+ // ----------------------------------- Image_2D<Exact>
+
+ template <typename Exact>
+ Image_2D<Exact>::Image_2D()
+ {
+ }
+
+ // ----------------------------------- Image_3D<Exact>
+
+ template <typename Exact>
+ Image_3D<Exact>::Image_3D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Accessible_Image_2D<Exact>
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::has_at(coord row, coord col) const
+ {
+ return exact(this)->impl_has_at(row, col);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::at(coord row, coord col) const
+ {
+ return exact(this)->impl_at(row, col);
+ }
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::impl_has_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->has(p);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
+ }
+
+ template <typename Exact>
+ Point_Wise_Accessible_Image_2D<Exact>::Point_Wise_Accessible_Image_2D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Mutable_Image_2D<Exact>
+
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::at(coord row, coord col)
+ {
+ return exact(this)->impl_at(row, col);
+ }
- static unsigned& current_image_id()
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
- static unsigned id_ = 0;
- return id_;
+ Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
}
# endif
@@ -225,4 +489,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_IMAGE_HH
+#endif // ! OLN_CORE_CONCEPT_IMAGE_HH
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 849)
+++ oln/core/concept/point_set.hh (working copy)
@@ -30,6 +30,7 @@
# include <ostream>
# include <oln/core/equipment.hh>
+# include <oln/core/point.hh>
namespace oln
@@ -77,7 +78,7 @@
bool
Point_Set<Exact>::has(const typename Point_Set<Exact>::point& p) const
{
- return exact(this)->impl_has();
+ return exact(this)->impl_has(p);
}
template <typename Exact>
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 849)
+++ oln/core/concept/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/value.hh>
# include <oln/core/equipment.hh>
+# include <oln/core/concept/operators.hh>
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 849)
+++ oln/core/equipment.hh (working copy)
@@ -40,35 +40,58 @@
# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
// b
+ stc_decl_associated_type( bkd_niter );
stc_decl_associated_type( bkd_piter );
+ stc_decl_associated_type( bkd_qiter );
stc_decl_associated_type( box );
+
// c
stc_decl_associated_type( coord );
+
// d
stc_decl_associated_type( data );
stc_decl_associated_type( dim );
stc_decl_associated_type( dpoint );
+
// f
+ stc_decl_associated_type( fwd_niter );
stc_decl_associated_type( fwd_piter );
+ stc_decl_associated_type( fwd_qiter );
+
// g
stc_decl_associated_type( grid );
+
// i
stc_decl_associated_type( index );
+
// l
stc_decl_associated_type( lvalue );
+ stc_decl_associated_type( lvaluep );
+
// n
stc_decl_associated_type( n );
+ stc_decl_associated_type( nbh );
+ stc_decl_associated_type( niter );
+
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
+
+ // q
+ stc_decl_associated_type( qiter );
+
// r
stc_decl_associated_type( rvalue );
+ stc_decl_associated_type( rvaluep );
+
// s
stc_decl_associated_type( std_container );
+
// v
stc_decl_associated_type( value );
+ stc_decl_associated_type( vsite );
} // end of namespace oln
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 0)
+++ oln/core/gen/single_value_image.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 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_SINGLE_VALUE_IMAGE_HH
+# define OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ template <typename Ps, typename T> class single_value_image;
+
+
+ /// Virtual types.
+ template <typename Ps, typename T>
+ struct vtypes< single_value_image<Ps, T> >
+ {
+ typedef typename Ps::point point;
+ typedef point psite;
+ typedef Ps pset;
+
+ typedef T value;
+ typedef const T& rvalue;
+
+ typedef internal::pair<Ps, T> data;
+
+ // FIXME: To be defined...
+ typedef mlc::none qiter;
+ typedef mlc::none fwd_qiter;
+ typedef mlc::none bkd_qiter;
+ };
+
+
+ /// Super type.
+ template <typename Ps, typename T>
+ struct super_trait_< single_value_image<Ps, T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+
+ /// Class for images defined by a point set and a single value.
+
+ template <typename Ps, typename T>
+ class single_value_image : public internal::image_base_< single_value_image<Ps, T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::image_base_<current> super;
+ public:
+
+
+ stc_using(point);
+ stc_using(rvalue);
+ stc_using(data);
+
+ single_value_image();
+
+ single_value_image(const Ps& ps, const T& val);
+
+ bool impl_owns_(const point& p) const;
+ bool impl_has (const point& p) const;
+
+ rvalue impl_read(const point&) const;
+
+ const Ps& impl_points() const;
+
+ void change_value(const T& new_value);
+
+ }; // end of single_value_image<Ps, T>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image()
+ {
+ }
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image(const Ps& pts,
+ const T& val)
+ {
+ this->data_ = new data(pts, val);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_owns_(const typename single_value_image<Ps, T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_has(const typename single_value_image<Ps, T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ typename single_value_image<Ps, T>::rvalue
+ single_value_image<Ps, T>::impl_read(const typename single_value_image<Ps, T>::point&) const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+ template <typename Ps, typename T>
+ const Ps&
+ single_value_image<Ps, T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename Ps, typename T>
+ void
+ single_value_image<Ps, T>::change_value(const T& new_value)
+ {
+ assert(this->has_data());
+ this->data_->value2 = new_value;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
Index: oln/core/gen/image_pset_piter.hh
--- oln/core/gen/image_pset_piter.hh (revision 0)
+++ oln/core/gen/image_pset_piter.hh (revision 0)
@@ -0,0 +1,252 @@
+// Copyright (C) 2007 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_IMAGE_PSET_PITER_HH
+# define OLN_CORE_GEN_IMAGE_PSET_PITER_HH
+
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ /// Fwd decls.
+
+ template <typename Ps> struct image_pset_fwd_piter_;
+ template <typename Ps> struct image_pset_bkd_piter_;
+
+
+ /// Super types.
+
+ template <typename Ps>
+ struct super_trait_< image_pset_fwd_piter_<Ps> >
+ {
+ typedef image_pset_fwd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename Ps>
+ struct super_trait_< image_pset_bkd_piter_<Ps> >
+ {
+ typedef image_pset_bkd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+ /// Virtual types.
+
+ template <typename Ps>
+ struct vtypes< image_pset_fwd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+ template <typename Ps>
+ struct vtypes< image_pset_bkd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+
+ /// Class image_pset_fwd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_fwd_piter_ : public Iterator_on_Points< image_pset_fwd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_fwd_piter_();
+
+ template <typename I>
+ image_pset_fwd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::fwd_piter i_;
+ };
+
+
+ /// Class image_pset_bkd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_bkd_piter_ : public Iterator_on_Points< image_pset_bkd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_bkd_piter_();
+
+ template <typename I>
+ image_pset_bkd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::bkd_piter i_;
+ };
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // -------------------- image_pset_fwd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_invalidate()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ bool image_pset_fwd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_fwd_piter_<Ps>::point
+ image_pset_fwd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_fwd_piter_<Ps>::point*
+ image_pset_fwd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+
+ // -------------------- image_pset_bkd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_invalidate()
+ {
+ i_.invalidate();
+ }
+
+ template <typename Ps>
+ bool image_pset_bkd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_bkd_piter_<Ps>::point
+ image_pset_bkd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_bkd_piter_<Ps>::point*
+ image_pset_bkd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_IMAGE_PSET_PITER_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 0)
+++ oln/core/internal/image_selectors.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 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_IMAGE_SELECTORS_HH
+# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+
+ // 1. mutability
+
+ typedef selector<Image, 1> Image_mutability;
+
+ template <typename Exact>
+ struct case_< Image_mutability, Exact, 1 > : where_< stc_type_is_found(lvalue) >
+ {
+ typedef Mutable_Image<Exact> ret;
+ };
+
+
+ // 2. point-wise accessibility
+
+ typedef selector<Image, 2> Image_pw_accessibility;
+
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 1 > : where_< mlc::eq_< stc_type(Exact, psite),
+ stc_type(Exact, point) > >
+ {
+ typedef Point_Wise_Accessible_Image<Exact> ret;
+ };
+
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 845)
+++ oln/core/internal/image_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,95 +25,298 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_IMAGE_ENTRY_HH
-# define OLN_CORE_IMAGE_ENTRY_HH
+#ifndef OLN_CORE_INTERNAL_IMAGE_BASE_HH
+# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
-# include <oln/core/abstract/entry.hh>
-# include <oln/core/abstract/image/all.hh>
-
-# include <oln/core/type_fun/plain.hh>
+# include <oln/core/internal/image_selectors.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/gen/box.hh>
+# include <oln/core/gen/image_pset_piter.hh>
namespace oln
{
- /// Fwd decl.
- template <typename E> struct image_entry;
+ /// Fwd decls.
+
+ namespace internal
+ {
+ template <typename Exact> struct image_base_;
+ template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct image_morpher_;
+ template <typename Exact> struct single_image_morpher_;
+ template <typename Exact> struct multiple_image_morpher_;
+ }
+
+
+ /// Super types.
+
+ template <typename Exact>
+ struct super_trait_< internal::image_base_<Exact> >
+ {
+ typedef top<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::primitive_image_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::image_morpher_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+ template <typename Exact>
+ struct super_trait_< internal::single_image_morpher_<Exact> >
+ {
+ typedef internal::image_morpher_<Exact> ret;
+ };
- template <typename E>
- struct set_super_type< image_entry<E> >
+ template <typename Exact>
+ struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
- typedef mlc::none ret;
+ typedef internal::image_morpher_<Exact> ret;
};
- /// Virtual types associated to image_entry<E>.
+ /// Virtual types.
- template <typename E>
- struct vtypes< image_entry<E> >
+ template <typename Exact>
+ struct vtypes< internal::image_base_<Exact> >
{
- typedef stc::abstract topo_type;
+ // Abstract.
+
+ typedef stc::abstract point;
+ typedef stc::abstract psite;
+ typedef stc::abstract pset;
+
+ typedef stc::abstract value;
+ typedef stc::abstract rvalue;
+
+ typedef stc::abstract data;
+
+ // Deferred.
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(pset) pset__;
+
+ // Final.
+
+ typedef stc::final< stc::is<Image> > category;
+ typedef stc::final< box_<point__> > box;
+ typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< typename pset__::fwd_piter > fwd_piter;
+ typedef stc::final< typename pset__::bkd_piter > bkd_piter;
+ typedef stc::final< fwd_piter > piter;
+
+ };
+
+
+ template <typename Exact>
+ struct vtypes< internal::primitive_image_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::image_morpher_<Exact> >
+ {
+ typedef stc::abstract delegatee;
+ typedef stc::not_delegated data;
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::single_image_morpher_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::multiple_image_morpher_<Exact> >
+ {
+ typedef stc::abstract n;
+ };
+
+
+
+ /// Implementation base classes.
+
+
+ namespace internal
+ {
+
+
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ class image_base_ : public top<Exact>
+ {
+ typedef top<Exact> super;
+ public:
+
+ stc_typename(data);
+
+ bool has_data() const;
+
+ protected:
+ image_base_();
+
+ tracked_ptr<data> data_;
+ };
- typedef stc::abstract point_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, grid)> grid_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, coord)> coord_type;
- typedef stc::abstract is_computed_type;
- typedef stc::abstract value_type;
+ /// primitive_image_<Exact>
- typedef stc::abstract fwd_piter_type;
- typedef stc::abstract bkd_piter_type;
+ template <typename Exact>
+ class primitive_image_ : public image_base_<Exact>
+ {
+ protected:
+ primitive_image_();
+ };
- // FIXME: final definitions:
- typedef oln_fwd_piter(E) piter_type;
- // FIXME: default definitions:
- typedef oln_point(E) psite_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_value(E) rvalue_type;
-# endif // !OLENA_USE_SCOOP_ALT
+ /// image_morpher_<Exact>
- /// \brief Morpher type.
- ///
- /// Optionally contains a tag indicating a kind of morpher.
- typedef mlc::none morpher_type;
+ template <typename Exact>
+ class image_morpher_ : public image_base_<Exact>
+ {
+ public:
+
+ stc_typename(delegatee);
+
+ protected:
+ image_morpher_();
};
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< image_entry<E>, typedef_::rvalue_type >
+
+ /// single_image_morpher_<Exact>
+
+ template <typename Exact>
+ class single_image_morpher_ : public image_morpher_<Exact>
{
- typedef oln_value(E) ret;
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+
+ // Abstract.
+ delegatee& image();
+ const delegatee& image() const;
+
+ protected:
+ single_image_morpher_();
};
-# endif // OLENA_USE_SCOOP_ALT
- /// Entry class for point sets: image_entry<E> is an alias for
- /// entry< abstract::image, E>.
+ /// multiple_image_morpher_<Exact>
- template <typename E>
- struct image_entry : public entry<abstract::image, E>
+ template <typename Exact>
+ class multiple_image_morpher_ : public image_morpher_<Exact>
{
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+ stc_typename(n);
+ enum { n_ = mlc_value(n) };
+
+ // Abstract.
+ delegatee& image(unsigned i = 0);
+ const delegatee& image(unsigned i = 0) const;
+
protected:
- image_entry();
+ multiple_image_morpher_();
};
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image_entry<E>::image_entry()
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ bool image_base_<Exact>::has_data() const
+ {
+ return this->data_ != 0;
+ }
+
+ template <typename Exact>
+ image_base_<Exact>::image_base_()
+ {
+ }
+
+ /// primitive_image_<Exact>
+
+ template <typename Exact>
+ primitive_image_<Exact>::primitive_image_()
{
}
+ // image_morpher_<Exact>
+
+ template <typename Exact>
+ image_morpher_<Exact>::image_morpher_()
+ {
+ }
+
+ // single_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image()
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ const typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image() const
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ single_image_morpher_<Exact>::single_image_morpher_()
+ {
+ }
+
+ // multiple_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i)
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ const typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i) const
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ multiple_image_morpher_<Exact>::multiple_image_morpher_()
+ {
+ }
+
+
# endif
+ } // end of namespace oln::internal
} // end of namespace oln
-#endif // ! OLN_CORE_IMAGE_ENTRY_HH
+#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 0)
+++ oln/core/internal/utils.hh (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 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_UTILS_HH
+# define OLN_CORE_INTERNAL_UTILS_HH
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ /// Simple singleton class.
+
+ template <typename T>
+ struct singleton
+ {
+ singleton()
+ {}
+ singleton(T val)
+ : value(val)
+ {}
+ T value;
+ };
+
+
+ /// Simple pair class.
+
+ template <typename T1, typename T2>
+ struct pair
+ {
+ pair()
+ {}
+ pair(T1 val1, T2 val2)
+ : value1(val1),
+ value2(val2)
+ {}
+ T1 value1;
+ T2 value2;
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_UTILS_HH
+
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 849)
+++ oln/stc/scoop.hxx (working copy)
@@ -867,22 +867,22 @@
};
template <typename abstraction, typename E>
- struct top;
+ struct top__;
template <template<class> class abstraction, typename E>
- struct top < stc::is<abstraction>, E > : public plug< abstraction, E >
+ struct top__ < stc::is<abstraction>, E > : public plug< abstraction, E >
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::none, E > : public Any<E>
+ struct top__ < mlc::none, E > : public Any<E>
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::not_found, E >; /* FIXME: Error msg here */
+ struct top__ < mlc::not_found, E >; /* FIXME: Error msg here */
} /* end of namespace internal */
@@ -900,7 +900,7 @@
};
template <typename E>
-struct top : public internal::top< stc_find_type(E, category), E >
+struct top : public internal::top__< stc_find_type(E, category), E >
{
protected:
top() {}
1
0
05 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update some abstractions and remove topology-related classes.
* oln/core/abstract/value.hh: Rename as...
* oln/core/concept/value.hh: ...this and update.
* oln/core/abstract/iterator_on_values.hh: Rename as...
* oln/core/concept/iterator_on_values.hh: ...this and update.
* oln/core/abstract/topology/topology_having_bbox.hh,
* oln/core/abstract/topology/hierarchies.hh,
* oln/core/abstract/topology/all.hh,
* oln/core/abstract/topology/topology_being_random_accessible.hh,
* oln/core/abstract/topology/topology_having_subset.hh,
* oln/core/abstract/topology/topology_having_neighborhood.hh:
Remove.
iterator_on_values.hh | 93 +++++++++++++++-----------------------------------
value.hh | 27 ++++++--------
2 files changed, 41 insertions(+), 79 deletions(-)
Index: oln/core/concept/iterator_on_values.hh
--- oln/core/concept/iterator_on_values.hh (revision 844)
+++ oln/core/concept/iterator_on_values.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,109 +26,72 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
+# define OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
-# include <oln/core/abstract/iterator.hh>
+# include <ostream>
+# include <oln/core/concept/iterator.hh>
namespace oln
{
+ /// Concept-class "Iterator_on_Values".
- // Forward declaration.
- namespace abstract { template <typename E> class iterator_on_values; }
-
-
- // Super type declaration.
- template <typename E>
- struct set_super_type< abstract::iterator_on_values<E> >
- {
- typedef abstract::iterator<E> ret;
- };
-
-
- /// Virtual types associated to abstract::iterator_on_values<E>.
- template <typename E>
- struct vtypes< abstract::iterator_on_values<E> >
- {
- typedef stc::abstract value_type;
- };
-
-
- namespace abstract
+ template <typename Exact>
+ struct Iterator_on_Values : public Iterator<Exact>
{
+ stc_typename(value);
- /// Abstract value iterator class.
- template <typename E>
- class iterator_on_values : public abstract::iterator<E>
- {
- public:
- typedef oln_vtype(E, value) value_type;
-
- value_type to_value() const;
+ value to_value() const;
- // Concrete method.
- operator value_type() const;
+ // Default.
+ operator value() const;
protected:
+ Iterator_on_Values();
- iterator_on_values();
+ }; // end of class oln::Iterator_on_Values<Exact>
- ~iterator_on_values();
- }; // end of class oln::abstract::iterator_on_values<E>
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Values<Exact>& vit);
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr,
- const iterator_on_values<E>& vit);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- typename iterator_on_values<E>::value_type
- iterator_on_values<E>::to_value() const
+ template <typename Exact>
+ typename Iterator_on_Values<Exact>::value
+ Iterator_on_Values<Exact>::to_value() const
{
precondition(this->is_valid());
- return this->exact().impl_to_value();
+ return exact(this)->impl_to_value();
}
- template <typename E>
- // Concrete method.
- iterator_on_values<E>::operator typename iterator_on_values<E>::value_type() const
+ template <typename Exact>
+ Iterator_on_Values<Exact>::operator typename Iterator_on_Values<Exact>::value() const
{
precondition(this->is_valid());
return this->to_value();
}
- template <typename E>
- iterator_on_values<E>::iterator_on_values()
- {
- }
-
- template <typename E>
- iterator_on_values<E>::~iterator_on_values()
+ template <typename Exact>
+ Iterator_on_Values<Exact>::Iterator_on_Values()
{
- mlc::assert_defined_< typename iterator_on_values<E>::value_type >::check();
}
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr,
- const iterator_on_values<E>& vit)
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Values<Exact>& vit)
{
- return ostr << vit.to_value();
+ return ostr << vit.to_point();
}
-
# endif
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
Index: oln/core/concept/value.hh
--- oln/core/concept/value.hh (revision 844)
+++ oln/core/concept/value.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2005, 2006, 2007 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
@@ -25,36 +26,34 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_VALUE_HH
-# define OLN_CORE_ABSTRACT_VALUE_HH
+#ifndef OLN_CORE_CONCEPT_VALUE_HH
+# define OLN_CORE_CONCEPT_VALUE_HH
-# include <oln/core/type.hh>
+# include <oln/core/equipment.hh>
-namespace oln {
+namespace oln
+{
- namespace abstract {
+ /// Concept-class "Value".
- // A value is not an oln::type. As a consequence,
- // traits are basically defined.
- struct value
+ template <typename Exact>
+ struct Value : public Any<Exact>
{
protected:
- value();
+ Value();
};
# ifndef OLN_INCLUDE_ONLY
- value::value()
+ Value::Value()
{
}
# endif
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_VALUE_HH
+#endif // ! OLN_CORE_CONCEPT_VALUE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleaning point set classes.
* oln/core/point_set_entry.hh: Rename as...
* oln/core/internal/point_set_base.hh: ...this and update.
* oln/core/abstract/point_set.hh: Rename as...
* oln/core/concept/point_set.hh: ...this and update.
* oln/core/abstract/iterator.hh: Rename as...
* oln/core/concept/iterator.hh: ...this and update.
* oln/core/abstract/iterator_on_points.hh: Rename as...
* oln/core/concept/iterator_on_points.hh: ...this and update.
* oln/core/abstract/point_set/point_set_being_random_accessible.hh,
* oln/core/abstract/point_set/point_set_having_known_size.hh,
* oln/core/abstract/point_set/hierarchies.hh,
* oln/core/abstract/point_set/all.hh,
* oln/core/abstract/point_set/point_set_being_connected.hh,
* oln/core/abstract/point_set/point_set_having_bbox.hh: Remove.
* oln/core/gen/bbox.hh: Split and rename as...
* oln/core/gen/box.hh: ...this and update...
* oln/core/gen/fbbox.hh: ...and this and update.
* oln/core/gen/bbox_fwd_piter.hh,
* oln/core/gen/bbox_bkd_piter.hh: Remove because merge with...
* oln/core/gen/box.hh: ...this.
* oln/core/gen/pset_.hh: Rename as...
* oln/core/gen/pset.hh: ...this and update.
* oln/core/gen/pset_list.hh: Rename as...
* oln/core/gen/plist.hh: ...this and update.
* oln/core/gen/pset_vec.hh: Rename as...
* oln/core/gen/pvec.hh: ...this and update.
* oln/core/gen/piter_on_std_based_pset.hh: Rename as...
* oln/core/internal/point_set_std_based.hh: ...this and update.
* oln/core/2d/aliases.hh: Update.
* oln/core/equipment.hh: Update.
* oln/core/2d/box2d.hh: New.
2d/aliases.hh | 11 -
2d/box2d.hh | 44 ++++
concept/iterator.hh | 74 ++-----
concept/iterator_on_points.hh | 120 +++--------
concept/point_set.hh | 107 ++++------
equipment.hh | 34 ++-
gen/box.hh | 420 ++++++++++++++++++++++++++--------------
gen/fbbox.hh | 127 ++++++++++++
gen/plist.hh | 149 +++-----------
gen/pset.hh | 129 ++----------
gen/pvec.hh | 144 ++++---------
internal/point_set_base.hh | 72 +++---
internal/point_set_std_based.hh | 343 +++++++++++++++++++++-----------
13 files changed, 951 insertions(+), 823 deletions(-)
Index: oln/core/concept/iterator_on_points.hh
--- oln/core/concept/iterator_on_points.hh (revision 843)
+++ oln/core/concept/iterator_on_points.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,131 +26,79 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
+# define OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/point.hh>
+# include <ostream>
+# include <oln/core/concept/iterator.hh>
+# include <oln/core/concept/point.hh>
namespace oln
{
+ /// Concept-class "Iterator_on_Points".
- // Forward declaration.
- namespace abstract { template <typename E> class iterator_on_points; }
-
-
- // Super type declaration.
- template <typename E>
- struct set_super_type< abstract::iterator_on_points<E> >
- {
- typedef abstract::iterator<E> ret;
- };
-
-
- /// Virtual types associated to abstract::iterator_on_points<E>.
- template <typename E>
- struct vtypes< abstract::iterator_on_points<E> >
- {
- typedef stc::abstract point_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_deduce_deferred_vtype(E, point, coord) coord_type;
-# endif // !OLENA_USE_SCOOP_ALT
- };
-
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< abstract::iterator_on_points<E>,
- typedef_::coord_type >
- {
- typedef oln_deduce_deferred_vtype(E, point, coord) ret;
- };
-# endif // OLENA_USE_SCOOP_ALT
-
-
- namespace abstract
- {
-
- /// Abstract point iterator class.
- template <typename E>
- class iterator_on_points : public abstract::iterator<E>
+ template <typename Exact>
+ struct Iterator_on_Points : public Iterator<Exact>
{
- typedef oln_point(E) point_t;
+ stc_typename(point);
- public:
+ point to_point() const;
+ const point* point_adr() const;
- point_t to_point() const;
-
- const point_t* point_adr() const;
-
- // Concrete method.
- operator point_t() const;
+ // Default.
+ operator point() const;
protected:
+ Iterator_on_Points();
- iterator_on_points();
-
- ~iterator_on_points();
+ }; // end of class oln::Iterator_on_Points<Exact>
- }; // end of class oln::abstract::iterator_on_points<E>
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const iterator_on_points<E>& pit);
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Points<Exact>& pit);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- typename iterator_on_points<E>::point_t
- iterator_on_points<E>::to_point() const
+ template <typename Exact>
+ typename Iterator_on_Points<Exact>::point
+ Iterator_on_Points<Exact>::to_point() const
{
precondition(this->is_valid());
- return this->exact().impl_to_point();
+ return exact(this)->impl_to_point();
}
- template <typename E>
- const typename iterator_on_points<E>::point_t*
- iterator_on_points<E>::point_adr() const
+ template <typename Exact>
+ const typename Iterator_on_Points<Exact>::point*
+ Iterator_on_Points<Exact>::point_adr() const
{
- return this->exact().impl_point_adr();
+ return exact(this)->impl_point_adr();
}
- template <typename E>
- // Concrete method.
- iterator_on_points<E>::operator typename iterator_on_points<E>::point_t() const
+ template <typename Exact>
+ Iterator_on_Points<Exact>::operator typename Iterator_on_Points<Exact>::point() const
{
precondition(this->is_valid());
return this->to_point();
}
- template <typename E>
- iterator_on_points<E>::iterator_on_points()
+ template <typename Exact>
+ Iterator_on_Points<Exact>::Iterator_on_Points()
{
+ mlc::assert_< mlc_is_a(typename Iterator_on_Points<Exact>::point, Point) >::check();
}
- template <typename E>
- iterator_on_points<E>::~iterator_on_points()
- {
- mlc::assert_defined_< typename iterator_on_points<E>::point_t >::check();
- mlc::assert_< mlc_is_a(typename iterator_on_points<E>::point_t, abstract::point) >::check();
- }
-
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const iterator_on_points<E>& pit)
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Points<Exact>& pit)
{
return ostr << pit.to_point();
}
-
# endif
- } // end of namespace oln::abstract
-
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 843)
+++ oln/core/concept/point_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,92 +25,89 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_POINT_SET_HH
-# define OLN_CORE_ABSTRACT_POINT_SET_HH
+#ifndef OLN_CORE_CONCEPT_POINT_SET_HH
+# define OLN_CORE_CONCEPT_POINT_SET_HH
-# include <oln/core/typedefs.hh>
+# include <ostream>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract
- {
-
-
- /// Abstract point class.
- template <typename E>
- class point_set : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
- bool is_valid() const;
+ /// Concept-class "Point_Set".
- struct decl
+ template <typename Exact>
+ struct Point_Set : public Any<Exact>
{
- oln_virtual_typedef(point);
-
- oln_virtual_typedef(piter);
- oln_virtual_typedef(fwd_piter);
- oln_virtual_typedef(bkd_piter);
-
- oln_virtual_typedef(bbox); // provides .bbox()
- oln_virtual_typedef(is_random_accessible); // provides .has(p)
- oln_virtual_typedef(has_known_size); // provides .npoints()
- oln_virtual_typedef(is_connected); // provides, e.g., .nrows()
-
- // derived from point:
- oln_virtual_typedef(coord);
- oln_virtual_typedef(grid);
- oln_virtual_typedef(dim);
-
- decl();
- };
-
- ~point_set();
+ stc_typename(point);
+ stc_typename(grid);
+ stc_typename(piter);
+ stc_typename(fwd_piter);
+ stc_typename(bkd_piter);
+ stc_typename(box);
+
+ // FIXME: Add coord and dim?
+
+ unsigned npoints() const;
+ bool has(const point& p) const;
+ const box& bbox() const;
protected:
+ Point_Set();
+
+ }; // end of oln::Point_Set<Exact>
- point_set();
- }; // end of class oln::abstract::point_set<E>
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool point_set<E>::is_valid() const
+ template <typename Exact>
+ unsigned
+ Point_Set<Exact>::npoints() const
{
- return this->exact().impl_is_valid();
+ return exact(this)->impl_npoints();
}
- template <typename E>
- point_set<E>::decl::decl()
+ template <typename Exact>
+ bool
+ Point_Set<Exact>::has(const typename Point_Set<Exact>::point& p) const
{
- // coherence check:
- // FIXME: Rec?
-// mlc::assert_equal_< oln_grid(fwd_piter), oln_grid(point) >::check();
-// mlc::assert_equal_< oln_grid(bkd_piter), oln_grid(point) >::check();
+ return exact(this)->impl_has();
}
- template <typename E>
- point_set<E>::point_set()
+ template <typename Exact>
+ const typename Point_Set<Exact>::box&
+ Point_Set<Exact>::bbox() const
{
+ return exact(this)->impl_bbox();
}
- template <typename E>
- point_set<E>::~point_set()
+ template <typename Exact>
+ Point_Set<Exact>::Point_Set()
{
- decl();
}
-# endif
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts)
+ {
+ ostr << "{ ";
+ typename Ps::piter p(pts);
+ for_all(p)
+ ostr << p << ' '; // FIXME: Add ','?
+ return ostr << " }";
+ }
+
+
+# endif
- } // end of namespace oln::abstract
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_POINT_SET_HH
+#endif // ! OLN_CORE_CONCEPT_POINT_SET_HH
Index: oln/core/concept/iterator.hh
--- oln/core/concept/iterator.hh (revision 843)
+++ oln/core/concept/iterator.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,92 +26,74 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_HH
+# define OLN_CORE_CONCEPT_ITERATOR_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
-namespace oln
-{
-
- namespace abstract { template <typename E> class iterator; }
+/// Macro for_all.
+# define for_all(i) for (i.start(); i.is_valid(); i.next())
- template <typename E>
- struct set_super_type< abstract::iterator<E> >
- {
- typedef mlc::none ret;
- };
- namespace abstract
+namespace oln
{
- /// Abstract iterator class.
- template <typename E>
- class iterator : public stc::any__best_memory<E>,
- public oln::type
- {
- public:
+ /// Concept-class "Iterator".
+ template <typename Exact>
+ struct Iterator : public Any<Exact>
+ {
void start();
-
void next();
-
void invalidate();
-
bool is_valid() const;
protected:
+ Iterator();
- iterator();
-
- }; // end of class oln::abstract::iterator<E>
+ }; // end of class oln::Iterator<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- void iterator<E>::start()
+ template <typename Exact>
+ void Iterator<Exact>::start()
{
- this->exact().impl_start();
+ exact(this)->impl_start();
}
- template <typename E>
- void iterator<E>::next()
+ template <typename Exact>
+ void Iterator<Exact>::next()
{
precondition(this->is_valid());
- this->exact().impl_next();
+ exact(this)->impl_next();
}
- template <typename E>
- void iterator<E>::invalidate()
+ template <typename Exact>
+ void Iterator<Exact>::invalidate()
{
- this->exact().impl_invalidate();
+ exact(this)->impl_invalidate();
}
- template <typename E>
- bool iterator<E>::is_valid() const
+ template <typename Exact>
+ bool Iterator<Exact>::is_valid() const
{
- return this->exact().impl_is_valid();
+ return exact(this)->impl_is_valid();
}
- template <typename E>
- iterator<E>::iterator()
+ template <typename Exact>
+ Iterator<Exact>::Iterator()
{
}
# endif
- } // end of namespace oln::abstract
-
-
} // end of namespace oln
-#define for_all(i) for (i.start(); i.is_valid(); i.next())
-
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_HH
Index: oln/core/2d/aliases.hh
--- oln/core/2d/aliases.hh (revision 843)
+++ oln/core/2d/aliases.hh (working copy)
@@ -35,12 +35,8 @@
/// Forward declarations.
/// \{
- template <unsigned D> struct grid_;
- template <typename C> class point2d_;
- template <typename C> class dpoint2d_;
template <typename D> class neighb_;
template <typename D> class window_;
- template <typename P> class bbox_;
template <typename P> class topo_lbbox_;
template <typename P> class fwd_piter_bbox_;
template <typename P> class bkd_piter_bbox_;
@@ -51,15 +47,10 @@
/// Aliases.
/// \{
- typedef grid_<2> grid2d;
-
- typedef point2d_<int> point2d;
- typedef dpoint2d_<int> dpoint2d;
typedef neighb_<dpoint2d> neighb2d;
typedef window_<dpoint2d> window2d;
- typedef bbox_<point2d> bbox2d;
typedef topo_lbbox_<point2d> topo2d;
typedef fwd_piter_bbox_<point2d> fwd_piter2d;
@@ -68,8 +59,6 @@
typedef fwd_qiter_win_<point2d> fwd_qiter2d;
typedef bkd_qiter_win_<point2d> bkd_qiter2d;
- typedef point2d_<float> point2df;
- typedef dpoint2d_<float> dpoint2df;
/// \}
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 0)
+++ oln/core/2d/box2d.hh (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (C) 2007 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_2D_BOX2D_HH
+# define OLN_CORE_2D_BOX2D_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/2d/point2d.hh>
+
+
+namespace oln
+{
+
+ typedef box_<point2d> box2d;
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_2D_BOX2D_HH
+
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 843)
+++ oln/core/equipment.hh (working copy)
@@ -39,22 +39,36 @@
# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
-
- stc_decl_associated_type(grid);
+ // b
+ stc_decl_associated_type( bkd_piter );
+ stc_decl_associated_type( box );
+ // c
stc_decl_associated_type(coord);
+ // d
+ stc_decl_associated_type( data );
stc_decl_associated_type(dim);
- stc_decl_associated_type(point);
stc_decl_associated_type(dpoint);
- stc_decl_associated_type(psite);
+ // f
+ stc_decl_associated_type( fwd_piter );
+ // g
+ stc_decl_associated_type( grid );
+ // i
stc_decl_associated_type(index);
- stc_decl_associated_type(value);
- stc_decl_associated_type(rvalue);
+ // l
stc_decl_associated_type(lvalue);
- stc_decl_associated_type(iter);
- stc_decl_associated_type(data);
- stc_decl_associated_type(box);
- stc_decl_associated_type(pset);
+ // n
stc_decl_associated_type(n);
+ // p
+ stc_decl_associated_type( piter );
+ stc_decl_associated_type( point );
+ stc_decl_associated_type( pset );
+ stc_decl_associated_type( psite );
+ // r
+ stc_decl_associated_type( rvalue );
+ // s
+ stc_decl_associated_type( std_container );
+ // v
+ stc_decl_associated_type( value );
} // end of namespace oln
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 843)
+++ oln/core/gen/box.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,239 +26,385 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_BBOX_HH
-# define OLN_CORE_GEN_BBOX_HH
+#ifndef OLN_CORE_GEN_BOX_HH
+# define OLN_CORE_GEN_BOX_HH
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/concept/point.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/point_set_base.hh>
namespace oln
{
// Forward declarations.
- template <typename point_t> class bbox_;
- template <typename point_t> class bbox_fwd_piter_;
- template <typename point_t> class bbox_bkd_piter_;
+ template <typename P> class box_;
+ template <typename P> class box_fwd_piter_;
+ template <typename P> class box_bkd_piter_;
// Super type declaration.
- template <typename point_t>
- struct set_super_type< bbox_<point_t> >
+ template <typename P>
+ struct super_trait_< box_<P> >
{
- typedef bbox_<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef box_<P> current__;
+ typedef internal::point_set_base_<current__> ret;
};
- /// Virtual types associated to oln::bbox_<point_t>.
- template <typename point_t>
- struct vtypes< bbox_<point_t> >
- {
- typedef point_t point_type;
- typedef bbox_fwd_piter_<point_t> fwd_piter_type;
- typedef bbox_bkd_piter_<point_t> bkd_piter_type;
-
- typedef bbox_<point_t> bbox_type;
-
- typedef mlc::true_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::true_ is_connected_type;
+ /// Virtual types associated to oln::box_<P>.
+ template <typename P>
+ struct vtypes< box_<P> >
+ {
+ typedef P point;
+ typedef box_fwd_piter_<P> fwd_piter;
+ typedef box_bkd_piter_<P> bkd_piter;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class bbox_ : public point_set_entry< bbox_<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
+ /// Generic box class based on a point class.
+
+ template <typename P>
+ class box_ : public internal::point_set_base_< box_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
{
- // Make self_type public so that is can be used to define a
- // virtual type of oln::topo_bbox_ and oln::topo_lbbox_.
+ typedef box_<P> current;
+ typedef internal::point_set_base_<current> super;
public:
- typedef bbox_<point_t> self_type;
+
+ stc_using(point);
+ stc_using(box);
private:
- typedef point_set_entry<self_type> super_t;
+ typedef stc_type(point, dim) dim__;
+ enum { n = mlc_value(dim__) };
- typedef oln_vtype(point_t, coord) coord_t;
+ public:
- typedef oln_vtype(point_t, dim) dim;
- enum { n = mlc_value(dim) };
+ box_();
+ box_(const P& pmin, const P& pmax);
- public:
+ unsigned impl_npoints() const;
+ bool impl_has(const P& p) const;
+ const box_<P>& impl_bbox() const;
- bbox_();
+ const P& pmin() const;
+ P& pmin();
+ const P& pmax() const;
+ P& pmax();
- bbox_(const point_t& pmin, const point_t& pmax);
+ protected:
+ point pmin_, pmax_;
- bbox_(const bbox_<point_t>& rhs);
+ }; // end of class oln::box_<P>
- bbox_<point_t>& operator=(const bbox_<point_t>& rhs);
- unsigned impl_npoints() const;
- bool impl_has(const point_t& p) const;
- void flush();
+ // -------------------- iterators on box_<P>
- void init_with(const point_t& p);
- void update_with(const point_t& p);
- void take(const point_t& p);
- // FIXME: Add "update : (rhs : exact)"
+ /// Super types.
+
+ template <typename P>
+ struct super_trait_< box_fwd_piter_<P> >
+ {
+ typedef box_fwd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename P>
+ struct super_trait_< box_bkd_piter_<P> >
+ {
+ typedef box_bkd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
- bool includes(const bbox_<point_t>& rhs) const;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< box_fwd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ template <typename P>
+ struct vtypes< box_bkd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+
+ /// Class box_fwd_piter_<P>.
+
+ template <typename P>
+ class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+ box_fwd_piter_();
+ box_fwd_piter_(const Point_Set< box_<P> >& b);
+ void set_box(const box_<P>& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
bool impl_is_valid() const;
+ P impl_to_point() const;
+ const P* impl_point_adr() const;
- void impl_print(std::ostream& ostr) const;
+ private:
+ box_<P> b_;
+ P p_, nop_;
+ };
- protected:
- bool is_valid_;
+ /// Class box_bkd_piter_<P>.
+
+ template <typename P>
+ class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+ box_bkd_piter_();
+ box_bkd_piter_(const Point_Set< box_<P> >& b);
+ void set_box(const box_<P>& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ P impl_to_point() const;
+ const P* impl_point_adr() const;
+
+ private:
+ box_<P> b_;
+ P p_, nop_;
+ };
- }; // end of class oln::bbox_<point_t>
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- bbox_<point_t>::bbox_()
+
+ // -------------------- box_<P>
+
+
+ template <typename P>
+ box_<P>::box_()
{
- flush();
}
- template <typename point_t>
- bbox_<point_t>::bbox_(const point_t& pmin, const point_t& pmax)
+ template <typename P>
+ box_<P>::box_(const P& pmin, const P& pmax)
{
+ for (unsigned i = 0; i < n; ++i)
+ precondition(pmax[i] >= pmin[i]);
this->pmin_ = pmin;
this->pmax_ = pmax;
- is_valid_ = true;
+ }
+ template <typename P>
+ unsigned
+ box_<P>::impl_npoints() const
+ {
+ unsigned count = 1;
for (unsigned i = 0; i < n; ++i)
- precondition(pmax[i] >= pmin[i]);
+ count *= (this->pmax_[i] - this->pmin_[i] + 1);
+ return count;
}
- template <typename point_t>
- bbox_<point_t>::bbox_(const bbox_<point_t>& rhs)
+ template <typename P>
+ bool
+ box_<P>::impl_has(const P& p) const
{
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
+ return false;
+ return true;
+ }
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ template <typename P>
+ const box_<P>&
+ box_<P>::impl_bbox() const
+ {
+ return *this;
+ }
+ template <typename P>
+ const P&
+ box_<P>::pmin() const
+ {
for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
+ invariant(pmin[i] <= pmax[i]);
+ return this->pmin_;
}
- template <typename point_t>
- bbox_<point_t>& bbox_<point_t>::operator=(const bbox_<point_t>& rhs)
+ template <typename P>
+ const P&
+ box_<P>::pmax() const
{
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ invariant(pmax[i] >= pmin[i]);
+ return this->pmax_;
+ }
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ template <typename P>
+ P&
+ box_<P>::pmin()
+ {
+ return this->pmin_;
+ }
- for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
+ template <typename P>
+ P&
+ box_<P>::pmax()
+ {
+ return this->pmax_;
+ }
- return *this;
+
+
+ // -------------------- box_fwd_piter_<P>
+
+
+ template <typename P>
+ box_fwd_piter_<P>::box_fwd_piter_()
+ {
}
- template <typename point_t>
- unsigned bbox_<point_t>::impl_npoints() const
+ template <typename P>
+ box_fwd_piter_<P>::box_fwd_piter_(const Point_Set< box_<P> >& b)
{
- unsigned count = 1;
- for (unsigned i = 0; i < n; ++i)
- count *= this->len(i);
- return count;
+ this->set_box(exact(b));
}
- template <typename point_t>
- bool bbox_<point_t>::impl_has(const point_t& p) const
+ template <typename P>
+ void box_fwd_piter_<P>::set_box(const box_<P>& b)
{
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
- return false;
- return true;
+ b_ = b;
+ nop_ = b_.pmax();
+ ++nop_[0];
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::flush()
+ template <typename P>
+ void box_fwd_piter_<P>::impl_start()
{
- is_valid_ = false;
+ p_ = b_.pmin();
}
- template <typename point_t>
- void bbox_<point_t>::init_with(const point_t& p)
+ template <typename P>
+ void box_fwd_piter_<P>::impl_next()
{
- precondition(not is_valid_);
- this->pmin_ = p;
- this->pmax_ = p;
- is_valid_ = true;
+ for (int i = P::n - 1; i >= 0; --i)
+ if (p_[i] = b_.pmax()[i])
+ p_[i] = b_.pmin()[i];
+ else
+ {
+ ++p_[i];
+ break;
+ }
+ if (p_ = b_.pmin())
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::update_with(const point_t& p)
+ template <typename P>
+ void box_fwd_piter_<P>::impl_invalidate()
{
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::take(const point_t& p)
+ template <typename P>
+ bool box_fwd_piter_<P>::impl_is_valid() const
{
- if (not is_valid_)
+ return p_ != nop_;
+ }
+
+ template <typename P>
+ P box_fwd_piter_<P>::impl_to_point() const
{
- init_with(p);
- return;
+ return p_;
}
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
+
+ template <typename P>
+ const P* box_fwd_piter_<P>::impl_point_adr() const
+ {
+ return &p_;
}
- template <typename point_t>
- bool bbox_<point_t>::includes(const bbox_<point_t>& rhs) const
+
+
+ // -------------------- box_bkd_piter_<P>
+
+
+ template <typename P>
+ box_bkd_piter_<P>::box_bkd_piter_()
{
- precondition(is_valid_ and rhs.is_valid());
- for (unsigned i = 0; i < n; ++i)
- if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i])
- return false;
- return true;
}
- template <typename point_t>
- bool bbox_<point_t>::impl_is_valid() const
+ template <typename P>
+ box_bkd_piter_<P>::box_bkd_piter_(const Point_Set< box_<P> >& b)
+ {
+ this->set_box(exact(b));
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::set_box(const box_<P>& b)
+ {
+ b_ = b;
+ nop_ = b_.pmin();
+ --nop_[0];
+ p_ = nop_;
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_start()
+ {
+ p_ = b_.pmax();
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_next()
+ {
+ for (int i = P::n - 1; i >= 0; --i)
+ if (p_[i] = b_.pmin()[i])
+ p_[i] = b_.pmax()[i];
+ else
+ {
+ --p_[i];
+ break;
+ }
+ if (p_ = b_.pmax())
+ p_ = nop_;
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_invalidate()
+ {
+ p_ = nop_;
+ }
+
+ template <typename P>
+ bool box_bkd_piter_<P>::impl_is_valid() const
+ {
+ return p_ != nop_;
+ }
+
+ template <typename P>
+ P box_bkd_piter_<P>::impl_to_point() const
{
- return is_valid_;
+ return p_;
}
- template <typename point_t>
- void bbox_<point_t>::impl_print(std::ostream& ostr) const
+ template <typename P>
+ const P* box_bkd_piter_<P>::impl_point_adr() const
{
- ostr << "{ pmin=" << this->pmin_
- << ", pmax=" << this->pmax_
- << ", valid=" << is_valid_
- << " }";
+ return &p_;
}
# endif
@@ -267,4 +413,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_BBOX_HH
+#endif // ! OLN_CORE_GEN_BOX_HH
Index: oln/core/gen/plist.hh
--- oln/core/gen/plist.hh (revision 843)
+++ oln/core/gen/plist.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,157 +25,78 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PSET_LIST_HH
-# define OLN_CORE_GEN_PSET_LIST_HH
+#ifndef OLN_CORE_GEN_PLIST_HH
+# define OLN_CORE_GEN_PLIST_HH
# include <list>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_list;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class plist_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_list<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< plist_<P> >
{
- typedef pset_list<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef plist_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_list<point_t>.
- template <typename point_t>
- struct vtypes< pset_list<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::list<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::list<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< plist_<P> >
+ {
+ typedef std::list<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_list : public point_set_entry< pset_list<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_list<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::list.
+ template <typename P>
+ class plist_ : public internal::point_set_std_based_< plist_<P> >
+ {
public:
- pset_list();
- pset_list(const pset_list<point_t>& rhs);
- pset_list<point_t>& operator=(const pset_list<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_list<point_t>& append(const point_t& p);
- pset_list<point_t>& prepend(const point_t& p);
-
- const std::list<point_t>& container() const;
- std::list<point_t>& container();
-
- protected:
-
- std::list<point_t> lp_;
+ plist_();
+ plist_<P>& append(const P& p);
+ plist_<P>& prepend(const P& p);
- }; // end of class oln::pset_list<point_t>
+ }; // end of class oln::plist_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_list<point_t>::pset_list()
+ template <typename P>
+ plist_<P>::plist_()
{
}
- template <typename point_t>
- pset_list<point_t>::pset_list(const pset_list<point_t>& rhs)
+ template <typename P>
+ plist_<P>& plist_<P>::append(const P& p)
{
- lp_ = rhs.lp_;
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::operator=(const pset_list<point_t>& rhs)
- {
- lp_ = rhs.lp_;
+ this->con_.push_back(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_list<point_t>::impl_npoints() const
- {
- return lp_.size();
- }
-
- template <typename point_t>
- bool pset_list<point_t>::impl_is_valid() const
+ template <typename P>
+ plist_<P>& plist_<P>::prepend(const P& p)
{
- return true;
- }
-
- template <typename point_t>
- void pset_list<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::list<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = lp_.begin(); it != lp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::append(const point_t& p)
- {
- precondition(std::find(lp_.begin(), lp_.end(), p)
- = lp_.end());
- lp_.push_back(p);
- return *this;
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::prepend(const point_t& p)
- {
- precondition(std::find(lp_.begin(), lp_.end(), p)
- = lp_.end());
- lp_.push_front(p);
+ this->con_.push_front(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- const std::list<point_t>& pset_list<point_t>::container() const
- {
- return lp_;
- }
-
- template <typename point_t>
- std::list<point_t>& pset_list<point_t>::container()
- {
- return lp_;
- }
-
# endif
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
-#endif // ! OLN_CORE_GEN_PSET_LIST_HH
+#endif // ! OLN_CORE_GEN_PLIST_HH
Index: oln/core/gen/pvec.hh
--- oln/core/gen/pvec.hh (revision 843)
+++ oln/core/gen/pvec.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,139 +25,82 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PSET_VEC_HH
-# define OLN_CORE_GEN_PSET_VEC_HH
+#ifndef OLN_CORE_GEN_PVEC_HH
+# define OLN_CORE_GEN_PVEC_HH
# include <vector>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_vec;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class pvec_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_vec<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< pvec_<P> >
{
- typedef pset_vec<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef pvec_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_vec<point_t>.
- template <typename point_t>
- struct vtypes< pset_vec<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::vector<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::vector<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< pvec_<P> >
+ {
+ typedef std::vector<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_vec : public point_set_entry< pset_vec<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_vec<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::set.
+ template <typename P>
+ class pvec_ : public internal::point_set_std_based_< pvec_<P> >
+ {
public:
- pset_vec();
- pset_vec(const pset_vec<point_t>& rhs);
- pset_vec<point_t>& operator=(const pset_vec<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_vec<point_t>& append(const point_t& p);
-
- const std::vector<point_t>& container() const;
- std::vector<point_t>& container();
+ pvec_();
+ pvec_<P>& append(const P& p);
+ const P& operator[](unsigned i) const;
+ P& operator[](unsigned i);
- protected:
-
- std::vector<point_t> vp_;
-
- }; // end of class oln::pset_vec<point_t>
+ }; // end of class oln::pvec_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_vec<point_t>::pset_vec()
+ template <typename P>
+ pvec_<P>::pvec_()
{
}
- template <typename point_t>
- pset_vec<point_t>::pset_vec(const pset_vec<point_t>& rhs)
+ template <typename P>
+ pvec_<P>&
+ pvec_<P>::append(const P& p)
{
- vp_ = rhs.vp_;
- }
-
- template <typename point_t>
- pset_vec<point_t>& pset_vec<point_t>::operator=(const pset_vec<point_t>& rhs)
- {
- vp_ = rhs.vp_;
+ this->con_.push_back(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_vec<point_t>::impl_npoints() const
+ template <typename P>
+ const P&
+ pvec_<P>::operator[](unsigned i) const
{
- return vp_.size();
+ precondition(i < this->npoints());
+ return this->con_[i];
}
- template <typename point_t>
- bool pset_vec<point_t>::impl_is_valid() const
+ template <typename P>
+ P& pvec_<P>::operator[](unsigned i)
{
- return true;
- }
-
- template <typename point_t>
- void pset_vec<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::vector<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = vp_.begin(); it != vp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_vec<point_t>& pset_vec<point_t>::append(const point_t& p)
- {
- precondition(std::find(vp_.begin(), vp_.end(), p)
- = vp_.end());
- vp_.push_back(p);
- return *this;
- }
-
- template <typename point_t>
- const std::vector<point_t>& pset_vec<point_t>::container() const
- {
- return vp_;
- }
-
- template <typename point_t>
- std::vector<point_t>& pset_vec<point_t>::container()
- {
- return vp_;
+ precondition(i < this->npoints());
+ return this->con_[i];
}
# endif
@@ -165,7 +108,4 @@
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
-#endif // ! OLN_CORE_GEN_PSET_VEC_HH
+#endif // ! OLN_CORE_GEN_PVEC_HH
Index: oln/core/gen/fbbox.hh
--- oln/core/gen/fbbox.hh (revision 0)
+++ oln/core/gen/fbbox.hh (revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 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_FBBOX_HH
+# define OLN_CORE_GEN_FBBOX_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/concept/point.hh>
+
+
+namespace oln
+{
+
+
+ /// Bounding box function based on a point class.
+
+ template <typename P>
+ class fbbox_ : private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ private:
+ typedef stc_type(P, dim) dim__;
+ enum { n = mlc_value(dim__) };
+
+ public:
+
+ fbbox_();
+ operator box_<P>() const;
+
+ bool is_valid() const;
+ void flush();
+ fbbox_<P>& take(const P& p);
+ const box_<P>& box() const;
+
+ private:
+ bool is_valid_;
+ box_<P> b_;
+
+ }; // end of class oln::fbbox_<P>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ fbbox_<P>::fbbox_()
+ {
+ this->flush();
+ }
+
+ template <typename P>
+ fbbox_<P>::operator box_<P>() const
+ {
+ precondition(this->is_valid_);
+ return this->b_;
+ }
+
+ template <typename P>
+ bool fbbox_<P>::is_valid() const
+ {
+ return this->is_valid_;
+ }
+
+ template <typename P>
+ void fbbox_<P>::flush()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ fbbox_<P>& fbbox_<P>::take(const P& p)
+ {
+ if (not this->is_valid_)
+ {
+ this->b_.pmin() = p;
+ this->b_.pmax() = p;
+ this->is_valid_ = true;
+ }
+ else
+ {
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->b_.pmin()[i])
+ this->b_.pmin()[i] = p[i];
+ else if (p[i] > this->b_.pmax()[i])
+ this->b_.pmax()[i] = p[i];
+ }
+ return *this;
+ }
+
+ template <typename P>
+ const box_<P>& fbbox_<P>::box() const
+ {
+ precondition(this->is_valid_);
+ return this->b_;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_FBBOX_HH
Index: oln/core/gen/pset.hh
--- oln/core/gen/pset.hh (revision 843)
+++ oln/core/gen/pset.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -29,142 +29,65 @@
# define OLN_CORE_GEN_PSET_HH
# include <set>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class pset_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< pset_<P> >
{
- typedef pset_<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef pset_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_<point_t>.
- template <typename point_t>
- struct vtypes< pset_<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::set<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::set<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< pset_<P> >
+ {
+ typedef std::set<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_ : public point_set_entry< pset_<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::set.
+ template <typename P>
+ class pset_ : public internal::point_set_std_based_< pset_<P> >
+ {
public:
pset_();
- pset_(const pset_<point_t>& rhs);
- pset_<point_t>& operator=(const pset_<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_<point_t>& insert(const point_t& p);
-
- const std::set<point_t>& container() const;
- std::set<point_t>& container();
-
- protected:
-
- std::set<point_t> sp_;
+ pset_<P>& insert(const P& p);
- }; // end of class oln::pset_<point_t>
+ }; // end of class oln::pset_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_<point_t>::pset_()
+ template <typename P>
+ pset_<P>::pset_()
{
}
- template <typename point_t>
- pset_<point_t>::pset_(const pset_<point_t>& rhs)
+ template <typename P>
+ pset_<P>& pset_<P>::insert(const P& p)
{
- sp_ = rhs.sp_;
- }
-
- template <typename point_t>
- pset_<point_t>& pset_<point_t>::operator=(const pset_<point_t>& rhs)
- {
- sp_ = rhs.sp_;
+ this->con_.insert(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_<point_t>::impl_npoints() const
- {
- return sp_.size();
- }
-
- template <typename point_t>
- bool pset_<point_t>::impl_is_valid() const
- {
- return true;
- }
-
- template <typename point_t>
- void pset_<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::set<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = sp_.begin(); it != sp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_<point_t>& pset_<point_t>::insert(const point_t& p)
- {
- precondition(sp_.find(p) = sp_.end());
- sp_.insert(p);
- return *this;
- }
-
- template <typename point_t>
- const std::set<point_t>& pset_<point_t>::container() const
- {
- return sp_;
- }
-
- template <typename point_t>
- std::set<point_t>& pset_<point_t>::container()
- {
- return sp_;
- }
-
# endif
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
#endif // ! OLN_CORE_GEN_PSET_HH
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 843)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,247 +25,348 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
-# define OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+#ifndef OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
+# define OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/iterator_on_points.hh>
+# include <ostream>
+# include <algorithm>
+
+# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/gen/fbbox.hh>
namespace oln
{
- // Fwd_piter version.
- // ------------------
-
-
- // Forward declaration.
- template <typename C> class fwd_piter_on_std_based_pset;
+ /// Fwd decl.
+ namespace internal { template <typename Exact> struct point_set_std_based_; }
+ template <typename P> class pset_std_based_fwd_piter_;
+ template <typename P> class pset_std_based_bkd_piter_;
- // Super.
- template <typename C>
- struct set_super_type< fwd_piter_on_std_based_pset<C> >
+ /// Super type.
+ template <typename Exact>
+ struct super_trait_< internal::point_set_std_based_<Exact> >
{
- typedef abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> > ret;
+ typedef internal::point_set_base_<Exact> ret;
};
- // Vtypes.
- template <typename C>
- struct vtypes< fwd_piter_on_std_based_pset<C> >
- {
- typedef typename C::value_type point_type;
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point_set_std_based_<Exact> >
+ {
+ typedef stc::abstract std_container;
+
+ typedef stc_deferred(std_container) std_container__;
+ typedef stc::final< typename std_container__::value_type > point;
+ typedef stc::final< pset_std_based_fwd_piter_<std_container__> > fwd_piter;
+ typedef stc::final< pset_std_based_bkd_piter_<std_container__> > bkd_piter;
};
- // Class.
- template <typename C>
- class fwd_piter_on_std_based_pset :
+ namespace internal
+ {
+
+ /// Base class for point sets defined over std containers.
- public abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> >,
- private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ template <typename Exact>
+ struct point_set_std_based_ : public point_set_base_<Exact>
{
+ typedef point_set_base_<Exact> super;
public:
- fwd_piter_on_std_based_pset(const C& container);
- template <typename point_set>
- fwd_piter_on_std_based_pset(const point_set& ps);
+ stc_using(point);
+ stc_using(box);
- void impl_start();
- void impl_next();
- void impl_invalidate();
- bool impl_is_valid() const;
- typename C::value_type impl_to_point() const;
- const typename C::value_type* impl_point_adr() const;
+ unsigned impl_npoints() const;
+ bool impl_has(const point& p) const;
+ const box& impl_bbox() const;
- private:
+ stc_typename(std_container);
+ const std_container& con() const;
- const C& container_;
- typename C::const_iterator it_;
+ protected:
+
+ point_set_std_based_();
+
+ void take_(const point& p);
+
+ std_container con_;
+ fbbox_<point> fb_;
+
+ }; // end of class point_set_std_based_<Exact>
+
+
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr,
+ const point_set_std_based_<Exact>& pts)
+ {
+ typename Exact::fwd_piter i(pts);
+ ostr << "{ ";
+ for_all(i)
+ ostr << i.to_point() << ' ';
+ ostr << "}";
+ }
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ unsigned
+ point_set_std_based_<Exact>::impl_npoints() const
+ {
+ return this->con_.size();
+ }
+
+ template <typename Exact>
+ bool
+ point_set_std_based_<Exact>::impl_has(const typename point_set_std_based_<Exact>::point& p) const
+ {
+ return std::find(this->con_.begin(), this->con_.end(), p) != this->con_.end();
+ }
+
+ template <typename Exact>
+ const typename point_set_std_based_<Exact>::box&
+ point_set_std_based_<Exact>::impl_bbox() const
+ {
+ precondition(this->fb_.is_valid());
+ return this->fb_.box();
+ }
+
+ template <typename Exact>
+ point_set_std_based_<Exact>::point_set_std_based_()
+ {
+ }
+
+ template <typename Exact>
+ void
+ point_set_std_based_<Exact>::take_(const typename point_set_std_based_<Exact>::point& p)
+ {
+ this->fb_.take(p);
+ }
+
+ template <typename Exact>
+ const typename point_set_std_based_<Exact>::std_container&
+ point_set_std_based_<Exact>::con() const
+ {
+ this->con_;
+ }
+
+# endif
+
+ } // end of namespace oln::internal
- }; // end of class fwd_piter_on_std_based_pset<C>
- // Bkd_piter version.
- // ------------------
+ // -------------------- iterators on classes deriving from internal::point_set_std_based_<Exact>
- // Forward declaration.
- template <typename C> class bkd_piter_on_std_based_pset;
+ // Super types.
- // Super.
template <typename C>
- struct set_super_type< bkd_piter_on_std_based_pset<C> >
+ struct super_trait_< pset_std_based_fwd_piter_<C> >
{
- typedef abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> > ret;
+ typedef pset_std_based_fwd_piter_<C> current__;
+ typedef Iterator_on_Points<current__> ret;
};
+ template <typename C>
+ struct super_trait_< pset_std_based_bkd_piter_<C> >
+ {
+ typedef pset_std_based_bkd_piter_<C> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+
+ /// Virtual types.
- // Vtypes.
template <typename C>
- struct vtypes< bkd_piter_on_std_based_pset<C> >
+ struct vtypes< pset_std_based_fwd_piter_<C> >
{
- typedef typename C::value_type point_type;
+ typedef typename C::value_type point;
};
+ template <typename C>
+ struct vtypes< pset_std_based_bkd_piter_<C> >
+ {
+ typedef typename C::value_type point;
+ };
+
+
+ // Class pset_std_based_fwd_piter_<C>.
- // Class.
template <typename C>
- class bkd_piter_on_std_based_pset :
+ class pset_std_based_fwd_piter_ : public Iterator_on_Points< pset_std_based_fwd_piter_<C> >
+ {
+ typedef pset_std_based_fwd_piter_<C> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ template <typename Ps>
+ pset_std_based_fwd_piter_(const internal::point_set_std_based_<Ps>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+
+ const C& con_;
+ typename C::const_iterator it_;
+
+ }; // end of class pset_std_based_fwd_piter_<C>
+
+
+ // Class pset_std_based_bkd_piter_<C>.
- public abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> >,
- private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ template <typename C>
+ class pset_std_based_bkd_piter_ : public Iterator_on_Points< pset_std_based_bkd_piter_<C> >
{
+ typedef pset_std_based_bkd_piter_<C> current;
+ typedef Iterator_on_Points<current> super;
public:
- bkd_piter_on_std_based_pset(const C& container);
- template <typename point_set>
- bkd_piter_on_std_based_pset(const point_set& ps);
+ stc_using(point);
+
+ template <typename Ps>
+ pset_std_based_bkd_piter_(const internal::point_set_std_based_<Ps>& pts);
void impl_start();
void impl_next();
void impl_invalidate();
bool impl_is_valid() const;
- typename C::value_type impl_to_point() const;
- const typename C::value_type* impl_point_adr() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
private:
- const C& container_;
+ const C& con_;
typename C::const_reverse_iterator it_;
- }; // end of class bkd_piter_on_std_based_pset<C>
-
+ }; // end of class pset_std_based_bkd_piter_<C>
# ifndef OLN_INCLUDE_ONLY
- // fwd_piter_on_std_based_pset<C>
+ // -------------------- pset_std_based_fwd_piter_<C>
- template <typename C>
- fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const C& container)
- : container_(container)
- {
- this->invalidate();
- }
template <typename C>
- template <typename point_set>
- fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const point_set& ps)
- : container_(ps.exact().container())
+ template <typename Ps>
+ pset_std_based_fwd_piter_<C>::pset_std_based_fwd_piter_(const internal::point_set_std_based_<Ps>& pts)
+ : con_(pts.con())
{
- this->invalidate();
+ this->it_ = this->con_.end();
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_start()
+ void pset_std_based_fwd_piter_<C>::impl_start()
{
- it_ = container_.begin();
+ this->it_ = this->con_.begin();
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_next()
+ void pset_std_based_fwd_piter_<C>::impl_next()
{
- ++it_;
+ ++this->it_;
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_invalidate()
+ void pset_std_based_fwd_piter_<C>::impl_invalidate()
{
- it_ = container_.end();
+ this->it_ = this->con_.end();
}
template <typename C>
- bool fwd_piter_on_std_based_pset<C>::impl_is_valid() const
+ bool pset_std_based_fwd_piter_<C>::impl_is_valid() const
{
- return it_ != container_.end();
+ return this->it_ != this->con_.end();
}
template <typename C>
- typename C::value_type
- fwd_piter_on_std_based_pset<C>::impl_to_point() const
+ typename pset_std_based_fwd_piter_<C>::point
+ pset_std_based_fwd_piter_<C>::impl_to_point() const
{
- return *it_;
+ return *this->it_;
}
template <typename C>
- const typename C::value_type*
- fwd_piter_on_std_based_pset<C>::impl_point_adr() const
+ const typename pset_std_based_fwd_piter_<C>::point*
+ pset_std_based_fwd_piter_<C>::impl_point_adr() const
{
- return 0;
- // FIXME: Read below.
- // "&(*it_)" is not correct because the std does not ensure that
- // "*it_" is dereferenceable (Cf. std trivial iterator concept).
- // However, "::point_adr()" is only required so that an iterator
- // based on another iterator (e.g., a niter constructed from a
- // piter) can stick to the point location of the latter. This
- // is not required for iterators on point set so this method should
- // be optional.
+ return &(*(this->it_));
+ // FIXME: "&(*it_)" is not always correct because the std does not
+ // ensure that "*it_" is dereferenceable (Cf. std trivial iterator
+ // concept). However, "::point_adr()" is only required so that an
+ // iterator based on another iterator (e.g., a niter constructed
+ // from a piter) can stick to the point location of the latter.
+ // This is not required for iterators on point set so this method
+ // should be optional.
}
- // bkd_piter_on_std_based_pset<C>
-
+ // -------------------- pset_std_based_bkd_piter_<C>
- template <typename C>
- bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const C& container)
- : container_(container)
- {
- this->invalidate();
- }
template <typename C>
- template <typename point_set>
- bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const point_set& ps)
- : container_(ps.exact().container())
+ template <typename Ps>
+ pset_std_based_bkd_piter_<C>::pset_std_based_bkd_piter_(const internal::point_set_std_based_<Ps>& pts)
+ : con_(pts.con())
{
- this->invalidate();
+ this->it_ = this->con_.rend();
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_start()
+ void pset_std_based_bkd_piter_<C>::impl_start()
{
- it_ = container_.rbegin();
+ this->it_ = this->con_.rbegin();
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_next()
+ void pset_std_based_bkd_piter_<C>::impl_next()
{
- ++it_;
+ ++this->it_;
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_invalidate()
+ void pset_std_based_bkd_piter_<C>::impl_invalidate()
{
- it_ = container_.rend();
+ this->it_ = this->con_.rend();
}
template <typename C>
- bool bkd_piter_on_std_based_pset<C>::impl_is_valid() const
+ bool pset_std_based_bkd_piter_<C>::impl_is_valid() const
{
- return it_ != container_.rend();
+ return this->it_ != this->con_.rend();
}
template <typename C>
- typename C::value_type
- bkd_piter_on_std_based_pset<C>::impl_to_point() const
+ typename pset_std_based_bkd_piter_<C>::point
+ pset_std_based_bkd_piter_<C>::impl_to_point() const
{
- return *it_;
+ return *this->it_;
}
template <typename C>
- const typename C::value_type*
- bkd_piter_on_std_based_pset<C>::impl_point_adr() const
+ const typename pset_std_based_bkd_piter_<C>::point*
+ pset_std_based_bkd_piter_<C>::impl_point_adr() const
{
- return 0;
- // FIXME: Read comments in the fwd version of this method.
+ return &(*(this->it_));
+ // FIXME: Read comments in pset_std_based_fwd_piter_<C>.
}
@@ -275,4 +376,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+#endif // ! OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 843)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -25,74 +25,70 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_POINT_SET_ENTRY_HH
-# define OLN_CORE_POINT_SET_ENTRY_HH
+#ifndef OLN_CORE_INTERNAL_POINT_SET_BASE_HH
+# define OLN_CORE_INTERNAL_POINT_SET_BASE_HH
-# include <oln/core/abstract/entry.hh>
-# include <oln/core/abstract/point_set/all.hh>
+# include <oln/core/concept/point_set.hh>
namespace oln
{
- /// Fwd decl.
- template <typename E> struct point_set_entry;
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct point_set_base_; }
+ template <typename P> class box_;
- template <typename E>
- struct set_super_type< point_set_entry<E> >
+ /// Super type.
+ template <typename Exact>
+ struct super_trait_< internal::point_set_base_<Exact> >
{
- typedef mlc::none ret;
+ typedef Point_Set<Exact> ret;
};
- /// Virtual types associated to point_set_entry<E>.
-
- template <typename E>
- struct vtypes< point_set_entry<E> >
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point_set_base_<Exact> >
{
- typedef stc::abstract point_type;
-
- typedef stc::abstract fwd_piter_type;
- typedef stc::abstract bkd_piter_type;
-
- typedef mlc::none bbox_type;
- typedef stc::abstract is_random_accessible_type;
- typedef stc::abstract has_known_size_type;
- typedef stc::abstract is_connected_type;
-
- // final.
- typedef oln_deduce_vtype(E, point, coord) coord_type;
- typedef oln_deduce_vtype(E, point, grid) grid_type;
- typedef oln_deduce_vtype(E, point, dim) dim_type;
- typedef oln_fwd_piter(E) piter_type;
+ typedef stc::abstract point;
+ typedef stc::abstract fwd_piter;
+ typedef stc::abstract bkd_piter;
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(fwd_piter) fwd_piter__;
+
+ typedef stc::final< box_<point__> > box;
+ typedef stc::final<stc_type(point__, grid)> grid;
+ typedef stc::final<fwd_piter__> piter;
};
+ namespace internal
+ {
- /// Entry class for point sets: point_set_entry<E> is an alias for
- /// entry< abstract::point_set, E>.
+ /// Base class for point sets.
- template <typename E>
- struct point_set_entry : public entry< abstract::point_set, E>
+ template <typename Exact>
+ struct point_set_base_ : public Point_Set<Exact>
{
protected:
- point_set_entry();
+ point_set_base_();
};
-
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- point_set_entry<E>::point_set_entry()
+ template <typename Exact>
+ point_set_base_<Exact>::point_set_base_()
{
}
# endif
+ } // end of namespace oln::internal
} // end of namespace oln
-#endif // ! OLN_CORE_POINT_SET_ENTRY_HH
+#endif // ! OLN_CORE_INTERNAL_POINT_SET_BASE_HH
1
0