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
November 2006
- 4 participants
- 22 discussions
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Remove virtual type `is_value_wise_mutable'.
* oln/core/typedefs.hh (is_value_wise_mutable): Remove virtual
type declaration.
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh:
(case_<image_hierarchy_wrt_value_wise_accessibility, E, 1>): No
longer use the virtual type `is_value_wise_mutable' in the
static switch condition; query `mutable_value_proxy' instead.
* olena/oln/morpher/with_lut.hh
(vtypes< morpher::with_lut<Image, Lut> >::is_value_wise_mutable_type):
Remove typedef.
core/abstract/image/value_wise_accessibility/hierarchy.hh | 8 +-------
core/typedefs.hh | 2 --
morpher/with_lut.hh | 11 +++--------
3 files changed, 4 insertions(+), 17 deletions(-)
Index: olena/oln/core/typedefs.hh
--- olena/oln/core/typedefs.hh (revision 701)
+++ olena/oln/core/typedefs.hh (working copy)
@@ -129,8 +129,6 @@
mlc_decl_typedef(topo_type);
mlc_decl_typedef(bbox_type);
- mlc_decl_typedef(is_value_wise_mutable_type);
-
/*-------.
| Grid. |
Index: olena/oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
--- olena/oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (revision 701)
+++ olena/oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (working copy)
@@ -130,17 +130,11 @@
| Value-wise accessibility switch. |
`----------------------------------*/
- /* FIXME: Handle mutability. This is not easy, as, for instance an
- image with LUT has no lvalue type, but can be perfectly const or
- mutable. How can we deal with this? By adding a specific
- vtype? */
-
/// With mutable value-wise random accessibility.
template <typename E>
struct case_< image_hierarchy_wrt_value_wise_accessibility, E, 1 > :
where_< mlc_and( mlc_is_ok(oln_type_of(E, fwd_viter)),
- mlc_eq( oln_type_of(E, is_value_wise_mutable),
- mlc::true_) ) >
+ mlc_is_ok(oln_type_of(E, mutable_value_proxy)) ) >
{
typedef abstract::mutable_image_being_value_wise_random_accessible<E> ret;
};
Index: olena/oln/morpher/with_lut.hh
--- olena/oln/morpher/with_lut.hh (revision 701)
+++ olena/oln/morpher/with_lut.hh (working copy)
@@ -71,17 +71,12 @@
/* lvalue_type: undefined
(see oln/morpher/internal/image_value_morpher.hh). */
- /* FIXME: This virtual type (``is_value_wise_mutable'') is
- useless, since the presence of mutable_value_proxy_type
- suffices to state that the image is value-wise mutable. */
-
+ typedef value::lut_value_proxy<Lut> value_proxy_type;
/* Mutability.
As the virtual type `lvalue' is undefined in with_lut<>, it is
not point-wise mutable. However, it is value-wise mutable,
- i.e., the values of the look-up table can be modified. */
- typedef mlc::true_ is_value_wise_mutable_type;
-
- typedef value::lut_value_proxy<Lut> value_proxy_type;
+ i.e., the values of the look-up table can be modified through
+ a mutable value proxy. */
typedef value::mutable_lut_value_proxy<Lut> mutable_value_proxy_type;
// fwd_viter_type: see below.
1
0
10 Nov '06
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Introduce oln::value::lut_value_proxy.
* olena/oln/value/lut_value_proxy.hh: New.
* oln/core/typedefs.hh (mutable_fwd_viter_type): Remove virtual
type declaration.
(value_proxy_type, mutable_value_proxy_type): New virtual types
declarations.
Aesthetic changes.
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
(image_being_value_wise_random_accessible::fwd_viter_t): Remove
typedef.
(image_being_value_wise_random_accessible::value_proxy_t): New
typedef.
(image_being_value_wise_random_accessible::value): Return a value
proxy instead of a value iterator.
(mutable_image_being_value_wise_random_accessible::fwd_viter_t):
Remove typedef.
(mutable_image_being_value_wise_random_accessible::value_proxy_t):
New typedef.
(mutable_image_being_value_wise_random_accessible::value)): Return
a value proxy instead of a value iterator.
* oln/morpher/with_lut.hh (oln/value/lut_value_proxy.hh): Include
it.
(vtypes< morpher::with_lut<Image, Lut> >::value_proxy_type)
(vtypes< morpher::with_lut<Image, Lut> >::mutable_value_proxy_type):
New typedefs.
(single_vtype<morpher::with_lut<Image, Lut>,
typedef_::mutable_fwd_viter_type>): Remove single virtual type.
(oln::morpher::with_lut::fwd_viter_type)
(oln::morpher::with_lut::mutable_fwd_viter_type): Remove.
(oln::morpher::with_lut::value_proxy_type)
(oln::morpher::with_lut::mutable_value_proxy_type): New typedefs.
(oln::morpher::with_lut::impl_value): Have these methods return
value proxies instead of value iterators.
* oln/Makefile.am (nobase_oln_HEADERS): Add
value/lut_value_proxy.hh.
Remove oln::mutable_fwd_viter_lut and clean up oln::fwd_viter_lut.
* olena/oln/core/abstract/iterator_on_values.hh: New.
* oln/core/internal/fwd_viter_lut.hh:
(oln::internal::fwd_viter_lut<Exact>): Inherit from
oln::abstract::iterator_on_values<Exact>.
s/rvalue_type/value_type/g.
(oln::internal::fwd_viter_lut(lut_type&, const value_type&)):
Remove ctor.
(oln::internal::fwd_viter_lut::start)
(oln::internal::fwd_viter_lut::next)
(oln::internal::fwd_viter_lut::invalidate)
(oln::internal::fwd_viter_lut::is_valid): Rename methods as...
(oln::internal::fwd_viter_lut::impl_start)
(oln::internal::fwd_viter_lut::impl_next)
(oln::internal::fwd_viter_lut::impl_invalidate)
(oln::internal::fwd_viter_lut::impl_is_valid): ...these.
* oln/core/gen/fwd_viter_lut.hh (oln::fwd_viter_lut<Lut>):
s/rvalue_type/value_type/g.
(oln::fwd_viter_lut::fwd_viter_lut(const Lut&, const rvalue_type&)):
Remove ctor.
(oln::fwd_viter_lut::operator rvalue_type): Turn this operator
into...
(oln::fwd_viter_lut::impl_to_value): ...this method.
(oln::mutable_fwd_viter_lut): Remove this class and it virtual
types.
(operator<<(std::ostream&, const mutable_fwd_viter_lut<Lut>&)):
Remove.
* oln/Makefile.am (nobase_oln_HEADERS): Add
core/abstract/iterator_on_values.hh
Makefile.am | 2
core/abstract/image/value_wise_accessibility/hierarchy.hh | 22 -
core/abstract/iterator_on_values.hh | 134 ++++++
core/gen/fwd_viter_lut.hh | 184 --------
core/internal/fwd_viter_lut.hh | 42 --
core/typedefs.hh | 40 +
morpher/with_lut.hh | 35 -
value/lut_value_proxy.hh | 289 ++++++++++++++
8 files changed, 499 insertions(+), 249 deletions(-)
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh (revision 700)
+++ oln/core/typedefs.hh (working copy)
@@ -97,23 +97,21 @@
mlc_decl_typedef(bkd_niter_type);
mlc_decl_typedef(fwd_viter_type);
- mlc_decl_typedef(mutable_fwd_viter_type);
// FIXME: bkd_viter_type.
- // FIXME: mutable_bkd_viter_type.
- /*----------------------.
- | category::point_set. |
- `-----------------------*/
+ /*------------.
+ | Point set. |
+ `------------*/
mlc_decl_typedef(has_known_size_type);
mlc_decl_typedef(is_random_accessible_type);
mlc_decl_typedef(is_connected_type);
- /*------------------.
- | category::image. |
- `------------------*/
+ /*--------.
+ | Image. |
+ `--------*/
mlc_decl_typedef(is_computed_type);
mlc_decl_typedef(value_type);
@@ -134,26 +132,34 @@
mlc_decl_typedef(is_value_wise_mutable_type);
- /*-----------------.
- | category::grid. |
- `-----------------*/
+ /*-------.
+ | Grid. |
+ `-------*/
// FIXME: Merge with dim_type?
mlc_decl_typedef(dimvalue_type);
mlc_decl_typedef(coord_type);
- /*-----------------.
- | category::point. |
- `-----------------*/
+ /*--------.
+ | Point. |
+ `--------*/
mlc_decl_typedef(dim_type);
mlc_decl_typedef(vec_type);
- /*-------------------------.
- | category::lookup_table. |
- `-------------------------*/
+ /*---------.
+ | Values. |
+ `---------*/
+
+ mlc_decl_typedef(value_proxy_type);
+ mlc_decl_typedef(mutable_value_proxy_type);
+
+
+ /*----------------.
+ | Look-up table. |
+ `----------------*/
mlc_decl_typedef(lut_type);
mlc_decl_typedef(lut_iter_type);
Index: oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
--- oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (revision 700)
+++ oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (working copy)
@@ -53,18 +53,22 @@
public automatic::get_impl< image_being_value_wise_random_accessible, E >
{
typedef oln_type_of(E, value) value_t;
- typedef oln_type_of(E, fwd_viter) fwd_viter_t;
-
+ typedef oln_type_of(E, value_proxy) value_proxy_t;
public:
- // Value descriptor (read-only access).
- fwd_viter_t value(const value_t& v) const;
+ /// Get a (read-only) value descriptor from a value.
+ ///
+ /// This method is not really useful, but we keep it for the
+ /// symmetry with
+ /// mutable_image_being_value_wise_random_accessible::value().
+ value_proxy_t value(const value_t& v) const;
protected:
/// Constructor (protected, empty).
image_being_value_wise_random_accessible();
};
+
/// Mutable image having a value-wise random accessibility.
template <typename E>
struct mutable_image_being_value_wise_random_accessible :
@@ -72,12 +76,12 @@
public automatic::get_impl< mutable_image_being_value_wise_random_accessible, E >
{
typedef oln_type_of(E, value) value_t;
- typedef oln_type_of(E, mutable_fwd_viter) mutable_fwd_viter_t;
+ typedef oln_type_of(E, mutable_value_proxy) mutable_value_proxy_t;
public:
using image_being_value_wise_random_accessible<E>::value;
- // Value descriptor (read-write access).
- mutable_fwd_viter_t value(const value_t& v);
+ /// Get a (read-only) value descriptor from a value.
+ mutable_value_proxy_t value(const value_t& v);
protected:
/// Constructor (protected, empty).
@@ -91,7 +95,7 @@
// image_being_value_wise_random_accessible.
template <typename E>
- typename image_being_value_wise_random_accessible<E>::fwd_viter_t
+ typename image_being_value_wise_random_accessible<E>::value_proxy_t
image_being_value_wise_random_accessible<E>::value(const typename image_being_value_wise_random_accessible<E>::value_t& v) const
{
return this->exact().impl_value(v);
@@ -106,7 +110,7 @@
// mutable_image_being_value_wise_random_accessible.
template <typename E>
- typename mutable_image_being_value_wise_random_accessible<E>::mutable_fwd_viter_t
+ typename mutable_image_being_value_wise_random_accessible<E>::mutable_value_proxy_t
mutable_image_being_value_wise_random_accessible<E>::value(const typename mutable_image_being_value_wise_random_accessible<E>::value_t& v)
{
return this->exact().impl_value(v);
Index: oln/core/abstract/iterator_on_values.hh
--- oln/core/abstract/iterator_on_values.hh (revision 0)
+++ oln/core/abstract/iterator_on_values.hh (revision 0)
@@ -0,0 +1,134 @@
+// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+# define OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+
+# include <oln/core/abstract/iterator.hh>
+
+
+namespace oln
+{
+
+
+ // Forward declaration.
+ namespace abstract { template <typename E> class iterator_on_values; }
+
+
+ // Super type declaration.
+ template <typename E>
+ struct set_super_type< abstract::iterator_on_values<E> >
+ {
+ typedef abstract::iterator<E> ret;
+ };
+
+
+ /// Virtual types associated to abstract::iterator_on_values<E>.
+ template <typename E>
+ struct vtypes< abstract::iterator_on_values<E> >
+ {
+ typedef mlc::undefined value_type;
+ };
+
+
+ namespace abstract
+ {
+
+ /// Abstract value iterator class.
+ template <typename E>
+ class iterator_on_values : public abstract::iterator<E>
+ {
+ public:
+ typedef oln_type_of(E, value) value_type;
+
+ value_type to_value() const;
+
+ // Concrete method.
+ operator value_type() const;
+
+ protected:
+
+ iterator_on_values();
+
+ ~iterator_on_values();
+
+ }; // end of class oln::abstract::iterator_on_values<E>
+
+
+ template <typename E>
+ std::ostream& operator<<(std::ostream& ostr,
+ const iterator_on_values<E>& vit);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ typename iterator_on_values<E>::value_type
+ iterator_on_values<E>::to_value() const
+ {
+ precondition(this->is_valid());
+ return this->exact().impl_to_value();
+ }
+
+ template <typename E>
+ // Concrete method.
+ iterator_on_values<E>::operator typename iterator_on_values<E>::value_type() const
+ {
+ precondition(this->is_valid());
+ return this->to_value();
+ }
+
+ template <typename E>
+ iterator_on_values<E>::iterator_on_values()
+ {
+ }
+
+ template <typename E>
+ iterator_on_values<E>::~iterator_on_values()
+ {
+ mlc::assert_defined_< typename iterator_on_values<E>::value_type >::check();
+ }
+
+
+ template <typename E>
+ std::ostream& operator<<(std::ostream& ostr,
+ const iterator_on_values<E>& vit)
+ {
+ return ostr << vit.to_value();
+ }
+
+
+# endif
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
Index: oln/core/gen/fwd_viter_lut.hh
--- oln/core/gen/fwd_viter_lut.hh (revision 700)
+++ oln/core/gen/fwd_viter_lut.hh (working copy)
@@ -34,9 +34,7 @@
namespace oln
{
- /*------------.
- | fwd_viter. |
- `------------*/
+ // FIXME: Merge this file with oln/core/internal/fwd_viter_lut.hh?
// Forward declaration.
template <typename Lut> class fwd_viter_lut;
@@ -58,7 +56,7 @@
// The look-up table is immutable.
typedef const Lut lut_type;
typedef typename Lut::const_iterator lut_iter_type;
- typedef typename Lut::new_value_type rvalue_type;
+ typedef typename Lut::new_value_type value_type;
};
@@ -74,16 +72,14 @@
public:
typedef oln_type_of(self_t, lut) lut_t;
- typedef oln_type_of(self_t, rvalue) rvalue_type;
+ typedef oln_type_of(self_t, value) value_type;
public:
// Construct an uninitialized value iterator.
fwd_viter_lut(const Lut& lut);
- // Construct an iterator pointing to value \a val.
- fwd_viter_lut(const Lut& lut, const rvalue_type& val);
// Get the value pointed by this iterator (const version).
- operator rvalue_type() const;
+ value_type impl_to_value() const;
void print(std::ostream& ostr) const;
};
@@ -106,15 +102,8 @@
}
template <typename Lut>
- fwd_viter_lut<Lut>::fwd_viter_lut(const Lut& lut,
- const typename fwd_viter_lut<Lut>::rvalue_type& val)
- : super_t(lut, val)
- {
- // The underlying iterator is initialized by the super class.
- }
-
- template <typename Lut>
- fwd_viter_lut<Lut>::operator typename fwd_viter_lut<Lut>::rvalue_type() const
+ typename fwd_viter_lut<Lut>::value_type
+ fwd_viter_lut<Lut>::impl_to_value() const
{
precondition(this->is_valid());
return this->i_->first;
@@ -124,7 +113,7 @@
void fwd_viter_lut<Lut>::print(std::ostream& ostr) const
{
precondition(this->is_valid());
- ostr << "fwd_viter_lut<Lut> { value = " << this->i_->first << " }";
+ ostr << "{ value = " << this->i_->first << " }";
}
@@ -138,165 +127,6 @@
# endif
-
-
- /*--------------------.
- | mutable_fwd_viter. |
- `--------------------*/
-
- // Forward declaration.
- template <typename Lut> class mutable_fwd_viter_lut;
-
-
- /// Super type declaration.
- template <typename Lut>
- struct set_super_type< mutable_fwd_viter_lut<Lut> >
- {
- typedef mutable_fwd_viter_lut<Lut> self_t;
- typedef internal::fwd_viter_lut<self_t> ret;
- };
-
-
- /// Virtual types associated to oln::mutable_fwd_viter_lut<Lut>.
- template <typename Lut>
- struct vtypes< mutable_fwd_viter_lut<Lut> >
- {
- typedef Lut lut_type;
- typedef typename Lut::iterator lut_iter_type;
- typedef typename Lut::new_value_type rvalue_type;
- typedef typename Lut::new_value_type& lvalue_type;
- };
-
-
- /// Const forward value iterator on look-up table.
- template <typename Lut>
- class mutable_fwd_viter_lut :
- public stc_get_supers(mutable_fwd_viter_lut<Lut>)
- // Check that Lut is a look-up table.
- // FIXME: an abstract::lookup_table would be useful.
- {
- typedef mutable_fwd_viter_lut<Lut> self_t;
- typedef stc_get_super(self_t) super_t;
- typedef oln_type_of(self_t, lut_iter) lut_iter_t;
- typedef typename Lut::orig_value_type orig_value_t;
- typedef typename Lut::new_value_type new_value_t;
-
- public:
- typedef Lut lut_t;
- typedef oln_type_of(self_t, rvalue) rvalue_type;
- typedef oln_type_of(self_t, lvalue) lvalue_type;
-
- self_t& operator=(const rvalue_type& rhs);
-
- public:
- // Construct an uninitialized value iterator.
- mutable_fwd_viter_lut(Lut& lut);
- // Construct an iterator pointing to value \a val.
- mutable_fwd_viter_lut(Lut& lut, const rvalue_type& val);
-
- // Get the value pointed by this iterator (const version).
- operator rvalue_type() const;
- // Get the value pointed by this iterator (mutable version).
- operator lvalue_type();
-
- void print(std::ostream& ostr) const;
- };
-
-
- template <typename Lut>
- std::ostream& operator<<(std::ostream& ostr,
- const mutable_fwd_viter_lut<Lut>& t);
-
-
-
-# ifndef OLN_INCLUDE_ONLY
-
- template <typename Lut>
- mutable_fwd_viter_lut<Lut>::mutable_fwd_viter_lut(Lut& lut)
- : super_t(lut)
- {
- // Initialize underlying iterator (i.e., \a i_.)
- this->invalidate();
- }
-
- template <typename Lut>
- mutable_fwd_viter_lut<Lut>::mutable_fwd_viter_lut(Lut& lut,
- const typename mutable_fwd_viter_lut<Lut>::rvalue_type& val)
- : super_t(lut, val)
- {
- // The underlying iterator is initialized by the super class.
- }
-
- template <typename Lut>
- mutable_fwd_viter_lut<Lut>::operator typename mutable_fwd_viter_lut<Lut>::rvalue_type() const
- {
- precondition(this->is_valid());
- return this->i_->second;
- }
-
- template <typename Lut>
- mutable_fwd_viter_lut<Lut>::operator typename mutable_fwd_viter_lut<Lut>::lvalue_type()
- {
- precondition(this->is_valid());
- return this->i_->first;
- }
-
- template <typename Lut>
- mutable_fwd_viter_lut<Lut>&
- mutable_fwd_viter_lut<Lut>::operator=(const typename mutable_fwd_viter_lut<Lut>::rvalue_type& rhs)
- {
- precondition(this->is_valid());
-
- // Current ``new'' value.
- new_value_t cur_new_val = this->i_->first;
-
- // Shortcuts.
- typedef lut_iter_t new_iter_t;
- typedef std::pair<new_iter_t, new_iter_t> new_iter_range_t;
-
- // Current ``original'' value(s) associated to the next ``new'' value RHS.
- new_iter_range_t cur_orig_val_range =
- this->lut_.new_to_orig_map().equal_range(cur_new_val);
- // A temporary map where additional bindings will be stored.
- typename Lut::new_to_orig_map_type additional_bindings;
-
- for (new_iter_t j = cur_orig_val_range.first;
- j != cur_orig_val_range.second; ++j)
- {
- // Update the orig-to-new map (substitution).
- orig_value_t orig_val = j->second;
- this->lut_.orig_to_new_map()[orig_val] = rhs;
- // Populate the temp map.
- additional_bindings.insert(std::make_pair(rhs, orig_val));
- }
- // Update the new-to-orig map (deletion).
- this->lut_.new_to_orig_map().erase(cur_orig_val_range.first,
- cur_orig_val_range.second);
- // Update the new-to-orig map (insertion).
- this->lut_.new_to_orig_map().insert(additional_bindings.begin(),
- additional_bindings.end());
- return *this;
- }
-
- template <typename Lut>
- void mutable_fwd_viter_lut<Lut>::print(std::ostream& ostr) const
- {
- precondition(this->is_valid());
- ostr
- << "mutable_fwd_viter_lut<Lut> { value = " << this->i_->first << " }";
- }
-
-
- template <typename Lut>
- std::ostream& operator<<(std::ostream& ostr,
- const mutable_fwd_viter_lut<Lut>& t)
- {
- t.print(ostr);
- return ostr;
- }
-
-# endif
-
} // end of namespace oln
Index: oln/core/internal/fwd_viter_lut.hh
--- oln/core/internal/fwd_viter_lut.hh (revision 700)
+++ oln/core/internal/fwd_viter_lut.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_INTERNAL_FWD_VITER_LUT_HH
# define OLN_CORE_INTERNAL_FWD_VITER_LUT_HH
-# include <oln/core/abstract/iterator.hh>
+# include <oln/core/abstract/iterator_on_values.hh>
namespace oln
@@ -46,8 +46,7 @@
template <typename Exact>
struct set_super_type< internal::fwd_viter_lut<Exact> >
{
- typedef internal::fwd_viter_lut<Exact> self_t;
- typedef abstract::iterator<self_t> ret;
+ typedef abstract::iterator_on_values<Exact> ret;
};
@@ -66,22 +65,23 @@
public:
typedef oln_type_of(Exact, lut) lut_type;
- typedef oln_type_of(Exact, rvalue) rvalue_type;
+ typedef oln_type_of(Exact, value) value_type;
public:
/// Iterator manipulators.
/// \{
- void start();
- void next();
- void invalidate();
- bool is_valid() const;
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
/// \}
protected:
// Construct an uninitialized value iterator.
fwd_viter_lut(lut_type& lut);
- // Construct an iterator pointing to value \a val.
- fwd_viter_lut(lut_type& lut, const rvalue_type& val);
+// FIXME: Should we keep this method?
+// // Construct an iterator pointing to value \a val.
+// fwd_viter_lut(lut_type& lut, const value_type& val);
protected:
/// Look-up table.
@@ -109,33 +109,21 @@
}
template <typename Exact>
- fwd_viter_lut<Exact>::fwd_viter_lut(typename fwd_viter_lut<Exact>::lut_type& lut,
- const typename fwd_viter_lut<Exact>::rvalue_type& val)
- : super_t(),
- lut_(lut),
- i_()
- {
- // Initialize underlying iterator (i.e., \a i_.)
- i_ = lut_.find(val);
- assert(i_ != lut_.end());
- }
-
- template <typename Exact>
void
- fwd_viter_lut<Exact>::start()
+ fwd_viter_lut<Exact>::impl_start()
{
i_ = lut_.begin();
}
template <typename Exact>
void
- fwd_viter_lut<Exact>::next()
+ fwd_viter_lut<Exact>::impl_next()
{
/* Iterate until a different key is reached. In fact,
std::multimap might not be the best choice to implement
new_to_orig_map_. Maybe a std::map binding orig_val to a
std::set of new_val's would is better?. */
- rvalue_type val = i_->first;
+ value_type val = i_->first;
do
++i_;
while (i_ != lut_.end() and i_->first == val);
@@ -143,14 +131,14 @@
template <typename Exact>
void
- fwd_viter_lut<Exact>::invalidate()
+ fwd_viter_lut<Exact>::impl_invalidate()
{
i_ = lut_.end();
}
template <typename Exact>
bool
- fwd_viter_lut<Exact>::is_valid() const
+ fwd_viter_lut<Exact>::impl_is_valid() const
{
return (i_ != lut_.end());
}
Index: oln/Makefile.am
--- oln/Makefile.am (revision 700)
+++ oln/Makefile.am (working copy)
@@ -90,6 +90,7 @@
core/abstract/image.hh \
core/abstract/iterator.hh \
core/abstract/iterator_on_points.hh \
+ core/abstract/iterator_on_values.hh \
core/abstract/neighborhood.hh \
core/abstract/point.hh \
core/abstract/point_set.hh \
@@ -210,6 +211,7 @@
value/bin.hh \
value/default.hh \
value/greylevel.hh \
+ value/lut_value_proxy.hh \
value/proxy.hh \
value/rw_counter.hh \
value/tags.hh \
Index: oln/morpher/with_lut.hh
--- oln/morpher/with_lut.hh (revision 700)
+++ oln/morpher/with_lut.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/morpher/internal/image_value_morpher.hh>
# include <oln/core/lookup_table.hh>
+# include <oln/value/lut_value_proxy.hh>
# include <oln/core/gen/fwd_viter_lut.hh>
@@ -70,17 +71,21 @@
/* lvalue_type: undefined
(see oln/morpher/internal/image_value_morpher.hh). */
+ /* FIXME: This virtual type (``is_value_wise_mutable'') is
+ useless, since the presence of mutable_value_proxy_type
+ suffices to state that the image is value-wise mutable. */
+
/* Mutability.
As the virtual type `lvalue' is undefined in with_lut<>, it is
not point-wise mutable. However, it is value-wise mutable,
i.e., the values of the look-up table can be modified. */
typedef mlc::true_ is_value_wise_mutable_type;
- // fwd_viter_type: see below.
- // mutable_fwd_viter_type: see below.
+ typedef value::lut_value_proxy<Lut> value_proxy_type;
+ typedef value::mutable_lut_value_proxy<Lut> mutable_value_proxy_type;
+ // fwd_viter_type: see below.
// FIXME: implement bkd_viter_type!
- // FIXME: implement mutable_bkd_viter_type!
};
// Rvalue.
@@ -100,14 +105,6 @@
{
typedef fwd_viter_lut<Lut> ret;
};
-
- /// Mutable forward viter vtype of morpher::with_lut.
- template <typename Image, typename Lut>
- struct single_vtype< morpher::with_lut<Image, Lut>,
- typedef_::mutable_fwd_viter_type >
- {
- typedef mutable_fwd_viter_lut<Lut> ret;
- };
/// \}
@@ -131,8 +128,8 @@
typedef oln_type_of(self_t, value) value_type;
typedef oln_type_of(self_t, rvalue) rvalue_type;
typedef oln_type_of(self_t, psite) psite_type;
- typedef oln_type_of(self_t, fwd_viter) fwd_viter_type;
- typedef oln_type_of(self_t, mutable_fwd_viter) mutable_fwd_viter_type;
+ typedef oln_type_of(self_t, value_proxy) value_proxy_type;
+ typedef oln_type_of(self_t, mutable_value_proxy) mutable_value_proxy_type;
public:
with_lut(const Image& image, const Lut& lut);
@@ -141,8 +138,8 @@
rvalue_type impl_op_read(const psite_type& p) const;
// FIXME: Constness of this method?
- fwd_viter_type impl_value(const value_type& v) const;
- mutable_fwd_viter_type impl_value(const value_type& v);
+ value_proxy_type impl_value(const value_type& v) const;
+ mutable_value_proxy_type impl_value(const value_type& v);
protected:
lut_type lut_;
@@ -170,17 +167,17 @@
}
template <typename Image, typename Lut>
- typename with_lut<Image, Lut>::fwd_viter_type
+ typename with_lut<Image, Lut>::value_proxy_type
with_lut<Image, Lut>::impl_value(const value_type& v) const
{
- return fwd_viter_type(lut_, v);
+ return value_proxy_type(lut_, v);
}
template <typename Image, typename Lut>
- typename with_lut<Image, Lut>::mutable_fwd_viter_type
+ typename with_lut<Image, Lut>::mutable_value_proxy_type
with_lut<Image, Lut>::impl_value(const value_type& v)
{
- return mutable_fwd_viter_type(lut_, v);
+ return mutable_value_proxy_type(lut_, v);
}
template <typename Image, typename Lut>
Index: oln/value/lut_value_proxy.hh
--- oln/value/lut_value_proxy.hh (revision 0)
+++ oln/value/lut_value_proxy.hh (revision 0)
@@ -0,0 +1,289 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_VALUE_LUT_VALUE_PROXY_HH
+# define OLN_CORE_VALUE_LUT_VALUE_PROXY_HH
+
+# include <iostream>
+# include <map>
+# include <set>
+# include <oln/value/proxy.hh>
+# include <oln/core/abstract/image/all.hh>
+
+
+namespace oln
+{
+
+ namespace value
+ {
+
+ /* FIXME: What entity we use to keep a reference on the pointed
+ value of the LUT:
+ - a LUT raw iterator (current choice), or
+ - a value iterator, or
+ - the value itself.
+ to keep a reference on the underlying value?
+
+ The third choice (value) /seems/ the most elegant from the
+ exterior of the proxy, but it's probably the most error-prone
+ too. */
+
+
+ /*------------------.
+ | lut_value_proxy. |
+ `------------------*/
+
+ template <typename Lut>
+ class lut_value_proxy :
+ public abstract::proxy< lut_value_proxy<Lut> >
+ {
+ public:
+
+ typedef typename Lut::new_value_type value_type;
+ typedef typename Lut::const_iterator lut_iter_type;
+
+ // Ctor.
+ lut_value_proxy(const Lut& lut, const value_type& v);
+
+ // Read.
+ template <typename V>
+ operator V() const;
+
+ // Explicit read.
+ value_type value() const;
+
+ // Write.
+ template <typename V>
+ lut_value_proxy<Lut>& operator=(const V& value);
+
+ // FIXME: Is this really necessary?
+ bool is_valid() const;
+
+ protected:
+ const Lut& lut_;
+ lut_iter_type i_;
+ };
+
+
+ template <typename Lut>
+ std::ostream& operator<<(std::ostream& ostr,
+ const lut_value_proxy<Lut>& proxy);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Ctor.
+ template <typename Lut>
+ lut_value_proxy<Lut>::lut_value_proxy(const Lut& lut,
+ const typename lut_value_proxy<Lut>::value_type& v)
+ : lut_(lut)
+ {
+ i_ = lut_.find(v);
+ postcondition(is_valid());
+ }
+
+ // Read.
+ template <typename Lut>
+ template <typename V>
+ lut_value_proxy<Lut>::operator V() const
+ {
+ precondition(is_valid());
+ V tmp = i_->second;
+ return tmp;
+ }
+
+ // Explicit read.
+ template <typename Lut>
+ typename lut_value_proxy<Lut>::value_type
+ lut_value_proxy<Lut>::value() const
+ {
+ precondition(is_valid());
+ precondition(i_ != lut_.end());
+ return i_->second;
+ }
+
+ template <typename Lut>
+ bool
+ lut_value_proxy<Lut>::is_valid() const
+ {
+ return i_ != lut_.end();
+ }
+
+ // Op <<.
+ template <typename Lut>
+ std::ostream& operator<<(std::ostream& ostr,
+ const lut_value_proxy<Lut>& proxy)
+ {
+ return ostr << proxy.value();
+ }
+
+# endif
+
+
+
+ /*--------------------------.
+ | mutable_lut_value_proxy. |
+ `--------------------------*/
+
+ template <typename Lut>
+ class mutable_lut_value_proxy :
+ public abstract::proxy< mutable_lut_value_proxy<Lut> >
+ {
+ public:
+
+ typedef typename Lut::new_value_type value_type;
+ typedef typename Lut::iterator lut_iter_type;
+
+ // Ctor.
+ mutable_lut_value_proxy(Lut& lut, const value_type& v);
+
+ // Read.
+ template <typename V>
+ operator V() const;
+
+ // Explicit read.
+ value_type value() const;
+
+ // Write.
+ template <typename V>
+ mutable_lut_value_proxy<Lut>& operator=(const V& value);
+
+ // FIXME: Is this really necessary?
+ bool is_valid() const;
+
+ protected:
+ Lut& lut_;
+ lut_iter_type i_;
+ };
+
+
+ template <typename Lut>
+ std::ostream& operator<<(std::ostream& ostr,
+ const mutable_lut_value_proxy<Lut>& proxy);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Ctor.
+ template <typename Lut>
+ mutable_lut_value_proxy<Lut>::mutable_lut_value_proxy(Lut& lut,
+ const typename mutable_lut_value_proxy<Lut>::value_type& v)
+ : lut_(lut)
+ {
+ i_ = lut_.find(v);
+ postcondition(is_valid());
+ }
+
+ // Read.
+ template <typename Lut>
+ template <typename V>
+ mutable_lut_value_proxy<Lut>::operator V() const
+ {
+ // FIXME: Turn this into a is_valid method.
+ precondition(is_valid());
+ V tmp = i_->second;
+ return tmp;
+ }
+
+ // Explicit read.
+ template <typename Lut>
+ typename mutable_lut_value_proxy<Lut>::value_type
+ mutable_lut_value_proxy<Lut>::value() const
+ {
+ // FIXME: Turn this into a is_valid method.
+ precondition(is_valid());
+ precondition(i_ != lut_.end());
+ return i_->second;
+ }
+
+ // Write.
+
+ template <typename Lut>
+ template <typename V>
+ mutable_lut_value_proxy<Lut>&
+ mutable_lut_value_proxy<Lut>::operator=(const V& value)
+ {
+ precondition(is_valid());
+
+ typedef typename Lut::orig_value_type orig_value_t;
+ typedef typename Lut::new_value_type new_value_t;
+
+ // Current ``new'' value.
+ new_value_t cur_new_val = i_->first;
+
+ // Shortcuts.
+ typedef lut_iter_type new_iter_t;
+ typedef std::pair<new_iter_t, new_iter_t> new_iter_range_t;
+
+ // Current ``original'' value(s) associated to the next ``new''
+ // value VALUE.
+ new_iter_range_t cur_orig_val_range =
+ lut_.new_to_orig_map().equal_range(cur_new_val);
+ // A temporary map where additional bindings will be stored.
+ typename Lut::new_to_orig_map_type additional_bindings;
+
+ for (new_iter_t j = cur_orig_val_range.first;
+ j != cur_orig_val_range.second; ++j)
+ {
+ // Update the orig-to-new map (substitution).
+ orig_value_t orig_val = j->second;
+ lut_.orig_to_new_map()[orig_val] = value;
+ // Populate the temp map.
+ additional_bindings.insert(std::make_pair(value, orig_val));
+ }
+ // Update the new-to-orig map (deletion).
+ lut_.new_to_orig_map().erase(cur_orig_val_range.first,
+ cur_orig_val_range.second);
+ // Update the new-to-orig map (insertion).
+ lut_.new_to_orig_map().insert(additional_bindings.begin(),
+ additional_bindings.end());
+ return *this;
+ }
+
+ template <typename Lut>
+ bool
+ mutable_lut_value_proxy<Lut>::is_valid() const
+ {
+ return i_ != lut_.end();
+ }
+
+ // Op <<.
+ template <typename Lut>
+ std::ostream& operator<<(std::ostream& ostr,
+ const mutable_lut_value_proxy<Lut>& proxy)
+ {
+ return ostr << proxy.value();
+ }
+
+# endif
+
+ } // end of namespace oln::value
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_VALUE_LUT_VALUE_PROXY_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix fwd_viter_lut and rgb8.
* oln/value/color/rgb.hh (rgb_<T>::operator==): Make it const.
* oln/core/gen/fwd_viter_lut.hh (operator rvalue_type, print): Fix
these methods.
* tests/morphers/with_lut.cc: Test oln::fwd_viter_lut.
oln/core/gen/fwd_viter_lut.hh | 11 ++++++-----
oln/value/color/rgb.hh | 4 ++--
tests/morphers/with_lut.cc | 30 ++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 7 deletions(-)
Index: tests/morphers/with_lut.cc
--- tests/morphers/with_lut.cc (revision 699)
+++ tests/morphers/with_lut.cc (working copy)
@@ -27,6 +27,8 @@
/// Test the look-up table morpher.
+#include <list>
+
#include <oln/basics2d.hh>
#include <oln/morpher/with_lut.hh>
#include <oln/value/color/rgb.hh>
@@ -144,6 +146,34 @@
assert(ima_with_lut(p) == red);
assert(ima_with_lut.at(1, 2) == red);
+
+ // Check fwd_viter_lut.
+ oln_type_of_(image_with_lut_t, fwd_viter) fv(ima_with_lut.lut());
+ std::list<rgb8> fwd_values;
+ std::cout << "values of lut (fwd) =" << std::endl;
+ for_all (fv)
+ {
+ // Push the values to the *back* of the list.
+ fwd_values.push_back(fv);
+ std::cout << " " << fv << std::endl;
+ }
+
+// FIXME: To be enabled later.
+
+// // Check bkd_viter_lut.
+// oln_type_of_(image_with_lut_t, bkd_viter) bv(ima_with_lut.lut());
+// std::list<rgb8> bkd_values;
+// std::cout << "values of lut (bkd) =" << std::endl;
+// for_all (bv)
+// {
+// // Push the values to the *front* of the list.
+// bkd_values.push_front(bv);
+// std::cout << " " << bv << std::endl;
+// }
+// // Compare the two lists.
+// assert (fwd_values == bkd_values);
+
+
// FIXME: To be enabled later, when oln::level::fill is specialized
// for abstract::mutable_image_being_value_wise_random_accessible.
#if 0
Index: oln/core/gen/fwd_viter_lut.hh
--- oln/core/gen/fwd_viter_lut.hh (revision 699)
+++ oln/core/gen/fwd_viter_lut.hh (working copy)
@@ -117,14 +117,14 @@
fwd_viter_lut<Lut>::operator typename fwd_viter_lut<Lut>::rvalue_type() const
{
precondition(this->is_valid());
- return this->i_->second;
+ return this->i_->first;
}
template <typename Lut>
void fwd_viter_lut<Lut>::print(std::ostream& ostr) const
{
precondition(this->is_valid());
- ostr << "fwd_viter_lut<Lut> { value = " << this->i_->second << " }";
+ ostr << "fwd_viter_lut<Lut> { value = " << this->i_->first << " }";
}
@@ -177,6 +177,7 @@
{
typedef mutable_fwd_viter_lut<Lut> self_t;
typedef stc_get_super(self_t) super_t;
+ typedef oln_type_of(self_t, lut_iter) lut_iter_t;
typedef typename Lut::orig_value_type orig_value_t;
typedef typename Lut::new_value_type new_value_t;
@@ -237,7 +238,7 @@
mutable_fwd_viter_lut<Lut>::operator typename mutable_fwd_viter_lut<Lut>::lvalue_type()
{
precondition(this->is_valid());
- return this->i_->second;
+ return this->i_->first;
}
template <typename Lut>
@@ -250,7 +251,7 @@
new_value_t cur_new_val = this->i_->first;
// Shortcuts.
- typedef typename Lut::iterator new_iter_t;
+ typedef lut_iter_t new_iter_t;
typedef std::pair<new_iter_t, new_iter_t> new_iter_range_t;
// Current ``original'' value(s) associated to the next ``new'' value RHS.
@@ -282,7 +283,7 @@
{
precondition(this->is_valid());
ostr
- << "mutable_fwd_viter_lut<Lut> { value = " << this->i_->second << " }";
+ << "mutable_fwd_viter_lut<Lut> { value = " << this->i_->first << " }";
}
Index: oln/value/color/rgb.hh
--- oln/value/color/rgb.hh (revision 699)
+++ oln/value/color/rgb.hh (working copy)
@@ -65,7 +65,7 @@
/// Op==.
template <typename U>
- bool operator==(const rgb_<U>& rhs);
+ bool operator==(const rgb_<U>& rhs) const;
T red() const;
T& red();
@@ -129,7 +129,7 @@
template <typename T>
template <typename U>
- bool rgb_<T>::operator==(const rgb_<U>& rhs)
+ bool rgb_<T>::operator==(const rgb_<U>& rhs) const
{
return
val_[0] == rhs.red() and
1
0
2006-11-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* xtd/vec.hh (L2_norm): New.
(include): Add cmath header.
Index: xtd/vec.hh
===================================================================
--- xtd/vec.hh (revision 694)
+++ xtd/vec.hh (working copy)
@@ -29,6 +29,8 @@
# define XTD_VEC_HH
# include <iostream>
+# include <cmath>
+
# include <mlc/contract.hh>
# include <xtd/optraits.hh>
@@ -317,6 +319,8 @@
}
+ // lexi_less.
+
struct lexi_less_t
{
template <unsigned n, typename T>
@@ -331,7 +335,6 @@
}
};
-
template <unsigned n, typename T>
bool lexi_less(const vec<n,T>& lhs, const vec<n,T>& rhs)
{
@@ -340,6 +343,19 @@
}
+ // L2_norm.
+
+ template <unsigned n, typename T>
+ float L2_norm(const vec<n,T>& v)
+ {
+ float val = 0.f;
+ for (unsigned i = 0; i < n; ++i)
+ val += float(v[i]) * float(v[i]);
+ return std::sqrt(val);
+ }
+
+
+
template <typename uop,
unsigned n, typename T>
struct set_trait_< uop, vec<n,T> >
1
0
2006-11-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add point-set types based on std containers.
* oln/core/gen/piter_on_std_based_pset.hh: New.
* oln/core/gen/pset_list.hh: New.
* oln/core/gen/pset_vec.hh: New.
* oln/core/gen/pset_.hh: New.
* oln/Makefile.am: Update.
2006-11-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Index: oln/core/gen/piter_on_std_based_pset.hh
===================================================================
--- oln/core/gen/piter_on_std_based_pset.hh (revision 0)
+++ oln/core/gen/piter_on_std_based_pset.hh (revision 0)
@@ -0,0 +1,278 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+# define OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+
+# include <oln/core/abstract/point.hh>
+# include <oln/core/abstract/iterator_on_points.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd_piter version.
+ // ------------------
+
+
+ // Forward declaration.
+ template <typename C> class fwd_piter_on_std_based_pset;
+
+
+ // Super.
+ template <typename C>
+ struct set_super_type< fwd_piter_on_std_based_pset<C> >
+ {
+ typedef abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> > ret;
+ };
+
+
+ // Vtypes.
+ template <typename C>
+ struct vtypes< fwd_piter_on_std_based_pset<C> >
+ {
+ typedef typename C::value_type point_type;
+ };
+
+
+ // Class.
+ template <typename C>
+ class fwd_piter_on_std_based_pset :
+
+ public abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> >,
+ private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ {
+ public:
+ fwd_piter_on_std_based_pset(const C& container);
+
+ template <typename point_set>
+ fwd_piter_on_std_based_pset(const point_set& ps);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ typename C::value_type impl_to_point() const;
+ const typename C::value_type* impl_point_adr() const;
+
+ private:
+
+ const C& container_;
+ typename C::const_iterator it_;
+
+ }; // end of class fwd_piter_on_std_based_pset<C>
+
+
+
+ // Bkd_piter version.
+ // ------------------
+
+
+ // Forward declaration.
+ template <typename C> class bkd_piter_on_std_based_pset;
+
+
+ // Super.
+ template <typename C>
+ struct set_super_type< bkd_piter_on_std_based_pset<C> >
+ {
+ typedef abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> > ret;
+ };
+
+
+ // Vtypes.
+ template <typename C>
+ struct vtypes< bkd_piter_on_std_based_pset<C> >
+ {
+ typedef typename C::value_type point_type;
+ };
+
+
+ // Class.
+ template <typename C>
+ class bkd_piter_on_std_based_pset :
+
+ public abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> >,
+ private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ {
+ public:
+ bkd_piter_on_std_based_pset(const C& container);
+
+ template <typename point_set>
+ bkd_piter_on_std_based_pset(const point_set& ps);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ typename C::value_type impl_to_point() const;
+ const typename C::value_type* impl_point_adr() const;
+
+ private:
+
+ const C& container_;
+ typename C::const_reverse_iterator it_;
+
+ }; // end of class bkd_piter_on_std_based_pset<C>
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // fwd_piter_on_std_based_pset<C>
+
+
+ template <typename C>
+ fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const C& container)
+ : container_(container)
+ {
+ this->invalidate();
+ }
+
+ template <typename C>
+ template <typename point_set>
+ fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const point_set& ps)
+ : container_(ps.exact().container())
+ {
+ this->invalidate();
+ }
+
+ template <typename C>
+ void fwd_piter_on_std_based_pset<C>::impl_start()
+ {
+ it_ = container_.begin();
+ }
+
+ template <typename C>
+ void fwd_piter_on_std_based_pset<C>::impl_next()
+ {
+ ++it_;
+ }
+
+ template <typename C>
+ void fwd_piter_on_std_based_pset<C>::impl_invalidate()
+ {
+ it_ = container_.end();
+ }
+
+ template <typename C>
+ bool fwd_piter_on_std_based_pset<C>::impl_is_valid() const
+ {
+ return it_ != container_.end();
+ }
+
+ template <typename C>
+ typename C::value_type
+ fwd_piter_on_std_based_pset<C>::impl_to_point() const
+ {
+ return *it_;
+ }
+
+ template <typename C>
+ const typename C::value_type*
+ fwd_piter_on_std_based_pset<C>::impl_point_adr() const
+ {
+ return 0;
+ // FIXME: Read below.
+ // "&(*it_)" is not correct because the std does not ensure that
+ // "*it_" is dereferenceable (Cf. std trivial iterator concept).
+ // However, "::point_adr()" is only required so that an iterator
+ // based on another iterator (e.g., a niter constructed from a
+ // piter) can stick to the point location of the latter. This
+ // is not required for iterators on point set so this method should
+ // be optional.
+ }
+
+
+ // bkd_piter_on_std_based_pset<C>
+
+
+ template <typename C>
+ bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const C& container)
+ : container_(container)
+ {
+ this->invalidate();
+ }
+
+ template <typename C>
+ template <typename point_set>
+ bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const point_set& ps)
+ : container_(ps.exact().container())
+ {
+ this->invalidate();
+ }
+
+ template <typename C>
+ void bkd_piter_on_std_based_pset<C>::impl_start()
+ {
+ it_ = container_.rbegin();
+ }
+
+ template <typename C>
+ void bkd_piter_on_std_based_pset<C>::impl_next()
+ {
+ ++it_;
+ }
+
+ template <typename C>
+ void bkd_piter_on_std_based_pset<C>::impl_invalidate()
+ {
+ it_ = container_.rend();
+ }
+
+ template <typename C>
+ bool bkd_piter_on_std_based_pset<C>::impl_is_valid() const
+ {
+ return it_ != container_.rend();
+ }
+
+ template <typename C>
+ typename C::value_type
+ bkd_piter_on_std_based_pset<C>::impl_to_point() const
+ {
+ return *it_;
+ }
+
+ template <typename C>
+ const typename C::value_type*
+ bkd_piter_on_std_based_pset<C>::impl_point_adr() const
+ {
+ return 0;
+ // FIXME: Read comments in the fwd version of this method.
+ }
+
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
Index: oln/core/gen/pset_list.hh
===================================================================
--- oln/core/gen/pset_list.hh (revision 0)
+++ oln/core/gen/pset_list.hh (revision 0)
@@ -0,0 +1,181 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PSET_LIST_HH
+# define OLN_CORE_GEN_PSET_LIST_HH
+
+# include <list>
+
+# include <oln/core/point_set_entry.hh>
+# include <oln/core/abstract/point.hh>
+
+
+namespace oln
+{
+
+ // Forward declarations.
+ template <typename point_t> class pset_list;
+ template <typename C> class fwd_piter_on_std_based_pset;
+ template <typename C> class bkd_piter_on_std_based_pset;
+
+
+ // Super type declaration.
+ template <typename point_t>
+ struct set_super_type< pset_list<point_t> >
+ {
+ typedef pset_list<point_t> self_t;
+ typedef point_set_entry<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::pset_list<point_t>.
+ template <typename point_t>
+ struct vtypes< pset_list<point_t> >
+ {
+ typedef point_t point_type;
+ typedef fwd_piter_on_std_based_pset< std::list<point_t> > fwd_piter_type;
+ typedef bkd_piter_on_std_based_pset< std::list<point_t> > bkd_piter_type;
+
+ typedef mlc::false_ is_random_accessible_type;
+ typedef mlc::true_ has_know_size_type;
+ typedef mlc::false_ is_connected_type;
+ };
+
+
+ /// Bounding box class based on a point class.
+ template <typename point_t>
+ class pset_list : public point_set_entry< pset_list<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
+ {
+ typedef pset_list<point_t> self_type;
+ typedef point_set_entry<self_type> super_t;
+
+ public:
+
+ pset_list();
+ pset_list(const pset_list<point_t>& rhs);
+ pset_list<point_t>& operator=(const pset_list<point_t>& rhs);
+
+ unsigned impl_npoints() const;
+ bool impl_is_valid() const;
+ void impl_print(std::ostream& ostr) const;
+
+ pset_list<point_t>& append(const point_t& p);
+ pset_list<point_t>& prepend(const point_t& p);
+
+ const std::list<point_t>& container() const;
+ std::list<point_t>& container();
+
+ protected:
+
+ std::list<point_t> lp_;
+
+ }; // end of class oln::pset_list<point_t>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ pset_list<point_t>::pset_list()
+ {
+ }
+
+ template <typename point_t>
+ pset_list<point_t>::pset_list(const pset_list<point_t>& rhs)
+ {
+ lp_ = rhs.lp_;
+ }
+
+ template <typename point_t>
+ pset_list<point_t>& pset_list<point_t>::operator=(const pset_list<point_t>& rhs)
+ {
+ lp_ = rhs.lp_;
+ return *this;
+ }
+
+ template <typename point_t>
+ unsigned pset_list<point_t>::impl_npoints() const
+ {
+ return lp_.size();
+ }
+
+ template <typename point_t>
+ bool pset_list<point_t>::impl_is_valid() const
+ {
+ return true;
+ }
+
+ template <typename point_t>
+ void pset_list<point_t>::impl_print(std::ostream& ostr) const
+ {
+ typename std::list<point_t>::const_iterator it;
+ ostr << "{ ";
+ for (it = lp_.begin(); it != lp_.end(); ++it)
+ ostr << *it << ' ';
+ ostr << "}";
+ }
+
+ template <typename point_t>
+ pset_list<point_t>& pset_list<point_t>::append(const point_t& p)
+ {
+ precondition(std::find(lp_.begin(), lp_.end(), p)
+ == lp_.end());
+ lp_.push_back(p);
+ return *this;
+ }
+
+ template <typename point_t>
+ pset_list<point_t>& pset_list<point_t>::prepend(const point_t& p)
+ {
+ precondition(std::find(lp_.begin(), lp_.end(), p)
+ == lp_.end());
+ lp_.push_front(p);
+ return *this;
+ }
+
+ template <typename point_t>
+ const std::list<point_t>& pset_list<point_t>::container() const
+ {
+ return lp_;
+ }
+
+ template <typename point_t>
+ std::list<point_t>& pset_list<point_t>::container()
+ {
+ return lp_;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/piter_on_std_based_pset.hh>
+
+
+#endif // ! OLN_CORE_GEN_PSET_LIST_HH
Index: oln/core/gen/pset_vec.hh
===================================================================
--- oln/core/gen/pset_vec.hh (revision 0)
+++ oln/core/gen/pset_vec.hh (revision 0)
@@ -0,0 +1,171 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PSET_VEC_HH
+# define OLN_CORE_GEN_PSET_VEC_HH
+
+# include <vector>
+
+# include <oln/core/point_set_entry.hh>
+# include <oln/core/abstract/point.hh>
+
+
+namespace oln
+{
+
+ // Forward declarations.
+ template <typename point_t> class pset_vec;
+ template <typename C> class fwd_piter_on_std_based_pset;
+ template <typename C> class bkd_piter_on_std_based_pset;
+
+
+ // Super type declaration.
+ template <typename point_t>
+ struct set_super_type< pset_vec<point_t> >
+ {
+ typedef pset_vec<point_t> self_t;
+ typedef point_set_entry<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::pset_vec<point_t>.
+ template <typename point_t>
+ struct vtypes< pset_vec<point_t> >
+ {
+ typedef point_t point_type;
+ typedef fwd_piter_on_std_based_pset< std::vector<point_t> > fwd_piter_type;
+ typedef bkd_piter_on_std_based_pset< std::vector<point_t> > bkd_piter_type;
+
+ typedef mlc::false_ is_random_accessible_type;
+ typedef mlc::true_ has_know_size_type;
+ typedef mlc::false_ is_connected_type;
+ };
+
+
+ /// Bounding box class based on a point class.
+ template <typename point_t>
+ class pset_vec : public point_set_entry< pset_vec<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
+ {
+ typedef pset_vec<point_t> self_type;
+ typedef point_set_entry<self_type> super_t;
+
+ public:
+
+ pset_vec();
+ pset_vec(const pset_vec<point_t>& rhs);
+ pset_vec<point_t>& operator=(const pset_vec<point_t>& rhs);
+
+ unsigned impl_npoints() const;
+ bool impl_is_valid() const;
+ void impl_print(std::ostream& ostr) const;
+
+ pset_vec<point_t>& append(const point_t& p);
+
+ const std::vector<point_t>& container() const;
+ std::vector<point_t>& container();
+
+ protected:
+
+ std::vector<point_t> vp_;
+
+ }; // end of class oln::pset_vec<point_t>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ pset_vec<point_t>::pset_vec()
+ {
+ }
+
+ template <typename point_t>
+ pset_vec<point_t>::pset_vec(const pset_vec<point_t>& rhs)
+ {
+ vp_ = rhs.vp_;
+ }
+
+ template <typename point_t>
+ pset_vec<point_t>& pset_vec<point_t>::operator=(const pset_vec<point_t>& rhs)
+ {
+ vp_ = rhs.vp_;
+ return *this;
+ }
+
+ template <typename point_t>
+ unsigned pset_vec<point_t>::impl_npoints() const
+ {
+ return vp_.size();
+ }
+
+ template <typename point_t>
+ bool pset_vec<point_t>::impl_is_valid() const
+ {
+ return true;
+ }
+
+ template <typename point_t>
+ void pset_vec<point_t>::impl_print(std::ostream& ostr) const
+ {
+ typename std::vector<point_t>::const_iterator it;
+ ostr << "{ ";
+ for (it = vp_.begin(); it != vp_.end(); ++it)
+ ostr << *it << ' ';
+ ostr << "}";
+ }
+
+ template <typename point_t>
+ pset_vec<point_t>& pset_vec<point_t>::append(const point_t& p)
+ {
+ precondition(std::find(vp_.begin(), vp_.end(), p)
+ == vp_.end());
+ vp_.push_back(p);
+ return *this;
+ }
+
+ template <typename point_t>
+ const std::vector<point_t>& pset_vec<point_t>::container() const
+ {
+ return vp_;
+ }
+
+ template <typename point_t>
+ std::vector<point_t>& pset_vec<point_t>::container()
+ {
+ return vp_;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/piter_on_std_based_pset.hh>
+
+
+#endif // ! OLN_CORE_GEN_PSET_VEC_HH
Index: oln/core/gen/pset_.hh
===================================================================
--- oln/core/gen/pset_.hh (revision 0)
+++ oln/core/gen/pset_.hh (revision 0)
@@ -0,0 +1,170 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PSET_HH
+# define OLN_CORE_GEN_PSET_HH
+
+# include <set>
+
+# include <oln/core/point_set_entry.hh>
+# include <oln/core/abstract/point.hh>
+
+
+namespace oln
+{
+
+ // Forward declarations.
+ template <typename point_t> class pset_;
+ template <typename C> class fwd_piter_on_std_based_pset;
+ template <typename C> class bkd_piter_on_std_based_pset;
+
+
+ // Super type declaration.
+ template <typename point_t>
+ struct set_super_type< pset_<point_t> >
+ {
+ typedef pset_<point_t> self_t;
+ typedef point_set_entry<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::pset_<point_t>.
+ template <typename point_t>
+ struct vtypes< pset_<point_t> >
+ {
+ typedef point_t point_type;
+ typedef fwd_piter_on_std_based_pset< std::set<point_t> > fwd_piter_type;
+ typedef bkd_piter_on_std_based_pset< std::set<point_t> > bkd_piter_type;
+
+ typedef mlc::false_ is_random_accessible_type;
+ typedef mlc::true_ has_know_size_type;
+ typedef mlc::false_ is_connected_type;
+ };
+
+
+ /// Bounding box class based on a point class.
+ template <typename point_t>
+ class pset_ : public point_set_entry< pset_<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
+ {
+ typedef pset_<point_t> self_type;
+ typedef point_set_entry<self_type> super_t;
+
+ public:
+
+ pset_();
+ pset_(const pset_<point_t>& rhs);
+ pset_<point_t>& operator=(const pset_<point_t>& rhs);
+
+ unsigned impl_npoints() const;
+ bool impl_is_valid() const;
+ void impl_print(std::ostream& ostr) const;
+
+ pset_<point_t>& insert(const point_t& p);
+
+ const std::set<point_t>& container() const;
+ std::set<point_t>& container();
+
+ protected:
+
+ std::set<point_t> sp_;
+
+ }; // end of class oln::pset_<point_t>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ pset_<point_t>::pset_()
+ {
+ }
+
+ template <typename point_t>
+ pset_<point_t>::pset_(const pset_<point_t>& rhs)
+ {
+ sp_ = rhs.sp_;
+ }
+
+ template <typename point_t>
+ pset_<point_t>& pset_<point_t>::operator=(const pset_<point_t>& rhs)
+ {
+ sp_ = rhs.sp_;
+ return *this;
+ }
+
+ template <typename point_t>
+ unsigned pset_<point_t>::impl_npoints() const
+ {
+ return sp_.size();
+ }
+
+ template <typename point_t>
+ bool pset_<point_t>::impl_is_valid() const
+ {
+ return true;
+ }
+
+ template <typename point_t>
+ void pset_<point_t>::impl_print(std::ostream& ostr) const
+ {
+ typename std::set<point_t>::const_iterator it;
+ ostr << "{ ";
+ for (it = sp_.begin(); it != sp_.end(); ++it)
+ ostr << *it << ' ';
+ ostr << "}";
+ }
+
+ template <typename point_t>
+ pset_<point_t>& pset_<point_t>::insert(const point_t& p)
+ {
+ precondition(sp_.find(p) == sp_.end());
+ sp_.insert(p);
+ return *this;
+ }
+
+ template <typename point_t>
+ const std::set<point_t>& pset_<point_t>::container() const
+ {
+ return sp_;
+ }
+
+ template <typename point_t>
+ std::set<point_t>& pset_<point_t>::container()
+ {
+ return sp_;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/piter_on_std_based_pset.hh>
+
+
+#endif // ! OLN_CORE_GEN_PSET_HH
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 696)
+++ oln/Makefile.am (working copy)
@@ -128,9 +128,14 @@
core/gen/fwd_qiter_win.hh \
core/gen/fwd_viter_lut.hh \
core/gen/piter_isubset.hh \
+ core/gen/piter_isubset.hh \
+ core/gen/pset_.hh \
+ core/gen/pset_list.hh \
+ core/gen/pset_vec.hh \
core/gen/grid.hh \
core/gen/mapimage.hh \
core/gen/neighb.hh \
+ core/gen/piter_on_std_based_pset.hh \
core/gen/pw_value.hh \
core/gen/topo_add_isubset.hh \
core/gen/topo_add_nbh.hh \
1
0
2006-11-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* TODO: Add description of primary image types.
Index: TODO
===================================================================
--- TODO (revision 696)
+++ TODO (working copy)
@@ -17,6 +17,237 @@
+* Primary image types
+
+
+** contents
+
+type Q
+
+image2d<T> 0
+slow::image_bbmap<P, T> 0
+
+rle_image<P, T> 1
+sparse_image<P, T> 1
+image_vec<P, T> 1
+image_map<P, T> 1
+
+one_value_image<S, T> 2
+image_p2v<S, F> 2
+
+igraph<T> 3
+image_2dhex<T> 3
+
+image2d_without_border<T> 1
+
+
+** image2d<T>
+
+*** parameter
+
+T: value type
+
+*** main features
+
+has a virtual border (same thickness for every axis)
+point-wise accessible and mutable
+not value-wise accessible
+
+*** data storage
+
+relies on array2d<T>
+
+*** to-do
+
+should rely on array2d< T::storage >
+
+*** related types
+
+image1d<T> and image3d<T> are similarly constructed
+
+
+** image_2dhex<T>
+
+on a 2D triangular grid (hexagonal pixels)
+FIXME: ...
+
+
+** igraph<T>
+
+FIXME: ...
+
+
+** image2d_without_border<T>
+
+*** status
+
+to-do
+
+*** main features
+
+same as image2d<T> but without virtual border
+
+*** data storage
+
+relies on array2d<T>
+
+
+** one_value_image<S, T>
+
+*** parameters
+
+S: point set type
+T: type of the value
+
+*** main features
+
+point-wise accessible but not mutable
+value-wise accessible and mutable
+
+*** data storage
+
+a single attribute: the unique value
+
+
+** image_p2v<S, F>
+
+*** parameters
+
+S: point set type
+F: function point-site -> value
+
+*** main features
+
+point-wise accessible but not mutable
+not value-wise accessible
+
+*** data storage
+
+combines the point set and the function to produce values
+on the fly
+
+
+** rle_image<P, T>
+
+*** parameter
+
+P: point type
+T: value type
+
+*** main features
+
+not point-wise accessible
+not value-wise accessible
+
+*** data storage
+
+std::vector of triplets (p_start, length, value)
+
+*** related type
+
+sparse_image<T>
+
+
+** sparse_image<P, T>
+
+*** parameter
+
+P: point type
+T: value type
+
+*** main features
+
+not point-wise accessible
+not value-wise accessible
+
+*** data storage
+
+std::vector of couples (p_start, std::vector<T>)
+
+*** related type
+
+rle_image<P, T>
+
+
+** image_vec<P, T>
+
+*** parameters
+
+P: point type
+T: value type
+
+*** main features
+
+not point-wise accessible
+not value-wise accessible
+
+*** data storage
+
+std::vector< std::pair<P, T> >
+
+
+** image_map<P, T>
+
+*** parameters
+
+P: point type
+T: value type
+
+*** main features
+
+not point-wise accessible
+not value-wise accessible
+
+*** data storage
+
+using std::map<P, T>
+
+*** related type
+
+slow::image_map<P, T>
+
+
+** slow::image_bbmap<P, T>
+
+*** parameters
+
+P: point type
+T: value type
+
+*** main features
+
+point-wise accessible and mutable
+not value-wise accessible
+bounding-boxed
+
+*** data storage
+
+some values are set in a std::map<P, T>
+when not set, a default value is provided by an attribute
+
+*** related type
+
+image_map<P, T>
+
+
+
+* Morpher types
+
+** FIXME
+
+do (really!) nothing when writing at p when outside the image domain
+error when reading at p when outside the image domain
+
+** FIXME
+
+add a default value when p is outside the image domain
+
+** sequence<I>
+
+FIXME: ...
+
+
+
Local Variables:
mode: outline
ispell-local-dictionary: "american"
1
0
On 2006-11-03, Roland Levillain <roland(a)lrde.epita.fr> wrote:
> Roland Levillain <roland(a)lrde.epita.fr> writes:
>
>> https://svn.lrde.epita.fr/svn/oln/trunk/metalic
>>
>>
>> Index: ChangeLog
>> from Roland Levillain <roland(a)lrde.epita.fr>
>>
>> Add spaces in macros to please icpc.
>> * mlc/is_a.hh, mlc/case.hh: Add spaces in macros to please icpc.
>>
>> 0 files changed
>>
>> Index: mlc/is_a.hh
>> Index: mlc/case.hh
>
> Sorry for this ``blank'' patch, but Vcs removes any white space in altered
> lines in diffs.
>
> BTW, is there an option to disable this behavior in Vcs? If not, I
> suggest adding an option like `--show-space-change' (i.e., the
> opposite from diff's --ignore-space-change).
>
Or simply when the diff is empty, diff it again without removing white spaces
and stuff.
>
> Here is a more readable diff:
>
LOL.
>
> Index: mlc/is_a.hh
>===================================================================
> --- mlc/is_a.hh (révision 693)
> +++ mlc/is_a.hh (révision 694)
> @@ -240,11 +240,11 @@
>
> # define mlc_is_a(T, U) \
> mlc::wrap_< \
> - typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< typename mlc::basic_<T>::ret, U > \
> + typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< typename mlc::basic_< T >::ret, U > \
> >
>
> # define mlc_is_a_(T, U) \
> -mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< mlc::basic_<T>::ret, U >
> +mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< mlc::basic_< T >::ret, U >
>
> [SNIP]
What's the problem with icpc? Why does it actually *need* whitespaces there?
--
SIGOURE Benoit aka Tsuna (SUSv3 compliant)
_____ "On a long enough timeline, the survival rate
/EPITA\ Promo 2008.CSI/ACU for everyone drops to zero" -- Jack.
2
2
2006-11-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add oln::morpher::two_way_rw.
* ChangeLog: Fix file dir in previous entry.
* tests/morphers/two_way_rw_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/morpher/two_way_rw.hh: New.
* oln/Makefile.am: Update.
* oln/morpher/two_way.hh (value::two_way): Move impl into...
* oln/value/two_way.hxx: ...this new file.
* oln/core/abstract/functions.hh (fun_rw): Update.
* oln/morpher/count_rw.hh (count_rw): Move impl into guards.
* oln/morpher/stack_rw.hh (include): Update.
Index: tests/morphers/two_way_rw_morpher.cc
===================================================================
--- tests/morphers/two_way_rw_morpher.cc (revision 0)
+++ tests/morphers/two_way_rw_morpher.cc (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test the "two-way read-write" morpher.
+
+# include <cassert>
+
+# include <oln/basics2d.hh>
+# include <oln/morpher/two_way_rw.hh>
+
+
+
+
+struct norm_t : public oln::abstract::fun_rw< norm_t >
+{
+ typedef float result_type;
+
+ template <typename I>
+ float read(const I& input, const oln_point(I)& p) const
+ {
+ return xtd::L2_norm(input(p));
+ }
+
+ template <typename I>
+ void write(I& input, const oln_point(I)& p, float val) const
+ {
+ float old_norm = xtd::L2_norm(input(p));
+ assert(old_norm != 0);
+ input(p) *= val / old_norm;
+ }
+};
+
+
+
+int main()
+{
+ norm_t norm;
+
+ using namespace oln;
+ using xtd::vec;
+ using xtd::mk_vec;
+
+ typedef image2d< vec<2,float> > image_t;
+
+ image_t ima(1, 1);
+ point2d p(0, 0);
+
+ ima(p) = mk_vec(5,1);
+ norm(ima)(p) = 1;
+ assert(xtd::L2_norm(ima(p)) == 1);
+}
Index: tests/morphers/Makefile.am
===================================================================
--- tests/morphers/Makefile.am (revision 695)
+++ tests/morphers/Makefile.am (working copy)
@@ -26,6 +26,7 @@
stack_morpher \
stack_rw_morpher \
two_way_morpher \
+ two_way_rw_morpher \
value_cast \
with_lut \
\
@@ -39,6 +40,7 @@
stack_morpher_SOURCES = stack_morpher.cc
stack_rw_morpher_SOURCES = stack_rw_morpher.cc
two_way_morpher_SOURCES = two_way_morpher.cc
+two_way_rw_morpher_SOURCES = two_way_rw_morpher.cc
value_cast_SOURCES = value_cast.cc
with_lut_SOURCES = with_lut.cc
Index: oln/core/abstract/functions.hh
===================================================================
--- oln/core/abstract/functions.hh (revision 695)
+++ oln/core/abstract/functions.hh (working copy)
@@ -39,7 +39,10 @@
// Fwd decl.
- namespace morpher { template <typename I, typename F> class two_way; }
+ namespace morpher {
+ template <typename I, typename F> class two_way;
+ template <typename I, typename F> class two_way_rw;
+ }
namespace value { template <typename I, typename F> class two_way; }
@@ -85,7 +88,7 @@
};
- // FIXME: Value1 -> Value2 *and* Value2 -> Value1.
+ // (Image, Point) -> Value2 *and* (Image, Point, Value2) -> Value1.
template <typename E>
struct fun_rw : public virtual stc::any__simple<E>,
@@ -94,7 +97,7 @@
public:
template <typename I>
- oln::morpher::two_way<I, E>
+ oln::morpher::two_way_rw<I, E>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 695)
+++ oln/Makefile.am (working copy)
@@ -194,6 +194,7 @@
morpher/thru_fun.hh \
morpher/thru_mfun.hh \
morpher/two_way.hh \
+ morpher/two_way_rw.hh \
morpher/value_cast.hh \
morpher/with_lut.hh \
\
@@ -208,6 +209,7 @@
value/rw_counter.hh \
value/tags.hh \
value/two_way.hh \
+ value/two_way.hxx \
\
basics1d.hh \
basics2d.hh \
Index: oln/morpher/two_way.hh
===================================================================
--- oln/morpher/two_way.hh (revision 695)
+++ oln/morpher/two_way.hh (working copy)
@@ -159,127 +159,10 @@
} // end of namespace oln::morpher
+} // end of namespace oln
-# ifndef OLN_INCLUDE_ONLY
- namespace value
- {
+# include <oln/value/two_way.hxx>
- // Ctor.
- template <typename I, typename F>
- two_way<I,F>::two_way(I& ima,
- F fun,
- const oln_psite(I)& p)
- : ima_(&ima),
- fun_(fun),
- p_(p)
- {
- }
- // Ctor.
- template <typename I, typename F>
- two_way<I,F>::two_way(I& ima,
- const oln_psite(I)& p)
- : ima_(&ima),
- fun_(),
- p_(p)
- {
- }
-
- // Read.
- template <typename I, typename F>
- template <typename V>
- two_way<I,F>::operator V() const
- {
- return read_(fun_);
- }
-
- // Explicit read.
- template <typename I, typename F>
- typename F::result_type
- two_way<I,F>::value() const
- {
- return read_(fun_);
- }
-
- // Write.
-
- template <typename I, typename F>
- template <typename V>
- two_way<I,F>&
- two_way<I,F>::operator=(const V& value)
- {
- write_(fun_, value);
- return *this;
- }
-
- // fun_v2w2v
-
- template <typename I, typename F>
- template <typename E, typename V>
- void
- two_way<I,F>::write_(const oln::abstract::fun_v2w2v<E>& f, const V& value)
- {
- (*ima_)(p_) = f.exact().reverse(value);
- }
-
- template <typename I, typename F>
- template <typename E>
- typename E::result_type
- two_way<I,F>::read_(const oln::abstract::fun_v2w2v<E>& f) const
- {
- return f.exact().direct((*ima_)(p_));
- }
-
- // fun_rw
-
- template <typename I, typename F>
- template <typename E, typename V>
- void
- two_way<I,F>::write_(const oln::abstract::fun_rw<E>& f, const V& value)
- {
- f.exact().write(*ima_, p_, value);
- }
-
- template <typename I, typename F>
- template <typename E>
- typename E::result_type
- two_way<I,F>::read_(const oln::abstract::fun_rw<E>& f) const
- {
- return f.exact().read(*ima_, p_);
- }
-
-
- // Op <<.
- template <typename I, typename F>
- std::ostream& operator<<(std::ostream& ostr,
- const two_way<I,F>& proxy)
- {
- return ostr << proxy.value();
- }
-
- } // end of namespace oln::value
-
-
- namespace abstract
- {
-
- template <typename F>
- template <typename I>
- oln::morpher::two_way<I, F>
- fun_v2w2v<F>::operator()(oln::abstract::mutable_image<I>& input) const
- {
- morpher::two_way<I, F> tmp(input.exact(), this->exact());
- return tmp;
- }
-
- } // end of namespace oln::abstract
-
-# endif
-
-
-
-} // end of namespace oln
-
-
#endif // ! OLN_MORPHER_TWO_WAY_HH
Index: oln/morpher/count_rw.hh
===================================================================
--- oln/morpher/count_rw.hh (revision 694)
+++ oln/morpher/count_rw.hh (working copy)
@@ -143,6 +143,17 @@
template <typename I>
morpher::count_rw_<I>
+ count_rw(oln::abstract::mutable_image<I>& input);
+
+ template <typename I>
+ morpher::count_rw_<I>
+ count_rw(const oln::abstract::mutable_image<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ morpher::count_rw_<I>
count_rw(oln::abstract::mutable_image<I>& input)
{
morpher::count_rw_<I> tmp(input.exact());
@@ -159,7 +170,9 @@
return tmp;
}
+# endif
+
} // end of namespace oln
Index: oln/morpher/two_way_rw.hh
===================================================================
--- oln/morpher/two_way_rw.hh (revision 0)
+++ oln/morpher/two_way_rw.hh (revision 0)
@@ -0,0 +1,160 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHER_TWO_WAY_RW_HH
+# define OLN_MORPHER_TWO_WAY_RW_HH
+
+# include <oln/value/two_way.hh>
+# include <oln/morpher/internal/image_value_morpher.hh>
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <typename Image, typename Fun> struct two_way_rw;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <typename Image, typename Fun>
+ struct set_super_type< morpher::two_way_rw<Image, Fun> >
+ {
+ typedef morpher::two_way_rw<Image, Fun> self_t;
+ typedef morpher::internal::image_value_morpher<Image, self_t> ret;
+ };
+
+
+ template <typename Image, typename Fun>
+ struct vtypes< morpher::two_way_rw<Image, Fun> >
+ {
+ typedef morpher::two_way_rw<Image, Fun> self_t;
+ public:
+ typedef mlc::true_ is_computed_type;
+
+ typedef typename Fun::result_type value_type;
+ typedef value::two_way<Image, Fun> lvalue_type;
+ };
+
+ template <typename Image, typename Fun>
+ struct single_vtype< morpher::two_way_rw<Image, Fun>, typedef_::rvalue_type >
+ {
+ typedef typename Fun::result_type ret;
+ };
+
+
+ namespace morpher
+ {
+
+ /// 'Image thru Function' morpher.
+ template <typename Image, typename Fun>
+ class two_way_rw : public internal::image_value_morpher< Image,
+ morpher::two_way_rw<Image, Fun> >
+ {
+ private:
+
+ typedef two_way_rw<Image, Fun> self_t;
+
+ typedef internal::image_value_morpher<Image, self_t> super_t;
+ using super_t::image_;
+
+ typedef oln_rvalue(self_t) rvalue_t;
+ typedef oln_lvalue(self_t) lvalue_t;
+ typedef oln_psite(self_t) psite_t;
+
+ public:
+
+ two_way_rw(oln::abstract::mutable_image<Image>& image);
+
+ two_way_rw(oln::abstract::mutable_image<Image>& image,
+ const oln::abstract::fun_rw<Fun>& fun);
+
+ rvalue_t impl_op_read(const psite_t& p) const;
+ lvalue_t impl_op_readwrite(const psite_t& p);
+
+ protected:
+
+ Fun fun_;
+ };
+
+
+ namespace ERROR
+ {
+
+ struct FIXME;
+
+ } // end of namespace oln::morpher::ERROR
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // public
+
+ template <typename Image, typename Fun>
+ two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image) :
+ super_t(image.exact()),
+ fun_()
+ {
+ }
+
+ template <typename Image, typename Fun>
+ two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image,
+ const oln::abstract::fun_rw<Fun>& fun) :
+ super_t(image.exact()),
+ fun_(fun.exact())
+ {
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way_rw<Image, Fun>::rvalue_t
+ two_way_rw<Image, Fun>::impl_op_read(const typename two_way_rw<Image, Fun>::psite_t& p) const
+ {
+ return fun_.read(this->delegate(), p);
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way_rw<Image, Fun>::lvalue_t
+ two_way_rw<Image, Fun>::impl_op_readwrite(const typename two_way_rw<Image, Fun>::psite_t& p)
+ {
+ typename two_way_rw<Image, Fun>::lvalue_t tmp(this->delegate(), p);
+ return tmp;
+ }
+
+# endif
+
+ } // end of namespace oln::morpher
+
+} // end of namespace oln
+
+
+# include <oln/value/two_way.hxx>
+
+
+#endif // ! OLN_MORPHER_TWO_WAY_RW_HH
Index: oln/morpher/stack_rw.hh
===================================================================
--- oln/morpher/stack_rw.hh (revision 695)
+++ oln/morpher/stack_rw.hh (working copy)
@@ -30,7 +30,6 @@
# include <xtd/vec.hh>
# include <oln/value/two_way.hh>
-# include <oln/morpher/two_way.hh>
# include <oln/morpher/internal/image_value_morpher.hh>
@@ -245,4 +244,7 @@
} // end of namespace oln
+# include <oln/value/two_way.hxx>
+
+
#endif // ! OLN_MORPHER_STACK_RW_HH
Index: oln/value/two_way.hxx
===================================================================
--- oln/value/two_way.hxx (revision 0)
+++ oln/value/two_way.hxx (revision 0)
@@ -0,0 +1,168 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_VALUE_TWO_WAY_HXX
+# define OLN_VALUE_TWO_WAY_HXX
+
+# include <oln/value/two_way.hh>
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+namespace oln
+{
+
+ namespace value
+ {
+
+ // Ctor.
+ template <typename I, typename F>
+ two_way<I,F>::two_way(I& ima,
+ F fun,
+ const oln_psite(I)& p)
+ : ima_(&ima),
+ fun_(fun),
+ p_(p)
+ {
+ }
+
+ // Ctor.
+ template <typename I, typename F>
+ two_way<I,F>::two_way(I& ima,
+ const oln_psite(I)& p)
+ : ima_(&ima),
+ fun_(),
+ p_(p)
+ {
+ }
+
+ // Read.
+ template <typename I, typename F>
+ template <typename V>
+ two_way<I,F>::operator V() const
+ {
+ return read_(fun_);
+ }
+
+ // Explicit read.
+ template <typename I, typename F>
+ typename F::result_type
+ two_way<I,F>::value() const
+ {
+ return read_(fun_);
+ }
+
+ // Write.
+
+ template <typename I, typename F>
+ template <typename V>
+ two_way<I,F>&
+ two_way<I,F>::operator=(const V& value)
+ {
+ write_(fun_, value);
+ return *this;
+ }
+
+ // fun_v2w2v
+
+ template <typename I, typename F>
+ template <typename E, typename V>
+ void
+ two_way<I,F>::write_(const oln::abstract::fun_v2w2v<E>& f, const V& value)
+ {
+ (*ima_)(p_) = f.exact().reverse(value);
+ }
+
+ template <typename I, typename F>
+ template <typename E>
+ typename E::result_type
+ two_way<I,F>::read_(const oln::abstract::fun_v2w2v<E>& f) const
+ {
+ return f.exact().direct((*ima_)(p_));
+ }
+
+ // fun_rw
+
+ template <typename I, typename F>
+ template <typename E, typename V>
+ void
+ two_way<I,F>::write_(const oln::abstract::fun_rw<E>& f, const V& value)
+ {
+ f.exact().write(*ima_, p_, value);
+ }
+
+ template <typename I, typename F>
+ template <typename E>
+ typename E::result_type
+ two_way<I,F>::read_(const oln::abstract::fun_rw<E>& f) const
+ {
+ return f.exact().read(*ima_, p_);
+ }
+
+
+ // Op <<.
+ template <typename I, typename F>
+ std::ostream& operator<<(std::ostream& ostr,
+ const two_way<I,F>& proxy)
+ {
+ return ostr << proxy.value();
+ }
+
+ } // end of namespace oln::value
+
+
+ namespace abstract
+ {
+
+ template <typename F>
+ template <typename I>
+ oln::morpher::two_way<I, F>
+ fun_v2w2v<F>::operator()(oln::abstract::mutable_image<I>& input) const
+ {
+ morpher::two_way<I, F> tmp(input.exact(), this->exact());
+ return tmp;
+ }
+
+ template <typename F>
+ template <typename I>
+ oln::morpher::two_way_rw<I, F>
+ fun_rw<F>::operator()(oln::abstract::mutable_image<I>& input) const
+ {
+ morpher::two_way_rw<I, F> tmp(input, *this);
+ return tmp;
+ }
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+#endif // ! OLN_VALUE_TWO_WAY_HXX
1
0
2006-11-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add morpher::stack_rw.
* olena/tests/morphers/stack_rw_morpher.cc: New.
* olena/tests/morphers/Makefile.am: Update.
* olena/oln/morpher/stack_rw.hh: New.
* olena/oln/Makefile.am: Update.
* olena/oln/debug/print.hh (print): Store loop 2D bounds.
* olena/oln/core/abstract/functions.hh (fun_rw): New.
* olena/oln/morpher/two_way.hh (ima_): Change type to pointer.
(two_way): New ctor for class value::two_way.
(read_, write_): New methods.
(operator, value): Call read_.
(operator=): Call write_.
* olena/oln/morpher/stack.hh (N): New.
* olena/oln/value/two_way.hh (two_way): New ctor decl.
(ima_): Change type to pointer.
(read_, write_): New method decls.
Index: olena/tests/morphers/Makefile.am
===================================================================
--- olena/tests/morphers/Makefile.am (revision 694)
+++ olena/tests/morphers/Makefile.am (working copy)
@@ -24,6 +24,7 @@
count_rw_morpher \
slice_morpher \
stack_morpher \
+ stack_rw_morpher \
two_way_morpher \
value_cast \
with_lut \
@@ -36,6 +37,7 @@
count_rw_morpher_SOURCES = count_rw_morpher.cc
slice_morpher_SOURCES = slice_morpher.cc
stack_morpher_SOURCES = stack_morpher.cc
+stack_rw_morpher_SOURCES = stack_rw_morpher.cc
two_way_morpher_SOURCES = two_way_morpher.cc
value_cast_SOURCES = value_cast.cc
with_lut_SOURCES = with_lut.cc
Index: olena/tests/morphers/stack_rw_morpher.cc
===================================================================
--- olena/tests/morphers/stack_rw_morpher.cc (revision 0)
+++ olena/tests/morphers/stack_rw_morpher.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test the "read-write stack morpher".
+
+#include <cassert>
+
+#include <oln/core/traits.hh>
+#include <oln/basics2d.hh>
+#include <oln/morpher/stack_rw.hh>
+#include <oln/debug/print.hh>
+
+
+
+int main()
+{
+ using namespace oln;
+ using xtd::vec;
+ using xtd::mk_vec;
+
+ typedef image2d<int> I;
+ typedef vec<2,int> vec_t;
+
+ I ima_0(3, 3);
+ I ima_1(3, 3);
+ point2d p(0,0);
+
+ morpher::stack_rw<2,I> ima_v = stack_rw(ima_0, ima_1);
+
+ ima_v(p) = mk_vec(5, 1);
+ debug::print(ima_v);
+
+ std::cout << ima_v(p) << std::endl;
+ std::cout << ima_0(p) << ' ' << ima_1(p) << std::endl;
+}
Index: olena/oln/debug/print.hh
===================================================================
--- olena/oln/debug/print.hh (revision 694)
+++ olena/oln/debug/print.hh (working copy)
@@ -86,9 +86,15 @@
void print(const abstract::classical_2d_image<I>& input,
std::ostream& ostr)
{
- for (int row = min_row(input); row <= max_row(input); ++row)
+ const oln_coord(I)
+ min_row = oln::min_row(input),
+ max_row = oln::max_row(input);
+ for (oln_coord(I) row = min_row; row <= max_row; ++row)
{
- for (int col = min_col(input); col <= max_col(input); ++col)
+ const oln_coord(I)
+ min_col = oln::min_col(input),
+ max_col = oln::max_col(input);
+ for (oln_coord(I) col = min_col; col <= max_col; ++col)
{
point2d p(row, col);
if (input.has(p))
Index: olena/oln/core/abstract/functions.hh
===================================================================
--- olena/oln/core/abstract/functions.hh (revision 694)
+++ olena/oln/core/abstract/functions.hh (working copy)
@@ -39,9 +39,8 @@
// Fwd decl.
- namespace morpher {
- template <typename I, typename F> class two_way;
- }
+ namespace morpher { template <typename I, typename F> class two_way; }
+ namespace value { template <typename I, typename F> class two_way; }
namespace abstract
@@ -76,14 +75,33 @@
public oln::type
{
public:
+
template <typename I>
oln::morpher::two_way<I, E>
operator()(oln::abstract::mutable_image<I>& input) const;
+
protected:
fun_v2w2v();
};
+ // FIXME: Value1 -> Value2 *and* Value2 -> Value1.
+
+ template <typename E>
+ struct fun_rw : public virtual stc::any__simple<E>,
+ public oln::type
+ {
+ public:
+
+ template <typename I>
+ oln::morpher::two_way<I, E>
+ operator()(oln::abstract::mutable_image<I>& input) const;
+
+ protected:
+ fun_rw();
+ };
+
+
// Point -> Point.
template <typename E>
@@ -113,6 +131,11 @@
}
template <typename E>
+ fun_rw<E>::fun_rw()
+ {
+ }
+
+ template <typename E>
fun_p2p<E>::fun_p2p()
{
}
Index: olena/oln/Makefile.am
===================================================================
--- olena/oln/Makefile.am (revision 694)
+++ olena/oln/Makefile.am (working copy)
@@ -190,6 +190,7 @@
morpher/tags.hh \
morpher/slice.hh \
morpher/stack.hh \
+ morpher/stack_rw.hh \
morpher/thru_fun.hh \
morpher/thru_mfun.hh \
morpher/two_way.hh \
Index: olena/oln/morpher/two_way.hh
===================================================================
--- olena/oln/morpher/two_way.hh (revision 694)
+++ olena/oln/morpher/two_way.hh (working copy)
@@ -170,18 +170,28 @@
two_way<I,F>::two_way(I& ima,
F fun,
const oln_psite(I)& p)
- : ima_(ima),
+ : ima_(&ima),
fun_(fun),
p_(p)
{
}
+ // Ctor.
+ template <typename I, typename F>
+ two_way<I,F>::two_way(I& ima,
+ const oln_psite(I)& p)
+ : ima_(&ima),
+ fun_(),
+ p_(p)
+ {
+ }
+
// Read.
template <typename I, typename F>
template <typename V>
two_way<I,F>::operator V() const
{
- return fun_.direct(ima_(p_));
+ return read_(fun_);
}
// Explicit read.
@@ -189,7 +199,7 @@
typename F::result_type
two_way<I,F>::value() const
{
- return fun_.direct(ima_(p_));
+ return read_(fun_);
}
// Write.
@@ -199,10 +209,47 @@
two_way<I,F>&
two_way<I,F>::operator=(const V& value)
{
- ima_(p_) = fun_.reverse(value);
+ write_(fun_, value);
return *this;
}
+ // fun_v2w2v
+
+ template <typename I, typename F>
+ template <typename E, typename V>
+ void
+ two_way<I,F>::write_(const oln::abstract::fun_v2w2v<E>& f, const V& value)
+ {
+ (*ima_)(p_) = f.exact().reverse(value);
+ }
+
+ template <typename I, typename F>
+ template <typename E>
+ typename E::result_type
+ two_way<I,F>::read_(const oln::abstract::fun_v2w2v<E>& f) const
+ {
+ return f.exact().direct((*ima_)(p_));
+ }
+
+ // fun_rw
+
+ template <typename I, typename F>
+ template <typename E, typename V>
+ void
+ two_way<I,F>::write_(const oln::abstract::fun_rw<E>& f, const V& value)
+ {
+ f.exact().write(*ima_, p_, value);
+ }
+
+ template <typename I, typename F>
+ template <typename E>
+ typename E::result_type
+ two_way<I,F>::read_(const oln::abstract::fun_rw<E>& f) const
+ {
+ return f.exact().read(*ima_, p_);
+ }
+
+
// Op <<.
template <typename I, typename F>
std::ostream& operator<<(std::ostream& ostr,
Index: olena/oln/morpher/stack.hh
===================================================================
--- olena/oln/morpher/stack.hh (revision 694)
+++ olena/oln/morpher/stack.hh (working copy)
@@ -82,6 +82,8 @@
public:
+ enum { N = n }; // FIXME: Hum...
+
stack(const xtd::vec<n, I>& images);
xtd::vec<n, oln_value(I)> impl_op_read(const psite_t& p) const;
Index: olena/oln/morpher/stack_rw.hh
===================================================================
--- olena/oln/morpher/stack_rw.hh (revision 0)
+++ olena/oln/morpher/stack_rw.hh (revision 0)
@@ -0,0 +1,248 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHER_STACK_RW_HH
+# define OLN_MORPHER_STACK_RW_HH
+
+# include <xtd/vec.hh>
+# include <oln/value/two_way.hh>
+# include <oln/morpher/two_way.hh>
+# include <oln/morpher/internal/image_value_morpher.hh>
+
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <unsigned n, typename I> struct stack_rw;
+
+ } // end of namespace oln::morpher
+
+
+ template <unsigned n, typename T>
+ struct rwvec : public oln::abstract::fun_rw< rwvec<n,T> >
+ {
+ typedef xtd::vec<n,T> result_type;
+
+ template <typename I>
+ xtd::vec<n,T> read(const I& input, const oln_point(I)& p) const
+ {
+ return input(p);
+ }
+
+ template <typename I>
+ void write(I& input, const oln_point(I)& p, const xtd::vec<n,T>& v) const
+ {
+ for (unsigned i = 0; i < I::N; ++i)
+ input.image(i)(p) = v[i];
+ }
+ };
+
+
+ /// Super type.
+ template <unsigned n, typename I>
+ struct set_super_type< morpher::stack_rw<n, I> >
+ {
+ typedef morpher::stack_rw<n, I> self_t;
+ typedef morpher::internal::image_value_morpher<I, self_t> ret;
+ };
+
+ template <unsigned n, typename I>
+ struct vtypes< morpher::stack_rw<n, I> >
+ {
+ typedef morpher::stack_rw<n, I> self_t;
+ typedef rwvec<n, oln_value(I)> fun_t;
+ public:
+ typedef mlc::true_ is_computed_type;
+ typedef xtd::vec<n, oln_value(I)> value_type;
+ };
+
+ template <unsigned n, typename I>
+ struct single_vtype< morpher::stack_rw<n, I>, typedef_::lvalue_type >
+ {
+ typedef morpher::stack_rw<n, I> self_t;
+ typedef rwvec<n, oln_value(I)> fun_t;
+ typedef value::two_way<self_t, fun_t> ret;
+ };
+
+ template <unsigned n, typename I>
+ struct single_vtype< morpher::stack_rw<n, I>, typedef_::rvalue_type >
+ {
+ typedef xtd::vec<n, oln_value(I)> ret;
+ };
+
+
+
+ namespace morpher
+ {
+
+ /// "Stack of images" morpher with "read-write" capabilities.
+
+ template <unsigned n, typename I>
+ class stack_rw : public internal::image_value_morpher< I, stack_rw<n, I> >
+ {
+ private:
+
+ typedef stack_rw<n, I> self_t;
+ typedef internal::image_value_morpher<I, self_t> super_t;
+
+ typedef oln_psite(self_t) psite_t;
+ typedef oln_rvalue(self_t) rvalue_t;
+ typedef oln_lvalue(self_t) lvalue_t;
+
+ public:
+
+ enum { N = n }; // FIXME: Hum...
+
+ stack_rw(const xtd::vec<n, I>& images);
+
+ xtd::vec<n, oln_value(I)> impl_op_read(const psite_t& p) const;
+ lvalue_t impl_op_readwrite(const psite_t& p);
+
+ const I& image(unsigned i) const;
+ I& image(unsigned i);
+
+ protected:
+ xtd::vec<n, I> images_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <unsigned n, typename I>
+ stack_rw<n, I>::stack_rw(const xtd::vec<n, I>& images) :
+ super_t(images[0]),
+ images_(images)
+ {
+ }
+
+ template <unsigned n, typename I>
+ xtd::vec<n, oln_value(I)>
+ stack_rw<n, I>::impl_op_read(const typename stack_rw<n, I>::psite_t& p) const
+ {
+ xtd::vec<n, oln_value(I)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = images_[i](p);
+ return tmp;
+ }
+
+ template <unsigned n, typename I>
+ typename stack_rw<n, I>::lvalue_t
+ stack_rw<n, I>::impl_op_readwrite(const typename stack_rw<n, I>::psite_t& p)
+ {
+ lvalue_t tmp(*this, p);
+ return tmp;
+ }
+
+ template <unsigned n, typename I>
+ const I&
+ stack_rw<n, I>::image(unsigned i) const
+ {
+ precondition(i < n);
+ return images_[i];
+ }
+
+ template <unsigned n, typename I>
+ I&
+ stack_rw<n, I>::image(unsigned i)
+ {
+ precondition(i < n);
+ return images_[i];
+ }
+
+# endif
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I>
+ morpher::stack_rw<2, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1);
+
+ template <typename I>
+ morpher::stack_rw<3, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2);
+
+ template <typename I>
+ morpher::stack_rw<4, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2,
+ abstract::mutable_image<I>& image_3);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ morpher::stack_rw<2, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1)
+ {
+ morpher::stack_rw<2, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack_rw<3, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2)
+ {
+ morpher::stack_rw<3, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack_rw<4, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2,
+ abstract::mutable_image<I>& image_3)
+ {
+ morpher::stack_rw<4, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact(),
+ image_3.exact()));
+ return tmp;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_STACK_RW_HH
Index: olena/oln/value/two_way.hh
===================================================================
--- olena/oln/value/two_way.hh (revision 694)
+++ olena/oln/value/two_way.hh (working copy)
@@ -50,6 +50,10 @@
two_way(I& ima,
F fun,
const oln_psite(I)& p);
+
+ // Ctor.
+ two_way(I& ima,
+ const oln_psite(I)& p);
// Read.
template <typename V>
@@ -63,9 +67,32 @@
two_way<I,F>& operator=(const V& value);
protected:
- I ima_;
+
+ I* ima_;
F fun_;
const oln_psite(I)& p_;
+
+ private:
+
+ // oln::abstract::fun_v2w2v
+ // Two-way function defined by "direct : v -> w" and "reverse : w -> v".
+
+ template <typename E, typename V>
+ void write_(const oln::abstract::fun_v2w2v<E>& f, const V& value);
+
+ template <typename E>
+ typename E::result_type
+ read_(const oln::abstract::fun_v2w2v<E>& f) const;
+
+ // oln::abstract::fun_rw<E>
+ // Two-way function defined by "read(ima, p)" and "write(ima, p, v)"
+
+ template <typename E, typename V>
+ void write_(const oln::abstract::fun_rw<E>& f, const V& value);
+
+ template <typename E>
+ typename E::result_type
+ read_(const oln::abstract::fun_rw<E>& f) const;
};
1
0
04 Nov '06
Roland Levillain <roland(a)lrde.epita.fr> writes:
> /* Icpc chokes when expanding this macro when T is a template type:
> T is substituted with no additional surrounding space, generating
> a token `>>'.
>
> G++ has no such problem, but I haven't checked which is the right
> behavior, required by the ISO standard.
>
> Note that this will no longer be a problem with C++ 0x, since
> expressions like `Foo<Foo<int>>' will be valid. */
Dans le code de CPP on trouve la fonction suivante :
/* Returns nonzero if a space should be inserted to avoid an
accidental token paste for output. For simplicity, it is
conservative, and occasionally advises a space where one is not
needed, e.g. "." and ".2". */
int
cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
const cpp_token *token2)
--
Utilisée dans l'outputing ici. avoid_paste est de gestion interne.
/* Subtle logic to output a space if and only if necessary. */
if (avoid_paste)
{
if (print.source == NULL)
print.source = token;
if (print.source->flags & PREV_WHITE
|| (print.prev
&& cpp_avoid_paste (pfile, print.prev, token))
|| (print.prev == NULL && token->type == CPP_HASH))
putc (' ', print.outf);
}
else if (token->flags & PREV_WHITE)
putc (' ', print.outf);
Il n'y a pas de commentaire sur le standard dans le code. Je n'ai
d'ailleurs rien trouvé dans les standards. Il y en a un pour CPP ?
--
/!\ My mail address changed, please update your files accordingly.
| In a World without Walls and Fences, Michaël `Micha' Cadilhac |
| who needs Windows and Gates? cadilh_m - Epita 2007 - CSI |
| -- Dino Esposito JID: micha(a)amessage.be |
`-- - - - - --'
1
0