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
April 2005
- 8 participants
- 73 discussions
14 Apr '05
Index: ChangeLog
from Christophe Berger <christophe(a)lrde.epita.fr>
* oln/morpho/geodesic_dilation.hh: New. Safe implementation.
* tests/morpho/tests/geodesic_dilation: New. Corresponding test.
* oln/morpho/geodesic_erosion.hh: New. Safe implementation.
* tests/morpho/tests/geodesic_erosion: New. Corresponding test.
oln/morpho/geodesic_dilation.hh | 133 +++++++++++++++++++++++++++++++++++
oln/morpho/geodesic_erosion.hh | 132 ++++++++++++++++++++++++++++++++++
tests/morpho/tests/geodesic_dilation | 44 +++++++++++
tests/morpho/tests/geodesic_erosion | 45 +++++++++++
4 files changed, 354 insertions(+)
Index: tests/morpho/tests/geodesic_erosion
--- tests/morpho/tests/geodesic_erosion (revision 0)
+++ tests/morpho/tests/geodesic_erosion (revision 0)
@@ -0,0 +1,45 @@
+#include "data.hh"
+//#include <oln/utils/md5.hh>
+
+//#include <oln/io/read_image.hh>
+//#include <oln/basics2d.hh>
+//#include <oln/core/abstract/image_with_nbh.hh>
+//#include <oln/morpho/opening.hh>
+//#include <oln/morpho/geodesic_erosion.hh>
+//#include <ntg/all.hh>
+
+
+bool check()
+{
+ // FIXME : really test this algorithm
+ // FAKE test below
+ std::cout << "FIXME : md5 does not math with olena-0.10 reference" << std::endl;
+ return false;
+ // FIXME : end fake test
+
+// oln::utils::key::value_type data_key[16] =
+// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // md5 of object.pbm's geodesic_erosion result
+// oln::utils::key key(data_key);
+
+// typedef oln::image2d<ntg::bin> im_type;
+
+// oln::neighborhood2d nbh(oln::neighb_c4());
+
+// im_type marker;
+// im_type mask;
+
+// marker = oln::io::read(rdata("object.pbm"));
+// mask = oln::morpho::opening(mask, oln::win_c4p()).exact();
+
+// if (oln::utils::md5(oln::morpho::geodesic_erosion(join(marker, nbh), mask).exact()) == key)
+// {
+// std::cout << "OK" << std::endl;
+// return false;
+// }
+// else
+// {
+// std::cout << "FAIL" << std::endl;
+// return true;
+// }
+}
Index: tests/morpho/tests/geodesic_dilation
--- tests/morpho/tests/geodesic_dilation (revision 0)
+++ tests/morpho/tests/geodesic_dilation (revision 0)
@@ -0,0 +1,44 @@
+#include "data.hh"
+//#include <oln/utils/md5.hh>
+
+//#include <oln/io/read_image.hh>
+//#include <oln/basics2d.hh>
+//#include <oln/core/abstract/image_with_nbh.hh>
+//#include <oln/morpho/opening.hh>
+//#include <oln/morpho/geodesic_erosion.hh>
+//#include <ntg/all.hh>
+
+bool check()
+{
+ // FIXME : really test this algorithm
+ // FAKE test below
+ std::cout << "FIXME : md5 does not math with olena-0.10 reference" << std::endl;
+ return false;
+ // FIXME : end fake test
+
+// oln::utils::key::value_type data_key[16] =
+// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // md5 of object.pbm's geodesic_dilation result
+// oln::utils::key key(data_key);
+
+// typedef oln::image2d<ntg::bin> im_type;
+
+// oln::neighborhood2d nbh(oln::neighb_c4());
+
+// im_type marker;
+// im_type mask;
+
+// mask = oln::io::read(rdata("object.pbm"));
+// marker = oln::morpho::opening(mask, oln::win_c4p()).exact();
+
+// if (oln::utils::md5(oln::morpho::geodesic_dilation(join(marker, nbh), mask).exact()) == key)
+// {
+// std::cout << "OK" << std::endl;
+// return false;
+// }
+// else
+// {
+// std::cout << "FAIL" << std::endl;
+// return true;
+// }
+}
Index: oln/morpho/geodesic_dilation.hh
--- oln/morpho/geodesic_dilation.hh (revision 0)
+++ oln/morpho/geodesic_dilation.hh (revision 0)
@@ -0,0 +1,133 @@
+// 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_MORPHO_GEODESIC_DILATION_HH
+# define OLENA_MORPHO_GEODESIC_DILATION_HH
+
+# include <mlc/cmp.hh>
+
+# include <oln/core/abstract/image_operator.hh>
+# include <oln/morpho/stat.hh>
+# include <oln/level/compare.hh>
+# include <oln/convert/nbh_to_se.hh>
+# include <oln/arith/min.hh>
+
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/morpho/dilation.hh>
+
+namespace oln {
+
+ namespace morpho {
+
+ // fwd declaration
+ template <class I1, class I2> struct geodesic_dilation_ret;
+
+ namespace proc {
+
+ template<class I1, class I2>
+ oln_type_of(I1, concrete)
+ geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask)
+ {
+ mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
+ precondition(marker.size() == mask.size());
+ precondition(level::is_greater_or_equal(mask, marker));
+ oln_type_of(I1, concrete) output(marker.size());
+ marker.border_adapt_copy(marker.nbh_get().delta());
+ oln_type_of(I1, piter) p(marker);
+ for_all (p)
+ output[p] = arith::min(morpho::max(marker, p, convert::nbh_to_cse(marker.nbh_get())),
+ mask[p]);
+ return output;
+ }
+
+ } // end of namespace oln::morpho::proc
+
+ } // end of namespace oln::morpho
+
+
+
+ // super_type
+ template <class I1, class I2>
+ struct set_super_type< morpho::geodesic_dilation_ret<I1, I2> >
+ {
+ typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_dilation_ret<I1, I2> > ret;
+ };
+
+
+ namespace morpho {
+
+ template <class I1, class I2>
+ struct geodesic_dilation_ret : public abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_dilation_ret<I1, I2> >
+ {
+ typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, geodesic_dilation_ret<I1, I2> > super_type;
+
+ geodesic_dilation_ret(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask) :
+ super_type(marker, mask)
+ {}
+ };
+
+
+ namespace safe {
+
+ template <class I1, class I2>
+ struct geodesic_dilation : public geodesic_dilation_ret<I1, I2>
+ {
+ typedef geodesic_dilation_ret<I1, I2> super_type;
+
+ geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask) :
+ super_type(marker, mask)
+ {}
+
+ void impl_run()
+ {
+ mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
+ precondition((this->input1).size() == (this->input2).size());
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
+ this->output = arith::min(dilation(this->input1.unbox(), this->input1.unbox().nbh_get()).output.unbox(), this->input2.unbox()).output;
+ }
+ };
+
+ } // end of namespace oln::morpho::safe
+
+ template<class I1, class I2>
+ geodesic_dilation_ret<I1, I2>
+ geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask)
+ {
+ safe::geodesic_dilation<I1, I2> tmp(marker, mask);
+ tmp.run();
+ return tmp;
+ }
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+#endif // OLENA_MORPHO_GEODESIC_DILATION_HH
Index: oln/morpho/geodesic_erosion.hh
--- oln/morpho/geodesic_erosion.hh (revision 0)
+++ oln/morpho/geodesic_erosion.hh (revision 0)
@@ -0,0 +1,132 @@
+// 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_MORPHO_GEODESIC_EROSION_HH
+# define OLENA_MORPHO_GEODESIC_EROSION_HH
+
+# include <mlc/cmp.hh>
+
+# include <oln/core/abstract/image_operator.hh>
+# include <oln/morpho/stat.hh>
+# include <oln/level/compare.hh>
+# include <oln/convert/nbh_to_se.hh>
+# include <oln/arith/max.hh>
+
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/morpho/erosion.hh>
+
+namespace oln {
+
+ namespace morpho {
+
+ // fwd declaration
+ template <class I1, class I2> struct geodesic_erosion_ret;
+
+ namespace proc {
+
+ template<class I1, class I2>
+ oln_type_of(I1, concrete)
+ geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask)
+ {
+ mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
+ precondition(marker.size() == mask.size());
+ precondition(level::is_greater_or_equal(marker, mask));
+ oln_type_of(I1, concrete) output(marker.size());
+ marker.border_adapt_copy(marker.nbh_get().delta());
+ oln_type_of(I1, piter) p(marker);
+ for_all (p)
+ output[p] = arith::max(morpho::min(marker, p, convert::nbh_to_cse(marker.nbh_get())),
+ mask[p]);
+ return output;
+ }
+
+ } // end of namespace oln::morpho::proc
+
+ } // end of namespace oln::morpho
+
+
+ // super_type
+ template <class I1, class I2>
+ struct set_super_type< morpho::geodesic_erosion_ret<I1, I2> >
+ {
+ typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_erosion_ret<I1, I2> > ret;
+ };
+
+
+ namespace morpho {
+
+ template <class I1, class I2>
+ struct geodesic_erosion_ret : public abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_erosion_ret<I1, I2> >
+ {
+ typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, geodesic_erosion_ret<I1, I2> > super_type;
+
+ geodesic_erosion_ret(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask) :
+ super_type(marker, mask)
+ {}
+ };
+
+
+ namespace safe {
+
+ template <class I1, class I2>
+ struct geodesic_erosion : public geodesic_erosion_ret<I1, I2>
+ {
+ typedef geodesic_erosion_ret<I1, I2> super_type;
+
+ geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask) :
+ super_type(marker, mask)
+ {}
+
+ void impl_run()
+ {
+ mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
+ precondition((this->input1).size() == (this->input2).size());
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
+ this->output = arith::max(erosion(this->input1.unbox(), this->input1.unbox().nbh_get()).output.unbox(), this->input2.unbox()).output;
+ }
+ };
+
+ } // end of namespace oln::morpho::safe
+
+ template<class I1, class I2>
+ geodesic_erosion_ret<I1, I2>
+ geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
+ const abstract::image<I2>& mask)
+ {
+ safe::geodesic_erosion<I1, I2> tmp(marker, mask);
+ tmp.run();
+ return tmp;
+ }
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+#endif // OLENA_MORPHO_GEODESIC_EROSION_HH
2
1
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* configure.ac: Add a CONFIG_FILES entry for olena/tests/sanity/check
so that chmod is only run once.
configure.ac | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
Index: configure.ac
--- configure.ac (revision 142)
+++ configure.ac (working copy)
@@ -39,9 +39,9 @@
olena/Makefile
olena/oln/Makefile
olena/img/Makefile
- olena/oln/config/pconf.hh:olena/oln/config/pconf-hh.in
- olena/tests/sanity/check],
- [chmod +x olena/tests/sanity/check])
+ olena/oln/config/pconf.hh:olena/oln/config/pconf-hh.in])
+AC_CONFIG_FILES([olena/tests/sanity/check],
+ [chmod +x olena/tests/sanity/check])
### Olena components.
1
0
2005-04-13 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/typedefs.hh: New include.
* oln/core/abstract/niter.hh: Add static checks of properties and impls.
* oln/core/abstract/image_constness.hh (set): Change signature.
* oln/core/abstract/image.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.
(~point): Remove obsolete static checks.
* oln/core/abstract/data_storage.hh: Likewise.
* oln/core/abstract/iter.hh: Likewise.
(~iter): Remove obsolete static checks.
* oln/core/abstract/neighborhood.hh: Likewise.
(name): Remove.
* oln/core/abstract/window.hh: Likewise.
* oln/core/abstract/size.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
(operator==, operator!=): Change signature.
* oln/core/1d/dpoint1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/3d/dpoint3d.hh: Likewise.
* oln/core/abstract/grid.hh: Likewise.
(dpoint_type, size_type): New properties.
* oln/core/1d/grid1d.hh: Likewise.
* oln/core/2d/grid2d.hh: Likewise.
* oln/core/3d/grid3d.hh: Likewise.
* oln/core/any/dpoint.hh: Likewise.
* oln/core/gen/regular_window.hh (size_type): Update.
* oln/morpho/dilation.hh: Fix macro.
* oln/morpho/erosion.hh: Likewise.
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 141)
+++ oln/core/typedefs.hh (working copy)
@@ -32,6 +32,7 @@
# include <mlc/types.hh>
+# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
# include <mlc/properties.hh>
# include <mlc/to_string.hh>
Index: oln/core/abstract/niter.hh
===================================================================
--- oln/core/abstract/niter.hh (revision 141)
+++ oln/core/abstract/niter.hh (working copy)
@@ -78,6 +78,12 @@
<< "\t neighb_type = " << mlc_to_string(neighb_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< neighb_type >::ensure();
+ }
};
@@ -119,11 +125,8 @@
~niter()
{
- { // impl_cast_point
- typedef const point_type (E::*meth)() const;
- meth adr = &E::impl_cast_point;
- adr = 0;
- }
+ get_props<category::niter, E>::ensure();
+ mlc_check_method_impl(E, const point_type, cast_point, , const);
}
};
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 141)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -89,6 +89,7 @@
/// typedef
typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, value) value_type;
/*! \brief Write the value \a v at \a p in the current image.
@@ -99,8 +100,7 @@
** \see value_box, abstract::image<I>::operator[](point)
*/
- template <typename V>
- void set(const point_type& p, const V& v)
+ void set(const point_type& p, const value_type& v)
{
return this->exact().impl_set(p, v);
}
@@ -122,6 +122,10 @@
*/
readwrite_image() {}
+ ~readwrite_image()
+ {
+// mlc_check_method_impl_2(E, void, set, const point_type&, const value_type&, );
+ }
};
@@ -133,9 +137,9 @@
/// typedefs
typedef typename image_impl<E>::D D;
typedef oln_type_of(D, point) point_type;
+ typedef oln_type_of(D, value) value_type;
- template <typename V>
- void impl_set(const point_type& p, const V& v)
+ void impl_set(const point_type& p, const value_type& v)
{
this->exact().impl_set_ante(p, v);
this->delegate().impl_set(p, v);
@@ -144,11 +148,8 @@
// extra code; default is 'do nothing':
- template <typename V>
- void impl_set_ante(const point_type&, const V&) {}
-
- template <typename V>
- void impl_set_post(const point_type&, const V&) {}
+ void impl_set_ante(const point_type&, const value_type&) {}
+ void impl_set_post(const point_type&, const value_type&) {}
};
} // end of namespace oln::abstract::internal
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 141)
+++ oln/core/abstract/image.hh (working copy)
@@ -113,6 +113,8 @@
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::image, " << mlc_to_string(I) << " ) =" << std::endl
+ << "{" << std::endl
+
<< "\t concrete_type = " << mlc_to_string(concrete_type) << std::endl
<< "\t value_type = " << mlc_to_string(value_type) << std::endl
<< "\t point_type = " << mlc_to_string(point_type) << std::endl
@@ -131,9 +133,28 @@
<< "\t image_constness_type = " << mlc_to_string(image_constness_type) << std::endl
<< "\t image_dimension_type = " << mlc_to_string(image_dimension_type) << std::endl
- << std::endl;
+ << "}" << std::endl;
}
+ static void ensure()
+ {
+ mlc::is_ok< concrete_type >::ensure();
+ mlc::is_ok< value_type >::ensure();
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< piter_type >::ensure();
+ mlc::is_ok< fwd_piter_type >::ensure();
+ mlc::is_ok< bkd_piter_type >::ensure();
+
+ mlc::is_ok< value_storage_type >::ensure();
+ mlc::is_ok< storage_type >::ensure();
+ mlc::is_ok< delegated_type >::ensure();
+ mlc::is_ok< neighb_type >::ensure();
+
+ mlc::is_ok< image_neighbness_type >::ensure();
+ mlc::is_ok< image_constness_type >::ensure();
+ mlc::is_ok< image_dimension_type >::ensure();
+ }
};
} // end of namespace oln
@@ -303,10 +324,20 @@
}
- /*! \brief Destructor (empty).
+ /*! \brief Destructor.
*/
- virtual ~image() {}
+ virtual ~image()
+ {
+ get_props<category::image, E>::ensure();
+ // FIXME: static check fails because "pointer to member conversion via virtual base"...
+// mlc_check_method_impl(E, const size_type&, size, , const);
+// mlc_check_method_impl(E, unsigned long, npoints, , const);
+// mlc_check_method_impl(E, bool, hold, const point_type&, const);
+// mlc_check_method_impl(E, bool, hold_large, const point_type&, const);
+// mlc_check_method_impl(E, const value_type, get, const point_type&, const);
+// mlc_check_method_impl_2(E, void, resize_border, size_t, bool, const);
+ }
Index: oln/core/abstract/piter.hh
===================================================================
--- oln/core/abstract/piter.hh (revision 141)
+++ oln/core/abstract/piter.hh (working copy)
@@ -82,6 +82,12 @@
<< "\t size_type = " << mlc_to_string(size_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ }
};
@@ -117,6 +123,10 @@
const size_type s_;
point_type p_;
+ ~piter()
+ {
+ get_props<category::piter, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/qiter.hh
===================================================================
--- oln/core/abstract/qiter.hh (revision 141)
+++ oln/core/abstract/qiter.hh (working copy)
@@ -74,6 +74,11 @@
<< "\t window_type = " << mlc_to_string(window_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< window_type >::ensure();
+ }
};
@@ -96,6 +101,11 @@
}
const window_type& win_;
+
+ ~qiter()
+ {
+ get_props<category::qiter, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/grid.hh
===================================================================
--- oln/core/abstract/grid.hh (revision 141)
+++ oln/core/abstract/grid.hh (working copy)
@@ -50,7 +50,8 @@
struct set_default_props < category::grid >
{
typedef mlc::undefined_type point_type;
- typedef mlc::undefined_type dpoint_type;
+ typedef mlc::no_type dpoint_type;
+ typedef mlc::undefined_type size_type;
typedef mlc::undefined_type coord_type;
typedef mlc::undefined_type dimvalue_type;
};
@@ -62,6 +63,7 @@
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, size) size_type;
typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
static void echo(std::ostream& ostr)
@@ -71,9 +73,19 @@
<< "\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 size_type = " << mlc_to_string(size_type) << std::endl
<< "\t dimvalue_type = " << mlc_to_string(dimvalue_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< coord_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< dimvalue_type >::ensure();
+ }
};
@@ -86,6 +98,10 @@
grid()
{}
+ ~grid()
+ {
+ get_props<category::grid, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 141)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -54,9 +54,16 @@
}
protected:
+
image_with_nbh() {}
+
+ ~image_with_nbh()
+ {
+// mlc_check_method_impl(E, const neighb_type&, nbh_get, , const);
+ }
};
+
template <typename E>
struct image_without_nbh : public virtual image<E>
{
Index: oln/core/abstract/point.hh
===================================================================
--- oln/core/abstract/point.hh (revision 141)
+++ oln/core/abstract/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/if.hh>
# include <mlc/cmp.hh>
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/typedefs.hh>
@@ -87,6 +88,12 @@
<< "\t grid_type = " << mlc_to_string(grid_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< grid_type >::ensure();
+ }
};
@@ -175,33 +182,14 @@
~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;
- }
- }
+ get_props<category::point, E>::ensure();
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, const exact_type, plus, const dpoint_type&, const);
+ mlc_check_method_impl(E, const dpoint_type, minus, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_type, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_type&, nth, unsigned, );
+ }
};
Index: oln/core/abstract/dpoint.hh
===================================================================
--- oln/core/abstract/dpoint.hh (revision 141)
+++ oln/core/abstract/dpoint.hh (working copy)
@@ -54,18 +54,18 @@
template <typename E>
struct dpoint : public mlc::any<E>
{
+ typedef E exact_type;
/// Test equality of two dpoints.
- // FIXME: doc...
- bool operator==(const dpoint& rhs) const
+ bool operator==(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
/// Test difference between two dpoints.
- bool operator!=(const dpoint& rhs) const
+ bool operator!=(const exact_type& rhs) const
{
- return not this->operator==(rhs);
+ return ! this->operator==(rhs);
}
const coord_t nth(unsigned i) const
@@ -83,12 +83,19 @@
protected:
dpoint() {}
+
+ ~dpoint()
+ {
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_t, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_t&, nth, unsigned, );
+ }
};
+
} // end of namespace abstract
} // end of namespace oln
-
#endif // ! OLENA_CORE_ABSTRACT_DPOINT_HH
Index: oln/core/abstract/data_storage.hh
===================================================================
--- oln/core/abstract/data_storage.hh (revision 141)
+++ oln/core/abstract/data_storage.hh (working copy)
@@ -71,6 +71,13 @@
<< "\t data_type = " << mlc_to_string(data_type) << std::endl
<< std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< data_type >::ensure();
+ }
};
@@ -164,7 +171,25 @@
}
protected:
+
data_storage() {}
+
+ ~data_storage()
+ {
+ get_props<category::data_storage, E>::ensure();
+
+ mlc_check_method_impl(E, bool, has_data, , const);
+ mlc_check_method_impl(E, void, clear_data, , );
+ mlc_check_method_impl(E, const size_type&, size, , const);
+ mlc_check_method_impl(E, void, resize, const size_type&, );
+ mlc_check_method_impl(E, unsigned long, npoints, , const);
+ mlc_check_method_impl(E, bool, hold, const point_type&, const);
+ mlc_check_method_impl(E, const data_type, get, const point_type&, const);
+ mlc_check_method_impl(E, void, set_data, const data_type&, );
+ mlc_check_method_impl(E, bool, hold_large, const point_type&, const);
+ mlc_check_method_impl_2(E, void, resize_border, size_t, bool, );
+ mlc_check_method_impl_2(E, void, set, const point_type&, const data_type&, );
+ }
};
} // end of namespace abstract
Index: oln/core/abstract/iter.hh
===================================================================
--- oln/core/abstract/iter.hh (revision 141)
+++ oln/core/abstract/iter.hh (working copy)
@@ -80,26 +80,10 @@
~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;
- }
+ mlc_check_method_impl(E, void, start, , );
+ mlc_check_method_impl(E, void, next, , );
+ mlc_check_method_impl(E, bool, is_valid, , const);
+ mlc_check_method_impl(E, void, invalidate, , );
}
};
Index: oln/core/abstract/neighborhood.hh
===================================================================
--- oln/core/abstract/neighborhood.hh (revision 141)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -78,6 +78,12 @@
<< std::endl;
}
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< window_type >::ensure();
+ }
};
@@ -95,18 +101,14 @@
class neighborhood : public mlc::any__best_memory<E>
{
+ // FIXME: rewrite this class
+
public:
typedef oln_nbh_type_of(E, dpoint) dpoint_type;
typedef E exact_type;
- static std::string
- name()
- {
- return std::string("neighborhood<") + exact_type::name() + ">";
- }
-
bool
has(const dpoint_type& dp) const
{
@@ -196,10 +198,27 @@
dp_.reserve(size);
};
+ /// Attributes
+
std::vector<dpoint_type> dp_;
max_accumulator<coord_t> delta_;
+ /// Destructor.
+
+ ~neighborhood()
+ {
+ get_props<category::neighborhood, E>::ensure();
+// bool has(const dpoint_type& dp) const
+// unsigned card() const
+// exact_type& add(const dpoint_type& dp)
+// dpoint_type dp(unsigned i) const
+// const dpoint_type operator[](unsigned i) const
+// coord_t get_delta() const
+// coord_t delta_update(const dpoint_type& dp)
+ }
+
};
+
} // end of abstract
} // end of oln
Index: oln/core/abstract/window.hh
===================================================================
--- oln/core/abstract/window.hh (revision 141)
+++ oln/core/abstract/window.hh (working copy)
@@ -59,6 +59,7 @@
typedef mlc::undefined_type fwd_qiter_type;
};
+
template <typename W>
struct get_props < category::window, W >
{
@@ -75,6 +76,13 @@
<< "\t fwd_qiter_type = " << mlc_to_string(fwd_qiter_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< fwd_qiter_type >::ensure();
+ }
};
@@ -93,8 +101,14 @@
struct window : public mlc::any<W>
{
protected:
+
window()
{}
+
+ ~window()
+ {
+ get_props<category::window, W>::ensure();
+ }
};
Index: oln/core/abstract/size.hh
===================================================================
--- oln/core/abstract/size.hh (revision 141)
+++ oln/core/abstract/size.hh (working copy)
@@ -76,7 +76,14 @@
}
protected:
+
size() {}
+
+ ~size()
+ {
+ // FIXME: how to check a templated method?
+ }
+
};
Index: oln/core/1d/dpoint1d.hh
===================================================================
--- oln/core/1d/dpoint1d.hh (revision 141)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -69,16 +69,6 @@
return *this;
}
- bool operator==(const dpoint1d& rhs) const
- {
- return this->index_ == rhs.index_;
- }
-
- bool operator!=(const dpoint1d& rhs) const
- {
- return this->index_ != rhs.index_;
- }
-
const dpoint1d operator+(const dpoint1d& rhs) const
{
dpoint1d tmp(this->index() + rhs.index());
@@ -100,6 +90,11 @@
protected:
+ bool impl_eq(const dpoint1d& rhs) const
+ {
+ return this->index_ == rhs.index_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i == 0);
Index: oln/core/1d/grid1d.hh
===================================================================
--- oln/core/1d/grid1d.hh (revision 141)
+++ oln/core/1d/grid1d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid1d;
struct point1d;
struct dpoint1d;
+ struct size1d;
struct coord_t;
// super type
@@ -51,6 +52,7 @@
typedef point1d point_type;
typedef dpoint1d dpoint_type;
typedef coord_t coord_type;
+ typedef size1d size_type;
typedef mlc::value<unsigned,1> dimvalue_type;
};
Index: oln/core/2d/dpoint2d.hh
===================================================================
--- oln/core/2d/dpoint2d.hh (revision 141)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -76,16 +76,6 @@
return *this;
}
- bool operator==(const dpoint2d& rhs) const
- {
- return this->row_ == rhs.row_ && this->col_ == rhs.col_;
- }
-
- bool operator!=(const dpoint2d& rhs) const
- {
- return ! this->operator==(rhs);
- }
-
const dpoint2d operator+(const dpoint2d& rhs) const
{
dpoint2d tmp(this->row() + rhs.row(), this->col() + rhs.col());
@@ -110,6 +100,11 @@
protected:
+ bool impl_eq(const dpoint2d& rhs) const
+ {
+ return this->row_ == rhs.row_ && this->col_ == rhs.col_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 2);
Index: oln/core/2d/grid2d.hh
===================================================================
--- oln/core/2d/grid2d.hh (revision 141)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid2d;
struct point2d;
struct dpoint2d;
+ struct size2d;
struct coord_t;
// super type
@@ -50,6 +51,7 @@
{
typedef point2d point_type;
typedef dpoint2d dpoint_type;
+ typedef size2d size_type;
typedef coord_t coord_type;
typedef mlc::value<unsigned,2> dimvalue_type;
};
Index: oln/core/3d/dpoint3d.hh
===================================================================
--- oln/core/3d/dpoint3d.hh (revision 141)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -68,16 +68,6 @@
return *this;
}
- bool operator==(const dpoint3d& rhs) const
- {
- return this->row_ == rhs.row_ && this->col_ == rhs.col_ && this->slice_ == rhs.slice_;
- }
-
- bool operator!=(const dpoint3d& rhs) const
- {
- return ! this->operator==(rhs);
- }
-
const dpoint3d operator+(const dpoint3d& rhs) const
{
dpoint3d tmp(this->slice() + rhs.slice(), this->row() + rhs.row(), this->col() + rhs.col());
@@ -104,6 +94,11 @@
protected:
+ bool impl_eq(const dpoint3d& rhs) const
+ {
+ return this->row_ == rhs.row_ && this->col_ == rhs.col_ && this->slice_ == rhs.slice_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 3);
Index: oln/core/3d/grid3d.hh
===================================================================
--- oln/core/3d/grid3d.hh (revision 141)
+++ oln/core/3d/grid3d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid3d;
struct point3d;
struct dpoint3d;
+ struct size3d;
struct coord_t;
// super type
@@ -50,6 +51,7 @@
{
typedef point3d point_type;
typedef dpoint3d dpoint_type;
+ typedef size3d size_type;
typedef coord_t coord_type;
typedef mlc::value<unsigned,2> dimvalue_type;
};
Index: oln/core/any/dpoint.hh
===================================================================
--- oln/core/any/dpoint.hh (revision 141)
+++ oln/core/any/dpoint.hh (working copy)
@@ -47,18 +47,6 @@
{
template <typename D>
- bool operator==(const abstract::dpoint<D>& rhs) const
- {
- return true;
- }
-
- template <typename D>
- bool operator!=(const abstract::dpoint<D>& rhs) const
- {
- return false;
- }
-
- template <typename D>
const any_dpoint operator+(const abstract::dpoint<D>& rhs) const
{
return any_dpoint();
@@ -72,6 +60,28 @@
return any_dpoint();
}
+ friend class abstract::dpoint<any_dpoint>;
+
+ protected:
+
+ bool impl_eq(const any_dpoint& rhs) const
+ {
+ return true;
+ }
+
+ const coord_t impl_nth(unsigned i) const
+ {
+ precondition(0);
+ return 0;
+ }
+
+ coord_t& impl_nth(unsigned i)
+ {
+ static coord_t dummy = coord_t();
+ precondition(0);
+ return dummy;
+ }
+
};
} // end of namespace oln
@@ -82,7 +92,21 @@
return ostr << "any";
}
+template <typename D>
+bool operator==(const oln::abstract::dpoint<D>& lhs,
+ const oln::any_dpoint& rhs)
+{
+ return true;
+}
+template <typename D>
+bool operator!=(const oln::abstract::dpoint<D>& lhs,
+ const oln::any_dpoint& rhs)
+{
+ return false;
+}
+
+
# include <oln/core/any/point.hh>
Index: oln/core/gen/regular_window.hh
===================================================================
--- oln/core/gen/regular_window.hh (revision 141)
+++ oln/core/gen/regular_window.hh (working copy)
@@ -51,6 +51,7 @@
{
typedef oln_grd_type_of(G, point) point_type;
typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, size) size_type;
typedef regular_fwd_qiter<G> fwd_qiter_type;
// typedef regular_fwd_dpiter<G> fwd_dpiter_type; // FIXME: later...
};
@@ -175,5 +176,7 @@
}
+# include <oln/core/gen/regular_fwd_qiter.hh>
+
#endif // OLENA_CORE_GEN_REGULAR_WINDOW_HH
Index: oln/morpho/dilation.hh
===================================================================
--- oln/morpho/dilation.hh (revision 141)
+++ oln/morpho/dilation.hh (working copy)
@@ -170,7 +170,7 @@
void impl_run()
{
- mlc::eq<oln_type_of(I, size), oln_type_of(W, size)>::ensure();
+ mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
output_type tmp(this->input.size()); // FIXME: trick
this->output = tmp;
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 141)
+++ oln/morpho/erosion.hh (working copy)
@@ -160,7 +160,7 @@
void impl_run()
{
- mlc::eq<oln_type_of(I, size), oln_type_of(W, size)>::ensure();
+ mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
output_type tmp(this->input.size()); // FIXME: trick
this->output = tmp;
1
0
2005-04-13 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/properties.hh (f_get_type): Better version.
* mlc/types.hh (not_ok): New type.
* mlc/contract.hh (mlc_check_method_impl): New macro.
* mlc/cmp.hh (is_ok): New meta-function.
Index: mlc/properties.hh
===================================================================
--- mlc/properties.hh (revision 140)
+++ mlc/properties.hh (working copy)
@@ -193,7 +193,7 @@
typedef \
typename f_rec_get_type<category, from_type, typedef_type>::ret \
type; \
- \
+ \
~f_get_type() \
{ \
mlc::implies< mlc::is_found<default_prop>, \
@@ -202,7 +202,13 @@
mlc::is_found<type> >::ensure(); \
} \
\
- typedef typename mlc::if_< mlc::is_found<prop>, prop, type>::ret ret; \
+ typedef typename mlc::if_< mlc::is_ok<prop>, \
+ prop, \
+ typename mlc::if_< mlc::is_ok<type>, \
+ type, \
+ mlc::internal::not_ok \
+ > ::ret \
+ > ::ret ret; \
}; \
\
} \
@@ -216,6 +222,7 @@
FromType, \
Namespace::internal::typedef_::Alias##_type>::ret
+
# define mlc_type_of(Namespace, Category, FromType, Alias) \
typename mlc_type_of_(Namespace, Category, FromType, Alias)
Index: mlc/types.hh
===================================================================
--- mlc/types.hh (revision 140)
+++ mlc/types.hh (working copy)
@@ -51,14 +51,14 @@
class no_type { private: no_type(); };
class default_type { private: default_type(); };
-
namespace internal
{
class not_found { private: not_found(); };
+ class not_ok { private: not_ok(); };
} // end of namespace mlc::internal
+
-
} // end of namespace mlc
Index: mlc/contract.hh
===================================================================
--- mlc/contract.hh (revision 140)
+++ mlc/contract.hh (working copy)
@@ -40,4 +40,22 @@
# define postcondition(expr) assert(expr)
+# define mlc_check_method_impl(WHERE, RETURN, NAME, ARG, CONST) \
+{ \
+ typedef RETURN (WHERE::*meth)(ARG) CONST; \
+ meth adr = &E::impl_##NAME; \
+ adr = 0; \
+} \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+# define mlc_check_method_impl_2(WHERE, RETURN, NAME, ARG1, ARG2, CONST) \
+{ \
+ typedef RETURN (WHERE::*meth)(ARG1, ARG2) CONST; \
+ meth adr = &E::impl_##NAME; \
+ adr = 0; \
+} \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
#endif // ! METALIC_CONTRACT_HH
Index: mlc/cmp.hh
===================================================================
--- mlc/cmp.hh (revision 140)
+++ mlc/cmp.hh (working copy)
@@ -79,6 +79,16 @@
{
};
+
+
+ template <typename T>
+ struct is_ok : public and_< and_< neq<T, internal::not_found>,
+ neq<T, internal::not_ok> >,
+ neq<T, undefined_type> >
+ {
+ };
+
+
} // end of namespace mlc
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 11 +++++++++++
oln/core/apply.hh | 12 ++++++------
tests/core/tests/apply-binary | 16 +++++++---------
tests/core/tests/apply-unary | 18 +++++++++---------
4 files changed, 33 insertions(+), 24 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix oln::apply.
* oln/core/apply.hh (apply1_type::impl_run)
(apply2_type::impl_run): Catch up with the new image_operator
definition.
* tests/core/tests/apply-unary, tests/core/tests/apply-binary: Fix
tests.
Conform to Olena coding standard.
2005-04-13 Roland Levillain <roland(a)lrde.epita.fr>
Index: olena/tests/core/tests/apply-unary
--- olena/tests/core/tests/apply-unary (revision 139)
+++ olena/tests/core/tests/apply-unary (working copy)
@@ -50,8 +50,8 @@
{
oln::image2d<int> ima;
ima = oln::apply(f_mult_3(), ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
// oln::apply, with a mlc::unary_function built using the helper
@@ -59,8 +59,8 @@
{
oln::image2d<int> ima;
ima = oln::apply(mlc::make_unary_fun(mult_3), ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
// oln::apply, with a mlc::unary_function built using the helper
@@ -68,8 +68,8 @@
{
oln::image2d<int> ima;
ima = oln::apply (mlc::make_unary_fun(std::negate<int>()), ima1);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
// oln::apply, with a (more complex) mlc::unary_function built using
@@ -79,9 +79,9 @@
ima =
oln::apply (mlc::make_unary_fun(std::bind2nd(std::multiplies<int>(), 3)),
ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
- return true;
+ return false;
}
Index: olena/tests/core/tests/apply-binary
--- olena/tests/core/tests/apply-binary (revision 139)
+++ olena/tests/core/tests/apply-binary (working copy)
@@ -50,19 +50,17 @@
// oln::apply, with a hand-made mlc::abstract::binary_function.
{
oln::image2d<int> ima;
-
ima = oln::apply(f_mult(), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
-
// oln::apply, with a mlc::binary_function built using the helper
// function mlc::make_binary_fun on a classic function.
{
oln::image2d<int> ima;
ima = oln::apply(mlc::make_binary_fun(mult), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
// oln::apply, with a mlc::binary_function built using the helper
@@ -71,9 +69,9 @@
oln::image2d<int> ima;
ima =
oln::apply (mlc::make_binary_fun(std::multiplies<int>()), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
- return true;
+ return false;
}
Index: olena/oln/core/apply.hh
--- olena/oln/core/apply.hh (revision 139)
+++ olena/oln/core/apply.hh (working copy)
@@ -78,11 +78,11 @@
void impl_run()
{
- output_type output(input_.size());
+ output_type tmp(input_.size());
oln_type_of(I, fwd_piter) p(input_.size());
for_all(p)
- output[p] = f_(input_[p]);
- this->image_ = output;
+ tmp[p] = f_(input_[p]);
+ this->output = tmp;
}
};
@@ -152,11 +152,11 @@
void impl_run()
{
- output_type output(input1_.size());
+ output_type tmp(input1_.size());
oln_type_of(I1, fwd_piter) p(input1_.size());
for_all(p)
- output[p] = f_(input1_[p], input2_[p]);
- this->image_ = output;
+ tmp[p] = f_(input1_[p], input2_[p]);
+ this->output = tmp;
}
};
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0/olena
ChangeLog | 13 +++++
oln/core/any/grid.hh | 71 +++++++++++++++++++++++++++
oln/core/any/point.hh | 12 ++++
oln/core/pw/apply.hh | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++
oln/makefile.src | 2
tests/pw/Makefile.am | 5 +
tests/pw/tests/apply | 18 +++++++
7 files changed, 247 insertions(+), 1 deletion(-)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add apply on point-wise functions.
* oln/core/pw/apply.hh: New file.
* tests/pw/Makefile.am: New file.
* tests/pw/tests/apply: New test.
* oln/core/any/grid.hh: New file.
* oln/core/any/point.hh: Conform to abstract::point constraints.
* oln/makefile.src (OLN_DEP): Add core/any/grid.hh and
core/pw/apply.hh.
2005-04-13 Roland Levillain <roland(a)lrde.epita.fr>
Property changes on: tests/pw
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Makefile
Index: tests/pw/tests/apply
--- tests/pw/tests/apply (revision 0)
+++ tests/pw/tests/apply (revision 0)
@@ -0,0 +1,18 @@
+ // -*- C++ -*-
+#include <iostream>
+
+#include <cmath>
+#include <oln/core/pw/apply.hh>
+#include <oln/core/pw/literal.hh>
+#include <oln/core/any/point.hh>
+
+using namespace oln;
+
+bool check()
+{
+ any_point p;
+ pw::literal<int> pv1 (p_lit(42));
+
+ int res = p_apply(mlc::make_unary_fun(std::negate<int>()), pv1)(p);
+ return !(res == -42);
+}
Index: tests/pw/Makefile.am
--- tests/pw/Makefile.am (revision 0)
+++ tests/pw/Makefile.am (revision 0)
@@ -0,0 +1,5 @@
+include ../check/Makefile.runtests
+include ../check/Makefile.check
+
+
+check-local: check-runtests
Index: oln/core/pw/apply.hh
--- oln/core/pw/apply.hh (revision 0)
+++ oln/core/pw/apply.hh (revision 0)
@@ -0,0 +1,127 @@
+// 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_APPLY_HH
+# define OLENA_CORE_PW_APPLY_HH
+
+# include <mlc/fun.hh>
+# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/macros.hh>
+
+
+namespace oln {
+
+ /*--------.
+ | Unary. |
+ `--------*/
+
+ // fwd decl
+ namespace pw {
+ template <typename F, typename T>
+ struct apply;
+ }
+
+ // super type
+ template <typename F, typename T>
+ struct set_super_type < pw::apply<F, T> >
+ {
+ typedef pw::abstract::function< pw::apply<F, T> > ret;
+ };
+
+ // props
+ template <typename F, typename T>
+ struct set_props < category::pw, pw::apply<F, T> >
+ {
+ typedef oln_pw_type_of(T, point) point_type;
+ typedef typename F::result_type value_type;
+ typedef oln_pw_type_of(T, size) size_type;
+ };
+
+
+ namespace pw {
+
+ template <typename F, typename T>
+ struct apply : public abstract::function < apply<F, T> >
+ {
+ typedef apply<F, T> self_type;
+
+ typedef oln_pw_type_of(self_type, point) point_type;
+ typedef oln_pw_type_of(self_type, value) value_type;
+ typedef oln_pw_type_of(self_type, size) size_type;
+
+ typedef abstract::function<self_type> super_type;
+
+ F f_;
+ T input_;
+
+ apply(const mlc::abstract::unary_function<F>& f,
+ const abstract::function<T>& input) :
+ super_type(),
+ f_(f.exact()),
+ input_(input.exact())
+ {
+ }
+
+ const size_type& impl_size() const
+ {
+ return input_.size();
+ }
+
+ const value_type impl_get(const point_type& p) const
+ {
+ return f_(input_(p));
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return input_.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return input_.hold_large(p);
+ }
+ };
+
+
+ } // end of namespace oln::pw
+
+} // end of namespace oln
+
+
+/// apply function on pwf
+
+template <typename F, typename T>
+oln::pw::apply<F, T> p_apply (const mlc::abstract::unary_function<F>& f,
+ const oln::pw::abstract::function<T>& x)
+{
+ oln::pw::apply<F, T> tmp(f, x);
+ return tmp;
+}
+
+
+#endif // ! OLENA_CORE_PW_APPLY_HH
Index: oln/core/any/grid.hh
--- oln/core/any/grid.hh (revision 0)
+++ oln/core/any/grid.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_CORE_ANY_GRID_HH
+# define OLENA_CORE_ANY_GRID_HH
+
+# include <mlc/value.hh>
+# include <oln/core/abstract/grid.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ struct any_grid;
+ struct any_point;
+ struct any_dpoint;
+ struct any_coord;
+
+ // super type
+ template <>
+ struct set_super_type < any_grid >
+ {
+ typedef abstract::grid< any_grid > ret;
+ };
+
+ // props
+ template <>
+ struct set_props < category::grid, any_grid >
+ {
+ typedef any_point point_type;
+ typedef any_dpoint dpoint_type;
+ typedef any_coord coord_type;
+ typedef mlc::value<unsigned,0> dimvalue_type;
+ };
+
+ struct any_grid : public abstract::grid< any_grid >
+ {
+ protected:
+ any_grid()
+ {}
+ };
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_ANY_GRID_HH
Index: oln/core/any/point.hh
--- oln/core/any/point.hh (revision 138)
+++ oln/core/any/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <iostream>
# include <oln/core/abstract/point.hh>
# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/any/grid.hh>
namespace oln {
@@ -38,32 +39,41 @@
// fwd decls
struct any_point;
struct any_dpoint;
+ struct any_grid;
// props
template <>
struct set_props < category::point, any_point >
{
typedef any_dpoint dpoint_type;
+ typedef any_grid grid_type;
+ typedef any_coord coord_type;
};
struct any_point : public abstract::point < any_point >
{
-
bool impl_eq(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
+ const any_point impl_plus(const any_dpoint& rhs) const;
+
template <typename D>
const any_point impl_plus(const abstract::dpoint<D>& rhs) const
{
return any_point();
}
+ const any_dpoint impl_minus(const any_point& rhs) const;
+
template <typename P>
const any_dpoint impl_minus(const abstract::point<P>& rhs) const;
+ const any_coord impl_nth(unsigned i) const;
+
+ any_coord& impl_nth(unsigned i);
};
Index: oln/makefile.src
--- oln/makefile.src (revision 138)
+++ oln/makefile.src (working copy)
@@ -77,6 +77,7 @@
\
core/any/all.hh \
core/any/dpoint.hh \
+ core/any/grid.hh \
core/any/point.hh \
core/any/size.hh \
\
@@ -96,6 +97,7 @@
\
core/pw/abstract/binary_function.hh \
core/pw/abstract/function.hh \
+ core/pw/apply.hh \
core/pw/all.hh \
core/pw/cmp.hh \
core/pw/div.hh \
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 28 ++++++++++++++++++++++++++++
oln/core/2d/array2d.hh | 2 --
oln/core/2d/dpoint2d.hh | 4 ++++
oln/core/2d/point2d.hh | 4 ++++
oln/core/2d/size2d.hh | 5 +++++
oln/core/abstract/image.hh | 1 -
oln/core/abstract/qiter.hh | 1 +
oln/core/any/dpoint.hh | 2 +-
oln/core/any/point.hh | 2 +-
oln/io/read_image.hh | 6 +++---
oln/io/read_image_2d_pnm.hh | 39 +++++++++++++--------------------------
oln/io/write_image.hh | 3 ++-
oln/io/write_image_2d_pnm.hh | 2 +-
oln/makefile.src | 1 -
14 files changed, 63 insertions(+), 37 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Repair the I/O routines.
* oln/io/read_image_2d_pnm.hh: Use output_ instead of image_.
(output): Remove method.
(read): Use the semantics of real image operator: return a
read_image_2d_raw instead of an image.
* oln/io/read_image.hh: Adjust.
* oln/io/write_image_2d_pnm.hh (impl_run): Rename as...
(run): ...this.
* oln/core/2d/array2d.hh: Do not set exact_ptr, since this class
not longer inherits from mlc::any__best_speed, but from mlc::any.
Please G++ and clean up.
* oln/core/abstract/qiter.hh (set_default_props): Add template <>
qualifier.
* oln/core/any/point.hh (operator<<): Do not name the second
argument.
* oln/core/any/dpoint.hh (operator<<): Likewise.
* oln/core/2d/point2d.hh (super_type): New typedef.
Explicitely call the super type ctor in ctors.
* oln/core/2d/dpoint2d.hh Likewise.
* oln/core/2d/size2d.hh: Likewise.
* oln/makefile.src (OLN_DEP): Remove core/2d/fwd_qiter2d.hh.
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh (revision 137)
+++ olena/oln/core/abstract/image.hh (working copy)
@@ -167,7 +167,6 @@
{
/// typedefs
-
typedef oln_type_of(E, size) size_type;
typedef oln_type_of(E, value) value_type;
typedef oln_type_of(E, point) point_type;
Index: olena/oln/core/abstract/qiter.hh
--- olena/oln/core/abstract/qiter.hh (revision 137)
+++ olena/oln/core/abstract/qiter.hh (working copy)
@@ -54,6 +54,7 @@
/// Default properties of any type in category::qiter.
+ template <>
struct set_default_props < category::qiter >
{
typedef mlc::undefined_type window_type;
Index: olena/oln/core/2d/dpoint2d.hh
--- olena/oln/core/2d/dpoint2d.hh (revision 137)
+++ olena/oln/core/2d/dpoint2d.hh (working copy)
@@ -47,17 +47,21 @@
struct dpoint2d : public abstract::dpoint < dpoint2d >
{
+ typedef abstract::dpoint< dpoint2d > super_type;
+
dpoint2d()
{
}
dpoint2d(coord_t row_, coord_t col_) :
+ super_type(),
row_(row_),
col_(col_)
{
}
dpoint2d(const dpoint2d& rhs) :
+ super_type(),
row_(rhs.row_),
col_(rhs.col_)
{
Index: olena/oln/core/2d/array2d.hh
--- olena/oln/core/2d/array2d.hh (revision 137)
+++ olena/oln/core/2d/array2d.hh (working copy)
@@ -79,7 +79,6 @@
array_(0),
size_()
{
- this->exact_ptr = this;
invariant_();
}
@@ -93,7 +92,6 @@
array_(0),
size_()
{
- this->exact_ptr = this;
this->resize(s);
}
Index: olena/oln/core/2d/point2d.hh
--- olena/oln/core/2d/point2d.hh (revision 137)
+++ olena/oln/core/2d/point2d.hh (working copy)
@@ -59,18 +59,22 @@
struct point2d : public abstract::point< point2d >
{
+ typedef abstract::point< point2d > super_type;
+
point2d()
{
// no initialization here so that row_ and col_ are 'undef'
}
point2d(coord_t row_, coord_t col_) :
+ super_type(),
row_(row_),
col_(col_)
{
}
point2d(const point2d& rhs) :
+ super_type(),
row_(rhs.row_),
col_(rhs.col_)
{
Index: olena/oln/core/2d/size2d.hh
--- olena/oln/core/2d/size2d.hh (revision 137)
+++ olena/oln/core/2d/size2d.hh (working copy)
@@ -46,24 +46,29 @@
struct size2d : public abstract::size< size2d >
{
+ typedef abstract::size< size2d > super_type;
+
size2d()
{
// no initialization here so that members are 'undef'
}
size2d(coord_t nrows_, coord_t ncols_) :
+ super_type(),
nrows_(nrows_),
ncols_(ncols_),
border_(2) // FIXME: 2!
{}
size2d(coord_t nrows_, coord_t ncols_, coord_t border_) :
+ super_type(),
nrows_(nrows_),
ncols_(ncols_),
border_(border_)
{}
size2d(const size2d& rhs) :
+ super_type(),
nrows_(rhs.nrows_),
ncols_(rhs.ncols_),
border_(rhs.border_)
Index: olena/oln/core/any/point.hh
--- olena/oln/core/any/point.hh (revision 137)
+++ olena/oln/core/any/point.hh (working copy)
@@ -81,7 +81,7 @@
} // end of namespace oln
-std::ostream& operator<<(std::ostream& ostr, const oln::any_point& p)
+std::ostream& operator<<(std::ostream& ostr, const oln::any_point&)
{
return ostr << "any";
}
Index: olena/oln/core/any/dpoint.hh
--- olena/oln/core/any/dpoint.hh (revision 137)
+++ olena/oln/core/any/dpoint.hh (working copy)
@@ -77,7 +77,7 @@
} // end of namespace oln
-std::ostream& operator<<(std::ostream& ostr, const oln::any_dpoint& dp)
+std::ostream& operator<<(std::ostream& ostr, const oln::any_dpoint&)
{
return ostr << "any";
}
Index: olena/oln/makefile.src
--- olena/oln/makefile.src (revision 137)
+++ olena/oln/makefile.src (working copy)
@@ -33,7 +33,6 @@
core/2d/dpoint2d.hh \
core/2d/fwd_niter2d.hh \
core/2d/fwd_piter2d.hh \
- core/2d/fwd_qiter2d.hh \
core/2d/image2d.hh \
core/2d/neighborhood2d.hh \
core/2d/point2d.hh \
Index: olena/oln/io/write_image_2d_pnm.hh
--- olena/oln/io/write_image_2d_pnm.hh (revision 137)
+++ olena/oln/io/write_image_2d_pnm.hh (working copy)
@@ -70,7 +70,7 @@
bin_v = 0;
}
- void impl_run()
+ void run()
{
point2d p;
value_type c;
Index: olena/oln/io/read_image_2d_pnm.hh
--- olena/oln/io/read_image_2d_pnm.hh (revision 137)
+++ olena/oln/io/read_image_2d_pnm.hh (working copy)
@@ -68,36 +68,25 @@
namespace impl {
template <typename I>
- struct read_image_2d_raw : public oln::abstract::image_operator<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::image_operator<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;
- // commented below cause 'image_' is inherited
-// mlc::box<I> image_;
-
std::istream& istr_;
internal::pnm_info& info_;
char v;
int offset;
- read_image_2d_raw(I& image,
- std::istream &istr,
+ read_image_2d_raw(std::istream &istr,
internal::pnm_info &info) :
- super_type(image),
+ super_type(),
istr_(istr),
info_(info),
offset(-1)
{
- this->image_ = image;
- }
-
-
- read_image_2d_raw<I>& output(I& output)
- {
- output = this->image_;
- return *this;
}
template <typename E>
@@ -110,7 +99,8 @@
template <typename E>
void precond(ntg::vect_value<E>& c)
{
- precondition(ntg_max_val(ntg_comp_type(value_type)) <= info_.max_val);
+ precondition(ntg_max_val(ntg_comp_type(value_type)) <=
+ info_.max_val);
precondition(info_.type == "P6");
precondition(ntg_nb_comp(value_type) == 3);
}
@@ -134,7 +124,7 @@
read_value_type(c);
tmp[p] = c;
}
- this->image_ = tmp;
+ this->output = tmp;
}
//FIXME: Should work with builtin types.
@@ -175,16 +165,13 @@
}
};
-
-
template <typename I>
- void read(abstract::image2d<I>& ima,
- std::istream& istr,
- internal::pnm_info info)
+ read_image_2d_raw<I>
+ read(std::istream& istr, internal::pnm_info info)
{
- read_image_2d_raw<I> tmp(ima.exact(), istr, info);
+ read_image_2d_raw<I> tmp(istr, info);
tmp.run();
- tmp.output(ima.exact());
+ return tmp;
}
}
Index: olena/oln/io/write_image.hh
--- olena/oln/io/write_image.hh (revision 137)
+++ olena/oln/io/write_image.hh (working copy)
@@ -89,7 +89,8 @@
void write(const abstract::image<I>& ima, const std::string& name)
{
std::string ext;
- oln_type_of(I, value) t;
+ // FIXME: Unused?
+ // oln_type_of(I, value) t;
ext = internal::utils::extension(name);
Index: olena/oln/io/read_image.hh
--- olena/oln/io/read_image.hh (revision 137)
+++ olena/oln/io/read_image.hh (working copy)
@@ -76,17 +76,17 @@
if (internal::read_pnm_header(istr, info))
if ((ext == "ppm" || ext == "pnm") && info.type == "P6")
- impl::read(ima.exact(), istr, info);
+ ima.exact() = impl::read<I>(istr, info);
else if ((ext == "ppm" || ext == "pnm") && info.type == "P3")
std::cerr << "error: read_image_2d_ppm_ascii not implemented"
<< std::endl;
else if ((ext == "pbm" || ext == "pnm") && info.type == "P4")
- impl::read(ima.exact(), istr, info);
+ ima.exact() = impl::read<I>(istr, info);
else if ((ext == "pbm" || ext == "pnm") && info.type == "P1")
std::cerr << "error: read_image_2d_ppm_ascii not implemented"
<< std::endl;
else if ((ext == "pgm" || ext == "pnm") && info.type == "P5")
- impl::read(ima.exact(), istr, info);
+ ima.exact() = impl::read<I>(istr, info);
else if ((ext == "pgm" || ext == "pnm") && info.type == "P2")
std::cerr << "error: read_image_2d_ppm_ascii not implemented"
<< std::endl;
1
0
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