Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* oln/core/abstract/struct_elt.hh: Add delta to stucturing element..
* oln/core/2d/window2d.hh: Likewise.
* oln/core/abstract/neighborhood.hh: Add delta to neighborhood.
* oln/core/2d/neighborhood2d.hh: Likewise.
* oln/core/accum.hh: New. Accumulator needed for delta computation.
* oln/makefile.src: Add missing files.
core/2d/neighborhood2d.hh | 25 ++++++++++------
core/2d/window2d.hh | 10 +++++-
core/abstract/neighborhood.hh | 27 +++++++++++++++--
core/abstract/struct_elt.hh | 25 ++++++++++++++--
core/accum.hh | 65 ++++++++++++++++++++++++++++++++++++++++++
makefile.src | 4 ++
6 files changed, 140 insertions(+), 16 deletions(-)
Index: oln/core/abstract/struct_elt.hh
--- oln/core/abstract/struct_elt.hh (revision 88)
+++ oln/core/abstract/struct_elt.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/properties.hh>
# include <oln/core/coord.hh>
# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/accum.hh>
# include <vector>
# include <utility>
# include <iostream>
@@ -132,6 +133,18 @@
return this->exact().impl_at(i);
}
+ coord_t
+ get_delta() const
+ {
+ return this->exact().impl_get_delta();
+ }
+
+ coord_t
+ delta_update(const dpoint_type& dp)
+ {
+ return this->exact().impl_delta_update(dp);
+ }
+
protected:
bool
@@ -145,9 +158,16 @@
{
if (!(impl_has(dp)))
this->dp_.push_back(dp);
+ this->delta_update(dp);
return this->exact();
}
+ coord_t
+ impl_get_delta() const
+ {
+ return delta_;
+ }
+
unsigned
impl_card() const
{
@@ -161,15 +181,16 @@
return dp_[i];
}
- struct_elt() : dp_()
+ struct_elt() : dp_(), delta_(0)
{};
- struct_elt(unsigned size) : dp_()
+ struct_elt(unsigned size) : dp_(), delta_(0)
{
dp_.reserve(size);
};
std::vector<dpoint_type> dp_;
+ max_accumulator<coord_t> delta_;
};
} // end of abstract
Index: oln/core/abstract/neighborhood.hh
--- oln/core/abstract/neighborhood.hh (revision 88)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/properties.hh>
# include <oln/core/coord.hh>
# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/accum.hh>
# include <vector>
# include <utility>
# include <iostream>
@@ -129,6 +130,18 @@
return this->exact().impl_at(i);
}
+ coord_t
+ get_delta() const
+ {
+ return this->exact().impl_get_delta();
+ }
+
+ coord_t
+ delta_update(const dpoint_type& dp)
+ {
+ return this->exact().impl_delta_update(dp);
+ }
+
protected:
bool
@@ -145,9 +158,16 @@
this->dp_.push_back(dp);
this->dp_.push_back(-dp);
}
+ this->delta_update(dp);
return this->exact();
}
-
+
+ coord_t
+ impl_get_delta() const
+ {
+ return delta_;
+ }
+
unsigned
impl_card() const
{
@@ -161,15 +181,16 @@
return dp_[i];
}
- neighborhood() : dp_()
+ neighborhood() : dp_(), delta_(0)
{};
- neighborhood(unsigned size) : dp_()
+ neighborhood(unsigned size) : dp_(), delta_(0)
{
dp_.reserve(size);
};
std::vector<dpoint_type> dp_;
+ max_accumulator<coord_t> delta_;
};
} // end of abstract
Index: oln/core/2d/neighborhood2d.hh
--- oln/core/2d/neighborhood2d.hh (revision 88)
+++ oln/core/2d/neighborhood2d.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/core/2d/dpoint2d.hh>
# include <oln/core/2d/size2d.hh>
# include <oln/core/coord.hh>
-# include <oln/core/abstract/struct_elt.hh>
+# include <oln/core/abstract/neighborhood.hh>
namespace oln {
@@ -39,29 +39,30 @@
// category
template <>
- struct set_category< neighborhood2d > { typedef category::struct_elt ret; };
+ struct set_category< neighborhood2d >
+ { typedef category::neighborhood ret; };
// super_type
template <>
struct set_super_type< neighborhood2d >
{
- typedef abstract::struct_elt< neighborhood2d > ret;
+ typedef abstract::neighborhood< neighborhood2d > ret;
};
template <>
- struct set_props< category::struct_elt, neighborhood2d >
- : public props_of<category::struct_elt>
+ struct set_props< category::neighborhood, neighborhood2d >
+ : public props_of<category::neighborhood>
{
typedef dpoint2d dpoint_type;
typedef size2d size_type;
};
- class neighborhood2d : public abstract::struct_elt<neighborhood2d>
+ class neighborhood2d : public abstract::neighborhood<neighborhood2d>
{
public:
- typedef abstract::struct_elt<neighborhood2d> super_type;
+ typedef abstract::neighborhood<neighborhood2d> super_type;
/*!
** \brief Construct a neighborhood of 2 dimensions.
@@ -108,8 +109,14 @@
return std::string("neighborhood2d");
}
- protected:
-
+ coord_t
+ impl_delta_update(const dpoint_type& dp)
+ {
+ delta_(abs(dp.row()));
+ delta_(abs(dp.col()));
+ return delta_;
+ }
+
};
inline const neighborhood2d&
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 88)
+++ oln/core/2d/window2d.hh (working copy)
@@ -110,8 +110,14 @@
return std::string("window2d");
}
- protected:
-
+ coord_t
+ impl_delta_update(const dpoint_type& dp)
+ {
+ delta_(abs(dp.row()));
+ delta_(abs(dp.col()));
+ return delta_;
+ }
+
};
Index: oln/core/accum.hh
--- oln/core/accum.hh (revision 0)
+++ oln/core/accum.hh (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (C) 2001, 2004, 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ACCUM_HH
+# define OLENA_CORE_ACCUM_HH
+
+
+/*! \class max_accumulator
+**
+** This is a \a functor. It saves the maximum T value
+** that has been passed as an argument of its operator()
+** method. To retrieve the value saved, just use the
+** max_accumulator as a T instance.
+*/
+
+template <class T>
+struct max_accumulator
+{
+
+ max_accumulator (T t) : acc_(t)
+ {}
+
+ void
+ operator()(T t)
+ {
+ if (t > acc_)
+ acc_ = t;
+ }
+
+ operator T() const
+ {
+ return acc_;
+ }
+
+private:
+
+ T acc_;
+
+};
+
+#endif // OLENA_CORE_ACCUM_HH
Index: oln/makefile.src
--- oln/makefile.src (revision 88)
+++ oln/makefile.src (working copy)
@@ -11,6 +11,9 @@
basics3d.hh \
config/pconf.hh \
config/system.hh \
+ convert/value_to_point.hh \
+ morpho/stat.hh \
+ morpho/erosion.hh \
core/1d/array1d.hh \
core/1d/dpoint1d.hh \
core/1d/fwd_piter1d.hh \
@@ -50,6 +53,7 @@
core/abstract/size.hh \
core/abstract/neighborhood.hh \
core/abstract/struct_elt.hh \
+ core/accum.hh \
core/coord.hh \
core/compose.hh \
core/properties.hh \