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
- 9625 discussions
2005-04-12 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/abstract/regular_niter.hh: Move to...
* oln/core/gen/regular_niter.hh: ...this.
* oln/core/2d/fwd_regular_niter2d.hh: Split into...
* oln/core/gen/regular_fwd_niter.hh: ...this.
* oln/core/2d/fwd_niter2d.hh: ...and this.
* oln/core/2d/fwd_qiter2d.hh: New file.
* oln/core/gen/regular_window.hh: New file.
* oln/core/gen/regular_fwd_qiter.hh: New file.
* oln/core/abstract/grid.hh: New file.
* oln/core/abstract/iter.hh: New file.
* oln/core/1d/grid1d.hh: New file.
* oln/core/1d/window1d.hh: New file.
* oln/core/2d/grid2d.hh: New file.
* oln/core/3d/grid3d.hh: New file.
* oln/core/3d/window3d.hh: New file.
* oln/convert/value_to_point.hh: Update:
* oln/basics1d.hh: Likewise.
* oln/core/typedefs.hh: Likewise.
* oln/core/abstract/niter.hh: Likewise.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/qiter.hh: Likewise.
* oln/core/abstract/image_neighbness.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
* oln/core/abstract/window.hh: Likewise.
* oln/core/abstract/internal/image_impl.hh: Likewise.
* oln/core/1d/dpoint1d.hh: Likewise.
* oln/core/1d/fwd_piter1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/fwd_piter2d.hh: Likewise.
* oln/core/2d/bkd_piter2d.hh: Likewise.
* oln/core/2d/window2d.hh: Likewise.
* oln/core/2d/neighborhood2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/accum.hh: Likewise.
* oln/core/pw/image.hh: Likewise.
* oln/core/pw/abstract/binary_function.hh: Likewise.
* oln/core/3d/dpoint3d.hh: Likewise.
* oln/core/3d/fwd_piter3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
* oln/basics2d.hh: Likewise.
* oln/basics3d.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/makefile.src: Likewise.
* oln/io/write_image_2d_pnm.hh: Likewise.
* oln/io/read_image_2d_pnm.hh: Likewise.
* oln/arith/ops.hh: Likewise.
* oln/arith/logic.hh: Likewise.
Index: oln/convert/value_to_point.hh
===================================================================
--- oln/convert/value_to_point.hh (revision 136)
+++ oln/convert/value_to_point.hh (working copy)
@@ -34,6 +34,7 @@
# include <oln/core/3d/point3d.hh>
// FIXME: waiting for a coherent convert.
+// FIXME: this is file is awful...
namespace oln {
Index: oln/basics1d.hh
===================================================================
--- oln/basics1d.hh (revision 136)
+++ oln/basics1d.hh (working copy)
@@ -28,6 +28,9 @@
#ifndef OLENA_BASICS1D_HH
# define OLENA_BASICS1D_HH
+# include <oln/basics.hh>
+
+# include <oln/core/1d/grid1d.hh>
# include <oln/core/1d/size1d.hh>
# include <oln/core/1d/point1d.hh>
# include <oln/core/1d/image1d.hh>
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 136)
+++ oln/core/typedefs.hh (working copy)
@@ -46,6 +46,8 @@
// category::image
+ mlc_decl_typedef(grid_type);
+
mlc_decl_typedef(data_type);
mlc_decl_typedef(value_type);
mlc_decl_typedef(neighb_type);
@@ -56,14 +58,14 @@
mlc_decl_typedef(image_type);
mlc_decl_typedef(concrete_type);
+ mlc_decl_typedef(iter_type);
mlc_decl_typedef(piter_type);
mlc_decl_typedef(fwd_piter_type);
mlc_decl_typedef(bkd_piter_type);
- mlc_decl_typedef(iter_type);
+ mlc_decl_typedef(fwd_niter_type);
mlc_decl_typedef(delegated_type);
mlc_decl_typedef(size_type);
- mlc_decl_typedef(se_type);
mlc_decl_typedef(window_type);
mlc_decl_typedef(image_neighbness_type);
@@ -83,25 +85,13 @@
mlc_decl_typedef(fwd_qiter_type);
mlc_decl_typedef(bkd_qiter_type);
+ // category::grid
+ mlc_decl_typedef(dimvalue_type);
+ mlc_decl_typedef(coord_type);
+
} // end of namespace oln
-
-// FIXME: memo...
-
-// namespace category
-// {
-// struct data_storage;
-// struct struct_elt;
-// struct neighborhood;
-// struct point;
-// struct size;
-// struct piter;
-// struct niter;
-// // FIXME: ...
-// }
-
-
#endif // ! OLENA_CORE_TYPEDEFS_HH
Index: oln/core/abstract/niter.hh
===================================================================
--- oln/core/abstract/niter.hh (revision 136)
+++ oln/core/abstract/niter.hh (working copy)
@@ -28,37 +28,20 @@
#ifndef OLENA_CORE_ABSTRACT_NITER_HH
# define OLENA_CORE_ABSTRACT_NITER_HH
-# include <vector>
-
-# include <mlc/any.hh>
-# include <mlc/types.hh>
# include <mlc/contract.hh>
-
# include <oln/core/typedefs.hh>
-
-# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/core/abstract/iter.hh>
# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/abstract/image_neighbness.hh>
-# define for_all_n(n) \
- for(n.start(); n.is_valid(); n.next())
+# define for_all_n_of_p(n, p) \
+ for(n.ensure_is_niter(), n.center_at(p), n.start(); n.is_valid(); n.next())
# define for_all_remaining_n(n) \
- for(; n.is_valid(); n.next())
+ for(n.ensure_is_niter(); n.is_valid(); n.next())
-// FIXME : bad place
-# include <oln/core/abstract/piter.hh>
-
-# define for_all_n_of_p(p, n) \
- for(p.start(); p.is_valid(); p.next()) \
- for(n.center_at(p), n.start(); n.is_valid(); n.next())
-
-
-
# define oln_nit_type_of(NiterType, Alias) \
mlc_type_of(oln, oln::category::niter, NiterType, Alias)
@@ -84,15 +67,16 @@
template <typename N>
struct get_props < category::niter, N >
{
- typedef oln_nit_type_of(N, point) point_type;
+ typedef oln_nit_type_of(N, point) point_type;
typedef oln_nit_type_of(N, neighb) neighb_type;
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::niter, " << mlc_to_string(N) << " ) =" << std::endl
- << "\t point_type = " << mlc_to_string(point_type) << std::endl
+ << "{" << std::endl
+ << "\t point_type = " << mlc_to_string(point_type) << std::endl
<< "\t neighb_type = " << mlc_to_string(neighb_type) << std::endl
- << std::endl;
+ << "}" << std::endl;
}
};
@@ -101,28 +85,16 @@
namespace abstract {
template <typename E>
- struct niter : public mlc::any<E>
+ struct niter : public iter<E>
{
- /// typedefs
-
- typedef niter<E> self_type;
-
- typedef oln_nit_type_of(E, point) point_type;
+ typedef oln_nit_type_of(E, point) point_type;
typedef oln_nit_type_of(E, neighb) neighb_type;
- typedef oln_nit_type_of(E, image) image_type;
- void start()
+ void ensure_is_niter() const
{
- this->exact().impl_start();
}
- void next()
- {
- precondition(this->is_valid());
- this->exact().impl_next();
- }
-
operator point_type() const
{
precondition(this->is_valid());
@@ -131,29 +103,29 @@
void center_at(const point_type& p)
{
- this->exact().impl_center_at(p);
+ this->p_ = p;
}
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
+ protected:
- void invalidate()
+ niter(const neighb_type& ima) :
+ nbh_(nbh),
+ p_()
{
- this->exact().impl_invalidate();
}
- protected:
+ const neighb_type& nbh_;
+ point_type p_;
- template <typename I>
- niter(const abstract::image_with_nbh<I>& ima) :
- nbh_(ima.nbh_get())
+ ~niter()
{
+ { // impl_cast_point
+ typedef const point_type (E::*meth)() const;
+ meth adr = &E::impl_cast_point;
+ adr = 0;
+ }
}
- const neighb_type& nbh_;
- point_type p_;
};
} // end of namespace oln::abstract
Index: oln/core/abstract/piter.hh
===================================================================
--- oln/core/abstract/piter.hh (revision 136)
+++ oln/core/abstract/piter.hh (working copy)
@@ -32,16 +32,17 @@
# include <mlc/types.hh>
# include <mlc/contract.hh>
+# include <oln/core/abstract/iter.hh>
# include <oln/core/abstract/point.hh>
# include <oln/core/typedefs.hh>
-# define for_all(p) \
- for(p.start(); p.is_valid(); p.next())
+# define for_all_p( p ) \
+ for(p.ensure_is_piter(), p.start(); p.is_valid(); p.next())
-# define for_all_remaining(p) \
- for(; p.is_valid(); p.next())
+# define for_all_remaining_p( p ) \
+ for(p.ensure_is_piter(); p.is_valid(); p.next())
@@ -53,7 +54,6 @@
namespace oln {
-
namespace category
{
struct piter;
@@ -88,7 +88,7 @@
namespace abstract {
template <typename E>
- struct piter : public mlc::any<E>
+ struct piter : public iter<E>
{
/// typedefs
@@ -97,36 +97,15 @@
typedef oln_pit_type_of(E, size) size_type;
typedef oln_pit_type_of(E, point) point_type;
+
+ void ensure_is_piter() {}
-
- void start()
- {
- this->exact().impl_start();
- }
-
- void next()
- {
- precondition(this->is_valid());
- this->exact().impl_next();
- }
-
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
operator point_type() const
{
precondition(this->is_valid());
return this->p_;
}
- void invalidate()
- {
- this->exact().impl_invalidate();
- postcondition(! this->is_valid());
- }
-
protected:
piter(const size_type& s) :
@@ -139,8 +118,10 @@
point_type p_;
};
- }
-}
+ } // end of namespace oln::abstract
+} // end of namespace oln
+
+
#endif // ! OLENA_CORE_ABSTRACT_PITER_HH
Index: oln/core/abstract/qiter.hh
===================================================================
--- oln/core/abstract/qiter.hh (revision 136)
+++ oln/core/abstract/qiter.hh (working copy)
@@ -28,16 +28,23 @@
#ifndef OLENA_CORE_ABSTRACT_QITER_HH
# define OLENA_CORE_ABSTRACT_QITER_HH
-# include <mlc/any.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/typedefs.hh>
+# include <oln/core/abstract/iter.hh>
# include <oln/core/abstract/window.hh>
+# include <oln/core/typedefs.hh>
+# define for_all_q( q ) \
+ for(q.ensure_is_qiter(), q.start(); q.is_valid(); q.next())
+
+# define for_all_remaining_q( q ) \
+ for(q.ensure_is_piter(); q.is_valid(); q.next())
+
+
# define oln_qit_type_of(QiterType, Alias) \
mlc_type_of(oln, oln::category::qiter, QiterType, Alias)
+
namespace oln {
namespace category
@@ -73,79 +80,26 @@
namespace abstract {
template <typename E>
- struct qiter : public mlc::any__best_speed<E>
+ struct qiter : public iter<E>
{
- typedef qiter<E> self_type;
+ typedef oln_qit_type_of(E, window) window_type;
- typedef oln_qit_type_of(E, window) window_type;
- typedef oln_wn_type_of(window_type, dpoint) dpoint_type;
+ void ensure_is_qiter() {}
- void start()
- {
- this->exact().impl_start();
- }
-
- void next()
- {
- precondition(this->is_valid());
- this->exact().impl_next();
- }
-
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- operator dpoint_type() const
- {
- precondition(this->is_valid());
- return this->win_[pos_];
- }
-
- void invalidate()
- {
- this->exact().impl_invalidate();
- postcondition(! this->is_valid());
- }
-
- coord_t nth(unsigned i)
- {
- return this->win_[this->pos_].nth(i);
- }
-
protected:
- void impl_start()
+ qiter(const window_type& win) :
+ win_(win)
{
- pos_ = 0;
}
- void impl_next()
- {
- ++pos_;
- }
-
- bool impl_is_valid() const
- {
- return pos_ != win_.card();
- }
-
- void impl_invalidate()
- {
- pos_ = win_.card();
- }
-
- qiter(const window_type& se)
- : win_(se), pos_(0)
- {}
-
const window_type& win_;
- unsigned pos_;
};
- } // abstract
+ } // end of namespace oln::abstract
-} // oln
+} // end of namespace oln
+
#endif // ! OLENA_CORE_ABSTRACT_QITER_HH
Index: oln/core/abstract/grid.hh
===================================================================
--- oln/core/abstract/grid.hh (revision 0)
+++ oln/core/abstract/grid.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_GRID_HH
+# define OLENA_CORE_ABSTRACT_GRID_HH
+
+# include <mlc/any.hh>
+# include <oln/core/typedefs.hh>
+
+
+# define oln_grd_type_of(GridType, Alias) \
+mlc_type_of(oln, oln::category::grid, GridType, Alias)
+
+
+
+namespace oln {
+
+
+ namespace category
+ {
+ struct grid;
+ }
+
+
+ template <>
+ struct set_default_props < category::grid >
+ {
+ typedef mlc::undefined_type point_type;
+ typedef mlc::undefined_type dpoint_type;
+ typedef mlc::undefined_type coord_type;
+ typedef mlc::undefined_type dimvalue_type;
+ };
+
+
+ template <typename G>
+ struct get_props < category::grid, G >
+ {
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( oln::category::grid, " << mlc_to_string(G) << " ) =" << std::endl
+ << "{" << std::endl
+ << "\t point_type = " << mlc_to_string(point_type) << std::endl
+ << "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
+ << "\t coord_type = " << mlc_to_string(coord_type) << std::endl
+ << "\t dimvalue_type = " << mlc_to_string(dimvalue_type) << std::endl
+ << "}" << std::endl;
+ }
+ };
+
+
+ namespace abstract {
+
+ template <typename E>
+ struct grid : public mlc::any<E>
+ {
+ protected:
+ grid()
+ {}
+
+ };
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_GRID_HH
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 136)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -48,7 +48,7 @@
typedef oln_type_of(E, neighb) neighb_type;
- const neighb_type& nbh_get() const
+ const neighb_type& nbh_get() const // FIXME: rename (?)
{
return this->exact().impl_nbh_get();
}
Index: oln/core/abstract/point.hh
===================================================================
--- oln/core/abstract/point.hh (revision 136)
+++ oln/core/abstract/point.hh (working copy)
@@ -34,6 +34,7 @@
# include <oln/core/coord.hh>
# include <oln/core/typedefs.hh>
+# include <oln/core/abstract/grid.hh>
// fwd decl
@@ -43,7 +44,8 @@
-# define oln_point_type_from_2(P1, P2) typename mlc::if_< mlc::eq< P2, oln::any_point >, P1, P2 >::ret
+# define oln_point_type_from_2(P1, P2) \
+typename mlc::if_< mlc::eq< P2, oln::any_point >, P1, P2 >::ret
# define oln_pt_type_of(PointType, Alias) \
@@ -67,6 +69,7 @@
struct set_default_props < category::point >
{
typedef mlc::undefined_type dpoint_type;
+ typedef mlc::undefined_type grid_type;
};
@@ -74,12 +77,15 @@
struct get_props < category::point, P >
{
typedef oln_pt_type_of(P, dpoint) dpoint_type;
+ typedef oln_pt_type_of(P, grid) grid_type;
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::point, " << mlc_to_string(P) << " ) =" << std::endl
+ << "{" << std::endl
<< "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
- << std::endl;
+ << "\t grid_type = " << mlc_to_string(grid_type) << std::endl
+ << "}" << std::endl;
}
};
@@ -147,22 +153,58 @@
return this->exact().impl_minus(rhs);
}
- coord_t nth(unsigned i) const
+ typedef oln_pt_type_of(E, grid) grid_type;
+ typedef oln_grd_type_of(grid_type, dimvalue) dimvalue_type;
+ typedef oln_grd_type_of(grid_type, coord) coord_type;
+
+ const coord_type nth(unsigned i) const
{
- // FIXME: add precondition
+ precondition(i < dimvalue_type::val);
return this->exact().impl_nth(i);
}
+ coord_type& nth(unsigned i)
+ {
+ precondition(i < dimvalue_type::val);
+ return this->exact().impl_nth(i);
+ }
+
protected:
point() {}
- /*! \brief Cpy constructor (protected, empty).
- */
- point(const exact_type& pt) {}
+ ~point()
+ {
+ { // impl_eq
+ typedef bool (E::*meth)(const exact_type&) const;
+ meth adr = &E::impl_eq;
+ adr = 0;
+ }
+ { // impl_plus
+ typedef const exact_type (E::*meth)(const dpoint_type&) const;
+ meth adr = &E::impl_plus;
+ adr = 0;
+ }
+ { // impl_minus
+ typedef const dpoint_type (E::*meth)(const exact_type&) const;
+ meth adr = &E::impl_minus;
+ adr = 0;
+ }
+ { // impl_nth const
+ typedef const coord_type (E::*meth)(unsigned) const;
+ meth adr = &E::impl_nth;
+ adr = 0;
+ }
+ { // impl_nth
+ typedef coord_type& (E::*meth)(unsigned);
+ meth adr = &E::impl_nth;
+ adr = 0;
+ }
+ }
};
+
} // end of namespace abstract
} // end of namespace oln
Index: oln/core/abstract/dpoint.hh
===================================================================
--- oln/core/abstract/dpoint.hh (revision 136)
+++ oln/core/abstract/dpoint.hh (working copy)
@@ -68,12 +68,18 @@
return not this->operator==(rhs);
}
- coord_t nth(unsigned i) const
+ const coord_t nth(unsigned i) const
{
// FIXME: add precondition
return this->exact().impl_nth(i);
}
+ coord_t& nth(unsigned i)
+ {
+ // FIXME: add precondition
+ return this->exact().impl_nth(i);
+ }
+
protected:
dpoint() {}
Index: oln/core/abstract/regular_niter.hh
===================================================================
--- oln/core/abstract/regular_niter.hh (revision 136)
+++ oln/core/abstract/regular_niter.hh (working copy)
@@ -1,124 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
-# define OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
-
-# include <vector>
-
-# include <mlc/any.hh>
-# include <mlc/types.hh>
-# include <mlc/contract.hh>
-
-# include <oln/core/abstract/niter.hh>
-# include <oln/core/gen/image_with_nbh.hh>
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/abstract/image_neighbness.hh>
-
-
-namespace oln {
-
- // fwd decl
- namespace abstract {
- template <typename E> struct regular_niter;
- }
-
- // super type
- template <typename E>
- struct set_super_type < abstract::regular_niter<E> > { typedef abstract::niter<E> ret; };
-
-
- namespace abstract {
-
- template <typename E>
- struct regular_niter : public niter<E>
- {
- typedef oln_type_of(E, point) point_type;
- typedef oln_type_of(E, dpoint) dpoint_type;
-
- void impl_start()
- {
- dp_cur_ = dp_.begin();
- }
-
- void impl_next()
- {
- ++dp_cur_;
- }
-
- void impl_center_at(const point_type& pt)
- {
- this->p_ = pt;
- dp_.clear();
- this->exact().impl_determine_neighb();
- }
-
- bool impl_is_valid() const
- {
- return dp_cur_ != dp_.end();
- }
-
- const point_type impl_cast_point() const
- {
- return *dp_cur_ + this->p_;
- }
-
- void impl_invalidate()
- {
- dp_cur_ = dp_.end();
- postcondition(! this->is_valid());
- }
-
- protected:
-
- void impl_determine_neighb()
- {
- for (unsigned i = 0; i < this->nbh_.card(); ++i)
- dp_.push_back(this->nbh_[i]);
- }
-
- typedef niter<E> super_type;
-
- template <typename I>
- regular_niter(const abstract::image_with_nbh<I>& ima) :
- super_type(ima)
- {
- }
-
- std::vector<dpoint_type> dp_;
- typename std::vector<dpoint_type>::const_iterator dp_cur_;
- };
-
- } // end of namespace oln::abstract
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
Index: oln/core/abstract/iter.hh
===================================================================
--- oln/core/abstract/iter.hh (revision 0)
+++ oln/core/abstract/iter.hh (revision 0)
@@ -0,0 +1,112 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_ITER_HH
+# define OLENA_CORE_ABSTRACT_ITER_HH
+
+# include <mlc/any.hh>
+# include <mlc/contract.hh>
+
+# include <oln/core/typedefs.hh>
+
+
+
+# define for_all(i) \
+ for(i.start(); i.is_valid(); i.next())
+
+# define for_all_remaining(i) \
+ for(; i.is_valid(); i.next())
+
+
+
+
+namespace oln {
+
+ namespace abstract {
+
+ template <typename E>
+ struct iter : public mlc::any<E>
+ {
+
+ void start()
+ {
+ this->exact().impl_start();
+ }
+
+ void next()
+ {
+ precondition(this->is_valid());
+ this->exact().impl_next();
+ }
+
+ bool is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ void invalidate()
+ {
+ this->exact().impl_invalidate();
+ postcondition(! this->is_valid());
+ }
+
+ protected:
+
+ iter() {}
+
+ ~iter()
+ {
+ { // impl_start
+ typedef void (E::*meth)();
+ meth adr = &E::impl_start;
+ adr = 0;
+ }
+ { // impl_next
+ typedef void (E::*meth)();
+ meth adr = &E::impl_next;
+ adr = 0;
+ }
+ { // impl_is_valid
+ typedef bool (E::*meth)() const;
+ meth adr = &E::impl_is_valid;
+ adr = 0;
+ }
+ { // impl_invalidate
+ typedef void (E::*meth)();
+ meth adr = &E::impl_invalidate;
+ adr = 0;
+ }
+ }
+
+ };
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_ITER_HH
Index: oln/core/abstract/window.hh
===================================================================
--- oln/core/abstract/window.hh (revision 136)
+++ oln/core/abstract/window.hh (working copy)
@@ -88,149 +88,20 @@
** its subclasses. Its goal is to deal with a set of 'move'
** points.
*/
+
template<class W>
- class window : public mlc::any<W>
+ struct window : public mlc::any<W>
{
-
- public:
-
- typedef oln_wn_type_of(W, dpoint) dpoint_type;
-
- typedef W exact_type;
-
- static std::string
- name()
- {
- return std::string("window<") + exact_type::name() + ">";
- }
-
- bool
- has(const dpoint_type& dp) const
- {
- return this->exact().impl_has(dp.exact());
- }
-
- unsigned
- card() const
- {
- return this->exact().impl_card();
- }
-
- exact_type&
- add(const dpoint_type& dp)
- {
- return this->exact().impl_add(dp);
- }
-
- dpoint_type
- dp(unsigned i) const
- {
- return this->exact().impl_at(i);
- }
-
- const dpoint_type
- operator[](unsigned i) const
- {
- return this->exact().impl_at(i);
- }
-
- coord_t
- get_delta() const
- {
- return this->exact().impl_get_delta();
- }
-
- coord_t
- delta_update(const dpoint_type& dp)
- {
- return this->exact().impl_delta_update(dp);
- }
-
- exact_type
- operator-() const
- {
- exact_type se(this->exact());
-
- se.sym();
- return se;
- }
-
- void
- sym()
- {
- this->exact().impl_sym();
- }
-
protected:
+ window()
+ {}
+ };
- void
- impl_sym()
- {
- for (unsigned i = 0; i < this->card(); ++i)
- dp_[i] = - dp_[i];
- }
- bool
- impl_has(const dpoint_type& dp) const
- {
- return std::find(dp_.begin(), dp_.end(), dp) != dp_.end();
- }
+ } // end of namespace oln::abstract
- exact_type&
- impl_add(const dpoint_type& dp)
- {
- if (!(impl_has(dp)))
- this->dp_.push_back(dp);
- this->delta_update(dp);
- return this->exact();
- }
+} // end of namespace oln
- coord_t
- impl_get_delta() const
- {
- return delta_;
- }
- unsigned
- impl_card() const
- {
- return dp_.size();
- }
- const dpoint_type
- impl_at(unsigned i) const
- {
- precondition(i < this->card());
- return dp_[i];
- }
-
- window() : dp_(), delta_(0)
- {};
-
- window(unsigned size) : dp_(), delta_(0)
- {
- dp_.reserve(size);
- };
-
- std::vector<dpoint_type> dp_;
- max_accumulator<coord_t> delta_;
-
- };
- } // end of abstract
-
-} // end of oln
-
-template<class W>
-std::ostream&
-operator<<(std::ostream& o, const oln::abstract::window<W>& se)
-{
- unsigned c = se.card();
- o << "[";
- for (unsigned i = 0; i < c; ++i)
- o << se.dp(i);
- o << "]";
- return o;
-}
-
-
#endif // ! OLENA_CORE_ABSTRACT_WINDOW_HH
Index: oln/core/abstract/internal/image_impl.hh
===================================================================
--- oln/core/abstract/internal/image_impl.hh (revision 136)
+++ oln/core/abstract/internal/image_impl.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef PROTO_OLN_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
-# define PROTO_OLN_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
+#ifndef OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
+# define OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
# include <mlc/any.hh>
# include <mlc/types.hh>
@@ -79,4 +79,4 @@
} // end of namespace oln
-#endif // ndef PROTO_OLN_CORE_ABSTRACT_IMAGE_HH
+#endif // ! OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
Index: oln/core/1d/dpoint1d.hh
===================================================================
--- oln/core/1d/dpoint1d.hh (revision 136)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -29,7 +29,7 @@
# define OLENA_CORE_1D_DPOINT1D_HH
# include <iostream>
-
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/abstract/dpoint.hh>
@@ -96,14 +96,22 @@
const coord_t index() const { return index_; }
coord_t& index() { return index_; }
- coord_t impl_nth(unsigned i) const
+ friend class abstract::dpoint<dpoint1d>;
+
+ protected:
+
+ const coord_t impl_nth(unsigned i) const
{
- // FIXME: remove when add in abstract::point
precondition(i == 0);
return index_;
}
- protected:
+ coord_t& impl_nth(unsigned i)
+ {
+ precondition(i == 0);
+ return index_;
+ }
+
coord_t index_;
};
Index: oln/core/1d/fwd_piter1d.hh
===================================================================
--- oln/core/1d/fwd_piter1d.hh (revision 136)
+++ oln/core/1d/fwd_piter1d.hh (working copy)
@@ -56,16 +56,17 @@
struct fwd_piter1d : public abstract::piter< fwd_piter1d >
{
+ typedef fwd_piter1d self_type;
+ typedef abstract::piter<self_type> super_type;
- typedef abstract::piter<fwd_piter1d> super_type;
-
fwd_piter1d(const size1d& size) :
super_type(size)
{
this->invalidate();
}
- friend class abstract::piter< fwd_piter1d >;
+ friend class abstract::iter<self_type>;
+ friend class abstract::piter<self_type>;
protected:
Index: oln/core/1d/grid1d.hh
===================================================================
--- oln/core/1d/grid1d.hh (revision 0)
+++ oln/core/1d/grid1d.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_1D_GRID1D_HH
+# define OLENA_CORE_1D_GRID1D_HH
+
+# include <mlc/value.hh>
+# include <oln/core/abstract/grid.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ struct grid1d;
+ struct point1d;
+ struct dpoint1d;
+ struct coord_t;
+
+ // super type
+ template <>
+ struct set_super_type < grid1d > { typedef abstract::grid< grid1d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::grid, grid1d >
+ {
+ typedef point1d point_type;
+ typedef dpoint1d dpoint_type;
+ typedef coord_t coord_type;
+ typedef mlc::value<unsigned,1> dimvalue_type;
+ };
+
+
+
+ struct grid1d : public abstract::grid< grid1d >
+ {
+ protected:
+ grid1d()
+ {}
+ };
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_1D_GRID1D_HH
Index: oln/core/1d/window1d.hh
===================================================================
--- oln/core/1d/window1d.hh (revision 0)
+++ oln/core/1d/window1d.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_WINDOW1D_HH
+# define OLENA_CORE_WINDOW1D_HH
+
+# include <oln/core/gen/regular_window.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/1d/dpoint1d.hh>
+
+
+namespace oln {
+
+ typedef regular_window< grid1d > window1d;
+
+ // classical 1d windows
+
+ /*!
+ ** \brief Create a window (1 dimension) of 2 elements.
+ ** \return The new window.
+ */
+ inline const window1d&
+ win_c2_only()
+ {
+ static const coord_t crd[2 * 1] = { -1, 1 };
+ static const window1d win(2, crd);
+ return win;
+ }
+
+ /*!
+ ** \brief Create a window (1 dimension) of 3 elements.
+ ** \return The new window.
+ **
+ ** It's the same than win_c2_only() plus the (0) point.
+ */
+ inline const window1d&
+ win_c2p()
+ {
+ static const coord_t crd[3 * 1] = { -1, 0, 1 };
+ static const window1d win(3, crd);
+ return win;
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_WINDOW1D_HH
Index: oln/core/1d/point1d.hh
===================================================================
--- oln/core/1d/point1d.hh (revision 136)
+++ oln/core/1d/point1d.hh (working copy)
@@ -30,6 +30,7 @@
# include <iostream>
# include <oln/core/abstract/point.hh>
+# include <oln/core/1d/grid1d.hh>
# include <oln/core/coord.hh>
@@ -49,6 +50,7 @@
struct set_props < category::point, point1d >
{
typedef dpoint1d dpoint_type;
+ typedef grid1d grid_type;
};
@@ -94,13 +96,18 @@
return this->index_ == rhs.index_;
}
- coord_t impl_nth(unsigned i) const
+ const coord_t impl_nth(unsigned i) const
{
- // FIXME: remove when add in abstract::point
precondition(i == 0);
return index_;
}
+ coord_t& impl_nth(unsigned i)
+ {
+ precondition(i == 0);
+ return index_;
+ }
+
protected:
coord_t index_;
Index: oln/core/2d/dpoint2d.hh
===================================================================
--- oln/core/2d/dpoint2d.hh (revision 136)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_2D_DPOINT2D_HH
# include <iostream>
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/abstract/dpoint.hh>
@@ -97,32 +98,32 @@
const coord_t row() const { return row_; }
const coord_t col() const { return col_; }
- //FIXME : name it impl_nth when dpoint2d derives from abstract::dpoint
- const coord_t nth(unsigned i) const
+
+ coord_t& row() { return row_; }
+ coord_t& col() { return col_; }
+
+ friend class abstract::dpoint<dpoint2d>;
+
+ protected:
+
+ const coord_t impl_nth(unsigned i) const
{
- assert(i < 2);
-
+ precondition(i < 2);
if (i == 0)
return row_;
else
return col_;
}
-
- coord_t& row() { return row_; }
- coord_t& col() { return col_; }
-
coord_t& impl_nth(unsigned i)
{
- assert(i < 2);
-
+ precondition(i < 2);
if (i == 0)
return row_;
else
return col_;
}
- protected:
coord_t row_, col_;
};
Index: oln/core/2d/fwd_niter2d.hh
===================================================================
--- oln/core/2d/fwd_niter2d.hh (revision 135)
+++ oln/core/2d/fwd_niter2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2005 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,113 +25,22 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
-# define OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
+#ifndef OLENA_CORE_2D_FWD_NITER2D_HH
+# define OLENA_CORE_2D_FWD_NITER2D_HH
-# include <vector>
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/2d/point2d.hh>
+# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/neighborhood2d.hh>
-# include <mlc/any.hh>
-# include <mlc/types.hh>
-# include <mlc/contract.hh>
+# include <oln/core/gen/regular_fwd_niter.hh>
-# include <oln/core/abstract/niter.hh>
-# include <oln/core/gen/image_with_nbh.hh>
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/abstract/image_neighbness.hh>
-
namespace oln {
- // fwd decls
+ typedef regular_fwd_niter<grid2d> fwd_niter2d;
- namespace abstract {
- template <typename E> struct regular_niter;
- }
-
- // category
-
- template <typename E>
- struct set_category< abstract::regular_niter<E> > {
- typedef category::niter ret;
- };
-
- // super type
-
- template <typename E>
- struct set_super_type < abstract::regular_niter<E> >
- {
- typedef abstract::niter<E> ret;
- };
-
-
- namespace abstract {
-
- template <typename E>
- struct regular_niter : public niter<E>
- {
-
- /// typedefs
- typedef oln_type_of(E, point) point_type;
- typedef oln_type_of(E, dpoint) dpoint_type;
- typedef regular_niter<E> self_type;
-
- void impl_start()
- {
- dp_cur_ = dp_.begin();
- }
-
- void impl_next()
- {
- precondition(this->is_valid());
- dp_cur_ ++;
- }
-
- void impl_center_at(const point_type& pt)
- {
- this->p_ = pt;
- dp_.clear();
- this->exact().impl_determine_neighb();
- }
-
- bool impl_is_valid() const
- {
- return dp_cur_ != dp_.end();
- }
-
- const point_type impl_cast_point() const
- {
- precondition(this->is_valid());
- return *dp_cur_ + this->p_;
- }
-
- void impl_invalidate()
- {
- dp_cur_ = dp_.end();
- postcondition(! this->is_valid());
- }
-
- protected:
-
- void impl_determine_neighb()
- {
- for (unsigned i = 0; i < this->nbh_.card(); ++i)
- dp_.push_back(this->nbh_[i]);
- }
-
- template <typename T>
- regular_niter(const abstract::image_with_nbh<T>& ima) :
- niter<E>(ima)
- {
- }
-
- typename std::vector<dpoint_type>::iterator dp_cur_;
- std::vector<dpoint_type> dp_;
- };
- }
}
-#endif // ! OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
+#endif // ! OLENA_CORE_2D_FWD_NITER2D_HH
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 136)
+++ oln/core/2d/image2d.hh (working copy)
@@ -51,6 +51,7 @@
// fwd decls
struct fwd_piter2d;
struct bkd_piter2d;
+ struct fwd_niter2d;
template <typename T> class image2d;
// super
@@ -74,6 +75,7 @@
typedef fwd_piter2d piter_type;
typedef fwd_piter2d fwd_piter_type;
typedef bkd_piter2d bkd_piter_type;
+ typedef fwd_niter2d fwd_niter_type;
// please note that value_storage_type means data_type
// since image2d is an image_with_data
Index: oln/core/2d/fwd_regular_niter2d.hh
===================================================================
--- oln/core/2d/fwd_regular_niter2d.hh (revision 136)
+++ oln/core/2d/fwd_regular_niter2d.hh (working copy)
@@ -1,137 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
-# define OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
-
-# include <vector>
-
-# include <mlc/any.hh>
-# include <mlc/types.hh>
-# include <mlc/contract.hh>
-
-# include <oln/core/abstract/niter.hh>
-# include <oln/core/gen/image_with_nbh.hh>
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/abstract/image_neighbness.hh>
-
-
-namespace oln {
-
- // fwd decls
-
- namespace abstract {
- template <typename E> struct regular_niter;
- }
-
- // category
-
- template <typename E>
- struct set_category< abstract::regular_niter<E> > {
- typedef category::niter ret;
- };
-
- // super type
-
- template <typename E>
- struct set_super_type < abstract::regular_niter<E> >
- {
- typedef abstract::niter<E> ret;
- };
-
-
- namespace abstract {
-
- template <typename E>
- struct regular_niter : public niter<E>
- {
-
- /// typedefs
- typedef oln_type_of(E, point) point_type;
- typedef oln_type_of(E, dpoint) dpoint_type;
- typedef regular_niter<E> self_type;
-
- void impl_start()
- {
- dp_cur_ = dp_.begin();
- }
-
- void impl_next()
- {
- precondition(this->is_valid());
- dp_cur_ ++;
- }
-
- void impl_center_at(const point_type& pt)
- {
- this->p_ = pt;
- dp_.clear();
- this->exact().impl_determine_neighb();
- }
-
- bool impl_is_valid() const
- {
- return dp_cur_ != dp_.end();
- }
-
- const point_type impl_cast_point() const
- {
- precondition(this->is_valid());
- return *dp_cur_ + this->p_;
- }
-
- void impl_invalidate()
- {
- dp_cur_ = dp_.end();
- postcondition(! this->is_valid());
- }
-
- protected:
-
- void impl_determine_neighb()
- {
- for (unsigned i = 0; i < this->nbh_.card(); ++i)
- dp_.push_back(this->nbh_[i]);
- }
-
- template <typename T>
- regular_niter(const abstract::image_with_nbh<T>& ima) :
- niter<E>(ima)
- {
- }
-
- typename std::vector<dpoint_type>::iterator dp_cur_;
- std::vector<dpoint_type> dp_;
- };
- }
-}
-
-
-#endif // ! OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
Index: oln/core/2d/fwd_piter2d.hh
===================================================================
--- oln/core/2d/fwd_piter2d.hh (revision 136)
+++ oln/core/2d/fwd_piter2d.hh (working copy)
@@ -55,16 +55,17 @@
struct fwd_piter2d : public abstract::piter< fwd_piter2d >
{
+ typedef fwd_piter2d self_type;
+ typedef abstract::piter<self_type> super_type;
- typedef abstract::piter<fwd_piter2d> super_type;
-
fwd_piter2d(const size2d& size) :
super_type(size)
{
this->invalidate();
}
- friend class abstract::piter< fwd_piter2d >;
+ friend class abstract::iter<self_type>;
+ friend class abstract::piter<self_type>;
protected:
Index: oln/core/2d/bkd_piter2d.hh
===================================================================
--- oln/core/2d/bkd_piter2d.hh (revision 136)
+++ oln/core/2d/bkd_piter2d.hh (working copy)
@@ -55,7 +55,7 @@
struct bkd_piter2d : public abstract::piter< bkd_piter2d >
{
-
+ typedef bkd_piter2d self_type;
typedef abstract::piter< bkd_piter2d > super_type;
bkd_piter2d(const size2d& size) :
@@ -64,9 +64,10 @@
this->invalidate();
}
- friend class abstract::piter< bkd_piter2d >; // FIXME: replace by super_type (?)
+// friend class abstract::iter<self_type>;
+// friend class abstract::piter<self_type>;
- protected:
+// protected:
void impl_start()
{
Index: oln/core/2d/fwd_qiter2d.hh
===================================================================
--- oln/core/2d/fwd_qiter2d.hh (revision 136)
+++ oln/core/2d/fwd_qiter2d.hh (working copy)
@@ -1,105 +0,0 @@
-// Copyright (C) 2001, 2003, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_FWD_QITER2D_HH
-# define OLENA_CORE_FWD_QITER2D_HH
-
-# include <string>
-
-# include <oln/core/abstract/qiter.hh>
-# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/window2d.hh>
-
-
-namespace oln {
-
- // fwd decl
- struct fwd_qiter2d;
-
- // category
- template <>
- struct set_super_type< fwd_qiter2d > { typedef abstract::qiter< fwd_qiter2d > ret; };
-
- // props
- template <>
- struct set_props < category::qiter, fwd_qiter2d >
- {
- typedef dpoint2d dpoint_type; // FIXME: !!!
- typedef window2d window_type; // FIXME: !!!
- };
-
-
- struct fwd_qiter2d : public abstract::qiter< fwd_qiter2d >
- {
- typedef abstract::qiter<fwd_qiter2d> super_type;
-
- fwd_qiter2d(const window2d& se) :
- se_(se),
- pos_(0)
- {
- this->invalidate();
- }
-
- coord_t impl_nth(unsigned i)
- {
- return se_[pos_].nth(i);
- }
-
- dpoint2d impl_cast_dpoint() const
- {
- precondition(this->is_valid());
- return se_[pos_];
- }
-
- void impl_start()
- {
- pos_ = 0;
- }
-
- void impl_next()
- {
- ++pos_;
- }
-
- bool impl_is_valid() const
- {
- return pos_ != se_.card();
- }
-
- void impl_invalidate()
- {
- pos_ = se_.card();
- }
-
- const window2d& se_;
- unsigned pos_;
-
- };
-
-} // end of namespace oln
-
-#endif // OLENA_CORE_FWD_QITER2D_HH
Index: oln/core/2d/grid2d.hh
===================================================================
--- oln/core/2d/grid2d.hh (revision 0)
+++ oln/core/2d/grid2d.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_2D_GRID2D_HH
+# define OLENA_CORE_2D_GRID2D_HH
+
+# include <mlc/value.hh>
+# include <oln/core/abstract/grid.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ struct grid2d;
+ struct point2d;
+ struct dpoint2d;
+ struct coord_t;
+
+ // super type
+ template <>
+ struct set_super_type < grid2d > { typedef abstract::grid< grid2d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::grid, grid2d >
+ {
+ typedef point2d point_type;
+ typedef dpoint2d dpoint_type;
+ typedef coord_t coord_type;
+ typedef mlc::value<unsigned,2> dimvalue_type;
+ };
+
+
+
+ struct grid2d : public abstract::grid< grid2d >
+ {
+ protected:
+ grid2d()
+ {}
+ };
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_2D_GRID2D_HH
Index: oln/core/2d/window2d.hh
===================================================================
--- oln/core/2d/window2d.hh (revision 136)
+++ oln/core/2d/window2d.hh (working copy)
@@ -28,96 +28,18 @@
#ifndef OLENA_CORE_WINDOW2D_HH
# define OLENA_CORE_WINDOW2D_HH
-# include <oln/core/abstract/window.hh>
+# include <oln/core/gen/regular_window.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/size2d.hh>
-# include <oln/core/coord.hh>
+# include <oln/core/2d/grid2d.hh>
-namespace oln {
+namespace oln
+{
- // fwd decls
- class window2d;
- class fwd_qiter2d;
+ typedef regular_window< grid2d > window2d;
- // super_type
- template <> struct set_super_type< window2d > { typedef abstract::window< window2d > ret; };
+ // classical 2d windows
- // props
- template <>
- struct set_props< category::window, window2d >
- {
- typedef dpoint2d dpoint_type;
- typedef size2d size_type;
- typedef fwd_qiter2d fwd_qiter_type;
- };
-
-
- class window2d : public abstract::window< window2d >
- {
-
- public:
-
- typedef abstract::window< window2d > super_type;
-
- /*!
- ** \brief Construct a window of 2 dimensions.
- */
- window2d() : super_type()
- {}
-
- /*!
- ** \brief Construct a window of 2 dimensions.
- ** \arg size The number of element.
- */
- window2d(unsigned size) : super_type(size)
- {}
-
- /*!
- ** \brief Construct a window of 2 dimensions from several points.
- ** \arg n The number of element.
- ** \arg crd The coordinates of the elements
- */
- window2d(unsigned n, const coord_t crd[]) : super_type(n)
- {
- for (unsigned i = 0; i < 2 * n; i += 2)
- this->add(dpoint_type(crd[i], crd[i+1]));
- }
-
- window2d&
- add(const dpoint_type& dp)
- {
- return this->exact().impl_add(dp);
- }
-
- window2d&
- add(coord_t row, coord_t col)
- {
- dpoint_type dp(row, col);
- return add(dp);
- }
-
-
- /// Return the name of the type.
- static std::string
- name()
- {
- return std::string("window2d");
- }
-
- coord_t
- impl_delta_update(const dpoint_type& dp)
- {
- delta_(abs(dp.row()));
- delta_(abs(dp.col()));
- return delta_;
- }
-
- };
-
-
- // std win
-
/*!
** \brief Create a window (2 dimensions) of 4 elements.
** \return The new window.
@@ -170,6 +92,7 @@
return win;
}
-} // end of oln
+} // end of namespace oln
-#endif // OLENA_CORE_WINDOW2D_HH
+
+#endif // ! OLENA_CORE_WINDOW2D_HH
Index: oln/core/2d/neighborhood2d.hh
===================================================================
--- oln/core/2d/neighborhood2d.hh (revision 136)
+++ oln/core/2d/neighborhood2d.hh (working copy)
@@ -101,14 +101,6 @@
return add(dp);
}
-
- /// Return the name of the type.
- static std::string
- name()
- {
- return std::string("neighborhood2d");
- }
-
coord_t
impl_delta_update(const dpoint2d& dp)
{
Index: oln/core/2d/point2d.hh
===================================================================
--- oln/core/2d/point2d.hh (revision 136)
+++ oln/core/2d/point2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <iostream>
# include <oln/core/abstract/point.hh>
+# include <oln/core/2d/grid2d.hh>
# include <oln/core/coord.hh>
@@ -51,6 +52,7 @@
struct set_props < category::point, point2d >
{
typedef dpoint2d dpoint_type;
+ typedef grid2d grid_type;
};
@@ -102,15 +104,19 @@
return this->row_ == rhs.row_ && this->col_ == rhs.col_;
}
- coord_t impl_nth(unsigned i) const
+ const coord_t impl_nth(unsigned i) const
{
- // FIXME: remove when add in abstract::point
precondition(i < 2);
// FIXME: replace by meta-prog when a meta-vec is attribute
return i == 0 ? row_ : col_;
}
- protected:
+ coord_t& impl_nth(unsigned i)
+ {
+ precondition(i < 2);
+ // FIXME: replace by meta-prog when a meta-vec is attribute
+ return i == 0 ? row_ : col_;
+ }
coord_t row_, col_;
};
Index: oln/core/accum.hh
===================================================================
--- oln/core/accum.hh (revision 136)
+++ oln/core/accum.hh (working copy)
@@ -37,6 +37,10 @@
** max_accumulator as a T instance.
*/
+
+// FIXME: no namespace !!!
+// FIXME: move this file !!!
+
template <class T>
struct max_accumulator
{
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 136)
+++ oln/core/pw/image.hh (working copy)
@@ -196,10 +196,10 @@
};
- /// Routine for_all_p.
+ /// Routine image_for_all_p.
template <typename F>
- image_from_pw<F> for_all_p(const pw::abstract::function<F>& fun)
+ image_from_pw<F> image_for_all_p(const pw::abstract::function<F>& fun)
{
image_from_pw<F> tmp(fun);
return tmp;
@@ -208,15 +208,15 @@
// FIXME: below, produce an error instead of correcting the client code (?)
- /// Specialization of for_all_p (so that "for_all_p(p_value(ima)) == ima").
+ /// Specialization of image_for_all_p (so that "image_for_all_p(p_value(ima)) == ima").
template <typename I>
- const I& for_all_p(const pw::image<I>& pv)
+ const I& image_for_all_p(const pw::image<I>& pv)
{
return pv.ima.unbox();
}
- /// Specialization of p_value (so that "p_value(for_all_p(fun)) == fun").
+ /// Specialization of p_value (so that "p_value(image_for_all_p(fun)) == fun").
template <typename F>
F p_value(const image_from_pw<F>& ima)
@@ -249,7 +249,7 @@
bool check(const pw::abstract::function<F>& pred)
{
mlc::eq< oln_typeness_of(oln_pw_type_of(F, value)), typeness::binary_tag >::ensure();
- return oln::check(for_all_p(pred));
+ return oln::check(image_for_all_p(pred));
}
} // end of namespace oln::pw
@@ -257,20 +257,20 @@
- /// Specialization of for_all_p that gives a compile-time error.
+ /// Specialization of image_for_all_p that gives a compile-time error.
template <typename I>
- void for_all_p(const abstract::image<I>&)
+ void image_for_all_p(const abstract::image<I>&)
{
- struct OLENA_ERROR__arg_of__for_all_p__should_not_be_an_image();
+ struct OLENA_ERROR__arg_of__image_for_all_p__should_not_be_an_image();
}
- /// Specialization of for_all_p that gives a compile-time error.
+ /// Specialization of image_for_all_p that gives a compile-time error.
template <typename P>
- void for_all_p(const abstract::point<P>&)
+ void image_for_all_p(const abstract::point<P>&)
{
- struct OLENA_ERROR__arg_of__for_all_p__should_not_be_a_point();
+ struct OLENA_ERROR__arg_of__image_for_all_p__should_not_be_a_point();
}
Index: oln/core/pw/abstract/binary_function.hh
===================================================================
--- oln/core/pw/abstract/binary_function.hh (revision 136)
+++ oln/core/pw/abstract/binary_function.hh (working copy)
@@ -121,9 +121,8 @@
{
}
- typedef abstract::binary_function<L, R, E> self_type;
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, size) size_type;
+ typedef oln_pw_type_of(E, point) point_type;
+ typedef oln_pw_type_of(E, size) size_type;
typedef internal::binary_function_helper<oln_pw_type_of(L, size),
oln_pw_type_of(R, size) > _helper_type;
Index: oln/core/3d/dpoint3d.hh
===================================================================
--- oln/core/3d/dpoint3d.hh (revision 136)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_3D_DPOINT3D_HH
# include <iostream>
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/abstract/dpoint.hh>
@@ -99,9 +100,12 @@
coord_t& col() { return col_; }
coord_t& slice() { return slice_; }
- coord_t impl_nth(unsigned i) const
+ friend class abstract::dpoint<dpoint3d>;
+
+ protected:
+
+ const coord_t impl_nth(unsigned i) const
{
- // FIXME: remove when add in abstract::point
precondition(i < 3);
// FIXME: replace by meta-prog when a meta-vec is attribute
switch (i) {
@@ -116,7 +120,23 @@
return 0;
}
- protected:
+ coord_t& impl_nth(unsigned i)
+ {
+ static coord_t dummy = coord_t();
+ precondition(i < 3);
+ // FIXME: replace by meta-prog when a meta-vec is attribute
+ switch (i) {
+ case 0:
+ return slice_;
+ case 1:
+ return row_;
+ case 2:
+ return col_;
+ }
+ postcondition(0);
+ return dummy;
+ }
+
coord_t slice_, row_, col_;
};
Index: oln/core/3d/fwd_piter3d.hh
===================================================================
--- oln/core/3d/fwd_piter3d.hh (revision 136)
+++ oln/core/3d/fwd_piter3d.hh (working copy)
@@ -52,16 +52,17 @@
struct fwd_piter3d : public abstract::piter< fwd_piter3d >
{
+ typedef fwd_piter3d self_type;
+ typedef abstract::piter<self_type> super_type;
- typedef abstract::piter< fwd_piter3d > super_type;
-
fwd_piter3d(const size3d& size) :
super_type(size)
{
this->invalidate();
}
- friend class abstract::piter< fwd_piter3d >;
+ friend class abstract::iter<self_type>;
+ friend class abstract::piter<self_type>;
protected:
Index: oln/core/3d/grid3d.hh
===================================================================
--- oln/core/3d/grid3d.hh (revision 0)
+++ oln/core/3d/grid3d.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_3D_GRID3D_HH
+# define OLENA_CORE_3D_GRID3D_HH
+
+# include <mlc/value.hh>
+# include <oln/core/abstract/grid.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ struct grid3d;
+ struct point3d;
+ struct dpoint3d;
+ struct coord_t;
+
+ // super type
+ template <>
+ struct set_super_type < grid3d > { typedef abstract::grid< grid3d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::grid, grid3d >
+ {
+ typedef point3d point_type;
+ typedef dpoint3d dpoint_type;
+ typedef coord_t coord_type;
+ typedef mlc::value<unsigned,2> dimvalue_type;
+ };
+
+
+
+ struct grid3d : public abstract::grid< grid3d >
+ {
+ protected:
+ grid3d()
+ {}
+ };
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_3D_GRID3D_HH
Index: oln/core/3d/window3d.hh
===================================================================
--- oln/core/3d/window3d.hh (revision 0)
+++ oln/core/3d/window3d.hh (revision 0)
@@ -0,0 +1,144 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_WINDOW3D_HH
+# define OLENA_CORE_WINDOW3D_HH
+
+# include <oln/core/gen/regular_window.hh>
+# include <oln/core/3d/dpoint3d.hh>
+# include <oln/core/3d/grid3d.hh>
+
+
+namespace oln {
+
+ typedef regular_window< grid3d > window3d;
+
+ // classical 3d windows
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 6 elements.
+ ** \return The new window.
+ */
+ inline const window3d&
+ win_c6_only()
+ {
+ static const coord_t crd[6 * 3] = { -1,0,0, 0,-1,0, 0,0,-1, 0,0,1, 0,1,0, 1,0,0 };
+ static const window3d win(6, crd);
+ return win;
+ }
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 7 elements.
+ ** \return The new window.
+ **
+ ** It's the same than win_c6_only() plus the (0,0,0) point.
+ */
+ inline const window3d&
+ win_c6p()
+ {
+ static const coord_t crd[7 * 3] = { -1,0,0, 0,-1,0, 0,0,-1, 0,0,0, 0,0,1, 0,1,0, 1,0,0 };
+ static const window3d win(7, crd);
+ return win;
+ }
+
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 18 elements.
+ ** \return The new window.
+ */
+ inline const window3d&
+ win_c18_only()
+ {
+ static const coord_t crd[18 * 3] =
+ {
+ -1,-1,0, -1,0,-1, -1,0,0, -1,0,1, -1,1,0,
+ 0,-1,-1, 0,-1,0, 0,-1,1, 0,0,-1, 0,0,1, 0,1,-1, 0,1,0, 0,1,1,
+ 1,-1,0, 1,0,-1, 1,0,0, 1,0,1, 1,1,0
+ };
+ static const window3d win(18, crd);
+ return win;
+ }
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 19 elements.
+ ** \return The new window.
+ **
+ ** It's the same than win_c18_only() plus the (0,0,0) point.
+ */
+ inline const window3d&
+ win_c18p()
+ {
+ static const coord_t crd[19 * 3] =
+ {
+ -1,-1,0, -1,0,-1, -1,0,0, -1,0,1, -1,1,0,
+ 0,-1,-1, 0,-1,0, 0,-1,1, 0,0,-1, 0,0,0, 0,0,1, 0,1,-1, 0,1,0, 0,1,1,
+ 1,-1,0, 1,0,-1, 1,0,0, 1,0,1, 1,1,0
+ };
+ static const window3d win(19, crd);
+ return win;
+ }
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 26 elements.
+ ** \return The new window.
+ */
+ inline const window3d&
+ win_c26_only()
+ {
+ static const coord_t crd[26 * 3] =
+ {
+ -1,-1,-1, -1,-1,0, -1,-1,1, -1,0,-1, -1,0,0, -1,0,1, -1,1,-1, -1,1,0, -1,1,1,
+ 0,-1,-1, 0,-1,0, 0,-1,1, 0,0,-1, 0,0,1, 0,1,-1, 0,1,0, 0,1,1,
+ 1,-1,-1, 1,-1,0, 1,-1,1, 1,0,-1, 1,0,0, 1,0,1, 1,1,-1, 1,1,0, 1,1,1
+ };
+ static const window3d win(26, crd);
+ return win;
+ }
+
+ /*!
+ ** \brief Create a window (3 dimensions) of 27 elements.
+ ** \return The new window.
+ **
+ ** It's the same than win_26_only() plus the (0,0,0) point.
+ */
+ inline const window3d&
+ win_c26p()
+ {
+ static const coord_t crd[27 * 3] =
+ {
+ -1,-1,-1, -1,-1,0, -1,-1,1, -1,0,-1, -1,0,0, -1,0,1, -1,1,-1, -1,1,0, -1,1,1,
+ 0,-1,-1, 0,-1,0, 0,-1,1, 0,0,-1, 0,0,0, 0,0,1, 0,1,-1, 0,1,0, 0,1,1,
+ 1,-1,-1, 1,-1,0, 1,-1,1, 1,0,-1, 1,0,0, 1,0,1, 1,1,-1, 1,1,0, 1,1,1
+ };
+ static const window3d win(27, crd);
+ return win;
+ }
+
+} // end of namespace oln
+
+
+#endif // OLENA_CORE_WINDOW3D_HH
Index: oln/core/3d/point3d.hh
===================================================================
--- oln/core/3d/point3d.hh (revision 136)
+++ oln/core/3d/point3d.hh (working copy)
@@ -31,8 +31,10 @@
# include <iostream>
# include <oln/core/abstract/point.hh>
+# include <oln/core/3d/grid3d.hh>
# include <oln/core/coord.hh>
+
namespace oln {
// fwd decls
@@ -48,6 +50,7 @@
struct set_props < category::point, point3d >
{
typedef dpoint3d dpoint_type;
+ typedef grid3d grid_type;
};
@@ -82,27 +85,49 @@
return *this;
}
+ const coord_t slice() const { return slice_; }
+ const coord_t row() const { return row_; }
+ const coord_t col() const { return col_; }
+
+ coord_t& slice() { return slice_; }
+ coord_t& row() { return row_; }
+ coord_t& col() { return col_; }
+
+ friend class abstract::point< point3d >;
+
+ protected:
+
bool impl_eq(const point3d& rhs) const
{
return this->slice_ == rhs.slice_ and
this->row_ == rhs.row_ and
this->col_ == rhs.col_;
}
+
const point3d impl_plus(const dpoint3d& rhs) const;
const dpoint3d impl_minus(const point3d& rhs) const;
- const coord_t slice() const { return slice_; }
- const coord_t row() const { return row_; }
- const coord_t col() const { return col_; }
+ const coord_t impl_nth(unsigned i) const
+ {
+ precondition(i < 3);
+ static coord_t dummy = coord_t();
+ // FIXME: replace by meta-prog when a meta-vec is attribute
+ switch (i) {
+ case 0:
+ return slice_;
+ case 1:
+ return row_;
+ case 2:
+ return col_;
+ }
+ postcondition(0);
+ return dummy;
+ }
- coord_t& slice() { return slice_; }
- coord_t& row() { return row_; }
- coord_t& col() { return col_; }
-
- coord_t impl_nth(unsigned i) const
+ coord_t& impl_nth(unsigned i)
{
- // FIXME: remove when add in abstract::point
precondition(i < 3);
+ static coord_t dummy = coord_t();
// FIXME: replace by meta-prog when a meta-vec is attribute
switch (i) {
case 0:
@@ -113,10 +138,9 @@
return col_;
}
postcondition(0);
- return 0;
+ return dummy;
}
- protected:
coord_t slice_, row_, col_;
};
Index: oln/core/gen/regular_niter.hh
===================================================================
--- oln/core/gen/regular_niter.hh (revision 0)
+++ oln/core/gen/regular_niter.hh (revision 0)
@@ -0,0 +1,98 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_GEN_REGULAR_NITER_HH
+# define OLENA_CORE_GEN_REGULAR_NITER_HH
+
+# include <vector>
+
+# include <mlc/contract.hh>
+# include <oln/core/abstract/niter.hh>
+# include <oln/core/abstract/grid.hh>
+# include <oln/core/abstract/point.hh>
+# include <oln/core/abstract/dpoint.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ namespace abstract {
+ template <typename G, typename E> struct regular_niter;
+ }
+
+ // super type
+ template <typename G, typename E>
+ struct set_super_type < abstract::regular_niter<G,E> > { typedef abstract::niter<E> ret; };
+
+ // props
+ template <typename G, typename E>
+ struct set_props < category::niter, abstract::regular_niter<G,E> >
+ {
+ typedef G grid_type;
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+
+ // FIXME: uncomment when class exists
+// typedef regular_neighborhood<G> neighb_type;
+ };
+
+
+
+ namespace abstract {
+
+ template <typename G, typename E>
+ struct regular_niter : public niter<E>
+ {
+
+ /// typedefs
+ typedef niter<E> super_type;
+ typedef oln_nit_type_of(E, point) point_type;
+ typedef oln_nit_type_of(E, dpoint) dpoint_type;
+ typedef oln_nit_type_of(E, neighb) neighb_type;
+
+ const point_type impl_cast_point() const
+ {
+ precondition(this->is_valid());
+ return this->p_ + *(this->dp_cur_);
+ }
+
+ protected:
+
+ regular_niter(const neighb_type& nbh) :
+ super_type(nbh)
+ {
+ }
+
+ typename std::vector<dpoint_type>::const_iterator dp_cur_;
+ };
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_GEN_REGULAR_NITER_HH
Index: oln/core/gen/regular_fwd_niter.hh
===================================================================
--- oln/core/gen/regular_fwd_niter.hh (revision 0)
+++ oln/core/gen/regular_fwd_niter.hh (revision 0)
@@ -0,0 +1,98 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_GEN_REGULAR_FWD_NITER_HH
+# define OLENA_CORE_GEN_REGULAR_FWD_NITER_HH
+
+# include <oln/core/gen/regular_niter.hh>
+
+# include <oln/core/2d/neighborhood2d.hh>
+# include <oln/core/gen/image_with_nbh.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ template <typename G> struct regular_fwd_niter;
+
+ // super type
+ template <typename G>
+ struct set_super_type < regular_fwd_niter<G> > { typedef abstract::regular_niter< G, regular_fwd_niter<G> > ret; };
+
+ // props
+ template <typename G>
+ struct set_props < category::niter, regular_fwd_niter<G> >
+ {
+ typedef neighborhood2d neighb_type; // FIXME: see FIXME in regular_niter
+ };
+
+
+ template <typename G>
+ struct regular_fwd_niter : public abstract::regular_niter< G, regular_fwd_niter<G> >
+ {
+ typedef regular_fwd_niter<G> self_type;
+ typedef abstract::regular_niter< G, self_type > super_type;
+
+ template <typename I>
+ regular_fwd_niter(const abstract::image_with_nbh<I>& image) :
+ super_type(image.nbh_get())
+ {
+ }
+
+ friend class abstract::iter<self_type>;
+
+ protected:
+
+ void impl_start()
+ {
+ this->dp_cur_ = this->dp_.begin();
+ }
+
+ void impl_next()
+ {
+ precondition(this->is_valid());
+ ++(this->dp_cur_);
+ }
+
+ bool impl_is_valid() const
+ {
+ return this->dp_cur_ != this->dp_.end();
+ }
+
+ void impl_invalidate()
+ {
+ this->dp_cur_ = this->dp_.end();
+ postcondition(! this->is_valid());
+ }
+
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_GEN_REGULAR_FWD_NITER_HH
Index: oln/core/gen/regular_fwd_qiter.hh
===================================================================
--- oln/core/gen/regular_fwd_qiter.hh (revision 135)
+++ oln/core/gen/regular_fwd_qiter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2005 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,81 +25,93 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_FWD_QITER2D_HH
-# define OLENA_CORE_FWD_QITER2D_HH
+#ifndef OLENA_CORE_REGULAR_FWD_QITER_HH
+# define OLENA_CORE_REGULAR_FWD_QITER_HH
-# include <string>
-
+# include <oln/core/abstract/grid.hh>
# include <oln/core/abstract/qiter.hh>
-# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/window2d.hh>
+# include <oln/core/gen/regular_window.hh>
namespace oln {
// fwd decl
- struct fwd_qiter2d;
+ template <typename G>
+ struct regular_fwd_qiter;
// category
- template <>
- struct set_super_type< fwd_qiter2d > { typedef abstract::qiter< fwd_qiter2d > ret; };
+ template <typename G>
+ struct set_super_type< regular_fwd_qiter<G> > { typedef abstract::qiter< regular_fwd_qiter<G> > ret; };
// props
- template <>
- struct set_props < category::qiter, fwd_qiter2d >
+ template <typename G>
+ struct set_props < category::qiter, regular_fwd_qiter<G> >
{
- typedef dpoint2d dpoint_type; // FIXME: !!!
- typedef window2d window_type; // FIXME: !!!
+ typedef regular_window<G> window_type;
};
- struct fwd_qiter2d : public abstract::qiter< fwd_qiter2d >
+ template <typename G>
+ struct regular_fwd_qiter : public abstract::qiter< regular_fwd_qiter<G> >
{
- typedef abstract::qiter<fwd_qiter2d> super_type;
+ typedef regular_fwd_qiter<G> self_type;
+ typedef abstract::qiter<self_type> super_type;
- fwd_qiter2d(const window2d& se) :
- se_(se),
- pos_(0)
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+
+ regular_fwd_qiter(const regular_window<G>& win) :
+ super_type(win)
{
this->invalidate();
}
- coord_t impl_nth(unsigned i)
+ const coord_type nth(unsigned i) const
{
- return se_[pos_].nth(i);
+ return this->win_[this->pos_].nth(i);
}
- dpoint2d impl_cast_dpoint() const
+ coord_type& nth(unsigned i)
{
+ return this->win_[this->pos_].nth(i);
+ }
+
+ operator dpoint_type() const
+ {
precondition(this->is_valid());
- return se_[pos_];
+ return this->win_[this->pos_];
}
+ friend class abstract::iter<self_type>;
+ friend class abstract::qiter<self_type>;
+
+ protected:
+
void impl_start()
{
- pos_ = 0;
+ this->pos_ = 0;
}
void impl_next()
{
- ++pos_;
+ ++(this->pos_);
}
bool impl_is_valid() const
{
- return pos_ != se_.card();
+ return this->pos_ != this->win_.card();
}
void impl_invalidate()
{
- pos_ = se_.card();
+ this->pos_ = this->win_.card();
}
- const window2d& se_;
unsigned pos_;
};
} // end of namespace oln
-#endif // OLENA_CORE_FWD_QITER2D_HH
+
+#endif // OLENA_CORE_REGULAR_FWD_QITER_HH
Index: oln/core/gen/regular_window.hh
===================================================================
--- oln/core/gen/regular_window.hh (revision 0)
+++ oln/core/gen/regular_window.hh (revision 0)
@@ -0,0 +1,179 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_GEN_REGULAR_WINDOW_HH
+# define OLENA_CORE_GEN_REGULAR_WINDOW_HH
+
+# include <iostream>
+
+# include <mlc/contract.hh>
+# include <oln/core/abstract/window.hh>
+# include <oln/core/abstract/grid.hh>
+# include <oln/core/accum.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ template <typename G> class regular_window;
+ template <typename G> class regular_fwd_qiter;
+
+ // super_type
+ template <typename G> struct set_super_type< regular_window<G> > { typedef abstract::window< regular_window<G> > ret; };
+
+ // props
+ template <typename G>
+ struct set_props< category::window, regular_window<G> >
+ {
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef regular_fwd_qiter<G> fwd_qiter_type;
+// typedef regular_fwd_dpiter<G> fwd_dpiter_type; // FIXME: later...
+ };
+
+
+
+ template <typename G>
+ class regular_window : public abstract::window< regular_window<G> >
+ {
+
+ public:
+
+ typedef regular_window<G> self_type;
+ typedef oln_wn_type_of(self_type, dpoint) dpoint_type;
+
+ typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+ static const unsigned dim = dimvalue_type::val;
+
+ regular_window() :
+ dp_(),
+ delta_(0)
+ {
+ }
+
+ regular_window(unsigned n,
+ const oln_grd_type_of(G, coord) crd[]) :
+ dp_(),
+ delta_(0)
+ {
+ precondition(n != 0);
+ // FIXME: size of crd wrt n
+ for (unsigned i = 0; i < n; ++i)
+ {
+ dpoint_type dp;
+ for (unsigned c = 0; c < dim; ++c)
+ dp.nth(c) = crd[i * dim + c];
+ this->add(dp);
+ }
+ }
+
+ bool has(const dpoint_type& dp) const
+ {
+ return std::find(this->dp_.begin(), this->dp_.end(), dp) != dp_.end();
+ }
+
+ self_type& add(const dpoint_type& dp)
+ {
+ if (! this->has(dp))
+ this->dp_.push_back(dp);
+ this->delta_update(dp);
+ return *this;
+ }
+
+ coord_t delta_update(const dpoint_type& dp)
+ {
+ for (unsigned c = 0; c < dim; ++c)
+ this->delta_(abs(dp.nth(c)));
+ return this->delta_;
+ }
+
+ coord_t get_delta() const
+ {
+ return this->delta_;
+ }
+
+ unsigned card() const
+ {
+ return this->dp_.size();
+ }
+
+ const dpoint_type at(unsigned i) const
+ {
+ precondition(i < this->card());
+ return dp_[i];
+ }
+
+ // FIXME: redundant...
+ dpoint_type dp(unsigned i) const
+ {
+ return this->at(i);
+ }
+
+ // FIXME: redundant...
+ const dpoint_type operator[](unsigned i) const
+ {
+ return this->at(i);
+ }
+
+// const self_type operator-() const
+// {
+// self_type tmp;
+// for (unsigned i = 0; i < this->card(), ++i)
+// tmp.add(- this->at(i));
+// return tmp;
+// }
+
+ void sym()
+ {
+ *this = - *this;
+ }
+
+ private:
+
+ std::vector<dpoint_type> dp_;
+ max_accumulator<coord_t> delta_;
+ };
+
+
+} // end of namespace oln
+
+
+
+template<class G>
+std::ostream& operator<<(std::ostream& ostr, const oln::regular_window<G>& win)
+{
+ unsigned c = win.card();
+ ostr << "[";
+ for (unsigned i = 0; i < c; ++i)
+ ostr << win.dp(i);
+ ostr << "]";
+ return ostr;
+}
+
+
+
+#endif // OLENA_CORE_GEN_REGULAR_WINDOW_HH
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 136)
+++ oln/basics2d.hh (working copy)
@@ -28,17 +28,15 @@
#ifndef OLENA_BASICS2D_HH
# define OLENA_BASICS2D_HH
-
# include <oln/basics.hh>
+# include <oln/core/2d/grid2d.hh>
# include <oln/core/2d/size2d.hh>
# include <oln/core/2d/point2d.hh>
# include <oln/core/2d/image2d.hh>
# include <oln/core/2d/fwd_piter2d.hh>
# include <oln/core/2d/bkd_piter2d.hh>
-# include <oln/core/2d/fwd_qiter2d.hh>
# include <oln/core/2d/window2d.hh>
# include <oln/core/2d/neighborhood2d.hh>
-
#endif // ! OLENA_BASICS2D_HH
Index: oln/basics3d.hh
===================================================================
--- oln/basics3d.hh (revision 136)
+++ oln/basics3d.hh (working copy)
@@ -28,9 +28,9 @@
#ifndef OLENA_BASICS3D_HH
# define OLENA_BASICS3D_HH
-
# include <oln/basics.hh>
+# include <oln/core/3d/grid3d.hh>
# include <oln/core/3d/size3d.hh>
# include <oln/core/3d/point3d.hh>
# include <oln/core/3d/dpoint3d.hh>
Index: oln/basics.hh
===================================================================
--- oln/basics.hh (revision 136)
+++ oln/basics.hh (working copy)
@@ -49,25 +49,27 @@
// oln::
-# include <oln/core/coord.hh>
+# include <oln/core/typedefs.hh>
# include <oln/core/box.hh>
+# include <oln/core/coord.hh>
+
# include <oln/core/abstract/size.hh>
# include <oln/core/abstract/point.hh>
-# include <oln/core/any/all.hh>
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/abstract/window.hh>
+# include <oln/core/abstract/neighborhood.hh>
+
# include <oln/core/abstract/images.hh>
-# include <oln/core/abstract/image_entry.hh>
# include <oln/core/abstract/image_operator.hh>
-# include <oln/core/pw/all.hh>
-
-
-# include <oln/core/abstract/window.hh>
-# include <oln/core/abstract/neighborhood.hh>
-
# include <oln/core/abstract/piter.hh>
# include <oln/core/abstract/qiter.hh>
# include <oln/core/abstract/niter.hh>
+# include <oln/core/any/all.hh>
+# include <oln/core/pw/all.hh>
+
+
#endif // ! OLENA_BASICS_HH
Index: oln/makefile.src
===================================================================
--- oln/makefile.src (revision 136)
+++ oln/makefile.src (working copy)
@@ -5,15 +5,19 @@
OLN_DEP = \
all.hh \
+ \
arith/max.hh \
arith/min.hh \
arith/ops.hh \
+ \
basics.hh \
basics1d.hh \
basics2d.hh \
basics3d.hh \
+ \
config/pconf.hh \
config/system.hh \
+ \
convert/nbh_to_se.hh \
convert/value_to_point.hh \
\
@@ -27,9 +31,9 @@
core/2d/array2d.hh \
core/2d/bkd_piter2d.hh \
core/2d/dpoint2d.hh \
+ core/2d/fwd_niter2d.hh \
core/2d/fwd_piter2d.hh \
core/2d/fwd_qiter2d.hh \
- core/2d/fwd_regular_niter2d.hh \
core/2d/image2d.hh \
core/2d/neighborhood2d.hh \
core/2d/point2d.hh \
@@ -60,28 +64,37 @@
core/abstract/image_with_extension.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
+ core/abstract/iter.hh \
core/abstract/neighborhood.hh \
core/abstract/niter.hh \
core/abstract/piter.hh \
core/abstract/point.hh \
core/abstract/qiter.hh \
- core/abstract/qiter.hh \
core/abstract/regular_niter.hh \
core/abstract/size.hh \
core/abstract/window.hh \
+ \
core/accum.hh \
+ \
core/any/all.hh \
core/any/dpoint.hh \
core/any/point.hh \
core/any/size.hh \
+ \
core/apply.hh \
core/box.hh \
core/ch_value_type.hh \
core/compose.hh \
core/coord.hh \
+ \
core/gen/identity.hh \
core/gen/image_with_nbh.hh \
core/gen/internal/value_box.hh \
+ core/gen/regular_fwd_niter.hh.hh \
+ core/gen/regular_fwd_qiter.hh.hh \
+ core/gen/regular_niter.hh.hh \
+ core/gen/regular_window.hh \
+ \
core/pw/abstract/binary_function.hh \
core/pw/abstract/function.hh \
core/pw/all.hh \
@@ -93,24 +106,29 @@
core/pw/minus.hh \
core/pw/plus.hh \
core/pw/times.hh \
+ \
core/typedefs.hh \
- core/typedefs.hh \
+ \
fancy/iota.hh \
fancy/print.hh \
+ \
io/gz_stream.hh \
io/read_image.hh \
io/read_image_2d_pnm.hh \
io/utils.hh \
io/write_image.hh \
io/write_image_2d_pnm.hh \
+ \
level/compare.hh \
level/fill.hh \
+ \
morpho/cc_tarjan.hh \
morpho/dilation.hh \
morpho/erosion.hh \
morpho/reconstruction.hh \
morpho/splitse.hh \
morpho/stat.hh \
+ \
utils/buffer.hh \
utils/clone.hh \
utils/key.hh \
Index: oln/io/write_image_2d_pnm.hh
===================================================================
--- oln/io/write_image_2d_pnm.hh (revision 136)
+++ oln/io/write_image_2d_pnm.hh (working copy)
@@ -37,8 +37,10 @@
# include <ntg/all.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/abstract/op.hh>
+// commented cause 'void_op' was removed
+//# include <oln/core/abstract/op.hh>
+
# include <oln/io/utils.hh>
namespace oln {
@@ -49,7 +51,8 @@
template <typename I>
struct write_image_2d_raw
- : public oln::abstract::void_op<write_image_2d_raw<I> >
+ // commented below cause 'void_op' was removed
+// : public oln::abstract::void_op<write_image_2d_raw<I> >
{
typedef oln_type_of(I, value) value_type;
Index: oln/io/read_image_2d_pnm.hh
===================================================================
--- oln/io/read_image_2d_pnm.hh (revision 136)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -37,8 +37,9 @@
# include <ntg/all.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/abstract/op.hh>
+# include <oln/core/abstract/image_operator.hh>
+
# include <oln/io/utils.hh>
@@ -54,18 +55,11 @@
}
}
- // category
- template <typename I>
- struct set_category < io::impl::read_image_2d_raw<I> >
- {
- typedef category::image ret;
- };
-
// super_type
template <typename I>
struct set_super_type < io::impl::read_image_2d_raw<I> >
{
- typedef abstract::op<I, io::impl::read_image_2d_raw<I> > ret;
+ typedef abstract::image_operator<I, io::impl::read_image_2d_raw<I> > ret;
};
@@ -74,13 +68,15 @@
namespace impl {
template <typename I>
- struct read_image_2d_raw : public oln::abstract::op<I, read_image_2d_raw<I> >
+ struct read_image_2d_raw : public oln::abstract::image_operator<I, read_image_2d_raw<I> >
{
- typedef oln::abstract::op<I, read_image_2d_raw<I> > super_type;
+ typedef oln::abstract::image_operator<I, read_image_2d_raw<I> > super_type;
typedef oln_type_of(I, value) value_type;
- mlc::box<I> image_;
+ // commented below cause 'image_' is inherited
+// mlc::box<I> image_;
+
std::istream& istr_;
internal::pnm_info& info_;
char v;
@@ -90,16 +86,17 @@
std::istream &istr,
internal::pnm_info &info) :
super_type(image),
- image_(image),
istr_(istr),
info_(info),
offset(-1)
- {}
+ {
+ this->image_ = image;
+ }
read_image_2d_raw<I>& output(I& output)
{
- output = *image_;
+ output = this->image_;
return *this;
}
@@ -137,7 +134,7 @@
read_value_type(c);
tmp[p] = c;
}
- *image_ = tmp;
+ this->image_ = tmp;
}
//FIXME: Should work with builtin types.
Index: oln/arith/ops.hh
===================================================================
--- oln/arith/ops.hh (revision 136)
+++ oln/arith/ops.hh (working copy)
@@ -41,7 +41,7 @@
operator + (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) + oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) + oln::p_value(rhs));
}
@@ -53,7 +53,7 @@
operator - (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) - oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) - oln::p_value(rhs));
}
@@ -64,7 +64,7 @@
oln::pw::image<R> > >
operator - (const oln::abstract::image<R>& rhs)
{
- return oln::for_all_p( - oln::p_value(rhs));
+ return oln::image_for_all_p( - oln::p_value(rhs));
}
@@ -76,7 +76,7 @@
operator * (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) * oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) * oln::p_value(rhs));
}
@@ -88,7 +88,7 @@
operator / (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) / oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) / oln::p_value(rhs));
}
@@ -100,7 +100,7 @@
operator SYMBOL (const oln::abstract::image<L>& lhs, \
TYPE value) \
{ \
- return oln::for_all_p(oln::p_value(lhs) SYMBOL oln::p_lit(value)); \
+ return oln::image_for_all_p(oln::p_value(lhs) SYMBOL oln::p_lit(value)); \
} \
template <typename R> \
oln::image_from_pw< oln::pw::NAME< oln::pw::literal<TYPE>, \
@@ -108,7 +108,7 @@
operator SYMBOL (TYPE value, \
const oln::abstract::image<R>& rhs) \
{ \
- return oln::for_all_p(oln::p_lit(value) SYMBOL oln::p_value(rhs)); \
+ return oln::image_for_all_p(oln::p_lit(value) SYMBOL oln::p_value(rhs)); \
}
Index: oln/arith/logic.hh
===================================================================
--- oln/arith/logic.hh (revision 136)
+++ oln/arith/logic.hh (working copy)
@@ -41,7 +41,7 @@
operator && (const oln::abstract::binary_image<L>& lhs,
const oln::abstract::binary_image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
}
@@ -53,7 +53,7 @@
operator || (const oln::abstract::binary_image<L>& lhs,
const oln::abstract::binary_image<R>& rhs)
{
- return oln::for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
+ return oln::image_for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
}
@@ -63,7 +63,7 @@
oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
operator ! (const oln::abstract::binary_image<I>& rhs)
{
- return oln::for_all_p(!oln::p_value(rhs));
+ return oln::image_for_all_p(!oln::p_value(rhs));
}
1
0
Ce patch ajoute un petit script olena/tests/sanity/check dans le
builddir qui permet de lancer un sanity check sur un fichier
donné. (Il est généré par configure, n'oubliez pas de relancer ce
dernier pour voir apparaître ce script).
Il suffit ensuite de le lancer en lui passant en argument un nom de
fichier, avec le chemin relatif au répertoire source d'Olena :
brasilia ~/src/oln % olena/tests/sanity/check oln/core/2d/point2d.hh
PASS: oln/core/2d/point2d.hh
C'est vraiment quick n' dirty , mais ça permet de gagner du temps
lorsque l'on veut relancer un test sur un fichier donné. (Le script
initial, olena/tests/sanity/includes.test avait plus ou moins cette
fonctionnalité, mais il fallait lui passer beaucoup de choses pour
qu'il fonctionne).
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0/olena
ChangeLog | 5 +++++
tests/sanity/Makefile.am | 2 +-
tests/sanity/check.in | 30 ++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* tests/sanity/check.in: New file.
* tests/sanity/Makefile.am (EXTRA_DIST): Add check.in.
2005-04-11 Roland Levillain <roland(a)lrde.epita.fr>
Index: tests/sanity/check.in
--- tests/sanity/check.in (revision 0)
+++ tests/sanity/check.in (revision 0)
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# Check that a header is self-contained and generates no warning.
+# This script is meant to be used ``by-hand'' to check a single file.
+
+: ${VERBOSE=1}
+
+. "@abs_builddir@/../check/defs" || exit 1
+
+set -e
+
+if test $# = 0; then
+ echo "usage: $0 oln/path/to/file.hh"
+ echo "(File path is relative to the Olena source directory.)"
+ exit 1
+else
+ top_srcdir=@abs_top_srcdir@
+ top_builddir=@abs_top_builddir@
+ file=$1
+ CPPFLAGS="$CPPFLAGS \
+ -I$top_srcdir/metalic -I$top_builddir/metalic \
+ -I$top_srcdir/integre -I$top_builddir/integre \
+ -I$top_srcdir/olena -I$top_builddir/olena"
+ echo "#include <$file>" > incltest.cc
+ if $CXX $CPPFLAGS $CXXFLAGS -c incltest.cc; then
+ echo " PASS: $file"
+ else
+ echo " FAIL: $file"
+ fi
+fi
Property changes on: tests/sanity/check.in
___________________________________________________________________
Name: svn:executable
+ *
Index: tests/sanity/Makefile.am
--- tests/sanity/Makefile.am (revision 135)
+++ tests/sanity/Makefile.am (working copy)
@@ -1,4 +1,4 @@
-EXTRA_DIST = includes.test
+EXTRA_DIST = check.in includes.test
check:
TOP_SRCDIR=$(top_srcdir) SRCDIR=$(srcdir) \
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 9 +++++++++
oln/makefile.src | 9 +++++++--
tests/sanity/includes.test | 3 ++-
3 files changed, 18 insertions(+), 3 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Update the test machinery.
* tests/sanity/includes.test: Ignore files whose path contains an
`internal' subdirectory.
* oln/makefile.src (OLN_DEP): Add core/abstract/image_entry.hh,
core/abstract/qiter.hh and core/typedefs.hh.
Property changes on: olena
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
+ Makefile
Makefile.in
diffs.patch
Index: olena/tests/sanity/includes.test
--- olena/tests/sanity/includes.test (revision 134)
+++ olena/tests/sanity/includes.test (working copy)
@@ -12,7 +12,8 @@
if test $# = 0; then
find "$PATH_TO_OLN_SRCDIR/oln" -name "${1-*}.hh" \
- -a ! -path '*/obsolete/*' -type f -print |
+ -a ! -path '*/obsolete/*' -type f \
+ -a ! -path '*/internal/*' -type f -print |
sed "s,$PATH_TO_OLN_SRCDIR/,,g"
else
echo "$@"
Index: olena/oln/makefile.src
--- olena/oln/makefile.src (revision 134)
+++ olena/oln/makefile.src (working copy)
@@ -16,14 +16,14 @@
config/system.hh \
convert/nbh_to_se.hh \
convert/value_to_point.hh \
-
+ \
core/1d/array1d.hh \
core/1d/dpoint1d.hh \
core/1d/fwd_piter1d.hh \
core/1d/image1d.hh \
core/1d/point1d.hh \
core/1d/size1d.hh \
-
+ \
core/2d/array2d.hh \
core/2d/bkd_piter2d.hh \
core/2d/dpoint2d.hh \
@@ -35,12 +35,14 @@
core/2d/point2d.hh \
core/2d/size2d.hh \
core/2d/window2d.hh \
+ \
core/3d/array3d.hh \
core/3d/dpoint3d.hh \
core/3d/fwd_piter3d.hh \
core/3d/image3d.hh \
core/3d/point3d.hh \
core/3d/size3d.hh \
+ \
core/abstract/data_storage.hh \
core/abstract/dpoint.hh \
core/abstract/image.hh \
@@ -48,6 +50,7 @@
core/abstract/image_constness.hh \
core/abstract/image_dimension.hh \
core/abstract/image_entry.hh \
+ core/abstract/image_entry.hh \
core/abstract/image_like_.hh \
core/abstract/image_neighbness.hh \
core/abstract/image_operator.hh \
@@ -62,6 +65,7 @@
core/abstract/piter.hh \
core/abstract/point.hh \
core/abstract/qiter.hh \
+ core/abstract/qiter.hh \
core/abstract/regular_niter.hh \
core/abstract/size.hh \
core/abstract/window.hh \
@@ -90,6 +94,7 @@
core/pw/plus.hh \
core/pw/times.hh \
core/typedefs.hh \
+ core/typedefs.hh \
fancy/iota.hh \
fancy/print.hh \
io/gz_stream.hh \
Property changes on: metalic
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
+ Makefile
Makefile.in
diffs.patch
1
1
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/value_box.hh: Move to...
* oln/core/gen/internal/value_box.hh: ...this.
* oln/core/abstract/struct_elt.hh: Rename as...
* oln/core/abstract/window.hh: ...this.
* oln/core/abstract/op.hh: Remove.
* oln/core/abstract/image.hh: Update.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/qiter.hh: Likewise.
* oln/core/abstract/image_operator.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/makefile.src: Likewise.
* oln/morpho/dilation.hh: Likewise.
* oln/morpho/splitse.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/morpho/erosion.hh: Likewise.
1
0
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/makefile.src: Update.
1
0
11 Apr '05
2005-04-11 Thierry Geraud <theo@shuttle>
Update files with a 2nd version of property system.
* oln/convert/nbh_to_se.hh: Update.
* oln/basics2d.hh: Likewise.
* oln/core/value_box.hh: Likewise.
* oln/core/apply.hh: Likewise.
* oln/core/ch_value_type.hh: Likewise.
* oln/core/box.hh: Likewise.
* oln/core/pw/times.hh: Likewise.
* oln/core/pw/image.hh: Likewise.
* oln/core/pw/div.hh: Likewise.
* oln/core/pw/plus.hh: Likewise.
* oln/core/pw/macros.hh: Likewise.
* oln/core/pw/abstract/function.hh: Likewise.
* oln/core/pw/abstract/binary_function.hh: Likewise.
* oln/core/pw/minus.hh: Likewise.
* oln/core/pw/literal.hh: Likewise.
* oln/core/pw/logic.hh: Likewise.
* oln/core/pw/cmp.hh: Likewise.
* oln/core/any/point.hh: Likewise.
* oln/core/abstract/niter.hh: Likewise.
* oln/core/abstract/image.hh: Likewise.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/image_like_.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
* oln/core/abstract/image_operator.hh: Likewise.
* oln/core/abstract/data_storage.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
* oln/core/abstract/regular_niter.hh: Likewise.
* oln/core/abstract/images.hh: Likewise.
* oln/core/abstract/image_with_data.hh: Likewise.
* oln/core/abstract/neighborhood.hh: Likewise.
* oln/core/abstract/image_by_delegation.hh: Likewise.
* oln/core/abstract/image_with_extension.hh: Likewise.
* oln/core/abstract/size.hh: Likewise.
* oln/core/abstract/internal/image_impl.hh: Likewise.
* oln/core/1d/dpoint1d.hh: Likewise.
* oln/core/1d/array1d.hh: Likewise.
* oln/core/1d/image1d.hh: Likewise.
* oln/core/1d/fwd_piter1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/1d/size1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/2d/array2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/fwd_regular_niter2d.hh: Likewise.
* oln/core/2d/bkd_piter2d.hh: Likewise.
* oln/core/2d/fwd_piter2d.hh: Likewise.
* oln/core/2d/neighborhood2d.hh: Likewise.
* oln/core/2d/window2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/2d/size2d.hh: Likewise.
* oln/core/3d/array3d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/core/3d/fwd_piter3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
* oln/core/gen/image_with_nbh.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/morpho/reconstruction.hh: Likewise.
* oln/morpho/splitse.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/arith/ops.hh: Likewise.
* oln/arith/min.hh: Likewise.
* oln/arith/max.hh: Likewise.
* oln/io/read_image.hh: Likewise.
* oln/core/abstract/witer.hh: Update and rename as...
* oln/core/abstract/qiter.hh: ...this.
* oln/core/abstract/entry.hh: Update and rename as...
* oln/core/abstract/image_entry.hh: ...this.
* oln/core/2d/fwd_witer2d.hh: Update and rename as...
* oln/core/2d/fwd_qiter2d.hh: ...this.
* oln/core/properties.hh: Update and rename as...
* oln/core/typedefs.hh: ...this.
1
0
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/typedef.hh: New file.
* mlc/implies.hh: New file.
* mlc/to_string.hh: New file.
* mlc/bool.hh (Boolean_value): Remove.
(value): Add inheritance.
(b): Rename as...
(Boolean_value): ... this.
(mlc_bool, internal::helper_get_bool): New.
(T::b): Update to mlc_bool(T).
* mlc/properties.hh: Rewrite.
* mlc/if.hh (internal::if_): Rename as...
(internal::fun_if_): ...this.
(::b): Update with mlc_bool.
* mlc/types.hh (internal::not_found): New type.
* mlc/cmp.hh (eq, neq): Add inheritance.
(is_found, is_not_found): New.
1
0
proto-1.0 130: Better code factorization in morphological reconstruction
by Damien Thivolle 08 Apr '05
by Damien Thivolle 08 Apr '05
08 Apr '05
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* oln/morpho/reconstruction.hh: Improve factorization.
reconstruction.hh | 367 ++++++++++++++++++++++++++++++------------------------
1 files changed, 207 insertions(+), 160 deletions(-)
Index: oln/morpho/reconstruction.hh
--- oln/morpho/reconstruction.hh (revision 129)
+++ oln/morpho/reconstruction.hh (working copy)
@@ -93,47 +93,44 @@
namespace impl {
- template <typename I, typename N>
+ template <typename I, typename N, typename E>
struct reconstruction_sequential_ret : public reconstruction_ret<I, N>
{
typedef reconstruction_ret<I, N> super_type;
+ void fwd_loop_body()
+ {
+ static_cast<E*>((void*)this)->fwd_loop_body_impl();
+ }
- virtual const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v)
+ void bkd_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return oln_type_of(I, value)();
+ static_cast<E*>((void*)this)->bkd_loop_body_impl();
}
+ void preconditions()
+ {
+ precondition(this->input1.size() == this->input2.size());
+ static_cast<E*>((void*)this)->preconditions_impl();
+ }
+
void impl_run()
{
mlc::eq<oln_type_of(I, size), oln_type_of(N, size)>::ensure();
- precondition(this->input1.size() == this->input2.size());
- precondition(level::is_greater_or_equal(this->input2, this->input1));
- // Conversion of neighborhood into a SE.
- oln_type_of(N, window) se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(N, window) se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
-
I output;
output = utils::clone(this->input1);
bool non_stability = true;
- oln_type_of(I, fwd_piter) fwd_p(output.size());
- oln_type_of(I, bkd_piter) bkd_p(output.size());
while (non_stability)
{
- I work;
- work = utils::clone(output);
+ work.unbox() = utils::clone(output);
for_all (fwd_p)
- work[fwd_p] = this->process(work, fwd_p, se_plus, this->input2[fwd_p].value());
+ fwd_loop_body();
for_all (bkd_p)
- work[bkd_p] = this->process(work, bkd_p, se_minus, this->input2[bkd_p].value());
+ bkd_loop_body();
non_stability = !(level::is_equal(work, output));
- output = work;
+ output = work.unbox();
}
this->output = output;
}
@@ -142,17 +139,27 @@
reconstruction_sequential_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
- : super_type(input1, input2, nbh)
- {}
+ : super_type(input1, input2, nbh),
+ fwd_p(input1.size()),
+ bkd_p(input1.size())
+ {
+ se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
+ se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
+ }
+ oln_type_of(N, window) se_plus;
+ oln_type_of(N, window) se_minus;
+ oln_type_of(I, fwd_piter) fwd_p;
+ oln_type_of(I, bkd_piter) bkd_p;
+ box<I> work;
};
-
template <typename I, typename N>
- struct reconstruction_dilation_ret : public reconstruction_sequential_ret<I, N>
+ struct reconstruction_dilation_ret :
+ public reconstruction_sequential_ret<I, N, reconstruction_dilation_ret<I, N> >
{
- typedef reconstruction_sequential_ret<I, N> super_type;
+ typedef reconstruction_sequential_ret<I, N, reconstruction_dilation_ret<I, N> > super_type;
reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -161,21 +168,35 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v)
+ void fwd_loop_body_impl()
{
- return ntg::min(morpho::max(work, p, se), v);
+ this->work[this->fwd_p] = ntg::min(morpho::max(this->work.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
+ void bkd_loop_body_impl()
+ {
+ this->work[this->bkd_p] = ntg::min(morpho::max(this->work.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void preconditions_impl()
+ {
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
+ }
+
};
template <typename I, typename N>
- struct reconstruction_erosion_ret : public reconstruction_sequential_ret<I, N>
+ struct reconstruction_erosion_ret :
+ public reconstruction_sequential_ret<I, N, reconstruction_erosion_ret<I, N> >
{
- typedef reconstruction_sequential_ret<I, N> super_type;
+ typedef reconstruction_sequential_ret<I, N, reconstruction_erosion_ret<I, N> > super_type;
reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -184,13 +205,27 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::max(morpho::min(work, p, se), v);
+ this->work[this->fwd_p] = ntg::max(morpho::min(this->work.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
+
+ void bkd_loop_body_impl()
+ {
+ this->work[this->bkd_p] = ntg::max(morpho::min(this->work.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void preconditions_impl()
+ {
+ precondition(level::is_greater_or_equal(this->input1, this->input2));
+ }
+
};
}
@@ -224,93 +259,113 @@
namespace impl {
- template <typename I, typename N>
+ template <typename I, typename N, typename E>
struct reconstruction_hybrid_ret : public reconstruction_ret<I, N>
{
typedef reconstruction_ret<I, N> super_type;
- reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
- const abstract::image<I>& input2, //mask
- const abstract::neighborhood<N>& nbh)
+ bool exist_init()
+ {
+ typedef oln_type_of(N, window) se_type;
+ oln_type_of(se_type, fwd_witer) dp(se_minus);
+ for_all (dp)
+ {
+ q = (oln_type_of(se_type, dpoint))dp +
+ (oln_type_of(I, point))bkd_p;
+ if (static_cast<E*>((void*)this)->exist_init_impl())
+ return true;
+ }
+ return false;
+ }
- : super_type(input1, input2, nbh)
- {}
+ void fwd_loop_body()
+ {
+ static_cast<E*>((void*)this)->fwd_loop_body_impl();
+ }
- virtual const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void bkd_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return oln_type_of(I, value)();
+ static_cast<E*>((void*)this)->bkd_loop_body_impl();
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void fifo_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
+ static_cast<E*>((void*)this)->fifo_loop_body_impl();
}
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& output,
- const oln_type_of(N, window)& se) const
+ void preconditions()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return true;
+ precondition(this->input1.size() == this->input2.size());
+ static_cast<E*>((void*)this)->preconditions_impl();
}
-
void impl_run()
{
mlc::eq<oln_type_of(I, size), oln_type_of(N, size)>::ensure();
- precondition(this->input1.size() == this->input2.size());
- precondition(level::is_greater_or_equal(this->input2, this->input1));
+ preconditions();
- oln_type_of(I, concrete) output;
- output = utils::clone(this->input1);
- {
- oln_type_of(N, window) se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(N, window) se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(I, fwd_piter) fwd_p(output.size());
- oln_type_of(I, fwd_piter) bkd_p(output.size());
+ this->output.unbox() = utils::clone(this->input1);
- for_all (fwd_p)
- output[fwd_p] = this->process(output, fwd_p, se_plus, this->input2[fwd_p].value());
+ std::cout << "for_all (fwd_p)" << std::endl;
+ for_all (fwd_p)
+ fwd_loop_body();
- std::queue<oln_type_of(I, point) > fifo;
- for_all (bkd_p)
- {
- output[bkd_p] = this->process(output, bkd_p, se_minus, this->input2[bkd_p].value());
- if (this->exist_init((oln_type_of(I, point))bkd_p, output, se_minus))
- fifo.push(bkd_p);
- }
+ std::cout << "for_all (bkd_p)" << std::endl;
+ for_all (bkd_p)
+ {
+ bkd_loop_body();
+ if (exist_init())
+ fifo.push(bkd_p);
+ }
// Propagation Step
- while (!fifo.empty())
- {
- oln_type_of(I, point) p = fifo.front();
- fifo.pop();
- typedef oln_type_of(N, window) window_type;
- window_type w = convert::nbh_to_se(this->nbh);
- oln_type_of(window_type, fwd_witer) dp(w);
+ while (!fifo.empty())
+ {
+ p = fifo.front();
+ fifo.pop();
+ typedef oln_type_of(N, window) window_type;
+ window_type w = convert::nbh_to_se(this->nbh);
+ oln_type_of(window_type, fwd_witer) dp(w);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(window_type, dpoint))dp + p;
- this->loop_body(p, q, output, fifo);
- }
- }
- }
- this->output = output;
+ for_all (dp)
+ {
+ q = (oln_type_of(window_type, dpoint))dp + p;
+ if (this->output.hold(q))
+ fifo_loop_body();
+ }
+ }
}
+
+ protected:
+
+ reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
+ const abstract::neighborhood<N>& nbh)
+
+ : super_type(input1, input2, nbh),
+ fwd_p(input1.size()),
+ bkd_p(input1.size())
+ {
+ se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
+ se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
+ }
+
+ oln_type_of(N, window) se_plus;
+ oln_type_of(N, window) se_minus;
+ oln_type_of(I, fwd_piter) fwd_p;
+ oln_type_of(I, bkd_piter) bkd_p;
+ oln_type_of(I, point) p;
+ oln_type_of(I, point) q;
+ std::queue<oln_type_of(I, point) > fifo;
+
+
};
template <typename I, typename N>
- struct reconstruction_dilation_ret : public reconstruction_hybrid_ret<I, N>
+ struct reconstruction_dilation_ret :
+ public reconstruction_hybrid_ret<I, N, reconstruction_dilation_ret<I, N> >
{
- typedef reconstruction_hybrid_ret<I, N> super_type;
+ typedef reconstruction_hybrid_ret<I, N, reconstruction_dilation_ret<I, N> > super_type;
reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -319,47 +374,43 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::min(morpho::max(work, p, se), v);
+ this->output[this->fwd_p] = ntg::min(morpho::max(this->output.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void bkd_loop_body_impl()
{
- if (output.hold(q))
+ this->output[this->bkd_p] = ntg::min(morpho::max(this->output.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void fifo_loop_body_impl()
+ {
+ if ((this->output[this->q] < this->output[this->p]) &&
+ (this->input2[this->q] != this->output[this->q]))
{
- if ((output[q] < output[p]) &&
- (this->input2[q] != output[q]))
- {
- output[q] = ntg::min(output[p].value(),
- this->input2[q].value());
- fifo.push(q);
- }
+ this->output[this->q] = ntg::min(this->output[this->p].value(),
+ this->input2[this->q].value());
+ this->fifo.push(this->q);
}
+ }
+ bool exist_init_impl()
+ {
+ return this->output.hold(this->q) &&
+ (this->output[this->q] < this->output[this->bkd_p]) &&
+ (this->output[this->q] < this->input2[this->q]);
}
-
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& marker,
- const oln_type_of(N, window)& se) const
+ void preconditions_impl()
{
- typedef oln_type_of(N, window) se_type;
- oln_type_of(se_type, fwd_witer) dp(se);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(se_type, dpoint))dp + p;
- if (marker.hold(q) && (marker[q] < marker[p]) &&
- (marker[q] < this->input2[q]))
- return true;
- }
- return false;
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
}
};
@@ -367,9 +418,10 @@
template <typename I, typename N>
- struct reconstruction_erosion_ret : public reconstruction_hybrid_ret<I, N>
+ struct reconstruction_erosion_ret :
+ public reconstruction_hybrid_ret<I, N, reconstruction_erosion_ret<I, N> >
{
- typedef reconstruction_hybrid_ret<I, N> super_type;
+ typedef reconstruction_hybrid_ret<I, N, reconstruction_erosion_ret<I, N> > super_type;
reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -378,52 +430,47 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::max(morpho::min(work, p, se), v);
+ this->output[this->fwd_p] = ntg::max(morpho::min(this->output.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void bkd_loop_body_impl()
{
- if (output.hold(q))
+ this->output[this->bkd_p] = ntg::max(morpho::min(this->output.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void fifo_loop_body_impl()
+ {
+ if ((this->output[this->q] > this->output[this->p]) &&
+ (this->input2[this->q] != this->output[this->q]))
{
- if ((output[q] > output[p]) &&
- (this->input2[q] != output[q]))
- {
- output[q] = ntg::max(output[p].value(),
- this->input2[q].value());
- fifo.push(q);
- }
+ this->output[this->q] = ntg::max(this->output[this->p].value(),
+ this->input2[this->q].value());
+ this->fifo.push(this->q);
}
}
+ bool exist_init_impl()
+ {
+ return this->output.hold(this->q) &&
+ (this->output[this->q] > this->output[this->bkd_p]) &&
+ (this->output[this->q] > this->input2[this->q]);
+ }
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& marker,
- const oln_type_of(N, window)& se) const
+ void preconditions_impl()
{
- typedef oln_type_of(N, window) se_type;
- oln_type_of(se_type, fwd_witer) dp(se);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(se_type, dpoint))dp + p;
- if (marker.hold(q) && (marker[q] > marker[p]) &&
- (marker[q] > this->input2[q]))
- return true;
- }
- return false;
+ precondition(level::is_greater_or_equal(this->input1, this->input2));
}
};
-
-
}
template<class I, class N>
1
0
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/pw/logic.hh: Fix include.
* oln/core/pw/cmp.hh: Cosmetic change.
* oln/utils/md5.hh: Conform to image_valuedness.
* oln/utils/md5.hxx: Likewise.
* oln/morpho/reconstruction.hh: Likewise.
* oln/arith/min.hh: Likewise.
* oln/arith/max.hh: Likewise.
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 128)
+++ oln/core/pw/logic.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/cmp.hh>
namespace oln {
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 128)
+++ oln/core/pw/cmp.hh (working copy)
@@ -129,12 +129,12 @@
# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
template <typename L, typename R> \
-oln::pw::cmp<L, R, oln::pw::internal::NAME> \
+oln::pw::cmp<L, R, oln::pw::internal:: NAME > \
operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
const oln::pw::abstract::function<R>& rhs) \
{ \
precondition(lhs.size() == rhs.size()); \
- oln::pw::cmp<L, R, oln::pw::internal::NAME> tmp(lhs, rhs); \
+ oln::pw::cmp<L, R, oln::pw::internal:: NAME > tmp(lhs, rhs); \
return tmp; \
}
Index: oln/utils/md5.hh
===================================================================
--- oln/utils/md5.hh (revision 128)
+++ oln/utils/md5.hh (working copy)
@@ -31,8 +31,7 @@
# include <ntg/all.hh>
# include <vector>
-# include <oln/core/abstract/image_vectorialness.hh>
-# include <oln/core/properties.hh>
+# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/piter.hh>
# include <oln/utils/key.hh>
@@ -218,11 +217,9 @@
** \param I Exact type of the image.
**
** \arg im Image to process.
- **
- ** Non vectorial image version.
*/
template <class I>
- key md5(const oln::abstract::non_vectorial_image<I> &im);
+ key md5(const oln::abstract::image<I> &im);
/*!
** \brief Compute The Md5 value of an image.
@@ -231,10 +228,10 @@
**
** \arg im Image to process.
**
- ** Vectorial image version.
+ ** For vector-valued images.
*/
template <class I>
- key md5(const oln::abstract::vectorial_image<I> &im);
+ key md5(const oln::abstract::vector_valued_image<I> &im);
} // !utils
} // !oln
Index: oln/utils/md5.hxx
===================================================================
--- oln/utils/md5.hxx (revision 128)
+++ oln/utils/md5.hxx (working copy)
@@ -286,7 +286,7 @@
// md5 implementation.
template <class I>
inline
-key md5(const oln::abstract::non_vectorial_image<I> &im)
+key md5(const oln::abstract::image<I> &im)
{
buffer b;
oln_type_of(I, fwd_piter) p(im.size());
@@ -303,7 +303,7 @@
// md5 implementation.
template <class I>
inline
-key md5(const oln::abstract::vectorial_image<I> &im)
+key md5(const oln::abstract::vector_valued_image<I> &im)
{
oln_type_of(I, fwd_piter) p(im.size());
buffer b;
Index: oln/morpho/reconstruction.hh
===================================================================
--- oln/morpho/reconstruction.hh (revision 128)
+++ oln/morpho/reconstruction.hh (working copy)
@@ -80,8 +80,8 @@
const N nbh;
- reconstruction_ret(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2,
+ reconstruction_ret(const abstract::image<I>& input1,
+ const abstract::image<I>& input2,
const abstract::neighborhood<N>& nbh) :
super_type(input1.exact(), input2.exact()),
nbh(nbh.exact())
@@ -139,8 +139,8 @@
}
protected:
- reconstruction_sequential_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_sequential_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
{}
@@ -154,8 +154,8 @@
{
typedef reconstruction_sequential_ret<I, N> super_type;
- reconstruction_dilation_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -177,8 +177,8 @@
{
typedef reconstruction_sequential_ret<I, N> super_type;
- reconstruction_erosion_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -197,8 +197,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_dilation(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_dilation(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_dilation_ret<I, N> tmp(marker, mask, nbh);
@@ -208,8 +208,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_erosion(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_erosion(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_erosion_ret<I, N> tmp(marker, mask, nbh);
@@ -229,8 +229,8 @@
{
typedef reconstruction_ret<I, N> super_type;
- reconstruction_hybrid_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -312,8 +312,8 @@
{
typedef reconstruction_hybrid_ret<I, N> super_type;
- reconstruction_dilation_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -371,8 +371,8 @@
{
typedef reconstruction_hybrid_ret<I, N> super_type;
- reconstruction_erosion_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -428,8 +428,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_dilation(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_dilation(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_dilation_ret<I, N> tmp(marker, mask, nbh);
@@ -439,8 +439,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_erosion(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_erosion(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_erosion_ret<I, N> tmp(marker, mask, nbh);
Index: oln/arith/min.hh
===================================================================
--- oln/arith/min.hh (revision 128)
+++ oln/arith/min.hh (working copy)
@@ -66,8 +66,8 @@
{
typedef abstract::image_binary_operator<I, I, I, min_type<I> > super_type;
- min_type(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2) :
+ min_type(const abstract::image<I>& input1,
+ const abstract::image<I>& input2) :
super_type(input1.exact(), input2.exact())
{}
@@ -87,11 +87,9 @@
}
- // FIXME: replace non_vectorial_image by scalar_image
- // FIXME: cause arithmetics is not defined for Booleans and labels...
template <typename I>
- impl::min_type<I> min(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2)
+ impl::min_type<I> min(const abstract::image<I>& input1,
+ const abstract::image<I>& input2)
{
impl::min_type<I> tmp(input1, input2);
tmp.run();
Index: oln/arith/max.hh
===================================================================
--- oln/arith/max.hh (revision 128)
+++ oln/arith/max.hh (working copy)
@@ -66,8 +66,8 @@
{
typedef abstract::image_binary_operator<I, I, I, max_type<I> > super_type;
- max_type(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2) :
+ max_type(const abstract::image<I>& input1,
+ const abstract::image<I>& input2) :
super_type(input1.exact(), input2.exact())
{}
@@ -88,8 +88,8 @@
}
template <typename I>
- impl::max_type<I> max(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2)
+ impl::max_type<I> max(const abstract::image<I>& input1,
+ const abstract::image<I>& input2)
{
impl::max_type<I> tmp(input1, input2);
tmp.run();
1
0
08 Apr '05
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/pw/logic.hh: New file.
* oln/core/abstract/image_valuedness.hh: New file.
* oln/core/abstract/image_vectorialness.hh: Remove.
* oln/core/abstract/image_typeness.hh: New file.
* oln/arith/logic.hh: New file.
* oln/core/pw/image.hh (image_vectorialness_type): Remove.
(for_all_p): Update.
* oln/core/pw/macros.hh (oln_pw_cmp_operator): New macro.
(oln_pw_cmp_operators): New macro.
* oln/core/pw/abstract/function.hh (operator!): New method.
* oln/core/pw/all.hh (oln/core/pw/logic.hh): New include.
* oln/core/pw/minus.hh: Cosmetic change.
* oln/core/pw/cmp.hh: Derive from pw::abstract::binary_function.
* oln/core/pw/logic.hh: New file.
* oln/core/properties.hh (image_typeness_type): New target.
(image_valuedness_type): Likewise.
(dummy_type): New target for temporary dummy tests.
* oln/core/abstract/image_constness.hh: Fix include.
* oln/core/abstract/image_neighbness.hh: Likewise.
* oln/core/abstract/image.hh (image_vectorialness_type): Remove.
* oln/core/abstract/image_operator.hh (abstract::image_operator):
New props and set_type_of for temporary dummy tests.
* oln/core/abstract/entry.hh (typeness::inheritance_switch): New
inheritance.
(valuedness::inheritance_switch): Likewise.
* oln/core/abstract/images.hh: Update.
* oln/core/abstract/image_with_data.hh: Cosmetic change.
* oln/core/1d/image1d.hh (image_vectorialness_type): Remove.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/makefile.src: Update.
* oln/morpho/stat.hh (min, max): Change sig.
* oln/morpho/erosion.hh (morpho::impl::generic_erosion): Add
code for temporary dummy tests.
* oln/arith/ops.hh (operator+): Add erroneous overloading.
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 125)
+++ oln/core/pw/image.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/cmp.hh>
# include <oln/core/box.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/abstract/entry.hh>
# include <oln/core/pw/abstract/function.hh>
@@ -130,7 +131,6 @@
// FIXME: AWFUL we do not know if it is 2d...
typedef is_a<abstract::image2d> image_dimension_type;
- typedef vectorialness_from_valuetype(value_type) image_vectorialness_type;
typedef fwd_piter2d piter_type;
typedef fwd_piter2d fwd_piter_type;
@@ -199,7 +199,7 @@
};
- /// Routine
+ /// Routine for_all_p.
template <typename F>
image_from_pw<F> for_all_p(const pw::abstract::function<F>& fun)
@@ -209,6 +209,16 @@
}
+ // FIXME: below, produce an error instead of correcting the client code (?)
+
+ /// Specialization of for_all_p (so that "for_all_p(p_value(ima)) == ima").
+
+ template <typename I>
+ const I& for_all_p(const pw::image<I>& pv)
+ {
+ return pv.ima.unbox();
+ }
+
/// Specialization of p_value (so that "p_value(for_all_p(fun)) == fun").
template <typename F>
@@ -220,13 +230,13 @@
+
+
/// Routine check.
- // FIXME: this should be an algorithm (pred = binary_image)
template <typename I>
- bool check(const abstract::image<I>& pred)
+ bool check(const abstract::binary_image<I>& pred)
{
- // FIXME: input should be binary
oln_type_of(I, fwd_piter) p(pred.size());
for_all (p)
if (! pred[p])
@@ -234,8 +244,6 @@
return true;
}
-
-
namespace pw {
/// Routine oln::pw::check.
@@ -243,13 +251,33 @@
template <typename F>
bool check(const pw::abstract::function<F>& pred)
{
- mlc::eq< oln_pw_value_type(F), bool >::ensure();
+ mlc::eq< oln_typeness_of(oln_pw_value_type(F)), typeness::binary_tag >::ensure();
return oln::check(for_all_p(pred));
}
} // end of namespace oln::pw
+
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename I>
+ void for_all_p(const abstract::image<I>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_an_image();
+ }
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename P>
+ void for_all_p(const abstract::point<P>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_a_point();
+ }
+
+
+
} // end of namespace oln
Index: oln/core/pw/macros.hh
===================================================================
--- oln/core/pw/macros.hh (revision 125)
+++ oln/core/pw/macros.hh (working copy)
@@ -35,18 +35,18 @@
# define oln_pw_size_type(F) typename oln::pw::traits<F>::size_type
-// FIXME: rename
+// FIXME: rename?
# define oln_pw_operator(NAME, SYMBOL, TYPE) \
template <typename L> \
oln::pw::NAME<L, oln::pw::literal<TYPE> > \
operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- TYPE value) \
+ const TYPE& value) \
{ \
return lhs SYMBOL oln::pw::literal<TYPE>(value); \
} \
template <typename R> \
oln::pw::NAME<oln::pw::literal<TYPE>, R> \
-operator SYMBOL (TYPE value, \
+operator SYMBOL (const TYPE& value, \
const oln::pw::abstract::function<R>& rhs) \
{ \
return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
@@ -54,4 +54,32 @@
+// FIXME: rename?
+# define oln_pw_cmp_operator(NAME, SYMBOL, TYPE) \
+template <typename L> \
+oln::pw::cmp<L, oln::pw::literal<TYPE>, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const TYPE& value) \
+{ \
+ return lhs SYMBOL oln::pw::literal<TYPE>(value); \
+} \
+template <typename R> \
+oln::pw::cmp<oln::pw::literal<TYPE>, R, oln::pw::internal::NAME> \
+operator SYMBOL (const TYPE& value, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
+}
+
+
+// FIXME: rename?
+# define oln_pw_cmp_operators(TYPE) \
+oln_pw_cmp_operator(eq, ==, TYPE) \
+oln_pw_cmp_operator(neq, !=, TYPE) \
+oln_pw_cmp_operator(geq, >=, TYPE) \
+oln_pw_cmp_operator(leq, <=, TYPE) \
+oln_pw_cmp_operator(g, >, TYPE) \
+oln_pw_cmp_operator(l, <, TYPE)
+
+
#endif // ! OLENA_CORE_PW_MACROS_HH
Index: oln/core/pw/abstract/function.hh
===================================================================
--- oln/core/pw/abstract/function.hh (revision 125)
+++ oln/core/pw/abstract/function.hh (working copy)
@@ -47,9 +47,9 @@
}
template <typename L, typename R> struct minus;
template <typename T> struct literal;
+ template <typename F> struct not_;
-
template <typename E>
struct traits < abstract::function<E> >
{
@@ -87,7 +87,8 @@
return this->exact().impl_hold_large(p);
}
- minus< literal<value_type>, E> operator-() const;
+ minus<literal<value_type>, E> operator-() const;
+ not_<E> operator!() const;
protected:
function() {}
Index: oln/core/pw/all.hh
===================================================================
--- oln/core/pw/all.hh (revision 125)
+++ oln/core/pw/all.hh (working copy)
@@ -34,13 +34,14 @@
# include <oln/core/pw/literal.hh>
# include <oln/core/pw/cmp.hh>
+# include <oln/core/pw/logic.hh>
# include <oln/core/pw/plus.hh>
# include <oln/core/pw/minus.hh>
# include <oln/core/pw/times.hh>
# include <oln/core/pw/div.hh>
-// FIXME: not xor mod...
+// FIXME: xor mod...
#endif // ! OLENA_CORE_PW_ALL_HH
Index: oln/core/pw/minus.hh
===================================================================
--- oln/core/pw/minus.hh (revision 125)
+++ oln/core/pw/minus.hh (working copy)
@@ -77,12 +77,12 @@
};
- // FIXME: uncomment?
+ // impl of abstract::function<E>::operator-()
namespace abstract {
template <typename E>
- minus< literal<oln_pw_value_type(E)>, E>
+ minus<literal<oln_pw_value_type(E)>, E>
function<E>::operator-() const
{
typedef literal<oln_pw_value_type(E)> lit_type;
@@ -91,7 +91,7 @@
return tmp;
}
- }
+ } // end of namespace oln::pw::abstract
} // end of namespace oln::pw
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 0)
+++ oln/core/pw/logic.hh (revision 0)
@@ -0,0 +1,172 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_PW_LOGIC_HH
+# define OLENA_CORE_PW_LOGIC_HH
+
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/abstract/function.hh>
+
+
+namespace oln {
+
+
+ namespace pw { // means "point-wise"
+
+
+ // FIXME: move somewhere else
+ namespace internal
+ {
+ struct not_ {
+ template <typename T>
+ bool operator()(const T& rhs) const {
+ return !rhs;
+ }
+ };
+ struct and_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs && rhs;
+ }
+ };
+ struct nand_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs && rhs);
+ }
+ };
+ struct or_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs || rhs;
+ }
+ };
+ struct nor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs || rhs);
+ }
+ };
+ struct xor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && !rhs) || (!lhs && rhs);
+ }
+ };
+ struct xnor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && rhs) || (!lhs && !rhs);
+ }
+ };
+ } // end of oln::pw::internal
+
+
+
+ // fwd decl
+ template <typename R> struct not_;
+
+ template <typename R>
+ struct traits < not_<R> >
+ {
+ typedef oln_pw_point_type(R) point_type;
+ typedef oln_pw_size_type(R) size_type;
+ typedef bool value_type;
+ };
+
+ template <typename R>
+ struct not_ : public abstract::function < not_<R> >
+ {
+ typedef not_<R> self_type;
+
+ typedef oln_pw_point_type(self_type) point_type;
+ typedef oln_pw_value_type(self_type) value_type;
+ typedef oln_pw_size_type(self_type) size_type;
+
+ R right;
+
+ not_(const abstract::function<R>& right) :
+ right(right.exact())
+ {
+ }
+
+ const bool impl_get(const point_type& p) const
+ {
+ return ! this->right(p);
+ }
+
+ const size_type& impl_size() const
+ {
+ return this->right.size();
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return this->right.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return this->right.hold_large(p);
+ }
+
+ };
+
+
+ // impl of abstract::function<E>::operator!()
+
+ namespace abstract {
+
+ template <typename E>
+ not_<E>
+ function<E>::operator!() const
+ {
+ mlc::eq< oln_typeness_of(oln_pw_value_type(E)), typeness::binary_tag >::ensure();
+ not_<E> tmp(this->exact());
+ return tmp;
+ }
+
+ } // end of namespace oln::pw::abstract
+
+
+ } // end of namespace oln::pw
+
+
+} // end of namespace oln
+
+
+
+/// Ops on pwf
+
+oln_pw_decl_cmp_op(and_, &&)
+oln_pw_decl_cmp_op(or_, ||)
+
+oln_pw_cmp_operator(and_, &&, bool)
+oln_pw_cmp_operator(or_, ||, bool)
+
+
+#endif // ! OLENA_CORE_PW_LOGIC_HH
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 125)
+++ oln/core/pw/cmp.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLENA_CORE_PW_CMP_HH
# define OLENA_CORE_PW_CMP_HH
-# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/abstract/binary_function.hh>
namespace oln {
@@ -76,59 +76,46 @@
return lhs < rhs;
}
};
- }
+ } // end of oln::pw::internal
+
// fwd decl
template <typename L, typename R, typename C> struct cmp;
template <typename L, typename R, typename C>
struct traits < cmp<L, R, C> >
{
- typedef oln_pw_point_type(L) point_type;
+ typedef abstract::binary_function<L, R, cmp<L, R, C> > super_type;
+ typedef typename traits<super_type>::point_type point_type;
+ typedef typename traits<super_type>::size_type size_type;
typedef bool value_type;
- typedef oln_pw_size_type(L) size_type;
};
+
template <typename L, typename R, typename C>
- struct cmp : public abstract::function < cmp<L, R, C> >
+ struct cmp : public abstract::binary_function < L, R, cmp<L, R, C> >
{
typedef cmp<L, R, C> self_type;
typedef oln_pw_point_type(self_type) point_type;
typedef oln_pw_size_type(self_type) size_type;
+ typedef oln_pw_value_type(self_type) value_type;
- L left;
- R right;
+ typedef abstract::binary_function < L, R, self_type > super_type;
cmp(const abstract::function<L>& left,
const abstract::function<R>& right) :
- left(left.exact()),
- right(right.exact())
+ super_type(left, right)
{
}
- const size_type& impl_size() const
- {
- return this->left.size();
- }
-
const bool impl_get(const point_type& p) const
{
static const C cmpfun = C();
return cmpfun(this->left(p), this->right(p));
}
- bool impl_hold(const point_type& p) const
- {
- return this->left.hold(p);
- }
-
- bool impl_hold_large(const point_type& p) const
- {
- return this->left.hold_large(p);
- }
-
};
} // end of namespace oln::pw
@@ -138,68 +125,30 @@
-/// Op+ on pwf
+/// Ops on pwf
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::eq>
-operator == (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::eq> tmp(lhs, rhs);
- return tmp;
+# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
+template <typename L, typename R> \
+oln::pw::cmp<L, R, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::cmp<L, R, oln::pw::internal::NAME> tmp(lhs, rhs); \
+ return tmp; \
}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::neq>
-operator != (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::neq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_decl_cmp_op(eq, ==)
+oln_pw_decl_cmp_op(neq, !=)
+oln_pw_decl_cmp_op(geq, >=)
+oln_pw_decl_cmp_op(leq, <=)
+oln_pw_decl_cmp_op(g, >)
+oln_pw_decl_cmp_op(l, <)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::geq>
-operator >= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::geq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_cmp_operators(int)
+oln_pw_cmp_operators(float)
+oln_pw_cmp_operators(double)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::leq>
-operator <= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::leq> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::g>
-operator > (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::g> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::l>
-operator < (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::l> tmp(lhs, rhs);
- return tmp;
-}
-
-
-
#endif // ! OLENA_CORE_PW_CMP_HH
Index: oln/core/properties.hh
===================================================================
--- oln/core/properties.hh (revision 125)
+++ oln/core/properties.hh (working copy)
@@ -75,8 +75,11 @@
struct image_neighbness_type;
struct image_constness_type;
struct image_dimension_type;
- struct image_vectorialness_type;
+ struct image_typeness_type;
+ struct image_valuedness_type;
// FIXME: ...
+
+ struct dummy_type; // FIXME: remove (test purpose!)
}
mlc_equip_namespace_for_properties();
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 125)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -28,7 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
-# include <oln/core/abstract/internal/image_impl.hh>
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 125)
+++ oln/core/abstract/image.hh (working copy)
@@ -77,7 +77,6 @@
mlc_decl_prop_with_default(category::image, image_neighbness_type, is_a<abstract::image_without_nbh>);
mlc_decl_prop_with_default(category::image, image_constness_type, is_a<abstract::readonly_image>);
mlc_decl_prop(category::image, image_dimension_type);
- mlc_decl_prop(category::image, image_vectorialness_type);
//...
@@ -97,7 +96,6 @@
<< " image_constness_type = " << typeid(image_constness_type).name()
<< " image_dimension_type = " << typeid(image_dimension_type).name()
- << " image_vectorialness_type = " << typeid(image_vectorialness_type).name()
<< " image_neighbness_type = " << typeid(image_neighbness_type).name()
<< " }" << std::endl;
@@ -119,7 +117,6 @@
mlc_register_prop(category::image, image_constness_type);
mlc_register_prop(category::image, image_dimension_type);
- mlc_register_prop(category::image, image_vectorialness_type);
mlc_register_prop(category::image, image_neighbness_type);
Index: oln/core/abstract/image_vectorialness.hh
===================================================================
--- oln/core/abstract/image_vectorialness.hh (revision 125)
+++ oln/core/abstract/image_vectorialness.hh (working copy)
@@ -1,125 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-# define OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-
-# include <mlc/switch.hh>
-# include <ntg/basics.hh>
-# include <oln/core/abstract/image.hh>
-
-
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
-
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
-
- template <typename E>
- struct data_type_image : public virtual image<E>
- {
- protected:
- data_type_image() {}
- };
-
- template <typename E>
- struct vectorial_image : public data_type_image<E>
- {
- protected:
- vectorial_image() {}
- };
-
- template <typename E>
- struct non_vectorial_image : public data_type_image<E>
- {
- protected:
- non_vectorial_image() {}
- };
-
- template <typename E>
- struct decimal_image : public non_vectorial_image<E>
- {
- protected:
- decimal_image() {}
- };
-
- template <typename E>
- struct integer_image : public non_vectorial_image<E>
- {
- protected:
- integer_image() {}
- };
-
- template <typename E>
- struct binary_image : public non_vectorial_image<E>
- {
- protected:
- binary_image() {}
- };
-
-
- } // end of namespace oln::abstract
-
- template <typename T>
- struct vectorialness_from_valuetype
- {
- typedef typename mlc::bool_switch_<
-
- mlc::bool_case_<ntg_is_a(T, ntg::binary)::val,
- is_a<abstract::binary_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::integer)::val,
- is_a<abstract::integer_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::decimal)::val,
- is_a<abstract::decimal_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::vectorial)::val,
- is_a<abstract::vectorial_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::non_vectorial)::val,
- is_a<abstract::non_vectorial_image>,
-
- mlc::bool_case_<true,
- is_a<abstract::data_type_image> >
-
- > > > > > >::ret ret;
- };
-
- #define vectorialness_from_valuetype(T) \
- typename vectorialness_from_valuetype< T >::ret
- #define vectorialness_from_valuetype_(T) \
- vectorialness_from_valuetype< T >::ret
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 125)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -28,10 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
-# include <mlc/bool.hh>
-
-# include <ntg/basics.hh>
-
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image_operator.hh
===================================================================
--- oln/core/abstract/image_operator.hh (revision 125)
+++ oln/core/abstract/image_operator.hh (working copy)
@@ -56,6 +56,22 @@
struct set_super_type< abstract::image_binary_operator<O, I1, I2, E> > { typedef abstract::image_operator<O, E> ret; };
+ // FIXME: an extension of props; remove (test purpose!)
+ template <typename O, typename E>
+ struct set_props < category::image, abstract::image_operator<O, E> > : public props_of<category::image>
+ {
+ typedef float dummy_type;
+ };
+ template <typename O, typename E>
+ struct set_type_of < category::image,
+ abstract::image_operator<O, E>,
+ target::dummy_type >
+ {
+ typedef double ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
namespace abstract {
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 125)
+++ oln/core/abstract/entry.hh (working copy)
@@ -28,13 +28,9 @@
#ifndef OLENA_CORE_ABSTRACT_ENTRY_HH
# define OLENA_CORE_ABSTRACT_ENTRY_HH
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
-# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/images.hh>
-// FIXME: this file should move to oln/core/abstract/
namespace oln {
@@ -52,28 +48,17 @@
typedef category::image ret;
};
-
-
namespace abstract {
-// namespace internal {
-
-// template < typename isa, typename E >
-// struct inherits
-// {
-// typedef typename isa::template instantiated_with<E>::ret ret;
-// };
-
-// }
-
template <typename E>
struct image_entry :
// intrusive:
public oln_type_of_(E, image_constness) ::template instantiated_with<E>::ret,
public oln_type_of_(E, image_dimension) ::template instantiated_with<E>::ret,
public oln_type_of_(E, image_neighbness) ::template instantiated_with<E>::ret,
- public oln_type_of_(E, image_vectorialness) ::template instantiated_with<E>::ret
- // ...
+ // ...
+ public typeness::inheritance_switch<E>,
+ public valuedness::inheritance_switch<E>
{
protected:
image_entry() {}
Index: oln/core/abstract/images.hh
===================================================================
--- oln/core/abstract/images.hh (revision 125)
+++ oln/core/abstract/images.hh (working copy)
@@ -29,11 +29,19 @@
# define OLENA_CORE_ABSTRACT_IMAGES_HH
-# include <oln/core/abstract/internal/image_impl.hh>
+# include <oln/core/abstract/image.hh>
-
-# include <oln/core/abstract/image.hh>
+// hierarchies:
# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/abstract/image_valuedness.hh>
+// hierarchy entry
+# include <oln/core/abstract/entry.hh>
+
+
+
#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
===================================================================
--- oln/core/abstract/image_with_data.hh (revision 125)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -30,7 +30,6 @@
# include <mlc/tracked_ptr.hh>
-
# include <oln/core/abstract/entry.hh>
Index: oln/core/abstract/image_valuedness.hh
===================================================================
--- oln/core/abstract/image_valuedness.hh (revision 0)
+++ oln/core/abstract/image_valuedness.hh (revision 0)
@@ -0,0 +1,253 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------------------------------
+// | | | | |
+//
+// scalar_valued_image vector_valued_image label_valued_image data_valued_image ...
+
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct scalar_valued_image;
+ template <typename E> struct vector_valued_image;
+ template <typename E> struct label_valued_image;
+ template <typename E> struct data_valued_image;
+ }
+}
+namespace std {
+ template <class T, class A> class vector;
+ template <class T> class complex;
+}
+
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::valuedness
+ ** \brief oln::valuedness namespace.
+ */
+ namespace valuedness {
+
+ enum {
+ scalar_tag = 1,
+ vector_tag = 2,
+ label_tag = 3,
+ data_tag = 4
+ };
+
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ // scalar
+
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::float_value<E>*);
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::int_value<E>*);
+
+ static tag_is<scalar_tag> selector( signed int*);
+ static tag_is<scalar_tag> selector(unsigned int*);
+ static tag_is<scalar_tag> selector( signed char*);
+ static tag_is<scalar_tag> selector(unsigned char*);
+ static tag_is<scalar_tag> selector( signed short*);
+ static tag_is<scalar_tag> selector(unsigned short*);
+ static tag_is<scalar_tag> selector( signed long*);
+ static tag_is<scalar_tag> selector(unsigned long*);
+ static tag_is<scalar_tag> selector(float*);
+ static tag_is<scalar_tag> selector(double*);
+
+ // vector
+
+ template <unsigned n, typename V>
+ static tag_is<vector_tag> selector(V (*)[n]);
+ template <class V, class A>
+ static tag_is<vector_tag> selector(std::vector<V,A>*);
+ template <typename E>
+ static tag_is<vector_tag> selector(ntg::vect_value<E>*);
+ template <class V>
+ static tag_is<vector_tag> selector(std::complex<V>*);
+ template <ntg::cplx_representation R, class V>
+ static tag_is<vector_tag> selector(ntg::cplx<R,V>*);
+
+ // label
+
+ template <typename E>
+ static tag_is<label_tag> selector(ntg::enum_value<E>*);
+ static tag_is<label_tag> selector(bool*);
+ static tag_is<label_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_s<1,b>*);
+
+ // data
+
+ static tag_is<data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <unsigned tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <scalar_tag, E> : public abstract::scalar_valued_image<E> {};
+ template <typename E> struct inheritance_case <vector_tag, E> : public abstract::vector_valued_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public abstract::label_valued_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public abstract::data_valued_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < of< oln_type_of(E, value) >::val, E >
+ {
+ };
+
+
+ } // end of namespace oln::valuedness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::scalar_image<E>
+ **
+ ** Class of images containing scalar values.
+ */
+
+ template <typename E>
+ struct scalar_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ scalar_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::vector_valued_image<E>
+ **
+ ** Class of images containing vectorial values.
+ */
+
+ template <typename E>
+ struct vector_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ vector_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::label_valued_image<E>
+ **
+ ** Class of images containing label values.
+ */
+
+ template <typename E>
+ struct label_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::data_valued_image<E>
+ **
+ ** Class of images containing values that cannot be qualified of scalars,
+ ** vectors, or labels.
+ */
+
+ template <typename E>
+ struct data_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_valued_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
Index: oln/core/abstract/image_typeness.hh
===================================================================
--- oln/core/abstract/image_typeness.hh (revision 0)
+++ oln/core/abstract/image_typeness.hh (revision 0)
@@ -0,0 +1,258 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------
+// | | | | |
+//
+// greylevel_image color_image label_image data_image ...
+//
+// ^
+// |
+//
+// binary_image
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct greylevel_image;
+ template <typename E> struct color_image;
+ template <typename E> struct label_image;
+ template <typename E> struct binary_image;
+ template <typename E> struct data_image;
+ }
+}
+
+
+/// Macro.
+# define oln_typeness_of(T) typename typeness::tag_< typeness::of<T>::val >::ret
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::typeness
+ ** \brief oln::typeness namespace.
+ */
+ namespace typeness {
+
+ enum {
+ _greylevel_tag = 1,
+ _color_tag = 2,
+ _label_tag = 3,
+ _binary_tag = 4,
+ _data_tag = 5
+ };
+
+ struct greylevel_tag;
+ struct color_tag;
+ struct label_tag;
+ struct binary_tag;
+ struct data_tag;
+
+ template <int tag> struct tag_;
+ template <> struct tag_ <_greylevel_tag> { typedef greylevel_tag ret; };
+ template <> struct tag_ <_color_tag> { typedef color_tag ret; };
+ template <> struct tag_ <_label_tag> { typedef label_tag ret; };
+ template <> struct tag_ <_binary_tag> { typedef binary_tag ret; };
+ template <> struct tag_ <_data_tag> { typedef data_tag ret; };
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ template <typename E>
+ static tag_is<_color_tag> selector(ntg::color_value<E>*);
+
+ template <typename E>
+ static tag_is<_label_tag> selector(ntg::enum_value<E>*);
+
+ static tag_is<_binary_tag> selector(bool*);
+ static tag_is<_binary_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_s<1,b>*);
+
+ static tag_is<_data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <typename tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <greylevel_tag, E> : public abstract::greylevel_image<E> {};
+ template <typename E> struct inheritance_case <color_tag, E> : public abstract::color_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public abstract::label_image<E> {};
+ template <typename E> struct inheritance_case <binary_tag, E> : public abstract::binary_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public abstract::data_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < typename tag_< of<oln_type_of(E, value)>::val >::ret, E >
+ {
+ };
+
+
+ } // end of namespace oln::typeness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::greylevel_image<E>
+ **
+ ** Class of greylevel images. An image that contains values whose
+ ** type is 'int' or 'unsigned char', or 'ntg::int_u<8>' (...) is
+ ** NOT a greylevel image. FIXME: say more.
+ */
+
+ template <typename E>
+ struct greylevel_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ greylevel_image() {}
+ };
+
+
+
+ /*! \class abstract::color_image<E>
+ **
+ ** Class of color images.
+ */
+
+ template <typename E>
+ struct color_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ color_image() {}
+ };
+
+
+
+ /*! \class abstract::label_image<E>
+ **
+ ** Class of images whose data are labels. Such images do not
+ ** support arithmetics.
+ */
+
+ template <typename E>
+ struct label_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_image() {}
+ };
+
+
+
+ /*! \class abstract::binary_image<E>
+ **
+ ** Class of images whose data are Boolean values. Such images are
+ ** abstract::label_image.
+ */
+
+ template <typename E>
+ struct binary_image : public label_image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ binary_image() {}
+ };
+
+
+
+ /*! \class abstract::data_image<E>
+ **
+ ** Class of images whose data cannot be qualified of greylevels,
+ ** colors, or labels.
+ */
+
+ template <typename E>
+ struct data_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
Index: oln/core/1d/image1d.hh
===================================================================
--- oln/core/1d/image1d.hh (revision 125)
+++ oln/core/1d/image1d.hh (working copy)
@@ -31,9 +31,8 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/fwd_piter1d.hh>
@@ -44,7 +43,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter1d;
template <typename T> class image1d;
// category
@@ -65,7 +65,6 @@
// intrusive property:
typedef is_a<abstract::image1d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 125)
+++ oln/core/2d/image2d.hh (working copy)
@@ -30,12 +30,9 @@
# include <mlc/traits.hh>
-# include <oln/core/abstract/image_like_.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/fwd_piter2d.hh>
-# include <oln/core/2d/bkd_piter2d.hh>
/*! \namespace oln
@@ -53,7 +50,9 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter2d;
+ struct bkd_piter2d;
template <typename T> class image2d;
// category
@@ -74,7 +73,6 @@
// intrusive property:
typedef is_a<abstract::image2d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/3d/image3d.hh
===================================================================
--- oln/core/3d/image3d.hh (revision 125)
+++ oln/core/3d/image3d.hh (working copy)
@@ -31,10 +31,10 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/3d/array3d.hh>
-# include <oln/core/3d/fwd_piter3d.hh>
+
/*! \namespace oln
** \brief oln namespace.
*/
@@ -42,7 +42,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter3d;
template <typename T> class image3d;
// category
@@ -63,7 +64,6 @@
// intrusive property:
typedef is_a<abstract::image3d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/makefile.src
===================================================================
--- oln/makefile.src (revision 125)
+++ oln/makefile.src (working copy)
@@ -47,7 +47,8 @@
core/abstract/image_dimension.hh \
core/abstract/image_like_.hh \
core/abstract/image_operator.hh \
- core/abstract/image_vectorialness.hh \
+ core/abstract/image_typeness.hh \
+ core/abstract/image_valuedness.hh \
core/abstract/image_with_data.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 125)
+++ oln/morpho/stat.hh (working copy)
@@ -154,7 +154,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- max(const abstract::non_vectorial_image<I>& input,
+ max(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
const abstract::struct_elt<E>& se)
{
@@ -176,7 +176,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- min(const abstract::non_vectorial_image<I>& input,
+ min(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
// const mlc_exact_type(I)::iter_type& p,
const abstract::struct_elt<E>& se)
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 125)
+++ oln/morpho/erosion.hh (working copy)
@@ -120,8 +120,35 @@
};
+
+ // FIXME: remove (test purpose!)
+ // fwd decl
namespace morpho {
+ namespace impl {
+ template <typename I, typename S> struct generic_erosion;
+ }
+ }
+ // category
+ template <typename I, typename S>
+ struct set_category< morpho::impl::generic_erosion<I,S> > { typedef category::image ret; };
+ // super_type
+ template <typename I, typename S>
+ struct set_super_type< morpho::impl::generic_erosion<I,S> >
+ {
+ typedef morpho::erosion_ret<I,S> ret;
+ };
+ template <typename I, typename S>
+ struct set_type_of< category::image, morpho::impl::generic_erosion<I,S>, target::dummy_type >
+ {
+ typedef S ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
+
+ namespace morpho {
+
/// Erosion return.
template <typename I, typename E>
@@ -142,6 +169,7 @@
};
+
namespace impl {
/// Erosion generic implementation.
Index: oln/arith/ops.hh
===================================================================
--- oln/arith/ops.hh (revision 125)
+++ oln/arith/ops.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_ARITH_OPS_HH
# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/pw/all.hh>
@@ -130,4 +131,19 @@
+template <typename I, typename F>
+void operator + (const oln::abstract::image<I>&,
+ const oln::pw::abstract::function<F>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+template <typename F, typename I>
+void operator + (const oln::pw::abstract::function<F>&,
+ const oln::abstract::image<I>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+// FIXME: to be continued...
+
+
#endif // ! OLENA_ARITH_OPS_HH
Index: oln/arith/logic.hh
===================================================================
--- oln/arith/logic.hh (revision 0)
+++ oln/arith/logic.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_LOGIC_OPS_HH
+# define OLENA_LOGIC_OPS_HH
+
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/all.hh>
+
+
+/// Operator 'and' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::and_ > >
+operator && (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
+}
+
+
+/// Operator 'or' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::or_ > >
+operator || (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
+}
+
+
+/// Unary operator 'not' on a binary image.
+
+template <typename I>
+oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
+operator ! (const oln::abstract::binary_image<I>& rhs)
+{
+ return oln::for_all_p(!oln::p_value(rhs));
+}
+
+
+
+#endif // ! OLENA_LOGIC_OPS_HH
1
0