Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
New sparse_image class, not working yet.
* oln/core/sparse: New.
* oln/core/sparse/sparse_image.hh: New.
sparse_image.hh | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 168 insertions(+)
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 0)
+++ oln/core/sparse/sparse_image.hh (revision 0)
@@ -0,0 +1,168 @@
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 SPARSE_IMAGE_HH_
+# define SPARSE_IMAGE_HH_
+
+# include <vector>
+
+namespace oln
+{
+ // Fwd decl.
+ template <typename P, typename T>
+ struct sparse_image;
+
+ // Super type.
+ template <typename P, typename T>
+ struct super_trait_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P, typename T>
+ struct vtypes< sparse_image<P, T> >
+ {
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef P point;
+ typedef typename P::coord coord;
+
+ typedef rle_psite<P> psite;
+
+ typedef rle_pset<point> pset;
+
+ //FIXME:
+ typedef mlc::none plain;
+
+ typedef std::pair< pset, std::map<point, std::vector<value> > > data;
+ };
+
+ template < typename P, typename T>
+ class sparse_image : public internal::primitive_image_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::primitive_image_< sparse_image<P, T> > super;
+ public:
+ stc_using(pset);
+ stc_using(box);
+ stc_using(point);
+ stc_using(value);
+ stc_using(rvalue);
+ stc_using(lvalue);
+ stc_using(psite);
+ stc_using(data);
+
+ sparse_image();
+
+ pset impl_points() const;
+ box impl_bbox() const;
+ bool impl_has(const point& p) const;
+ bool impl_owns_(const psite& p) const;
+ void insert(const point& p, unsigned len, const std::vector<value>& val);
+ rvalue impl_read(const psite& p) const;
+ lvalue impl_read_write(const psite& p);
+
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename P, typename T>
+ sparse_image<P, T>::sparse_image()
+ {
+ this->data_ = new data;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::pset
+ sparse_image<P, T>::impl_points() const
+ {
+ return this->data_->first;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::box
+ sparse_image<P, T>::impl_bbox() const
+ {
+ return this->data_->first.bbox();
+ }
+
+ template <typename P, typename T>
+ bool
+ sparse_image<P, T>::impl_has(const typename sparse_image<P, T>::point& p) const
+ {
+ return this->data_->first.has(p);
+ }
+
+ template <typename P, typename T>
+ bool
+ sparse_image<P, T>::impl_owns_(const typename sparse_image<P, T>::psite& p) const
+ {
+ return this->data_->first.has(p.start_);
+ }
+
+ template <typename P, typename T>
+ void
+ sparse_image<P, T>::insert(const point& p, unsigned len, const std::vector<typename sparse_image<P, T>::value>& val)
+ {
+ this->data_->first.insert(p, len);
+ this->data_->second[p] = val;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::rvalue
+ sparse_image<P, T>::impl_read(const sparse_image<P, T>::psite& ps) const
+ {
+ typename std::map<point, value>::const_iterator irun;
+
+ irun = this->data_->second.find(ps.start_);
+ assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_));
+ return irun->second[ps.index_];
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::lvalue
+ sparse_image<P, T>::impl_read_write(const sparse_image<P, T>::psite& ps)
+ {
+ typename std::map<point, value>::const_iterator irun;
+
+ irun = this->data_->second.find(ps.start_);
+ assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_));
+ return irun->second[ps.index_];
+ }
+
+
+# endif /* !OLN_INCLUDE_ONLY */
+
+
+} // end of namespace oln
+
+#endif /* !SPARSE_IMAGE_HH_ */
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Remove dead code.
* oln/core/abstract/image/hybrid/classical.hh,
* oln/core/abstract/image/type/binary.hh,
* oln/core/abstract/image/type/data.hh,
* oln/core/abstract/image/type/grey_level.hh,
* oln/core/abstract/image/type/integre.hh,
* oln/core/abstract/image/type/color.hh,
* oln/core/abstract/image/type/hierarchy.hh,
* oln/core/abstract/image/type/label.hh,
* oln/core/abstract/image/mutability/hierarchy.hh,
* oln/core/abstract/image/hierarchies.hh,
* oln/core/abstract/image/computability/hierarchy.hh,
* oln/core/abstract/image/dimension/1d.hh,
* oln/core/abstract/image/dimension/2d.hh,
* oln/core/abstract/image/dimension/3d.hh,
* oln/core/abstract/image/dimension/hierarchy.hh,
* oln/core/abstract/image/all.hh,
* oln/core/abstract/image/neighborhood/hierarchy.hh,
* oln/core/abstract/image/point_wise_accessibility/hierarchy.hh,
* oln/core/abstract/image/bbox/hierarchy.hh,
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh,
* oln/core/abstract/fwd_decls.hh,
* oln/core/abstract/array.hh,
* oln/core/abstract/internal/image_impl.hh,
* oln/core/automatic/image/image.hh,
* oln/core/automatic/image/image1d.hh,
* oln/core/automatic/image/image2d.hh,
* oln/core/automatic/image/image3d.hh,
* oln/core/automatic/image/image_being_point_wise_random_accessible.hh,
* oln/core/automatic/image/image_being_value_wise_random_accessible.hh,
* oln/core/automatic/image/image_having_neighborhood.hh,
* oln/core/automatic/image/mutable_image.hh,
* oln/core/automatic/image/mutable_image1d.hh,
* oln/core/automatic/image/mutable_image2d.hh,
* oln/core/automatic/image/mutable_image3d.hh,
* oln/core/automatic/impl.hh,
* oln/core/automatic/topology/topology_being_random_accessible.hh,
* oln/core/automatic/topology/topology_having_bbox.hh,
* oln/core/automatic/topology/topology_having_neighborhood.hh,
* oln/core/automatic/topology/topology_having_subset.hh,
* oln/core/iterator_vtypes.hh,
* oln/core/spe/row.hh,
* oln/core/spe/col.hh,
* oln/core/spe/slice.hh,
* oln/core/type_fun/plain.hh,
* oln/core/type_fun/ch_value.hh,
* oln/core/type_fun/slice.hh: Remove files.
* oln/core/abstract/functions.hh: Rename as...
* oln/core/concept/functions.hh: ...this and update.
* oln/core/concept/image.hh: Add doc.
* oln/core/abstract/image/hybrid,
* oln/core/abstract/image/type,
* oln/core/abstract/image/mutability,
* oln/core/abstract/image/computability,
* oln/core/abstract/image/dimension,
* oln/core/abstract/image/neighborhood,
* oln/core/abstract/image/point_wise_accessibility,
* oln/core/abstract/image/bbox,
* oln/core/abstract/image/value_wise_accessibility,
* oln/core/abstract/image,
* oln/core/abstract/internal,
* oln/core/abstract,
* oln/core/automatic/image,
* oln/core/automatic/topology,
* oln/core/spe,
* oln/core/type_fun: Remove directories.
functions.hh | 96 ++++++++++++++++++++++++++++++++---------------------------
image.hh | 6 +++
2 files changed, 59 insertions(+), 43 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 871)
+++ oln/core/concept/image.hh (working copy)
@@ -76,6 +76,12 @@
|
|
|
+ o -- + -- Plain_Image
+ | |
+ | + -- Computed_Image
+ |
+ |
+ |
o -- + -- Gray_Level_Image
| |
| + -- Color_Image
Index: oln/core/concept/functions.hh
--- oln/core/concept/functions.hh (revision 870)
+++ oln/core/concept/functions.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_FUNCTIONS_HH
-# define OLN_CORE_ABSTRACT_FUNCTIONS_HH
+#ifndef OLN_CORE_CONCEPT_FUNCTIONS_HH
+# define OLN_CORE_CONCEPT_FUNCTIONS_HH
-# include <stc/any.hh>
-# include <oln/core/type.hh>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/mutability/hierarchy.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
+ /*
// Fwd decl.
namespace morpher {
@@ -45,109 +43,121 @@
}
namespace value { template <typename I, typename F> class two_way; }
+ */
- namespace abstract
+ template <typename Exact>
+ struct Function : public Any<Exact>
{
+ protected:
+ Function();
+ };
+
// Point -> Value.
- template <typename E>
- struct fun_p2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_p2v : public Function<Exact>
{
protected:
- fun_p2v();
+ Function_p2v();
};
// Value -> Value.
- template <typename E>
- struct fun_v2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_v2v : public Function<Exact>
{
protected:
- fun_v2v();
+ Function_v2v();
};
+ /*
+
// Value1 -> Value2 *and* Value2 -> Value1.
- template <typename E>
- struct fun_v2w2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_v2w2v : public Function<Exact>
{
public:
template <typename I>
- oln::morpher::two_way<I, E>
+ oln::morpher::two_way<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
- fun_v2w2v();
+ Function_v2w2v();
};
// (Image, Point) -> Value2 *and* (Image, Point, Value2) -> Value1.
- template <typename E>
- struct fun_rw : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_rw : public Function<Exact>
{
public:
template <typename I>
- oln::morpher::two_way_rw<I, E>
+ oln::morpher::two_way_rw<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
- fun_rw();
+ Function_rw();
};
+ */
+
// Point -> Point.
- template <typename E>
- struct fun_p2p : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_p2p : public Function<Exact>
{
protected:
- fun_p2p();
+ Function_p2p();
};
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- fun_p2v<E>::fun_p2v()
+ template <typename Exact>
+ Function<Exact>::Function()
{
}
- template <typename E>
- fun_v2v<E>::fun_v2v()
+ template <typename Exact>
+ Function_p2v<Exact>::Function_p2v()
{
}
- template <typename E>
- fun_v2w2v<E>::fun_v2w2v()
+ template <typename Exact>
+ Function_v2v<Exact>::Function_v2v()
{
}
- template <typename E>
- fun_rw<E>::fun_rw()
+ /*
+
+ template <typename Exact>
+ Function_v2w2v<Exact>::Function_v2w2v()
{
}
- template <typename E>
- fun_p2p<E>::fun_p2p()
+ template <typename Exact>
+ Function_rw<Exact>::Function_rw()
{
}
-# endif
+ */
+
+ template <typename Exact>
+ Function_p2p<Exact>::Function_p2p()
+ {
+ }
- } // end of namespace oln::abstract
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_FUNCTIONS_HH
+#endif // ! OLN_CORE_CONCEPT_FUNCTIONS_HH
1
0
870: Add oln_plain_value, update level::apply, and provide a sample test code.
by Thierry Geraud 13 Mar '07
by Thierry Geraud 13 Mar '07
13 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add oln_plain_value, update level::apply, and provide a sample test code.
* oln/core/internal/f_ch_value.hh (oln_plain_value): New.
* oln/core/internal/image_base.hh (include): Add f_ch_value.
* oln/level/apply.hh: Inactivate almost the whole code.
(apply): Update a single version.
* tests/core/apply.cc: New.
* tests/core/Makefile.am: Update.
oln/core/internal/f_ch_value.hh | 4
oln/core/internal/image_base.hh | 5 +
oln/level/apply.hh | 173 ++++++++++++++++++++--------------------
tests/core/Makefile.am | 4
tests/core/apply.cc | 46 ++++++++++
5 files changed, 146 insertions(+), 86 deletions(-)
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 869)
+++ tests/core/Makefile.am (working copy)
@@ -19,6 +19,7 @@
check_PROGRAMS = \
+ apply \
dpoint2d \
point2d \
grid \
@@ -41,5 +42,8 @@
# Methods.
at_SOURCES = at.cc
+# FIXME: Temp!
+apply_SOURCES = apply.cc
+
TESTS = $(check_PROGRAMS)
Index: tests/core/apply.cc
--- tests/core/apply.cc (revision 0)
+++ tests/core/apply.cc (revision 0)
@@ -0,0 +1,46 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+// FIXME: Move this file into tests/level/.
+
+#include <oln/core/2d/image2d.hh>
+#include <oln/level/apply.hh>
+
+namespace my
+{
+ bool negate(bool b)
+ {
+ return not b;
+ }
+}
+
+int main()
+{
+ using namespace oln;
+ image2d<bool> ima(3,3);
+ ima = level::apply(my::negate, ima);
+}
Index: oln/level/apply.hh
--- oln/level/apply.hh (revision 869)
+++ oln/level/apply.hh (working copy)
@@ -29,9 +29,7 @@
#ifndef OLN_LEVEL_APPLY_HH
# define OLN_LEVEL_APPLY_HH
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/functions.hh>
+# include <oln/core/concept/image.hh>
namespace oln
@@ -41,22 +39,23 @@
{
/// Fwd decl.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&));
-
- /// Fwd decl.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun);
-
- /// Fwd decl.
- template <typename I, typename V>
- void apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&));
-
- /// Fwd decl.
- template <typename I, typename F>
- void apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun);
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input);
+
+
+// /// Fwd decl.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun);
+
+// /// Fwd decl.
+// template <typename I, typename V>
+// void apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&));
+
+// /// Fwd decl.
+// template <typename I, typename F>
+// void apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun);
# ifndef OLN_INCLUDE_ONLY
@@ -65,85 +64,87 @@
{
/// Generic version.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&))
- {
- oln_plain_value(I, V) output(input.topo());
- oln_piter(I) p(input.topo());
- for_all(p)
- output(p) = fun(input(p));
- return output;
- }
- /// Generic version.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input)
{
- oln_plain_value(I, typename F::result_value) output(input.topo());
- oln_piter(I) p(input.topo());
+ oln_plain_value(I, R) output(input.points());
+ oln_piter(I) p(input.points());
for_all(p)
- output(p) = fun.exact()(input(p));
+ output(p) = fun(input(p));
return output;
}
- /// Generic version.
- template <typename I, typename V>
- void
- apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun(input(p));
- }
-
- /// Generic version.
- template <typename I, typename F>
- void
- apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun.exact()(input(p));
- }
+// /// Generic version.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// oln_plain_value(I, typename F::result_value) output(input.topo());
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// output(p) = fun.exact()(input(p));
+// return output;
+// }
+
+
+// /// Generic version.
+// template <typename I, typename V>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
+// {
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// input(p) = fun(input(p));
+// }
+
+// /// Generic version.
+// template <typename I, typename F>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// input(p) = fun.exact()(input(p));
+// }
} // end of namespace oln::level::impl
/// Facade.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&))
- {
- return impl::apply(input, fun);
- }
-
- /// Facade.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- return impl::apply(input, fun);
- }
-
-
- /// Facade.
- template <typename I, typename V>
- void
- apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
- {
- return impl::apply_inplace(input, fun);
- }
-
- /// Facade.
- template <typename I, typename F>
- void
- apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- return impl::apply_inplace(input, fun);
- }
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input)
+ {
+ return impl::apply(fun, exact(input));
+ }
+
+// /// Facade.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// return impl::apply(input, fun);
+// }
+
+
+// /// Facade.
+// template <typename I, typename V>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
+// {
+// return impl::apply_inplace(input, fun);
+// }
+
+// /// Facade.
+// template <typename I, typename F>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// return impl::apply_inplace(input, fun);
+// }
# endif
Index: oln/core/internal/f_ch_value.hh
--- oln/core/internal/f_ch_value.hh (revision 869)
+++ oln/core/internal/f_ch_value.hh (working copy)
@@ -38,6 +38,10 @@
typename oln::internal::f_ch_value_< stc_type_in(oln, I, skeleton), T >::ret
+# define oln_plain_value(I, T) \
+typename oln::internal::f_ch_value_< stc_type_in(oln, oln_plain(I), skeleton), T >::ret
+
+
namespace oln
{
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 869)
+++ oln/core/internal/image_base.hh (working copy)
@@ -416,4 +416,9 @@
} // end of namespace oln
+// FIXME: Bad!
+# include <oln/core/internal/f_ch_value.hh>
+
+
+
#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add plain and ch_value functions on images.
* oln/core/internal/f_ch_value.hh,
* oln/core/internal/f_pset_plain.hh: New.
* tests/core/neighb2d.cc: Fix.
* tests/core/Makefile.am: Fix.
* oln/core/concept/image.hh (plain): New.
* oln/core/equipment.hh (plain, skeleton): New.
(oln_plain): New.
* oln/core/2d/image2d.hh: Update.
* oln/core/2d/image2d_b.hh: Update.
* oln/core/gen/op.hh (op_): New ctor.
* oln/core/gen/single_value_image.hh: Update.
* oln/core/internal/op_image_plus_nbh.hh: Separate decl and impl.
(special_op_): New ctor.
* oln/core/internal/instant_value.hh: Inactivate code that does not
compile with g++-3.
* oln/core/internal/image_base.hh (pl::value, pl::rec): New.
(image_base_): Update.
* oln/stc/scoop.hh (stc_type_in_, stc_type_in): New.
oln/core/2d/image2d.hh | 3
oln/core/2d/image2d_b.hh | 3
oln/core/concept/image.hh | 1
oln/core/equipment.hh | 3
oln/core/gen/op.hh | 6 +
oln/core/gen/single_value_image.hh | 6 +
oln/core/internal/f_ch_value.hh | 101 +++++++++++++++++++++++++++++++++
oln/core/internal/f_pset_plain.hh | 71 +++++++++++++++++++++++
oln/core/internal/image_base.hh | 21 ++++++
oln/core/internal/instant_value.hh | 6 +
oln/core/internal/op_image_plus_nbh.hh | 55 ++++++++++++++++-
oln/stc/scoop.hh | 4 +
tests/core/Makefile.am | 1
tests/core/neighb2d.cc | 1
14 files changed, 272 insertions(+), 10 deletions(-)
Index: tests/core/neighb2d.cc
--- tests/core/neighb2d.cc (revision 868)
+++ tests/core/neighb2d.cc (working copy)
@@ -60,6 +60,5 @@
// 2 + 3 + 2 +
// 3 + 4 + 3 +
// 2 + 3 + 2 = 24
- std::cout << test::run(ima + c4) << std::endl;
assert(test::run(ima + c4) = 24);
}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 868)
+++ tests/core/Makefile.am (working copy)
@@ -25,7 +25,6 @@
image2d \
neighb2d \
npoints \
- neighb2d \
window2d \
at
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 868)
+++ oln/core/concept/image.hh (working copy)
@@ -123,6 +123,7 @@
stc_typename(pset);
// stc_typename(output); // FIXME: Uncomment!
+ stc_typename(plain);
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 868)
+++ oln/core/equipment.hh (working copy)
@@ -95,11 +95,13 @@
// p
stc_decl_associated_type( piter );
+ stc_decl_associated_type( plain );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
# define oln_piter(T) oln_typename_shortcut__(T, piter)
+# define oln_plain(T) oln_typename_shortcut__(T, plain)
# define oln_point(T) oln_typename_shortcut__(T, point)
// q
@@ -114,6 +116,7 @@
// s
stc_decl_associated_type( std_container );
+ stc_decl_associated_type( skeleton );
// t
stc_decl_associated_type( tag );
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 868)
+++ oln/core/2d/image2d.hh (working copy)
@@ -56,6 +56,9 @@
typedef box2d pset;
typedef array2d_<value, coord> data;
+
+ typedef image2d<T> plain;
+ typedef image2d<pl::value> skeleton;
};
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 868)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -101,6 +101,9 @@
typedef box2d pset;
typedef internal::array_b_<point2d, T> data;
+ typedef image2d_b<T> plain;
+ typedef image2d_b<pl::value> skeleton;
+
// FIXME: wrong qiter!!!
};
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 868)
+++ oln/core/gen/op.hh (working copy)
@@ -138,6 +138,7 @@
class op_ : public super
{
public:
+ op_();
op_(L& l, R& r);
}; // end of op_<L, OpName, R>
@@ -147,6 +148,11 @@
# ifndef OLN_INCLUDE_ONLY
template <typename L, typename OpName, typename R>
+ op_<L, OpName, R>::op_()
+ {
+ }
+
+ template <typename L, typename OpName, typename R>
op_<L, OpName, R>::op_(L& l, R& r)
: super (l, r)
{
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 868)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
+# include <oln/core/internal/f_pset_plain.hh>
namespace oln
@@ -54,6 +55,9 @@
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
+
+ typedef oln_f_pset_plain(Ps, T) plain;
+ typedef single_value_image<Ps, pl::value> skeleton;
};
@@ -151,7 +155,7 @@
this->data_->value2 = new_value;
}
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/f_ch_value.hh
--- oln/core/internal/f_ch_value.hh (revision 0)
+++ oln/core/internal/f_ch_value.hh (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_F_CH_VALUE_HH
+# define OLN_CORE_INTERNAL_F_CH_VALUE_HH
+
+# include <oln/core/internal/image_base.hh>
+
+
+#define oln_ch_value_(I, T) \
+oln::internal::f_ch_value_< stc_type_in_(oln, I, skeleton), T >::ret
+
+#define oln_ch_value(I, T) \
+typename oln::internal::f_ch_value_< stc_type_in(oln, I, skeleton), T >::ret
+
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename I, typename T> struct f_ch_value_;
+
+
+ template <template <class> class tc,
+ typename T>
+ struct f_ch_value_< tc<pl::value>,
+ T >
+ {
+ typedef tc<T> ret;
+ };
+
+
+ template <template <class, class> class tcc, typename t,
+ typename T>
+ struct f_ch_value_< tcc<t, pl::value>,
+ T >
+ {
+ typedef tcc<t, T> ret;
+ };
+
+
+ template <template <class> class tc, typename t,
+ typename T>
+ struct f_ch_value_< tc< pl::rec<t> >,
+ T >
+ {
+ typedef tc< oln_ch_value(t, T) > ret;
+ };
+
+
+ template <template <class, class> class tcc, typename t1, typename t2,
+ typename T>
+ struct f_ch_value_< tcc< pl::rec<t1>, t2 >,
+ T >
+ {
+ typedef tcc< oln_ch_value(t1, T), t2 > ret;
+ };
+
+
+ template <template <class, class, class> class tccc, typename t1, typename t2, typename t3,
+ typename T>
+ struct f_ch_value_< tccc< pl::rec<t1>, t2, t3 >,
+ T >
+ {
+ typedef tccc< oln_ch_value(t1, T), t2, t3 > ret;
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_CH_VALUE_HH
Index: oln/core/internal/f_pset_plain.hh
--- oln/core/internal/f_pset_plain.hh (revision 0)
+++ oln/core/internal/f_pset_plain.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
+# define OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
+
+# include <oln/core/concept/point_set.hh>
+
+
+#define oln_f_pset_plain(Ps, T) typename oln::internal::f_pset_plain_< Ps, T >::ret
+
+
+namespace oln
+{
+
+ // Fwd decls.
+ struct grid2d_rec;
+ template <typename P> class box_;
+ typedef box_<point2d> box2d;
+ template <typename T> class image2d_b;
+
+
+ namespace internal
+ {
+
+ template <typename Gr, typename Ps, typename T>
+ struct f_pset_plain__;
+
+ template <typename T>
+ struct f_pset_plain__< grid2d_rec, box2d, T >
+ {
+ typedef image2d_b<T> ret;
+ };
+
+ template <typename Ps, typename T>
+ struct f_pset_plain_ : private mlc::assert_< mlc_is_a(Ps, Point_Set) >,
+ public f_pset_plain__< stc_type(Ps, grid), Ps, T >
+
+ {
+ };
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 868)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -62,6 +62,9 @@
typedef N nbh;
typedef dpoints_fwd_piter_<point__> fwd_niter;
typedef dpoints_bkd_piter_<point__> bkd_niter;
+
+ typedef op_<oln_plain(I), plus, N> plain;
+ typedef op_<pl::rec<I>, plus, N> skeleton;
};
@@ -81,18 +84,60 @@
stc_using(data);
stc_using(delegatee);
- delegatee& impl_image() { assert(this->has_data()); return this->data_->value1; }
- const delegatee& impl_image() const { assert(this->has_data()); return this->data_->value1; }
+ delegatee& impl_image();
+ const delegatee& impl_image() const;
- nbh impl_nbhood() const { assert(this->has_data()); return this->data_->value2; }
+ nbh impl_nbhood() const;
protected:
- special_op_(I& ima, N& n)
+ special_op_();
+ special_op_(I& ima, N& n);
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+# define current \
+ special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+
+ template <typename I, typename N>
+ current::special_op_()
+ {
+ }
+
+ template <typename I, typename N>
+ current::special_op_(I& ima, N& n)
{
this->data_ = new data(ima, n);
}
- };
+ template <typename I, typename N>
+ typename current::delegatee&
+ current::impl_image()
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename I, typename N>
+ const typename current::delegatee&
+ current::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename I, typename N>
+ typename current::nbh
+ current::impl_nbhood() const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+# undef current
+
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln::internal
Index: oln/core/internal/instant_value.hh
--- oln/core/internal/instant_value.hh (revision 868)
+++ oln/core/internal/instant_value.hh (working copy)
@@ -60,13 +60,16 @@
{
V value;
+ /*
template <typename W>
- operator M<W>() const;
+ operator M<W>() const; // FIXME: do not compile with g++-3!!!
+ */
};
# ifndef OLN_INCLUDE_ONLY
+ /*
template <template<class> class M, typename V>
template <typename W>
instant_value_<M,V>::operator M<W>() const
@@ -74,6 +77,7 @@
M<W> tmp(this->value);
return tmp;
}
+ */
# endif // OLN_INCLUDE_ONLY
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 868)
+++ oln/core/internal/image_base.hh (working copy)
@@ -40,6 +40,19 @@
namespace oln
{
+
+ // FIXME: Experimental code below.
+
+ namespace pl // placeholder for short
+ {
+ struct value;
+ template <typename t> struct rec;
+ }
+
+ // End of experimental code.
+
+
+
/// Fwd decls.
namespace internal
@@ -116,7 +129,9 @@
typedef stc::abstract rvalue;
// FIXME: Uncomment below!
- // typedef stc::abstract output;
+ // typedef stc::abstract ...
+ typedef stc::abstract skeleton;
+ typedef stc::abstract plain;
typedef stc::abstract data;
@@ -155,7 +170,11 @@
{
typedef stc::abstract delegatee;
typedef stc::abstract behavior;
+
+ // not delegated:
typedef stc::not_delegated data;
+ typedef stc::not_delegated plain;
+ typedef stc::not_delegated skeleton;
};
template <typename Exact>
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 868)
+++ oln/stc/scoop.hh (working copy)
@@ -99,6 +99,10 @@
# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
# define stc_type(From, Type) typename stc_type_(From, Type)
+# define stc_type_in_(Namespace, From, Type) Namespace::vtype<From, Namespace::typedef_::Type>::ret
+# define stc_type_in(Namespace, From, Type) typename stc_type_in_(Namespace, From, Type)
+
+
# define stc_get_type_(Type) vtype<Exact, typedef_::Type>::ret
# define stc_get_type(Type) typename stc_get_type_(Type)
1
0
13 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add initialization material; extend point2d and box2d with it.
* oln/core/init.hh,
* oln/core/internal/initializer.hh,
* oln/core/internal/instant_value.hh: New.
* oln/core/concept/grid.hh (from, to): New.
* oln/core/2d/grid2d.hh (row, col),
(drow, dcol, nrows, ncols): New.
* oln/core/2d/box2d.hh (init__): New.
* oln/core/2d/point2d.hh (init__): New.
* oln/core/gen/box.hh (init__): New.
(operator<<): New.
* oln/core/internal/utils.hh: Add FIXME.
2d/box2d.hh | 65 +++++++++++++++++++++++++-
2d/grid2d.hh | 9 +++
2d/point2d.hh | 30 ++++++++++++
concept/grid.hh | 6 ++
gen/box.hh | 43 ++++++++++++++++-
init.hh | 105 ++++++++++++++++++++++++++++++++++++++++++
internal/initializer.hh | 115 ++++++++++++++++++++++++++++++++++++++++++++++
internal/instant_value.hh | 85 ++++++++++++++++++++++++++++++++++
internal/utils.hh | 6 ++
9 files changed, 460 insertions(+), 4 deletions(-)
Index: oln/core/concept/grid.hh
--- oln/core/concept/grid.hh (revision 867)
+++ oln/core/concept/grid.hh (working copy)
@@ -30,11 +30,17 @@
# define OLN_CORE_CONCEPT_GRID_HH
# include <oln/core/equipment.hh>
+# include <oln/core/internal/instant_value.hh>
namespace oln
{
+ /// Instant values.
+ oln_decl_instant_value(from);
+ oln_decl_instant_value(to);
+
+
/// Concept-class "Grid".
template <typename Exact>
Index: oln/core/init.hh
--- oln/core/init.hh (revision 0)
+++ oln/core/init.hh (revision 0)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INIT_HH
+# define OLN_CORE_INIT_HH
+
+# include <oln/core/internal/utils.hh>
+# include <oln/core/internal/instant_value.hh>
+# include <oln/core/internal/initializer.hh>
+
+
+
+namespace oln
+{
+
+
+ template <template<class> class M, typename V>
+ internal::initializer_< internal::singleton< M<V> > >
+ init(const internal::instant_value_<M,V>& v);
+
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2>
+ internal::initializer_< internal::pair< M1<V1>, M2<V2> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2);
+
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2,
+ template<class> class M3, typename V3>
+ internal::initializer_< internal::triplet< M1<V1>, M2<V2>, M3<V3> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2,
+ const internal::instant_value_<M3,V3>& v3);
+
+ // ...
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <template<class> class M, typename V>
+ internal::initializer_< internal::singleton< M<V> > >
+ init(const internal::instant_value_<M,V>& v)
+ {
+ internal::singleton< M<V> > tmp(v.value);
+ return tmp;
+ }
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2>
+ internal::initializer_< internal::pair< M1<V1>, M2<V2> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2)
+ {
+ internal::pair< M1<V1>, M2<V2> > tmp(v1.value, v2.value);
+ return tmp;
+ }
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2,
+ template<class> class M3, typename V3>
+ internal::initializer_< internal::triplet< M1<V1>, M2<V2>, M3<V3> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2,
+ const internal::instant_value_<M3,V3>& v3)
+ {
+ internal::triplet< M1<V1>, M2<V2>, M3<V3> > tmp(v1.value, v2.value, v3.value);
+ return tmp;
+ }
+
+ // ...
+
+# endif // OLN_INCLUDE_ONLY
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INIT_HH
Property changes on: oln/core/init.hh
___________________________________________________________________
Name: svn:executable
+ *
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 867)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/concept/grid.hh>
+
# define OLN_ENV_2D
@@ -39,6 +40,14 @@
namespace oln
{
+ /// Instant values.
+ oln_decl_instant_value(row);
+ oln_decl_instant_value(col);
+ oln_decl_instant_value(drow);
+ oln_decl_instant_value(dcol);
+ oln_decl_instant_value(nrows);
+ oln_decl_instant_value(ncols);
+
/// \{
/// Fwd decls.
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 867)
+++ oln/core/2d/box2d.hh (working copy)
@@ -28,18 +28,79 @@
#ifndef OLN_CORE_2D_BOX2D_HH
# define OLN_CORE_2D_BOX2D_HH
-# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
namespace oln
{
+ // Fwd decl.
+ template <typename P> class box_;
+
+
// FIXME: box2d should be an actual type, not an alias...
typedef box_<point2d> box2d;
+
+ /// init__
+ namespace internal
+ {
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data);
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data);
+
+ } // end of namespace oln::internal
+
} // end of namespace oln
-#endif // ! OLN_CORE_2D_BOX2D_HH
+# include <oln/core/gen/box.hh>
+
+# ifndef OLN_INCLUDE_ONLY
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data)
+ {
+ C nrows = data->value1.value;
+ C ncols = data->value2.value;
+ precondition(nrows > 0 and ncols > 0);
+ b.pmin().row() = 0;
+ b.pmin().col() = 0;
+ b.pmax().row() = nrows - 1;
+ b.pmax().col() = ncols - 1;
+ }
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data)
+ {
+ C nrows = data->value2.value;
+ C ncols = data->value3.value;
+ precondition(nrows > 0 and ncols > 0);
+ b.pmin() = data->value1.value;
+ b.pmax().row() = b.pmin().row() + nrows - 1;
+ b.pmax().col() = b.pmin().col() + ncols - 1;
+ }
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+# endif // OLN_INCLUDE_ONLY
+
+
+#endif // ! OLN_CORE_2D_BOX2D_HH
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 867)
+++ oln/core/2d/point2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/2d/grid2d.hh>
# include <oln/core/internal/point2d.hh>
+# include <oln/core/init.hh>
namespace oln
@@ -59,13 +60,25 @@
};
+ /// init__
+ namespace internal
+ {
+ template <typename C>
+ void init__(point2d& p,
+ const initializer_< pair< row_t<C>, col_t<C> > >& data);
+ }
+
+
/// Usual 2D point class.
class point2d : public internal::point2d_< point2d >
{
public:
+
/// Ctors.
point2d();
point2d(int row, int col);
+ template <typename D>
+ point2d(const internal::initializer_<D>& data);
};
@@ -82,6 +95,23 @@
this->col() = col;
}
+ template <typename D>
+ point2d::point2d(const internal::initializer_<D>& data)
+ {
+ internal::init__(*this, data);
+ }
+
+ namespace internal
+ {
+ template <typename C>
+ void init__(point2d& p,
+ const initializer_< pair< row_t<C>, col_t<C> > >& data)
+ {
+ p.row() = data->value1.value; // FIXME: first
+ p.col() = data->value2.value; // FIXME: second
+ }
+ }
+
# endif
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 867)
+++ oln/core/gen/box.hh (working copy)
@@ -32,11 +32,13 @@
# include <oln/core/concept/point.hh>
# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/init.hh>
namespace oln
{
+
// Forward declarations.
template <typename P> class box_;
template <typename P> class box_fwd_piter_;
@@ -62,6 +64,15 @@
};
+ /// init__
+ namespace internal
+ {
+ template <typename P>
+ void init__(box_<P>& b,
+ const initializer_< pair< from_t<P>, to_t<P> > >& data);
+ }
+
+
/// Generic box class based on a point class.
template <typename P>
@@ -83,6 +94,8 @@
box_();
box_(const P& pmin, const P& pmax);
+ template <typename D>
+ box_(const internal::initializer_<D>& data);
unsigned impl_npoints() const;
bool impl_has(const P& p) const;
@@ -99,6 +112,11 @@
}; // end of class oln::box_<P>
+ template <typename P>
+ std::ostream& operator<<(std::ostream& ostr, const box_<P>& b)
+ {
+ return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
+ }
// -------------------- iterators on box_<P>
@@ -209,6 +227,13 @@
}
template <typename P>
+ template <typename D>
+ box_<P>::box_(const internal::initializer_<D>& data)
+ {
+ internal::init__(*this, data);
+ }
+
+ template <typename P>
unsigned
box_<P>::impl_npoints() const
{
@@ -268,6 +293,22 @@
}
+ // -------------------- init__
+
+
+ namespace internal
+ {
+
+ template <typename P>
+ void init__(box_<P>& b,
+ const initializer_< pair< from_t<P>, to_t<P> > >& data)
+ {
+ b.pmin() = data->value1.value;
+ b.pmax() = data->value2.value;
+ }
+
+ }
+
// -------------------- box_fwd_piter_<P>
@@ -407,7 +448,7 @@
return &p_;
}
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/initializer.hh
--- oln/core/internal/initializer.hh (revision 0)
+++ oln/core/internal/initializer.hh (revision 0)
@@ -0,0 +1,115 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_INITIALIZER_HH
+# define OLN_CORE_INTERNAL_INITIALIZER_HH
+
+
+namespace oln
+{
+
+
+ namespace ERROR
+ {
+
+ template <typename S>
+ struct bad_initialization_of_
+ {
+ template <typename D>
+ struct with_;
+ };
+
+ } // end of namespace oln::ERROR
+
+
+
+ namespace internal
+ {
+
+
+ template <typename D>
+ struct initializer_
+ {
+ initializer_(const D& data);
+ const D& operator*() const;
+ const D* operator->() const;
+
+ protected:
+ D data_;
+ };
+
+
+ template <typename Tag, typename Subject, typename D>
+ void init__(const Tag& t, Subject& s, const initializer_<D>& d);
+
+ template <typename Subject, typename D>
+ void init__(Subject& s, const initializer_<D>& d);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename D>
+ initializer_<D>::initializer_(const D& data)
+ : data_(data)
+ {}
+
+ template <typename D>
+ const D&
+ initializer_<D>::operator*() const
+ {
+ return this->data_;
+ }
+
+ template <typename D>
+ const D*
+ initializer_<D>::operator->() const
+ {
+ return &(this->data_);
+ }
+
+ template <typename Tag, typename Subject, typename D>
+ void init__(const Tag&, Subject&, const initializer_<D>&)
+ {
+ mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ }
+
+ template <typename Subject, typename D>
+ void init__(Subject&, const initializer_<D>&)
+ {
+ mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_INITIALIZER_HH
Property changes on: oln/core/internal/initializer.hh
___________________________________________________________________
Name: svn:executable
+ *
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 867)
+++ oln/core/internal/utils.hh (working copy)
@@ -35,6 +35,11 @@
namespace internal
{
+
+ // FIXME: Rename attributes as first / second / third / fourth?
+
+
+
/// Simple singleton class.
template <typename T>
@@ -109,4 +114,3 @@
#endif // ! OLN_CORE_INTERNAL_UTILS_HH
-
Index: oln/core/internal/instant_value.hh
--- oln/core/internal/instant_value.hh (revision 0)
+++ oln/core/internal/instant_value.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_INSTANT_VALUE_HH
+# define OLN_CORE_INTERNAL_INSTANT_VALUE_HH
+
+
+# define oln_decl_instant_value(Name) \
+ \
+template <typename V> \
+struct Name##_t : public internal::instant_value_< Name##_t, V> \
+{ \
+ Name##_t(const V& v) { this->value = v; } \
+}; \
+ \
+template <typename V> \
+Name##_t<V> Name(const V& v) \
+{ \
+ return Name##_t<V>(v); \
+} \
+ \
+struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ /// Class internal::instant_value_<M,V>.
+
+ template <template<class> class M, typename V>
+ struct instant_value_
+ {
+ V value;
+
+ template <typename W>
+ operator M<W>() const;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <template<class> class M, typename V>
+ template <typename W>
+ instant_value_<M,V>::operator M<W>() const
+ {
+ M<W> tmp(this->value);
+ return tmp;
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_INSTANT_VALUE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Tiny fix.
* mlc/typedef.hh (result): Rename as...
(result_): ...this; disambiguation.
* mlc/cmp.hh (assert_found_),
(assert_not_found_): New.
cmp.hh | 10 ++++++++++
typedef.hh | 18 +++++++++---------
2 files changed, 19 insertions(+), 9 deletions(-)
Index: mlc/typedef.hh
--- mlc/typedef.hh (revision 866)
+++ mlc/typedef.hh (working copy)
@@ -161,29 +161,29 @@
static no selector(...); \
\
template <class T, bool found_> \
- struct result; \
+ struct result_; \
\
template <class T> \
- struct result <T, true> { \
+ struct result_ <T, true> { \
typedef typename T::TypedefName ret; \
}; \
\
template <class T> \
- struct result <T, false> { \
+ struct result_ <T, false> { \
typedef mlc::not_found ret; \
}; \
\
template <class T, bool found_> \
- struct result2; \
+ struct result_2; \
\
template <class T> \
- struct result2 <T, true> { \
+ struct result_2 <T, true> { \
typedef mlc::pair_<mlc::found, \
typename T::TypedefName> ret; \
}; \
\
template <class T> \
- struct result2 <T, false> { \
+ struct result_2 <T, false> { \
typedef mlc::pair_<mlc::not_found, \
mlc::dummy> ret; \
}; \
@@ -205,11 +205,11 @@
}; \
public: \
typedef \
- typename helper_::result<T, found_>::ret \
+ typename helper_::result_<T, found_>::ret \
ret; \
\
typedef \
- typename helper_::result2<T, found_>::ret \
+ typename helper_::result_2<T, found_>::ret \
ret2; \
}; \
\
@@ -235,7 +235,7 @@
\
} \
\
-struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
/*! \macro mlc_typedef(Type, TypedefName)
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 866)
+++ mlc/cmp.hh (working copy)
@@ -161,6 +161,16 @@
struct is_found_ : public mlc_is_not_a(T, mlc::not_found)::bexpr
{
};
+
+ template <typename T, typename err = no_error_message>
+ struct assert_found_ : public assert_< is_found_<T>, err >
+ {
+ };
+
+ template <typename T, typename err = no_error_message>
+ struct assert_not_found_ : public assert_< is_not_found_<T>, err >
+ {
+ };
/// \}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add 1D classes and remove some dead code.
* oln/core/internal/utils.hh (triplet): New.
* oln/core/1d/image1d_b.hh,
* oln/core/1d/grid1d.hh,
* oln/core/1d/box1d.hh,
* oln/core/internal/dpoint1d.hh,
* oln/core/internal/point1d.hh: New.
* tests/core/grid.cc,
* oln/core/1d/neighb1d.hh,
* oln/core/1d/dpoint1d.hh,
* oln/core/1d/array1d.hh,
* oln/core/1d/image1d.hh,
* oln/core/1d/window1d.hh,
* oln/core/1d/point1d.hh: Update.
* oln/core/aliases.hh,
* oln/core/fwd_decls.hh,
* oln/core/1d/aliases.hh,
* oln/core/1d/topo1d.hh,
* oln/core/1d/fwd_decls.hh,
* oln/core/2d/aliases.hh,
* oln/core/2d/topo2d.hh,
* oln/core/2d/fwd_decls.hh,
* oln/core/3d/aliases.hh,
* oln/core/3d/topo3d.hh,
* oln/core/3d/fwd_decls.hh,
* oln/core/gen/fwd_decls.hh: Remove.
* oln/core/2d/box2d.hh,
* oln/core/2d/neighb2d.hh,
* oln/core/2d/window2d.hh (include): Remove aliases.
* oln/core/internal/point2d.hh (grid_): Remove fwd decl.
oln/core/1d/array1d.hh | 149 ++++++++++++++++++++---------
oln/core/1d/box1d.hh | 45 +++++++++
oln/core/1d/dpoint1d.hh | 91 +++++-------------
oln/core/1d/grid1d.hh | 93 ++++++++++++++++++
oln/core/1d/image1d.hh | 154 ++++++++++++++++++------------
oln/core/1d/image1d_b.hh | 210 ++++++++++++++++++++++++++++++++++++++++++
oln/core/1d/neighb1d.hh | 10 +-
oln/core/1d/point1d.hh | 107 +++++----------------
oln/core/1d/window1d.hh | 18 ++-
oln/core/2d/box2d.hh | 2
oln/core/2d/neighb2d.hh | 2
oln/core/2d/window2d.hh | 2
oln/core/internal/dpoint1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point2d.hh | 1
oln/core/internal/utils.hh | 48 ++++++++-
tests/core/grid.cc | 4
17 files changed, 880 insertions(+), 272 deletions(-)
Index: tests/core/grid.cc
--- tests/core/grid.cc (revision 865)
+++ tests/core/grid.cc (working copy)
@@ -30,8 +30,8 @@
#include <cassert>
#include <oln/core/2d/grid2d.hh>
// FIXME: Disabled.
-// #include <oln/core/1d/aliases.hh>
-// #include <oln/core/3d/aliases.hh>
+// #include <oln/core/1d/grid1d.hh>
+// #include <oln/core/3d/grid3d.hh>
int
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 865)
+++ oln/core/1d/neighb1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -36,6 +36,7 @@
namespace oln
{
+ // FIXME: neighb2d should be an actual type, not an alias...
typedef neighb_<dpoint1d> neighb1d;
@@ -49,10 +50,9 @@
neighb1d mk_c2()
{
- neighb1d the_;
- the_
- .add(dpoint1d(1));
- return the_;
+ neighb1d tmp;
+ tmp.take(dpoint1d(1));
+ return tmp;
}
# endif
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 865)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,103 +29,66 @@
#ifndef OLN_CORE_1D_DPOINT1D_HH
# define OLN_CORE_1D_DPOINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/internal/dpoint_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/dpoint1d.hh>
namespace oln
{
- typedef dpoint1d_<int> dpoint1d;
-
- /// Fwd decls.
- template <unsigned D> struct grid_;
- typedef grid_<1> grid1d;
- template <typename C> struct point1d_;
- typedef point1d_<int> point1d;
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< dpoint1d_<C> >
+ template<>
+ struct super_trait_< dpoint1d >
{
- typedef internal::dpoint_nd< dpoint1d_<C> > ret;
+ typedef internal::dpoint1d_< dpoint1d > ret;
};
- /// Virtual types associated to oln::dpoint1d_<C>.
- template <typename C>
- struct vtypes< dpoint1d_<C> >
- {
- typedef grid1d grid_type;
- typedef point1d point_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< dpoint1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef point1d point;
};
- /// General 1D dpoint class.
- template <typename C>
- class dpoint1d_
- : public internal::dpoint_nd< dpoint1d_<C> >
+ /// Usual 1D dpoint class.
+ class dpoint1d : public internal::dpoint1d_< dpoint1d >
{
- typedef dpoint1d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- dpoint1d_();
-
- /// Ctor.
- dpoint1d_(const xtd::vec<1,C>& v);
-
- /// Ctor.
- dpoint1d_(C index);
-
- C index() const;
- C& index();
+ /// Ctors.
+ dpoint1d();
+ dpoint1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- dpoint1d_<C>::dpoint1d_()
+ dpoint1d::dpoint1d()
{
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ dpoint1d::dpoint1d(int ind)
{
+ this->ind() = ind;
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(C index)
- : super_t(xtd::mk_vec(index))
- {
- }
-
- template <typename C>
- C dpoint1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& dpoint1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// dpoint1d goes with point1d so:
+# include <oln/core/1d/point1d.hh>
+
+
#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 865)
+++ oln/core/1d/array1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,40 +29,51 @@
#ifndef OLN_CORE_1D_ARRAY1D_HH
# define OLN_CORE_1D_ARRAY1D_HH
-# include <cstdlib>
+# include <cstddef>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 1D array class.
- template <typename value_t, typename coord_t = int>
- class array1d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array1d_
{
public:
/// Ctor.
- array1d(coord_t min, coord_t max);
+ array1d_(C imin, C imax);
+
/// Ctor.
- array1d(coord_t len);
+ array1d_(C len);
/// Dtor.
- ~array1d();
+ ~array1d_();
+
+ const T& operator()(C i) const;
+ T& operator()(C i);
+
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
- value_t operator()(coord_t i) const;
- value_t& operator()(coord_t i);
+ bool has(C i) const;
- bool has(coord_t i) const;
+ std::size_t memsize() const;
+ std::size_t ncells() const;
- size_t memsize() const;
+ C imin() const;
+ C imax() const;
+
+ const T* buffer() const;
+ T* buffer();
protected:
- coord_t min_, max_;
- coord_t len_;
- value_t* buffer_;
+ C imin_, imax_;
+ C len_;
+ T* buffer_;
private:
@@ -74,65 +85,113 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t min, coord_t max) :
- min_(min), max_(max)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C imin, C imax) :
+ imin_(imin),
+ imax_(imax)
{
- precondition(max >= min);
- len_ = max - min + 1;
+ precondition(imax >= imin);
+ len_ = imax - imin + 1;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t len) :
- min_(0), len_(len)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C len) :
+ imin_(0),
+ len_(len)
{
precondition(len > 0);
- max_ = min_ + len_;
+ imax_ = imin_ + len_;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::~array1d()
+ template <typename T, typename C>
+ array1d_<T, C>::~array1d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t array1d<value_t, coord_t>::operator()(coord_t i) const
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator()(C i) const
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
}
- template <typename value_t, typename coord_t>
- value_t& array1d<value_t, coord_t>::operator()(coord_t i)
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator()(C i)
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
+ }
+
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ bool array1d_<T, C>::has(C i) const
+ {
+ return i >= imin_ and i <= imax_;
+ }
+
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ const T* array1d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array1d_<T, C>::buffer()
+ {
+ return buffer_;
}
- template <typename value_t, typename coord_t>
- bool array1d<value_t, coord_t>::has(coord_t i) const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::ncells() const
{
- return
- i >= min_ and i <= max_;
+ return len_;
}
- template <typename value_t, typename coord_t>
- size_t array1d<value_t, coord_t>::memsize() const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::memsize() const
{
- return size_t(len_) * sizeof(value_t);
+ return len_ * sizeof(T);
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(len_)];
+ buffer_ = new T[len_];
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::deallocate_()
{
precondition(buffer_ != 0);
delete[] buffer_;
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 865)
+++ oln/core/1d/image1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,73 +29,73 @@
#ifndef OLN_CORE_1D_IMAGE1D_HH
# define OLN_CORE_1D_IMAGE1D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/1d/topo1d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/1d/box1d.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image1d;
- /// Virtual types associated to oln::image1d<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image1d<T> >
{
- typedef topo1d topo_type;
+ typedef point1d point;
- typedef point1d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef array1d_<value, coord> data;
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image1d<T> >
+ struct super_trait_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 1D image class.
+
template <typename T>
- class image1d : public image_entry< image1d<T> >
+ class image1d : public internal::plain_primitive_image_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef array1d<T> array_t;
-
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> super;
public:
+ stc_using(data);
- /// Ctor using sizes.
- image1d(unsigned nindices, unsigned border = 2);
+ image1d();
+ image1d(const box1d& b);
+ image1d(unsigned n);
- /// Ctor using an existing topology.
- image1d(const topo1d& topo);
+ bool impl_owns_(const point1d& p) const;
- const topo1d& impl_topo() const;
+ bool impl_has(const point1d& p) const;
- T impl_op_read(const point1d& p) const;
- T& impl_op_readwrite(const point1d& p);
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
- T* adr_at(int index);
- const T* adr_at(int index) const;
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
- private:
+ std::size_t impl_npoints() const;
- topo1d topo_;
- internal::tracked_ptr<array_t> data_;
+ box1d impl_bbox() const;
+ box1d impl_points() const;
};
@@ -103,57 +103,87 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image1d<T>::image1d(unsigned nindices, unsigned border)
- : topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
- data_(new array_t(0 - border,
- nindices - 1 + border))
+ image1d<T>::image1d()
+ {
+ }
+
+ template <typename T>
+ image1d<T>::image1d(const box1d& b)
+ {
+ this->data_ = new data(b.pmin().ind(), b.pmax().ind());
+ }
+
+ template <typename T>
+ image1d<T>::image1d(unsigned n)
+ {
+ precondition(n != 0);
+ this->data_ = new data(0, n - 1);
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d<T>::impl_read(const point1d& p) const
{
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- image1d<T>::image1d(const topo1d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().index(),
- topo.bbox().pmax().index()))
+ const T& image1d<T>::impl_index_read(unsigned i) const
{
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- const topo1d& image1d<T>::impl_topo() const
+ T& image1d<T>::impl_read_write(const point1d& p)
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- T image1d<T>::impl_op_read(const point1d& p) const
+ T& image1d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- T& image1d<T>::impl_op_readwrite(const point1d& p)
+ std::size_t image1d<T>::impl_npoints() const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ // faster than the default code given by primitive_image_
+ assert(this->has_data());
+ return this->data_->ncells();
}
template <typename T>
- T* image1d<T>::adr_at(int index)
+ box1d image1d<T>::impl_bbox() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ assert(this->has_data());
+ box1d b(this->data_->imin(), this->data_->imax());
+ return b;
}
template <typename T>
- const T* image1d<T>::adr_at(int index) const
+ box1d image1d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ return this->bbox();
}
# endif
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 0)
+++ oln/core/1d/image1d_b.hh (revision 0)
@@ -0,0 +1,210 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_1D_IMAGE1D_B_HH
+# define OLN_CORE_1D_IMAGE1D_B_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/1d/array1d.hh>
+# include <oln/core/1d/box1d.hh>
+
+
+namespace oln
+{
+
+
+ // FIXME: Conversely to image2d_b, we use here the triplet class
+ // instead of the array_b_ class.
+
+
+ // Fwd decl.
+ template <typename T> class image1d_b;
+
+
+ /// Virtual types.
+ template <typename T>
+ struct vtypes< image1d_b<T> >
+ {
+ typedef point1d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef internal::triplet< array1d_<T, int>,
+ unsigned,
+ box_<point1d> > data;
+ };
+
+
+ /// Super type.
+ template <typename T>
+ struct super_trait_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
+ };
+
+
+ /// General 1D image class.
+
+ template <typename T>
+ class image1d_b : public internal::plain_primitive_image_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
+ typedef array1d_<T, int> array_t;
+ public:
+ stc_using(data);
+
+ image1d_b();
+ image1d_b(const box1d& b, unsigned border = 2);
+ image1d_b(unsigned n, unsigned border = 2);
+
+ bool impl_owns_(const point1d& p) const;
+
+ bool impl_has(const point1d& p) const;
+
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
+
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
+
+ std::size_t impl_npoints() const;
+
+ box1d impl_bbox() const;
+ box1d impl_points() const;
+
+ unsigned border() const;
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image1d_b<T>::image1d_b()
+ {
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(const box1d& b, unsigned border)
+ {
+ this->data_ = new data(array_t(b.pmin().ind() - border,
+ b.pmax().ind() + border),
+ border,
+ b);
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(unsigned n, unsigned border)
+ {
+ precondition(n != 0);
+ this->data_ = new data(array_t(- border,
+ n - 1 + border),
+ border,
+ box1d(0, n - 1));
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value3.has(p);
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_read(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_index_read(unsigned i) const
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_read_write(const point1d& p)
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_index_read_write(unsigned i)
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_bbox() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ unsigned image1d_b<T>::border() const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_IMAGE1D_B_HH
Index: oln/core/1d/grid1d.hh
--- oln/core/1d/grid1d.hh (revision 0)
+++ oln/core/1d/grid1d.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_1D_GRID1D_HH
+# define OLN_CORE_1D_GRID1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/concept/grid.hh>
+
+
+# define OLN_ENV_1D
+
+
+
+namespace oln
+{
+
+
+ /// \{
+ /// Fwd decls.
+
+ template <typename Exact> struct Grid_1D;
+ struct grid1d;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_1D.
+
+ template <typename Exact>
+ struct vtypes< Grid_1D<Exact> >
+ {
+ typedef mlc::uint_<1> dim;
+ };
+
+ template <typename Exact>
+ struct Grid_1D : public Grid<Exact>
+ {
+ protected:
+ Grid_1D() {}
+ };
+
+ /// \}
+
+
+ /// \{
+ /// Super type.
+
+ template<>
+ struct super_trait_< grid1d >
+ {
+ typedef Grid_1D< grid1d > ret;
+ };
+
+ /// \}
+
+
+
+ /// One-dimensional grid struct.
+
+ struct grid1d : public Grid_1D< grid1d >
+ {};
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_GRID1D_HH
Index: oln/core/1d/window1d.hh
--- oln/core/1d/window1d.hh (revision 865)
+++ oln/core/1d/window1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,18 @@
#ifndef OLN_CORE_1D_WINDOW1D_HH
# define OLN_CORE_1D_WINDOW1D_HH
-// Headers required for the complete definition of oln::window1d
-// (i.e., oln::window_<dpoint1d>).
-# include <oln/core/1d/aliases.hh>
-# include <oln/core/1d/dpoint1d.hh>
# include <oln/core/gen/window.hh>
+# include <oln/core/1d/dpoint1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: window1d should be an actual type, not an alias...
+ typedef window_<dpoint1d> window1d;
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_1D_WINDOW1D_HH
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 0)
+++ oln/core/1d/box1d.hh (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_1D_BOX1D_HH
+# define OLN_CORE_1D_BOX1D_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/1d/point1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: box1d should be an actual type, not an alias...
+ typedef box_<point1d> box1d;
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_BOX1D_HH
+
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 865)
+++ oln/core/1d/point1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,119 +29,66 @@
#ifndef OLN_CORE_1D_POINT1D_HH
# define OLN_CORE_1D_POINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/internal/point_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/point1d.hh>
namespace oln
{
- /// Fwd decls.
- template <unsigned D> struct grid_;
- template <typename C> struct dpoint1d_;
- template <typename C> struct point1d_;
-
-
- typedef grid_<1> grid1d;
- typedef dpoint1d_<int> dpoint1d;
- typedef point1d_<int> point1d;
-
-
-
- /* FIXME: Is this the right place for these functions (on types)?
- In particular, the function on dpoint1d should be near the
- definition of dpoint1d, not point1d's. */
- /// Specializations of functions point and dpoint :
- /// \f$(n, coord) \rightarrow type\f$ for \f$n = 1\f$.
- /// \{
- template <typename C> struct point_ <1, C> { typedef point1d_<C> ret; };
- template <typename C> struct dpoint_ <1, C> { typedef dpoint1d_<C> ret; };
- /// \}
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< point1d_<C> >
+ template<>
+ struct super_trait_< point1d >
{
- typedef internal::point_nd< point1d_<C> > ret;
+ typedef internal::point1d_< point1d > ret;
};
- /// Virtual types associated to oln::point1d_<C>.
- template <typename C>
- struct vtypes< point1d_<C> >
- {
- typedef grid1d grid_type;
- typedef dpoint1d dpoint_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< point1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef dpoint1d dpoint;
};
- /// General 1D point class.
- template <typename C>
- class point1d_ : public internal::point_nd< point1d_<C> >
+ /// Usual 1D point class.
+ class point1d : public internal::point1d_< point1d >
{
- typedef point1d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- point1d_();
-
- /// Ctor.
- point1d_(C index);
-
- /// Ctor.
- point1d_(const xtd::vec<1,C>& v);
-
- /// Dtor.
- ~point1d_()
- {
- }
-
- C index() const;
- C& index();
+ /// Ctors.
+ point1d();
+ point1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
-
- template <typename C>
- point1d_<C>::point1d_()
- {
- }
-
- template <typename C>
- point1d_<C>::point1d_(C index)
- : super_t (xtd::mk_vec(index))
+ point1d::point1d()
{
}
- template <typename C>
- point1d_<C>::point1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ point1d::point1d(int ind)
{
+ this->ind() = ind;
}
- template <typename C>
- C point1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& point1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// point1d goes with dpoint1d so:
+# include <oln/core/1d/dpoint1d.hh>
+
+
#endif // ! OLN_CORE_1D_POINT1D_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 865)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -31,13 +31,13 @@
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: neighb2d should be an actual type, not an alias...
+ typedef neighb_<dpoint2d> neighb2d;
namespace internal
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 865)
+++ oln/core/2d/window2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/window.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: window2d should be an actual type, not an alias...
+ typedef window_<dpoint2d> window2d;
window2d mk_square(unsigned odd_len);
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 865)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: box2d should be an actual type, not an alias...
+ typedef box_<point2d> box2d;
} // end of namespace oln
Index: oln/core/internal/dpoint1d.hh
--- oln/core/internal/dpoint1d.hh (revision 0)
+++ oln/core/internal/dpoint1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_DPOINT1D_HH
+# define OLN_CORE_INTERNAL_DPOINT1D_HH
+
+# include <oln/core/internal/dpoint_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct dpoint1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::dpoint1d_<Exact> >
+ {
+ typedef internal::dpoint_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::dpoint1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class dpoint1d_ : public dpoint_base_<Exact>
+ {
+ typedef dpoint_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ dpoint1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ dpoint1d_<Exact>::dpoint1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord
+ dpoint1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord &
+ dpoint1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_DPOINT1D_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 865)
+++ oln/core/internal/utils.hh (working copy)
@@ -42,8 +42,8 @@
{
singleton()
{}
- singleton(T val)
- : value(val)
+ singleton(T value)
+ : value(value)
{}
T value;
};
@@ -56,15 +56,53 @@
{
pair()
{}
- pair(T1 val1, T2 val2)
- : value1(val1),
- value2(val2)
+ pair(T1 value1, T2 value2)
+ : value1(value1),
+ value2(value2)
{}
T1 value1;
T2 value2;
};
+ /// Simple triplet class.
+
+ template <typename T1, typename T2, typename T3>
+ struct triplet
+ {
+ triplet()
+ {}
+ triplet(T1 value1, T2 value2, T3 value3)
+ : value1(value1),
+ value2(value2),
+ value3(value3)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ };
+
+
+ /// Simple quartet class.
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ struct quartet
+ {
+ quartet()
+ {}
+ quartet(T1 value1, T2 value2, T3 value3, T4 value4)
+ : value1(value1),
+ value2(value2),
+ value3(value3),
+ value4(value4)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ T4 value4;
+ };
+
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/point1d.hh
--- oln/core/internal/point1d.hh (revision 0)
+++ oln/core/internal/point1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_POINT1D_HH
+# define OLN_CORE_INTERNAL_POINT1D_HH
+
+# include <oln/core/internal/point_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct point1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::point1d_<Exact> >
+ {
+ typedef internal::point_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class point1d_ : public point_base_<Exact>
+ {
+ typedef point_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ point1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ point1d_<Exact>::point1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord
+ point1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord &
+ point1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_POINT1D_HH
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 865)
+++ oln/core/internal/point2d.hh (working copy)
@@ -37,7 +37,6 @@
/// Fwd decls.
- template <unsigned D> struct grid_;
namespace internal { template <typename Exact> struct point2d_; }
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add type of 2d images with border.
* tests/core/Makefile.am (check_PROGRAMS): Add neighb2d.
* oln/debug/print.hh: Update.
* oln/core/2d/array2d.hh (operator[], blen_): New.
* oln/core/2d/image2d.hh (npoints): Fix; rename as...
(impl_npoints): ...this.
(operator[]): Update.
* oln/core/2d/image2d_b.hh: Update.
* oln/core/2d/grid2d.hh (OLN_ENV_2D): New.
* oln/core/equipment.hh (oln_coord): New.
* oln/core/gen/dpoints_piter.hh (dps_): Change type.
* oln/core/internal/image_base.hh (impl_npoints): New; default impl.
* oln/core/internal/point_set_std_based.hh: Fix.
oln/core/2d/array2d.hh | 27 +++
oln/core/2d/grid2d.hh | 4
oln/core/2d/image2d.hh | 9 -
oln/core/2d/image2d_b.hh | 213 ++++++++++++++++++++-----------
oln/core/equipment.hh | 2
oln/core/gen/dpoints_piter.hh | 9 -
oln/core/internal/image_base.hh | 9 +
oln/core/internal/point_set_std_based.hh | 2
oln/debug/print.hh | 55 +++++---
tests/core/Makefile.am | 2
10 files changed, 231 insertions(+), 101 deletions(-)
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 863)
+++ tests/core/Makefile.am (working copy)
@@ -23,6 +23,7 @@
point2d \
grid \
image2d \
+ neighb2d \
npoints \
neighb2d \
window2d \
@@ -33,6 +34,7 @@
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image2d_SOURCES = image2d.cc
+neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
window2d_SOURCES = window2d.cc
neighb2d_SOURCES = neighb2d.cc
Index: oln/debug/print.hh
--- oln/debug/print.hh (revision 863)
+++ oln/debug/print.hh (working copy)
@@ -29,11 +29,7 @@
# define OLN_DEBUG_PRINT_HH
# include <iostream>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/hybrid/classical.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/spe/row.hh>
-# include <oln/core/spe/col.hh>
+# include <oln/core/concept/image.hh>
# ifdef OLN_ENV_2D
# include <oln/core/2d/point2d.hh>
@@ -49,7 +45,7 @@
/// Fwd decl.
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr = std::cout);
+ void print(const Image<I>& input, std::ostream& ostr = std::cout);
# ifndef OLN_INCLUDE_ONLY
@@ -70,30 +66,47 @@
/// Generic version.
+
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr)
+ void print_Gen(const Image<I>& input, std::ostream& ostr)
{
- oln_vtype(I, fwd_piter) p(input.topo());
+ oln_fwd_piter(I) p(input.points());
for_all(p)
ostr << p.to_point() << ':' << format(input(p)) << ' ';
}
+ template <typename I>
+ void print(const Image<I>& input, std::ostream& ostr)
+ {
+ print_Gen(input, ostr);
+ }
+
+
# ifdef OLN_ENV_2D
+ /// Default version.
+
+ template <typename I>
+ void print_2D(const Image<I>&, const I& input, std::ostream& ostr)
+ {
+ print_Gen(input, ostr);
+ }
+
/// Version for classical 2D images.
+
template <typename I>
- void print(const abstract::classical_2d_image<I>& input,
+ void print_2D(const Point_Wise_Accessible_Image<I>&, const I& input,
std::ostream& ostr)
{
const oln_coord(I)
- min_row = oln::min_row(input),
- max_row = oln::max_row(input);
+ min_row = input.bbox().pmin().row(),
+ max_row = input.bbox().pmax().row();
+ const oln_coord(I)
+ min_col = input.bbox().pmin().col(),
+ max_col = input.bbox().pmax().col();
for (oln_coord(I) row = min_row; row <= max_row; ++row)
{
- const oln_coord(I)
- min_col = oln::min_col(input),
- max_col = oln::max_col(input);
for (oln_coord(I) col = min_col; col <= max_col; ++col)
{
point2d p(row, col);
@@ -107,7 +120,13 @@
}
}
-# endif
+ template <typename I>
+ void print(const Image_2D<I>& input, std::ostream& ostr)
+ {
+ impl::print_2D(exact(input), exact(input), ostr);
+ }
+
+# endif // OLN_ENV_2D
} // end of namespace oln::debug::impl
@@ -115,13 +134,15 @@
/// Facade.
template <typename I>
- void print(const abstract::image<I>& input, std::ostream& ostr)
+ void print(const Image<I>& input, std::ostream& ostr)
{
- impl::print(input.exact(), ostr);
+ impl::print(exact(input), ostr);
}
+
# endif // ! OLN_INCLUDE_ONLY
+
} // end of namespace oln::debug
} // end of namespace oln
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 863)
+++ oln/core/2d/array2d.hh (working copy)
@@ -55,6 +55,9 @@
const T& operator()(C i, C j) const;
T& operator()(C i, C j);
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
+
bool has(C i, C j) const;
std::size_t memsize() const;
@@ -72,6 +75,7 @@
C imin_, jmin_, imax_, jmax_;
C ilen_, jlen_;
+ std::size_t blen_;
T* buffer_;
T** array_;
@@ -132,6 +136,22 @@
}
template <typename T, typename C>
+ const T& array2d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array2d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
bool array2d_<T, C>::has(C i, C j) const
{
return
@@ -179,7 +199,7 @@
template <typename T, typename C>
std::size_t array2d_<T, C>::ncells() const
{
- return std::size_t(ilen_) * std::size_t(jlen_);
+ return blen_;
}
template <typename T, typename C>
@@ -187,7 +207,7 @@
{
return
// buffer_
- std::size_t(ilen_) * std::size_t(jlen_) * sizeof(T)
+ blen_ * sizeof(T)
+
// array_
std::size_t(ilen_) * sizeof(T*);
@@ -196,7 +216,8 @@
template <typename T, typename C>
void array2d_<T, C>::allocate_()
{
- buffer_ = new T[std::size_t(ilen_) * std::size_t(jlen_)];
+ blen_ = std::size_t(ilen_) * std::size_t(jlen_);
+ buffer_ = new T[blen_];
array_ = new T*[std::size_t(ilen_)];
T* buf = buffer_ - jmin_;
for (C i = 0; i < ilen_; ++i)
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 863)
+++ oln/core/2d/image2d.hh (working copy)
@@ -95,7 +95,7 @@
T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- std::size_t npoints() const;
+ std::size_t impl_npoints() const;
box2d impl_bbox() const;
box2d impl_points() const;
@@ -157,7 +157,7 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->buffer()[i];
+ return this->data_->operator[](i);
}
template <typename T>
@@ -179,7 +179,7 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->buffer()[i];
+ return this->data_->operator[](i);
}
template <typename T>
@@ -190,8 +190,9 @@
}
template <typename T>
- std::size_t image2d<T>::npoints() const
+ std::size_t image2d<T>::impl_npoints() const
{
+ // faster than the default code given by primitive_image_
assert(this->has_data());
return this->data_->ncells();
}
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 863)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -29,79 +29,124 @@
#ifndef OLN_CORE_2D_IMAGE2D_B_HH
# define OLN_CORE_2D_IMAGE2D_B_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/topo2d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/2d/box2d.hh>
namespace oln
{
- // Forward declaration.
+
+ // FIXME: Move it!
+
+ namespace internal
+ {
+
+
+ template <typename P, typename T>
+ struct f_point_value_to_array_;
+
+ template <typename T>
+ struct f_point_value_to_array_< point2d, T >
+ {
+ typedef array2d_<T, int> ret;
+ };
+
+
+ template <typename P, typename T>
+ struct array_b_
+ {
+ typedef typename f_point_value_to_array_<P, T>::ret array_t;
+ typedef typename P::coord coord;
+
+ array_b_(const P& pmin, const P& pmax, unsigned border)
+ : array(pmin.row() - border, pmin.col() - border,
+ pmax.row() + border, pmax.col() + border),
+ border(border),
+ box(pmin, pmax)
+ {
+ }
+
+ array_t array;
+ unsigned border;
+ box_<P> box;
+ };
+
+
+ } // end of namespace oln::internal
+
+
+ // end of FIXME
+
+
+
+ // Fwd decl.
template <typename T> class image2d_b;
- /// Virtual types associated to oln::image2d_b<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image2d_b<T> >
{
- typedef topo2d topo_type;
+ typedef point2d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
- typedef point2d point_type;
+ typedef box2d pset;
+ typedef internal::array_b_<point2d, T> data;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ // FIXME: wrong qiter!!!
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image2d_b<T> >
+ struct super_trait_< image2d_b<T> >
{
- typedef image2d_b<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image2d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 2D image class.
+
template <typename T>
- class image2d_b : public image_entry< image2d_b<T> >
+ class image2d_b : public internal::plain_primitive_image_< image2d_b<T> >
{
- typedef image2d_b<T> self_t;
- typedef array2d<T> array_t;
-
+ typedef image2d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
public:
+ stc_using(data);
- /// Ctor without info.
image2d_b();
-
- /// Ctor using sizes.
+ image2d_b(const box2d& b, unsigned border = 2);
image2d_b(unsigned nrows, unsigned ncols, unsigned border = 2);
- /// Ctor using an existing topology.
- image2d_b(const topo2d& topo);
+ bool impl_owns_(const point2d& p) const;
- const topo2d& impl_topo() const;
+ bool impl_has(const point2d& p) const;
+ bool impl_has_at(int row, int col) const;
- T impl_op_read(const point2d& p) const;
- T impl_at(int row, int col) const;
+ const T& impl_read(const point2d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int row, int col) const;
- T& impl_op_readwrite(const point2d& p);
+ T& impl_read_write(const point2d& p);
+ T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- T* adr_at(int row, int col);
- const T* adr_at(int row, int col) const;
+ std::size_t impl_npoints() const;
- private:
+ box2d impl_bbox() const;
+ box2d impl_points() const;
- topo2d topo_;
- internal::tracked_ptr<array_t> data_;
+ unsigned border() const;
};
@@ -110,86 +155,108 @@
template <typename T>
image2d_b<T>::image2d_b()
- : topo_(),
- data_()
{
}
template <typename T>
+ image2d_b<T>::image2d_b(const box2d& b, unsigned border)
+ {
+ this->data_ = new data(b.pmin(), b.pmax(), border);
+ }
+
+ template <typename T>
image2d_b<T>::image2d_b(unsigned nrows, unsigned ncols, unsigned border)
- : topo_(bbox2d(point2d(0, 0 ),
- point2d(nrows - 1, ncols - 1)),
- border),
- data_(new array_t(0 - border, 0 - border,
- nrows - 1 + border, ncols - 1 + border))
{
+ precondition(nrows != 0 and ncols != 0);
+ this->data_ = new data(point2d(0, 0),
+ point2d(nrows - 1, ncols - 1),
+ border);
}
template <typename T>
- image2d_b<T>::image2d_b(const topo2d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().row(),
- topo.bbox().pmin().col(),
- topo.bbox().pmax().row(),
- topo.bbox().pmax().col()))
+ bool image2d_b<T>::impl_owns_(const point2d& p) const
{
+ assert(this->has_data());
+ return this->data_->array.has(p.row(), p.col());
}
+ template <typename T>
+ bool image2d_b<T>::impl_has(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->box.has(p);
+ }
template <typename T>
- const topo2d& image2d_b<T>::impl_topo() const
+ bool image2d_b<T>::impl_has_at(int row, int col) const
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->box.has(point2d(row, col));
}
+ template <typename T>
+ const T& image2d_b<T>::impl_read(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->array(p.row(), p.col());
+ }
template <typename T>
- T image2d_b<T>::impl_op_read(const point2d& p) const
+ const T& image2d_b<T>::impl_index_read(unsigned i) const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->array[i];
}
template <typename T>
- T image2d_b<T>::impl_at(int row, int col) const
+ const T& image2d_b<T>::impl_at(int row, int col) const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->array(row, col);
}
+ template <typename T>
+ T& image2d_b<T>::impl_read_write(const point2d& p)
+ {
+ assert(this->has_data());
+ return this->data_->array(p.row(), p.col());
+ }
template <typename T>
- T& image2d_b<T>::impl_op_readwrite(const point2d& p)
+ T& image2d_b<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->array[i];
}
template <typename T>
T& image2d_b<T>::impl_at(int row, int col)
{
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->array(row, col);
}
+ template <typename T>
+ box2d image2d_b<T>::impl_bbox() const
+ {
+ assert(this->has_data());
+ return this->data_->box;
+ }
template <typename T>
- T* image2d_b<T>::adr_at(int row, int col)
+ box2d image2d_b<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ return this->data_->box;
}
template <typename T>
- const T* image2d_b<T>::adr_at(int row, int col) const
+ unsigned image2d_b<T>::border() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ return this->data_->border;
}
# endif
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 863)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -32,6 +32,10 @@
# include <oln/core/concept/grid.hh>
+# define OLN_ENV_2D
+
+
+
namespace oln
{
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 863)
+++ oln/core/equipment.hh (working copy)
@@ -55,6 +55,8 @@
stc_decl_associated_type( coord );
stc_decl_associated_type( ch_value );
+# define oln_coord(T) oln_typename_shortcut__(T, coord)
+
// d
stc_decl_associated_type( data );
stc_decl_associated_type( dim );
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 863)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -80,6 +80,9 @@
{
public:
+ dpoints_piter_impl_(const dpoints_piter_impl_&);
+ void operator=(const dpoints_piter_impl_&);
+
void impl_invalidate();
bool impl_is_valid() const;
@@ -91,7 +94,7 @@
protected:
const P* p_ref_;
- const std::vector<typename P::dpoint>* dps_;
+ std::vector<typename P::dpoint> dps_;
unsigned n_, i_;
P p_;
@@ -168,7 +171,7 @@
const internal::dpoints_impl_<typename P::dpoint>& data)
{
p_ref_ = point_adr_(ref);
- dps_ = &(data.dpoints());
+ dps_ = data.dpoints();
n_ = data.size();
i_ = n_;
postcondition(n_ != 0);
@@ -206,7 +209,7 @@
void
dpoints_piter_impl_<P>::update_p_()
{
- p_ = *p_ref_+ (*dps_)[i_];
+ p_ = *p_ref_+ dps_[i_];
}
} // end of namespace oln::internal
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 863)
+++ oln/core/internal/image_base.hh (working copy)
@@ -208,6 +208,8 @@
template <typename Exact>
class primitive_image_ : public image_base_<Exact>
{
+ public:
+ std::size_t impl_npoints() const;
protected:
primitive_image_();
};
@@ -309,6 +311,13 @@
{
}
+ template <typename Exact>
+ std::size_t primitive_image_<Exact>::impl_npoints() const
+ {
+ precondition(this->has_data());
+ return this->pset().npoints();
+ }
+
/// plain_primitive_image_<Exact>
template <typename Exact>
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 863)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -153,7 +153,7 @@
const typename point_set_std_based_<Exact>::std_container&
point_set_std_based_<Exact>::con() const
{
- this->con_;
+ return this->con_;
}
# endif
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update tests.
* tests/core/image_entry.cc: Remove; obsolete.
* tests/core/window2d.cc,
* tests/core/point2d.cc,
* tests/core/dpoint2d.cc,
* tests/core/at.cc,
* tests/core/Makefile.am,
* tests/core/grid.cc,
* tests/core/image2d.cc,
* tests/core/npoints.cc,
* oln/debug/print_nbh.hh,
* oln/level/fill.hh: Update.
oln/core/concept/image.hh | 12 +--
oln/core/equipment.hh | 23 +++++-
oln/debug/print_nbh.hh | 6 +
oln/level/fill.hh | 164 ++++++++++++++++------------------------------
tests/core/Makefile.am | 9 --
tests/core/at.cc | 19 ++---
tests/core/dpoint2d.cc | 10 +-
tests/core/grid.cc | 18 ++---
tests/core/image2d.cc | 16 ++--
tests/core/npoints.cc | 8 +-
tests/core/point2d.cc | 9 --
tests/core/window2d.cc | 54 ++++-----------
12 files changed, 145 insertions(+), 203 deletions(-)
Index: tests/core/window2d.cc
--- tests/core/window2d.cc (revision 859)
+++ tests/core/window2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -27,40 +27,25 @@
/// Test oln::window2d.
-#include <oln/basics2d.hh>
-#include <oln/debug/print.hh>
-#include <oln/io/pnm.hh>
-#include <oln/morpher/add_neighborhood.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/window2d.hh>
-#include "data.hh"
namespace test
{
template <typename I, typename W>
- void run(const oln::abstract::image<I>& ima,
- const oln::abstract::window<W>& win)
+ unsigned run(const oln::Point_Wise_Accessible_Image<I>& input,
+ const oln::Window<W>& win)
{
- oln_piter(I) p(ima.topo());
- oln_qiter(I) q(p, win);
+ oln_piter(I) p(input.points());
+ oln_qiter(W) q(p, win);
+ unsigned count = 0;
for_all(p)
- {
-#if 0
- // Disable the display to speed up the test.
- std::cout << unsigned(ima(p)) << ": ";
-#endif
for_all(q)
- {
-#if 0
- // Likewise.
- std::cout << unsigned(ima(q)) << " ";
-#endif
- }
-#if 0
- // Likewise.
- std::cout << std::endl;
-#endif
- }
+ if (input.has(q))
+ ++count;
+ return count;
}
}
@@ -70,16 +55,9 @@
{
using namespace oln;
- image2d<unsigned char> ima = io::load_pgm(rdata("lena32.pgm"));
-#if 0
- // Disable the display to speed up the test.
- debug::println(ima);
-#endif
-
- window2d win;
- win
- .add(dpoint2d(-1, 0))
- .add(dpoint2d(-2, 0));
-
- test::run(ima, win);
+ image2d<bool> ima(3, 3);
+ // 4 + 6 + 4 +
+ // 6 + 9 + 6 +
+ // 4 + 6 + 4 = 49
+ assert(test::run(ima, win3x3) = 49);
}
Index: tests/core/point2d.cc
--- tests/core/point2d.cc (revision 859)
+++ tests/core/point2d.cc (working copy)
@@ -25,19 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#include <mlc/assert.hh>
-#include <mlc/is_a.hh>
-// FIXME: There is an inter-dependency between point2d and dpoint2d.
-// Maybe we'll solve this with the interface/implementation separation?
#include <oln/core/2d/point2d.hh>
-#include <oln/core/2d/dpoint2d.hh>
int
main()
{
- typedef oln::point2d_<int> point_t;
+ typedef oln::point2d point_t;
mlc::assert_<
- mlc_is_a_( point_t, oln::internal::point_nd )
+ mlc_is_a_( point_t, oln::Point )
>::check();
}
Index: tests/core/dpoint2d.cc
--- tests/core/dpoint2d.cc (revision 859)
+++ tests/core/dpoint2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,17 +29,17 @@
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
-#include <oln/basics2d.hh>
+#include <oln/core/2d/dpoint2d.hh>
int
main()
{
- typedef oln::dpoint2d_<int> dpoint_t;
+ typedef oln::dpoint2d dpoint_t;
mlc::assert_<
- mlc_is_a_( dpoint_t, oln::internal::dpoint_nd )
+ mlc_is_a_( dpoint_t, oln::Dpoint )
>::check();
- typedef oln_vtype_(dpoint_t, vec) vec_t;
+ typedef dpoint_t::vec_t vec_t;
mlc::assert_< mlc_is_a_( vec_t, mlc_comma_1(xtd::vec< 2u, int >) ) >::check();
}
Index: tests/core/at.cc
--- tests/core/at.cc (revision 859)
+++ tests/core/at.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,11 +26,9 @@
// Public License.
#include <cassert>
-// FIXME: Don't include oln/basics2d.hh, which is too big.
-// (Fix.)
-#include <oln/basics1d.hh>
-#include <oln/basics2d.hh>
-#include <oln/morpher/add_neighborhood.hh>
+// FIXME: Disabled #include <oln/basics1d.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/neighb2d.hh>
int
@@ -46,8 +44,9 @@
assert(ima(p) = 51);
- image1d<int> sig(1);
- point1d i(0);
- (sig + c2).at(0) = 51;
- assert(sig(i) = 51);
+ // FIXME: Disabled
+// image1d<int> sig(1);
+// point1d i(0);
+// (sig + c2).at(0) = 51;
+// assert(sig(i) = 51);
}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 859)
+++ tests/core/Makefile.am (working copy)
@@ -22,26 +22,17 @@
dpoint2d \
point2d \
grid \
- image_entry \
- image1d \
image2d \
- image3d \
npoints \
- pw_value \
window2d \
- \
at
# Images and auxiliary structures.
dpoint2d_SOURCES = dpoint2d.cc
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
-image_entry_SOURCES = image_entry.cc
-image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
-image3d_SOURCES = image3d.cc
npoints_SOURCES = npoints.cc
-pw_value_SOURCES = pw_value.cc
window2d_SOURCES = window2d.cc
# Methods.
Index: tests/core/grid.cc
--- tests/core/grid.cc (revision 859)
+++ tests/core/grid.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,11 @@
/// Test grids.
#include <cassert>
-#include <oln/core/1d/aliases.hh>
-#include <oln/core/2d/aliases.hh>
-#include <oln/core/3d/aliases.hh>
-#include <oln/core/gen/grid.hh>
+#include <oln/core/2d/grid2d.hh>
+// FIXME: Disabled.
+// #include <oln/core/1d/aliases.hh>
+// #include <oln/core/3d/aliases.hh>
+
int
main()
@@ -39,7 +40,8 @@
// The extra pairs of parenthesis around mlc_value are needed to
// prevent the assert macro from interpreting the arguments of
// mlc_value as its own.
- assert((mlc_value(oln_vtype_(oln::grid1d, dimvalue))) = 1);
- assert((mlc_value(oln_vtype_(oln::grid2d, dimvalue))) = 2);
- assert((mlc_value(oln_vtype_(oln::grid3d, dimvalue))) = 3);
+ assert((mlc_value(oln::grid2d::dim)) = 2);
+ // FIXME: Disabled.
+// assert((mlc_value(oln::grid1d::dim)) = 1);
+// assert((mlc_value(oln::grid3d::dim)) = 3);
}
Index: tests/core/image2d.cc
--- tests/core/image2d.cc (revision 859)
+++ tests/core/image2d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,7 +30,7 @@
#include <cassert>
// FIXME: We should not include oln/basics2d.hh, but
// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?).
-#include <oln/basics2d.hh>
+#include <oln/core/2d/image2d.hh>
#include <oln/level/fill.hh>
int
@@ -38,24 +38,24 @@
{
// Fill a 2D image using its iterator.
oln::image2d<char> ima1(3, 3);
- oln_vtype_(oln::image2d<char>, piter) p1(ima1.topo());
+ oln::image2d<char>::piter p1(ima1.points());
for_all(p1)
ima1(p1) = 1;
// Fill a 2D image using a classic loop.
- oln::image2d<int> ima2(ima1.topo());
+ oln::image2d<int> ima2(ima1.points());
for (unsigned i = 0; i < 3; ++i)
for (unsigned j = 0; j < 3; ++j)
- ima2(oln::point2d(i, j)) = 2;
+ ima2.at(i, j) = 2;
// Fill a 2D image using the routine oln::level::fill.
- oln::image2d<long> ima3(ima1.topo());
+ oln::image2d<long> ima3(ima1.points());
oln::level::fill(ima3, 3);
// Add the three images.
- oln::image2d<long> sum(ima1.topo());
- oln_vtype_(oln::image2d<long>, piter) p(sum.topo());
+ oln::image2d<long> sum(ima1.points());
+ oln::image2d<long>::piter p(sum.points());
for_all(p)
sum(p) = ima1(p) + ima2(p) + ima3(p);
// And check the sum.
Index: tests/core/npoints.cc
--- tests/core/npoints.cc (revision 859)
+++ tests/core/npoints.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,13 +28,13 @@
/// Test image2d.
#include <cassert>
-#include <oln/basics2d.hh>
+#include <oln/core/2d/image2d.hh>
template <typename I>
-unsigned npoints(const oln::abstract::image<I>& input)
+unsigned npoints(const oln::Image<I>& input)
{
- oln_vtype(I, piter) p(input.topo());
+ typename I::piter p(input.points());
unsigned count = 0;
for_all(p)
++count;
Index: oln/debug/print_nbh.hh
--- oln/debug/print_nbh.hh (revision 859)
+++ oln/debug/print_nbh.hh (working copy)
@@ -49,7 +49,8 @@
// Image
template <typename I>
- void print_nbh(const Image<I>&, const I& input, std::ostream& ostr)
+ void print_nbh(const Image<I>&,
+ const I& input, std::ostream& ostr)
{
typename I::fwd_piter p(input.points());
typename I::fwd_niter n(p, input.nbhood());
@@ -67,7 +68,8 @@
// Point_Wise_Accessible_Image
template <typename I>
- void print_nbh(const Point_Wise_Accessible_Image<I>&,const I& input, std::ostream& ostr)
+ void print_nbh(const Point_Wise_Accessible_Image<I>&,
+ const I& input, std::ostream& ostr)
{
typename I::fwd_piter p(input.points());
typename I::fwd_niter n(p, input.nbhood());
Index: oln/level/fill.hh
--- oln/level/fill.hh (revision 859)
+++ oln/level/fill.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,12 +29,8 @@
#ifndef OLN_LEVEL_FILL_HH
# define OLN_LEVEL_FILL_HH
-# include <iostream>
-
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/value_wise_accessibility/hierarchy.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/functions.hh>
+# include <oln/core/concept/image.hh>
+// # include <oln/core/concept/function.hh>
namespace oln
@@ -46,159 +42,119 @@
}
- /// Fwd decl.
- template <typename I, typename V>
- I& operator<<(abstract::mutable_image<I>& input, const V values[]);
-
- /// Fwd decl.
- template <typename I>
- I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value);
-
-
namespace level
{
- /// Fwd decl.
+ /// Fwd decls.
+
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value);
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value);
- /// Fwd decl.
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[]);
+ void fill(Mutable_Image<I>& input, const V values[]);
- /// Fwd decl.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&));
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&));
- /// Fwd decl.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun);
- /// Fwd decl.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value);
+
+ // FIXME: Inactivated.
+
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun);
+
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value);
# ifndef OLN_INCLUDE_ONLY
+
namespace impl
{
- /// Generic version.
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value)
{
- oln_piter(I) p(input.topo());
+ oln_piter(I) p(input.points());
for_all(p)
input(p) = value;
}
- /// Generic version.
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input,
+// const oln_value(I)& value)
+// {
+// oln_viter(I) v(input);
+// for_all(v)
+// input.value_(v) = value;
+// }
+
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[])
+ void fill(Mutable_Image<I>& input, const V values[])
{
- oln_piter(I) p(input.topo());
+ oln_piter(I) p(input.points());
unsigned i = 0;
for_all(p)
input(p) = values[i++];
}
- /// Generic version.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&))
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&))
{
- oln_piter(I) p(input.topo());
- unsigned i = 0;
+ oln_piter(I) p(input.points());
for_all(p)
input(p) = fun(p);
}
- /// Generic version.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun)
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun.exact()(p);
- }
-
- /// Version specialized for mutable images being value-wise
- /// random accessible.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value)
- {
- // FIXME: We should not need to call exact() here.
- oln_viter(I) v(input.exact());
- for_all(v)
- input.value(v) = value;
- }
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun)
+// {
+// oln_piter(I) p(input.points());
+// for_all(p)
+// input(p) = fun.exact()(p);
+// }
} // end of namespace oln::level::impl
- /// Facade.
+
+ /// Facades.
+
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
+ void fill(Mutable_Image<I>& input, const oln_value(I)& value)
{
- impl::fill(input.exact(), value);
+ impl::fill(exact(input), value);
}
- /// Facade.
template <typename I, typename V>
- void fill(abstract::mutable_image<I>& input, const V values[])
+ void fill(Mutable_Image<I>& input, const V values[])
{
- return impl::fill(input.exact(), values);
+ impl::fill(exact(input), values);
}
- /// Facade.
template <typename I, typename V, typename P>
- void fill(abstract::mutable_image<I>& input, V (*fun)(const P&))
+ void fill(Mutable_Image<I>& input, V (*fun)(const P&))
{
- return impl::fill(input.exact(), fun);
+ impl::fill(exact(input), fun);
}
- /// Facade.
- template <typename I, typename F>
- void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun)
- {
- return impl::fill(input.exact(), fun);
- }
-
- /// Facade.
- template <typename I>
- void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input,
- const oln_value(I)& value)
- {
- return impl::fill(input.exact(), value);
- }
+// template <typename I, typename F>
+// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun)
+// {
+// impl::fill(exact(input), fun);
+// }
+
+// template <typename I>
+// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value)
+// {
+// impl::fill(exact(input), value);
+// }
# endif
} // end of namespace oln::level
-
-# ifndef OLN_INCLUDE_ONLY
-
- /// Fwd decl.
- template <typename I, typename V>
- I& operator<<(abstract::mutable_image<I>& input, const V values[])
- {
- level::fill(input, values);
- return input.exact();
- }
-
- /// Fwd decl.
- template <typename I>
- I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value)
- {
- level::fill(input, value);
- return input.exact();
- }
-
-# endif
-
} // end of namespace oln
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 859)
+++ oln/core/concept/image.hh (working copy)
@@ -215,7 +215,7 @@
{
stc_typename(vsite);
stc_typename(rvaluep);
- rvaluep value(const vsite& v) const;
+ rvaluep value_(const vsite& v) const;
protected:
Value_Wise_Accessible_Image();
@@ -232,7 +232,7 @@
using Value_Wise_Accessible_Image<Exact>::value;
stc_typename(lvaluep);
- lvaluep value(const vsite& v);
+ lvaluep value_(const vsite& v);
protected:
Value_Wise_Mutable_Image();
@@ -440,7 +440,7 @@
template <typename Exact>
typename Value_Wise_Accessible_Image<Exact>::rvaluep
- Value_Wise_Accessible_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
+ Value_Wise_Accessible_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
{
return exact(this)->impl_value_read(v);
}
@@ -454,7 +454,7 @@
template <typename Exact>
typename Value_Wise_Mutable_Image<Exact>::lvaluep
- Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
+ Value_Wise_Mutable_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
return exact(this)->impl_value_read_write(v);
}
@@ -514,7 +514,7 @@
Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
{
typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
- return this->at(p);
+ return this->operator()(p);
}
template <typename Exact>
@@ -536,7 +536,7 @@
Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
typename Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
- return this->at(p);
+ return this->operator()(p);
}
template <typename Exact>
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 859)
+++ oln/core/equipment.hh (working copy)
@@ -28,12 +28,14 @@
#ifndef OLN_CORE_EQUIPMENT_HH
# define OLN_CORE_EQUIPMENT_HH
-# include <cassert>
-# include <mlc/value.hh>
# include <mlc/contract.hh>
# include <oln/stc/scoop.hh> // FIXME: Remove "oln/" later.
+# define oln_typename_shortcut__(Type, Alias) typename Type::Alias
+
+
+
namespace oln
{
@@ -45,6 +47,10 @@
stc_decl_associated_type( bkd_qiter );
stc_decl_associated_type( box );
+# define oln_bkd_niter(T) oln_typename_shortcut__(T, bkd_niter)
+# define oln_bkd_piter(T) oln_typename_shortcut__(T, bkd_piter)
+# define oln_bkd_qiter(T) oln_typename_shortcut__(T, bkd_qiter)
+
// c
stc_decl_associated_type( coord );
stc_decl_associated_type( ch_value );
@@ -59,6 +65,10 @@
stc_decl_associated_type( fwd_piter );
stc_decl_associated_type( fwd_qiter );
+# define oln_fwd_niter(T) oln_typename_shortcut__(T, fwd_niter)
+# define oln_fwd_piter(T) oln_typename_shortcut__(T, fwd_piter)
+# define oln_fwd_qiter(T) oln_typename_shortcut__(T, fwd_qiter)
+
// g
stc_decl_associated_type( grid );
@@ -75,6 +85,8 @@
stc_decl_associated_type( nbh );
stc_decl_associated_type( niter );
+# define oln_niter(T) oln_typename_shortcut__(T, niter)
+
// o
stc_decl_associated_type( oper );
stc_decl_associated_type( output );
@@ -85,9 +97,14 @@
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
+# define oln_piter(T) oln_typename_shortcut__(T, piter)
+# define oln_point(T) oln_typename_shortcut__(T, point)
+
// q
stc_decl_associated_type( qiter );
+# define oln_qiter(T) oln_typename_shortcut__(T, qiter)
+
// r
stc_decl_associated_type( right );
stc_decl_associated_type( rvalue );
@@ -103,6 +120,8 @@
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
+# define oln_value(T) oln_typename_shortcut__(T, value)
+
} // end of namespace oln
1
0
859: Add the notion of image plus neighborhood and the underlying mechanism.
by Thierry Geraud 08 Mar '07
by Thierry Geraud 08 Mar '07
08 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the notion of image plus neighborhood and the underlying
mechanism.
* oln/debug/print_nbh.hh,
* oln/debug/iota.hh,
* oln/core/concept/image_identity.hh,
* oln/core/gen/op.hh,
* oln/core/internal/op_image_plus_nbh.hh,
* oln/core/internal/special_op.hh: New.
* oln/core/concept/image.hh (fwd_niter, bkd_niter, niter): New.
* oln/core/concept/neighborhood.hh (category): New.
(include): Add op_image_plus_nbh.hh.
(oln_decl_op_plus): New. Handle "Image + Neighborhood".
* oln/core/equipment.hh (left, right, oper, tag): New.
* oln/core/gen/single_value_image.hh: Fix.
* oln/core/internal/neighborhood_base.hh (category): New.
(neighborhood_base_): Fix inheritance.
* oln/core/internal/image_base.hh (image_extension_): New.
(image_base_): Add dpoint.
* oln/stc/scoop.hxx (vtypes, super_trait_): Add specialization
for const types.
(super_trait_): Handle error when not user-defined.
core/concept/image.hh | 5
core/concept/image_identity.hh | 292 +++++++++++++++++++++++++++++++++++++
core/concept/neighborhood.hh | 6
core/equipment.hh | 6
core/gen/op.hh | 162 ++++++++++++++++++++
core/gen/single_value_image.hh | 5
core/internal/image_base.hh | 35 ++++
core/internal/neighborhood_base.hh | 3
core/internal/op_image_plus_nbh.hh | 102 ++++++++++++
core/internal/special_op.hh | 76 +++++++++
debug/iota.hh | 56 +++++++
debug/print_nbh.hh | 101 ++++++++++++
stc/scoop.hxx | 21 ++
13 files changed, 863 insertions(+), 7 deletions(-)
Index: oln/debug/print_nbh.hh
--- oln/debug/print_nbh.hh (revision 0)
+++ oln/debug/print_nbh.hh (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_DEBUG_PRINT_NBH_HH
+# define OLN_DEBUG_PRINT_NBH_HH
+
+# include <iostream>
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+ // fwd decl
+ template <typename I>
+ void print_nbh(const Image_with_Nbh<I>& input, std::ostream& ostr = std::cout);
+
+
+ namespace impl
+ {
+
+ // Image
+
+ template <typename I>
+ void print_nbh(const Image<I>&, const I& input, std::ostream& ostr)
+ {
+ typename I::fwd_piter p(input.points());
+ typename I::fwd_niter n(p, input.nbhood());
+ for_all(p)
+ {
+ ostr << input(p) << ": ";
+ for_all(n)
+ if (input.owns_(n))
+ ostr << input(n) << " ";
+ ostr << std::endl;
+ }
+ }
+
+
+ // Point_Wise_Accessible_Image
+
+ template <typename I>
+ void print_nbh(const Point_Wise_Accessible_Image<I>&,const I& input, std::ostream& ostr)
+ {
+ typename I::fwd_piter p(input.points());
+ typename I::fwd_niter n(p, input.nbhood());
+ for_all(p)
+ {
+ ostr << input(p) << ": ";
+ for_all(n)
+ if (input.has(n))
+ ostr << input(n) << " ";
+ ostr << std::endl;
+ }
+ }
+
+ } // end of namespace oln::debug::impl
+
+
+ // facade
+ template <typename I>
+ void print_nbh(const Image_with_Nbh<I>& input, std::ostream& ostr)
+ {
+ impl::print_nbh(exact(input), exact(input), ostr);
+ }
+
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_PRINT_NBH_HH
Index: oln/debug/iota.hh
--- oln/debug/iota.hh (revision 0)
+++ oln/debug/iota.hh (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_DEBUG_IOTA_HH
+# define OLN_DEBUG_IOTA_HH
+
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+
+ template <typename I>
+ void iota(Mutable_Image<I>& in_out)
+ {
+ typename I::value v = 0;
+ typename I::fwd_piter p(in_out.points());
+ for_all(p)
+ in_out(p) = v++;
+ }
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_IOTA_HH
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 858)
+++ oln/core/concept/image.hh (working copy)
@@ -142,6 +142,11 @@
public automatic::get_impl<Image_with_Nbh, Exact>
{
stc_typename(nbh);
+
+ stc_typename(fwd_niter);
+ stc_typename(bkd_niter);
+ typedef fwd_niter niter;
+
nbh nbhood() const;
protected:
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 858)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -29,6 +29,9 @@
# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# include <oln/core/equipment.hh>
+# include <oln/core/internal/op_image_plus_nbh.hh>
+
+
namespace oln
@@ -41,6 +44,7 @@
{
stc_typename(grid);
stc_typename(point);
+ stc_typename(category);
protected:
Neighborhood();
@@ -48,6 +52,8 @@
}; // end of oln::Neighborhood<Exact>
+ oln_decl_op_plus(Image, Neighborhood);
+
# ifndef OLN_INCLUDE_ONLY
Index: oln/core/concept/image_identity.hh
--- oln/core/concept/image_identity.hh (revision 0)
+++ oln/core/concept/image_identity.hh (revision 0)
@@ -0,0 +1,292 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
+# define OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
+
+# include <oln/core/concept/image.hh>
+
+
+
+namespace oln
+{
+
+ namespace behavior { struct identity; }
+
+
+ namespace automatic
+ {
+
+
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ struct set_impl< Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(psite);
+ stc_typename(rvalue);
+ stc_typename(box);
+ stc_typename(pset);
+
+ bool impl_owns_(const psite& p) const;
+ rvalue impl_read(const psite& p) const;
+ box impl_bbox() const;
+ pset impl_points() const;
+ };
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ struct set_impl< Image_with_Nbh, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(nbh);
+ nbh impl_nbhood() const;
+ };
+
+
+ /// Concept-class "Mutable_Image".
+
+ template <typename Exact>
+ struct set_impl< Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(psite);
+ stc_typename(lvalue);
+ lvalue impl_read_write(const psite& p);
+ };
+
+
+ /// Concept-class "Fast_Image".
+
+ template <typename Exact>
+ struct set_impl< Fast_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(rvalue);
+ stc_typename(lvalue);
+ stc_typename(index);
+
+ rvalue impl_index_read(index i) const;
+ lvalue impl_index_read_write(index i);
+ std::size_t impl_npoints() const;
+ };
+
+
+ /// Concept-class "Point_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(point);
+ bool impl_has(const point& p) const;
+ };
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(rvaluep);
+ rvaluep impl_value_read(const vsite& v) const;
+ };
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ struct set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(lvaluep);
+ lvaluep impl_value_read_write(const vsite& v);
+ };
+
+
+ /// Concept-class "Image_1D".
+
+ template <typename Exact>
+ struct set_impl< Image_1D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Image_3D".
+
+ template <typename Exact>
+ struct set_impl< Image_3D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ };
+
+
+ /// Concept-class "Point_Wise_Accessible_Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Accessible_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ // default code is provided in Point_Wise_Accessible_Image_2D<Exact>
+ };
+
+
+ /// Concept-class "Point_Wise_Mutable_Image_2D".
+
+ template <typename Exact>
+ struct set_impl< Point_Wise_Mutable_Image_2D, behavior::identity, Exact > : public virtual Any<Exact>
+ {
+ // default code is provided in Point_Wise_Mutable_Image_2D<Exact>
+ };
+
+
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ bool
+ set_impl< Image, behavior::identity, Exact >::impl_owns_(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
+ {
+ return exact(this)->image().owns_(p);
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::rvalue
+ set_impl< Image, behavior::identity, Exact >::impl_read(const typename set_impl< Image, behavior::identity, Exact >::psite& p) const
+ {
+ return exact(this)->image()(p);
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::box
+ set_impl< Image, behavior::identity, Exact >::impl_bbox() const
+ {
+ return exact(this)->image().bbox();
+ }
+
+ template <typename Exact>
+ typename set_impl< Image, behavior::identity, Exact >::pset
+ set_impl< Image, behavior::identity, Exact >::impl_points() const
+ {
+ return exact(this)->image().points();
+ }
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ typename set_impl< Image_with_Nbh, behavior::identity, Exact >::nbh
+ set_impl< Image_with_Nbh, behavior::identity, Exact >::impl_nbhood() const
+ {
+ return exact(this)->image().nbhood();
+ }
+
+
+ /// Concept-class "Mutable_Image".
+
+ template <typename Exact>
+ typename set_impl< Mutable_Image, behavior::identity, Exact >::lvalue
+ set_impl< Mutable_Image, behavior::identity, Exact >::impl_read_write(const typename set_impl< Mutable_Image, behavior::identity, Exact >::psite& p)
+ {
+ return exact(this)->image().operator()(p);
+ }
+
+
+ /// Concept-class "Fast_Image".
+
+ template <typename Exact>
+ typename set_impl< Fast_Image, behavior::identity, Exact >::rvalue
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read(typename set_impl< Fast_Image, behavior::identity, Exact >::index i) const
+ {
+ return exact(this)->image()[i];
+ }
+
+ template <typename Exact>
+ typename set_impl< Fast_Image, behavior::identity, Exact >::lvalue
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_index_read_write(typename set_impl< Fast_Image, behavior::identity, Exact >::index i)
+ {
+ return exact(this)->image()[i];
+ }
+
+ template <typename Exact>
+ std::size_t
+ set_impl< Fast_Image, behavior::identity, Exact >::impl_npoints() const
+ {
+ return exact(this)->image().npoints();
+ }
+
+
+ /// Concept-class "Point_Wise_Accessible_Image".
+
+ template <typename Exact>
+ bool
+ set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::impl_has(const typename set_impl< Point_Wise_Accessible_Image, behavior::identity, Exact >::point& p) const
+ {
+ return exact(this)->image().has(p);
+ }
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::rvaluep
+ set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::impl_value_read(const typename set_impl< Value_Wise_Accessible_Image, behavior::identity, Exact >::vsite& v) const
+ {
+ return exact(this)->image().value(v);
+ }
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::lvaluep
+ set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::impl_value_read_write(const typename set_impl< Value_Wise_Mutable_Image, behavior::identity, Exact >::vsite& v)
+ {
+ return exact(this)->image().value(v);
+ }
+
+
+# endif
+
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_CONCEPT_IMAGE_IDENTITY_HH
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 858)
+++ oln/core/equipment.hh (working copy)
@@ -66,6 +66,7 @@
stc_decl_associated_type( index );
// l
+ stc_decl_associated_type( left );
stc_decl_associated_type( lvalue );
stc_decl_associated_type( lvaluep );
@@ -75,6 +76,7 @@
stc_decl_associated_type( niter );
// o
+ stc_decl_associated_type( oper );
stc_decl_associated_type( output );
// p
@@ -87,12 +89,16 @@
stc_decl_associated_type( qiter );
// r
+ stc_decl_associated_type( right );
stc_decl_associated_type( rvalue );
stc_decl_associated_type( rvaluep );
// s
stc_decl_associated_type( std_container );
+ // t
+ stc_decl_associated_type( tag );
+
// v
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 0)
+++ oln/core/gen/op.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_OP_HH
+# define OLN_CORE_GEN_OP_HH
+
+# include <oln/core/internal/special_op.hh>
+
+
+
+// Macro.
+
+# define oln_decl_op_(OpName, Lconcept, OpSym, Rconcept) \
+ \
+ template <typename L, typename R> \
+ op_<L, OpName, R> \
+ operator OpSym (Lconcept<L>& lhs, Rconcept<R>& rhs) \
+ { \
+ op_<L, OpName, R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<L, OpName, const R> \
+ operator OpSym (Lconcept<L>& lhs, const Rconcept<R>& rhs) \
+ { \
+ op_<L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<const L, OpName, R> \
+ operator OpSym (const Lconcept<L>& lhs, Rconcept<R>& rhs) \
+ { \
+ op_<const L, OpName, R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ template <typename L, typename R> \
+ op_<const L, OpName, const R> \
+ operator OpSym (const Lconcept<L>& lhs, const Rconcept<R>& rhs) \
+ { \
+ op_<const L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d___w_i_t_h___a___s_e_m_i___c_o_l_u_m_n
+
+
+# define oln_decl_op_plus(Lconcept, Rconcept) oln_decl_op_(plus, Lconcept, +, Rconcept)
+# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_(such_as, Lconcept, |, Rconcept)
+// ...
+
+
+
+
+# define oln_category_of_(Type) typename oln::internal::category_of_<Type>::ret
+
+
+namespace oln
+{
+
+
+ namespace internal
+ {
+ template <typename T>
+ struct category_of_
+ {
+ typedef stc_type(T, category) ret;
+ };
+
+ // ...
+
+ } // end of namespace oln::internal
+
+
+
+ /// \{
+ /// Operator Names.
+
+ struct plus;
+ struct such_as;
+
+ /// \}
+
+
+
+ // Fwd decl.
+ template <typename L, typename OpName, typename R> class op_;
+
+
+ /// Virtual types.
+ template <typename L, typename OpName, typename R>
+ struct vtypes< op_<L, OpName, R> >
+ {
+ };
+
+
+ /// Super type.
+
+# define super \
+ internal::special_op_< oln_category_of_(L), L, OpName, oln_category_of_(R), R >
+
+ template <typename L, typename OpName, typename R>
+ struct super_trait_< op_<L, OpName, R> >
+ {
+ typedef super ret;
+ };
+
+
+ /// Class for result of "L op R".
+
+ template <typename L, typename OpName, typename R>
+ class op_ : public super
+ {
+ public:
+ op_(L& l, R& r);
+
+ }; // end of op_<L, OpName, R>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename L, typename OpName, typename R>
+ op_<L, OpName, R>::op_(L& l, R& r)
+ : super (l, r)
+ {
+ }
+
+# endif
+
+# undef super
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_OP_HH
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 858)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -54,11 +54,6 @@
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
-
- // FIXME: To be defined...
- typedef mlc::none qiter;
- typedef mlc::none fwd_qiter;
- typedef mlc::none bkd_qiter;
};
Index: oln/core/internal/neighborhood_base.hh
--- oln/core/internal/neighborhood_base.hh (revision 858)
+++ oln/core/internal/neighborhood_base.hh (working copy)
@@ -56,6 +56,7 @@
typedef stc_deferred(point) point__;
typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< stc::is<Neighborhood> > category;
};
@@ -65,7 +66,7 @@
/// Base class for implementation of neighborhoods class.
template <typename Exact>
- class neighborhood_base_ : public Neighborhood< neighb_<Exact> >
+ class neighborhood_base_ : public Neighborhood<Exact>
{
protected:
neighborhood_base_();
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 0)
+++ oln/core/internal/op_image_plus_nbh.hh (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
+# define OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
+
+# include <oln/core/gen/op.hh>
+# include <oln/core/gen/dpoints_piter.hh>
+# include <oln/core/internal/image_base.hh>
+
+
+namespace oln
+{
+
+ /// Fwd decls.
+ template <typename Exact> struct Image;
+ template <typename Exact> struct Neighborhood;
+
+
+ /// Super type.
+ template <typename I, typename N>
+ struct super_trait_< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ {
+ typedef internal::image_extension_< op_<I, plus, N> > ret;
+ };
+
+
+ /// Virtual types.
+ template <typename I, typename N>
+ struct vtypes< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ {
+ typedef op_<I, plus, N> Exact;
+ typedef stc_type(I, point) point__;
+
+ typedef I delegatee;
+ typedef internal::pair<I,N> data;
+
+ typedef N nbh;
+ typedef dpoints_fwd_piter_<point__> fwd_niter;
+ typedef dpoints_bkd_piter_<point__> bkd_niter;
+ };
+
+
+ namespace internal
+ {
+
+ /// Implementation class the result of "Image I + Neighborhood N".
+
+ template <typename I, typename N>
+ class special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+ :
+ public internal::image_extension_< op_<I, plus, N> >
+ {
+ typedef internal::image_extension_< op_<I, plus, N> > super;
+ public:
+ stc_using(nbh);
+ stc_using(data);
+ stc_using(delegatee);
+
+ delegatee& impl_image() { assert(this->has_data()); return this->data_->value1; }
+ const delegatee& impl_image() const { assert(this->has_data()); return this->data_->value1; }
+
+ nbh impl_nbhood() const { assert(this->has_data()); return this->data_->value2; }
+
+ protected:
+ special_op_(I& ima, N& n)
+ {
+ this->data_ = new data(ima, n);
+ }
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 858)
+++ oln/core/internal/image_base.hh (working copy)
@@ -29,10 +29,11 @@
# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
# include <oln/core/internal/image_selectors.hh>
+# include <oln/core/concept/image_identity.hh>
+
# include <oln/core/internal/tracked_ptr.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
-# include <oln/core/gen/image_pset_piter.hh>
@@ -50,6 +51,7 @@
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
+ template <typename Exact> struct image_extension_;
template <typename Exact> struct multiple_image_morpher_;
}
@@ -87,6 +89,12 @@
};
template <typename Exact>
+ struct super_trait_< internal::image_extension_<Exact> >
+ {
+ typedef internal::single_image_morpher_<Exact> ret;
+ };
+
+ template <typename Exact>
struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
typedef internal::image_morpher_<Exact> ret;
@@ -122,6 +130,7 @@
typedef stc::final< stc::is<Image> > category;
typedef stc::final< box_<point__> > box;
typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< stc_type(point__, dpoint) > dpoint;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
typedef fwd_piter piter;
@@ -145,6 +154,7 @@
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
+ typedef stc::abstract behavior;
typedef stc::not_delegated data;
};
@@ -154,6 +164,12 @@
};
template <typename Exact>
+ struct vtypes< internal::image_extension_<Exact> >
+ {
+ typedef stc::final< behavior::identity > behavior;
+ };
+
+ template <typename Exact>
struct vtypes< internal::multiple_image_morpher_<Exact> >
{
typedef stc::abstract n;
@@ -239,6 +255,16 @@
};
+ /// image_extension_<Exact>
+
+ template <typename Exact>
+ class image_extension_ : public single_image_morpher_<Exact>
+ {
+ protected:
+ image_extension_();
+ };
+
+
/// multiple_image_morpher_<Exact>
template <typename Exact>
@@ -320,6 +346,13 @@
{
}
+ // image_extension_<Exact>
+
+ template <typename Exact>
+ image_extension_<Exact>::image_extension_()
+ {
+ }
+
// multiple_image_morpher_<Exact>
template <typename Exact>
Index: oln/core/internal/special_op.hh
--- oln/core/internal/special_op.hh (revision 0)
+++ oln/core/internal/special_op.hh (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_SPECIAL_OP_HH
+# define OLN_CORE_INTERNAL_SPECIAL_OP_HH
+
+# include <oln/core/internal/image_base.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decls.
+ namespace internal {
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ class special_op_;
+ }
+ template <typename L, typename OpName, typename R> class op_;
+
+
+ /// Virtual types.
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ struct vtypes< internal::special_op_<Lcat, L, OpName, Rcat, R> >
+ /* undefined; to be specialized... */
+ ;
+
+
+ /// Super type.
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ struct super_trait_< internal::special_op_<Lcat, L, OpName, Rcat, R> >
+ /* undefined; to be specialized... */
+ ;
+
+
+ namespace internal
+ {
+
+ /// Class for result of "L op R".
+
+ template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
+ class special_op_;
+ /* undefined; to be specialized... */
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_SPECIAL_OP_HH
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 858)
+++ oln/stc/scoop.hxx (working copy)
@@ -56,6 +56,9 @@
struct no_delegatee_declared_;
+ template <typename T>
+ struct super_trait_not_defined_for_;
+
} /* end of namespace ERROR */
@@ -69,6 +72,11 @@
{
};
+template <typename from_type>
+struct vtypes <const from_type> : public vtypes <from_type>
+{
+};
+
template <typename from_type, typename type>
struct single_vtype
{
@@ -77,17 +85,30 @@
+/* super_trait_ */
template <typename from_type>
struct super_trait_;
+template <typename from_type>
+struct super_trait_ <const from_type> : super_trait_<from_type>
+{
+};
+
template <template <class> class abstraction, typename Exact>
struct super_trait_< abstraction<Exact> >
{
typedef mlc::none ret;
};
+template <typename from_type>
+struct super_trait_ :
+ mlc::abort_< ERROR::super_trait_not_defined_for_<from_type> >
+{
+ typedef mlc::none ret;
+};
+
1
0