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));
}