Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* oln/level/cc.hh (frontp_connected_component): Be more precise
in the description of the `nb_label' argument.
Index: olena/oln/level/cc.hh
--- olena/oln/level/cc.hh Tue, 27 Jul 2004 17:22:49 +0200 levill_r (oln/e/20_cc.hh 1.11.1.17 600)
+++ olena/oln/level/cc.hh Fri, 29 Oct 2004 15:16:16 +0200 levill_r (oln/e/20_cc.hh 1.11.1.17 600)
@@ -59,7 +59,9 @@
**
** \arg input Image of markers.
** \arg se Neighborhood.
- ** \arg nb_label Returns the number of labels (optional).
+ ** \arg nb_label Optional. Returns the number of labels
+ ** (including the background); i.e. connected components are
+ ** labelled from 1 to \f$nb\_label - 1\f$ (included).
**
** \return An image of type \a DestType.
**
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* oln/level/cc.hh (frontp_connected_component): Use the
imperative in documentation.
Use Doxygen's \param instead of \arg to document arguments.
Index: olena/oln/level/cc.hh
--- olena/oln/level/cc.hh Fri, 29 Oct 2004 15:20:00 +0200 levill_r (oln/e/20_cc.hh 1.11.1.18 600)
+++ olena/oln/level/cc.hh Tue, 02 Nov 2004 10:36:29 +0100 levill_r (oln/e/20_cc.hh 1.11.1.18 600)
@@ -57,11 +57,11 @@
**
** \pre the input must be a binary image.
**
- ** \arg input Image of markers.
- ** \arg se Neighborhood.
- ** \arg nb_label Optional. Returns the number of labels
- ** (including the background); i.e. connected components are
- ** labelled from 1 to \f$nb\_label - 1\f$ (included).
+ ** \param input Image of markers.
+ ** \param se Neighborhood.
+ ** \param nb_label Optional. Return the number of labels
+ ** (including the background); i.e. connected components
+ ** are labelled from 1 to \f$nb\_label - 1\f$ (included).
**
** \return An image of type \a DestType.
**
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/core/abstract/point.hh: Restart from scratch.
abstract::point is the interface, abstract::point_nd is an
implementation, point<i> add syntactic sugar.
* olena/oln/core/abstract/point.hxx: New. Likewise.
* olena/oln/core/abstract/dpoint.hh: Likewise.
* olena/oln/core/abstract/dpoint.hxx: New. Likewise.
* olena/oln/core/dpoint1d.hh: Restart from scratch.
* olena/oln/core/dpoint2d.hh: Likewise.
* olena/oln/core/dpoint3d.hh: Likewise.
* olena/oln/core/point1d.hh: Likewise.
* olena/oln/core/point2d.hh: Likewise.
* olena/oln/core/point3d.hh: Likewise.
* olena/oln/core/point_nd.hh: New. Likewise.
* olena/oln/core/dpoint_nd.hh: New. Likewise.
* olena/oln/core/dpoint1d.hh: Remove.
* olena/oln/core/dpoint2d.hh: Likewise.
* olena/oln/core/dpoint3d.hh: Likewise.
* olena/oln/core/point1d.hh: Likewise.
* olena/oln/core/point2d.hh: Likewise.
* olena/oln/core/point3d.hh: Likewise.
* olena/oln/core/macros.hh: Add macros. FIXME: to be continue.
Index: olena/oln/core/dpoint1d.hh
--- olena/oln/core/dpoint1d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/d/27_dpoint1d.h 1.14 600)
+++ olena/oln/core/dpoint1d.hh Mon, 13 Sep 2004 21:58:13 +0200 van-vl_n
(oln/d/27_dpoint1d.h 1.14 600)
@@ -28,142 +28,38 @@
#ifndef OLENA_CORE_DPOINT1D_HH
# define OLENA_CORE_DPOINT1D_HH
-# include <oln/config/system.hh>
-# include <ntg/core/predecls.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <iostream>
+# include <oln/core/abstract/dpoint_nd.hh>
namespace oln {
- // fwd decl
- class point1d;
+ template<unsigned dim>
+ class dpoint; //fwd decl
- class dpoint1d; //fwd_decl
-
- /*! \class dpoint_traits<dpoint1d>
+ /*! \class Concrete dpoint 1.
**
- ** The specialized version for dpoint1d.
+ ** Provides syntactic sugar.
*/
-
template <>
- struct dpoint_traits<dpoint1d>: public
- dpoint_traits<abstract::dpoint<dpoint1d> >
- {
- enum { dim = 1 };
- typedef point1d point_type;
- };
-
- /*! \class dpoint1d
- **
- ** Subclass of abstract::dpoint, declaration of dpoint
- ** for image1d. To instantiate a dpoint1d on an
- ** oln::image1d<ntg::rgb_8> for example, use the
- ** macro oln_dpoint_type(I).\n
- ** oln_dpoint_type(oln::image1d<ntg::rgb_8>) p();\n
- ** or\n
- ** oln_dpoint_type(oln::image1d<ntg::rgb_8>) p(1);
- */
-
- class dpoint1d : public abstract::dpoint<dpoint1d>
+ struct dpoint<1>: public abstract::dpoint_nd<dpoint<1> >
{
-
- public:
-
- typedef abstract::dpoint<dpoint1d> super_type;
-
- friend class abstract::dpoint<dpoint1d>;
-
-
- dpoint1d();
-
- /// The coordinate of the dpoint1d is set to \a c.
-
- dpoint1d(coord c);
-
- /// The coordinate of the dpoint1d is set to the \p coordinate.
-
- explicit dpoint1d(const point1d& p);
-
- /// Return the value of the dpoint1d coordinate.
- coord
- col() const;
-
- /// Return a reference to the dpoint1d coordinate.
-
- coord&
- col();
-
- static std::string
- name()
+ dpoint()
+ {}
+ dpoint(coord col)
{
- return "dpoint1d";
+ coord_[0] = col;
}
- protected:
-
- /*! \brief Return a dpoint1d whose coordinate is equal to
- ** \a dp coordinate plus the current dpoint1d coordinate.
- **
- */
-
- dpoint1d
- plus_dp(const dpoint1d& dp) const;
-
- /*! \brief Return a dpoint1d whose coordinate is equal to
- ** the opposite of the current dpoint1d coordinate.
- */
-
- dpoint1d
- minus() const;
-
- /*! \brief Return a dpoint1d whose coordinate is equal to
- ** the current dpoint1d coordinate minus 'dp' coordinate.
- */
-
- dpoint1d
- minus_dp(const dpoint1d& dp) const;
-
- /*! \brief Return a reference to the current dpoint1d
- ** plus 'dp'.
- */
-
- dpoint1d&
- plus_assign_dp(const dpoint1d& dp);
-
- /*! \brief Return a reference to the current dpoint1d
- ** minus 'dp'.
- */
-
- dpoint1d&
- minus_assign_dp(const dpoint1d& dp);
-
+ coord col() const { return coord_[0]; }
+ coord& col() { return coord_[0]; }
};
- namespace internal
- {
- /*! \class default_less<dpoint1d>
- **
- ** The specialized version for dpoint1d.
- */
- template<>
- struct default_less<dpoint1d> :
- public default_less<dpoint1d::super_type>
- {
- };
+ /// Depreciated. Use dpoint<1> instead.
+ typedef dpoint<1> dpoint1d;
- } // end of internal
} // end of oln
-/// Write on an output stream \a o the coordinate of the dpoint1d \a dp.
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint1d& dp);
-
-# include <oln/core/dpoint1d.hxx>
-
#endif // ! OLENA_CORE_DPOINT1D_HH
Index: olena/oln/core/dpoint2d.hh
--- olena/oln/core/dpoint2d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/d/25_dpoint2d.h 1.13 600)
+++ olena/oln/core/dpoint2d.hh Mon, 13 Sep 2004 21:58:13 +0200 van-vl_n
(oln/d/25_dpoint2d.h 1.13 600)
@@ -28,148 +28,43 @@
#ifndef OLENA_CORE_DPOINT2D_HH
# define OLENA_CORE_DPOINT2D_HH
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <iostream>
+# include <oln/core/dpoint_nd.hh>
namespace oln {
- // fwd decl
- class point2d;
- class dpoint2d;
+ template<unsigned dim>
+ class dpoint; //fwd decl
-
-
- /*! \class dpoint_traits<dpoint2d>
+ /*! \class Concrete dpoint 2.
**
- ** The specialized version for dpoint2d.
+ ** Provides syntactic sugar.
*/
-
template<>
- struct dpoint_traits<dpoint2d>: public
- dpoint_traits<abstract::dpoint<dpoint2d> >
- {
- enum { dim = 2 };
- typedef point2d point_type;
- };
-
- /*! \class dpoint2d
- **
- ** Subclass of abstract::dpoint, declaration of dpoint
- ** for image2d. To instantiate a dpoint2d on an
- ** oln::image2d<ntg::rgb_8> for example, use the
- ** macro oln_dpoint_type(I).\n
- ** oln_dpoint_type(oln::image2d<ntg::rgb_8>) dp();\n
- ** or\n
- ** oln_dpoint_type(oln::image2d<ntg::rgb_8>) dp(1, 2);
- */
-
-
- class dpoint2d : public abstract::dpoint< dpoint2d >
+ struct dpoint<2>: public abstract::dpoint_nd<dpoint<2> >
{
-
- public:
-
- typedef abstract::dpoint< dpoint2d > super_type;
-
- friend class abstract::dpoint< dpoint2d >;
-
- dpoint2d();
-
- /// The coordinates of the dpoint2d are set to \a row and \a col.
-
- dpoint2d(coord row, coord col);
-
- /// The coordinates of the dpoint2d are set to the \a p coordinates.
- explicit dpoint2d(const point2d& p);
-
- /// Return the value of the dpoint2d row coordinate.
-
- coord
- row() const;
-
- /// Return a reference to the dpoint2d row coordinate.
-
- coord&
- row();
-
- /// Return the value of the dpoint2d column coordinate.
-
- coord
- col() const;
-
- /// Return a reference to the dpoint2d column coordinate.
-
- coord&
- col();
-
- static std::string
- name()
+ dpoint()
+ {}
+ dpoint(coord row,coord col)
{
- return "dpoint2d";
+ coord_[0] = row;
+ coord_[1] = col;
}
- protected:
-
-
- /*! \brief Return a dpoint2d whose coordinates are equal to
- ** \a dp coordinates plus the current dpoint2d coordinates.
- */
-
- dpoint2d
- plus_dp(const dpoint2d& dp) const;
-
- /*! \brief Return a dpoint2d whose coordinates are equal to
- ** the opposite of the current dpoint2d coordinates.
- */
-
- dpoint2d
- minus() const;
-
-
- /*! \brief Return a dpoint2d whose coordinates are equal to
- ** the current dpoint2d coordinates minus \a dp coordinates.
- */
-
- dpoint2d
- minus_dp(const dpoint2d& dp) const;
-
- /*! \brief Return a reference to the current dpoint2d
- ** plus \a dp.
- */
-
- dpoint2d&
- plus_assign_dp(const dpoint2d& dp);
+ coord row() const { return coord_[0]; }
+ coord& row() { return coord_[0]; }
- /*! \brief Return a reference to the current dpoint2d
- ** minus \a dp.
- */
+ coord col() const { return coord_[1]; }
+ coord& col() { return coord_[1]; }
+ };
- dpoint2d&
- minus_assign_dp(const dpoint2d& dp);
- };
- namespace internal
- {
- /*! \class default_less<dpoint2d>
- **
- ** The specialized version for dpoint2d.
- */
- template<>
- struct default_less<dpoint2d> :
- public default_less<dpoint2d::super_type>
- {};
- } // end of internal
+ /// Depreciated. Use dpoint<2> instead.
+ typedef dpoint<2> dpoint2d;
} // end of oln
-/// Write on an output stream \a o the coordinates of the dpoint2d \a dp.
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint2d& dp);
-# include <oln/core/dpoint2d.hxx>
+#endif // ! OLENA_CORE_DPOINT2D_HH
-#endif // OLENA_CORE_DPOINT2D_HH
Index: olena/oln/core/dpoint3d.hh
--- olena/oln/core/dpoint3d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/d/23_dpoint3d.h 1.13 600)
+++ olena/oln/core/dpoint3d.hh Mon, 13 Sep 2004 21:58:13 +0200 van-vl_n
(oln/d/23_dpoint3d.h 1.13 600)
@@ -1,3 +1,5 @@
+
+#endif // ! OLENA_CORE_DPOINT3D_HH
// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and
Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -28,159 +30,47 @@
#ifndef OLENA_CORE_DPOINT3D_HH
# define OLENA_CORE_DPOINT3D_HH
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <iostream>
+# include <oln/core/abstract/dpoint_nd.hh>
namespace oln {
- // fwd decl
- class point3d;
- class dpoint3d;
+ template<unsigned dim>
+ class dpoint; //fwd decl
- /*! \class dpoint_traits<dpoint3d>
+ /*! \class Concrete dpoint 2.
**
- ** The specialized version for dpoint3d.
+ ** Provides syntactic sugar.
*/
-
template<>
- struct dpoint_traits<dpoint3d>: public
- dpoint_traits<abstract::dpoint<dpoint3d> >
+ struct dpoint<3>: public abstract::dpoint_nd<dpoint<3> >
{
- enum { dim = 3 };
- typedef point3d point_type;
- };
-
- /*! \class dpoint3d
- **
- ** Subclass of abstract::dpoint, declaration of dpoint
- ** for image3d. To instantiate a dpoint3d on an
- ** oln::image3d<ntg::rgb_8> for example, use the
- ** macro oln_dpoint_type(I).\n
- ** oln_dpoint_type(oln::image3d<ntg::rgb_8>) dp();\n
- ** or\n
- ** oln_dpoint_type(oln::image3d<ntg::rgb_8>) dp(1, 2, 3);
- */
-
- class dpoint3d : public abstract::dpoint< dpoint3d >
+ dpoint()
+ {}
+ dpoint(coord slice, coord row,coord col)
{
-
- public:
-
- typedef abstract::dpoint< dpoint3d > super_type;
-
- friend class abstract::dpoint< dpoint3d >;
-
- dpoint3d();
-
- /// The coordinates of the dpoint3d are set to \a slice, \a row,
and \a col.
-
- dpoint3d(coord slice, coord row, coord col);
-
- /// The coordinates of the dpoint3d are set to the \a p coordinates.
-
- explicit dpoint3d(const point3d& p);
-
-
- /// Return the value of the dpoint3d slice coordinate.
-
- coord
- slice() const;
-
- /// Return a reference to the dpoint3d slice coordinate.
-
- coord&
- slice();
-
- /// Give the value of the dpoint3d row coordinate.
-
- coord
- row() const;
-
- /*! \brief Return a reference to the dpoint3d row coordinate.
- **
- */
-
- coord&
- row();
-
- /// Return the value of the dpoint3d column coordinate.
-
- coord
- col() const;
-
- /// Return a reference to the dpoint3d column coordinate.
-
- coord&
- col();
-
- static std::string
- name()
- {
- return "dpoint3d";
+ coord_[0] = slice;
+ coord_[1] = row;
+ coord_[2] = col;
}
- protected:
-
- /*! \brief Return a dpoint3d whose coordinates are equal to
- ** \a dp coordinates plus the current dpoint3d coordinates.
- **
- */
-
- dpoint3d
- plus_dp(const dpoint3d& dp) const;
-
- /*! \brief Return a dpoint3d whose coordinates are equal to
- ** the opposite of the current dpoint3d coordinates.
- */
-
- dpoint3d
- minus() const;
-
- /*! \brief Return a dpoint3d whose coordinates are equal to
- ** the current dpoint3d coordinates minus \a dp coordinates.
- */
-
- dpoint3d
- minus_dp(const dpoint3d& dp) const;
+ coord slice() const { return coord_[0]; }
+ coord& slice() { return coord_[0]; }
- /*! \brief Return a reference to the current dpoint3d
- ** plus \a dp.
- */
-
- dpoint3d&
- plus_assign_dp(const dpoint3d& dp);
-
- /*! \brief Return a reference to the current dpoint3d
- ** minus 'dp'.
- */
-
- dpoint3d&
- minus_assign_dp(const dpoint3d& dp);
+ coord row() const { return coord_[1]; }
+ coord& row() { return coord_[1]; }
+ coord col() const { return coord_[2]; }
+ coord& col() { return coord_[2]; }
};
- namespace internal
- {
- /*! \class default_less<dpoint3d>
- **
- ** The specialized version for dpoint3d.
- */
- template<>
- struct default_less<dpoint3d> :
- public default_less<dpoint3d::super_type>
- {
- };
- } // end of internal
-} // end of oln
-/// Write on an output stream \a o the coordinates of the dpoint3d \a dp.
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint3d& dp);
+ /// Depreciated. Use dpoint<3> instead.
+ typedef dpoint<3> dpoint3d;
-# include <oln/core/dpoint3d.hxx>
+} // end of oln
#endif // ! OLENA_CORE_DPOINT3D_HH
+
Index: olena/oln/core/abstract/dpoint.hh
--- olena/oln/core/abstract/dpoint.hh Mon, 15 Mar 2004 17:40:54 +0100
van-vl_n (oln/d/28_dpoint.hh 1.20 600)
+++ olena/oln/core/abstract/dpoint.hh Mon, 13 Sep 2004 21:58:38 +0200
van-vl_n (oln/d/28_dpoint.hh 1.20 600)
@@ -24,240 +24,212 @@
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
-
#ifndef OLENA_CORE_ABSTRACT_DPOINT_HH
# define OLENA_CORE_ABSTRACT_DPOINT_HH
# include <mlc/type.hh>
# include <oln/core/coord.hh>
-# include <ntg/float.hh>
-# include <cmath>
-
-namespace oln {
+# include <oln/core/macros.hh>
+# include <iostream>
+# include <sstream>
- namespace abstract {
- template<class Exact>
- struct dpoint; // fwd_decl
-
- template<class Exact>
- struct point; // fwd_decl
- } // end of abstract
+namespace oln
+{
template<class Exact>
- struct dpoint_traits; // fwd_decl
+ struct prop; // fwd declaration
- /*! \class dpoint_traits<abstract::dpoint<Exact> >
- **
- ** The specialized version for abstract::dpoint<Exact>.
- */
+ namespace abstract {
template<class Exact>
- struct dpoint_traits<abstract::dpoint<Exact> >
- {
+ struct point; // fwd declaration
- };
- namespace abstract {
-
- /*! \class dpoint
+ /*! \class Abstract dpoint.
**
- ** The abstract dpoint class from whom derives
- ** all the others dpoint classes.
+ ** This class provides an interface.
+ ** \see oln::dpoint
*/
-
template<class Exact>
struct dpoint : public mlc_hierarchy::any<Exact>
{
+ public:
- typedef Exact exact_type;
- typedef dpoint<Exact> self_type;
- enum { dim = dpoint_traits<exact_type>::dim };
- typedef typename dpoint_traits<exact_type>::point_type point_type;
+ /// Give the value of the nth coordinate of the dpoint.
+ coord
+ nth(const unsigned dim) const
+ {
+ mlc_dispatch(nth)(dim);
+ }
- /*! \brief Construct a dpoint with the same coordinates
- ** a the point \a p.
- */
+ /// Return a reference to the nth coordinate of the dpoint.
+ coord&
+ nth(const unsigned dim)
+ {
+ mlc_dispatch(nth)(dim);
+ }
- explicit dpoint(const abstract::point<point_type>& p)
+ /// Add a delta dpoint \a dp to the current dpoint
+ Exact &
+ operator+=(const Exact &dp)
{
- for (unsigned i = 0; i < dim; ++i)
- nth(i) = p.exact().nth(i);
+ mlc_dispatch(op_plus_assign)(dp);
}
- /// Return the dth coordinate of the current dpoint.
- coord
- nth(const unsigned d) const
+ /// Subtract a delta dpoint \a dp from the current dpoint.
+ Exact&
+ operator-=(const Exact &dp)
{
- return coord_[d];
+ mlc_dispatch(op_minus_assign)(dp);
}
- /// Return a reference to the dth coordinate of the current dpoint.
- coord&
- nth(const unsigned d)
+ /// Subtract a dpoint \a p from the current dpoint.
+ Exact
+ operator-(const Exact &p) const
{
- return coord_[d];
+ mlc_dispatch(op_minus)(p);
}
- /*! \brief Return a dpoint whose coordinates are the opposite
- ** of the current dpoint coordinates.
- */
- exact_type
+ /// Addition of a delta dpoint \a dp and the current dpoint.
+ Exact
+ operator+(const Exact &dp) const
+ {
+ mlc_dispatch(op_plus)(dp);
+ }
+ /// Opposite of the current dpoint coordinates
+ Exact
operator-() const
{
- return this->exact().minus();
+ mlc_dispatch(op_minus)();
}
- /*! \brief Add a dpoint \a dp to the current dpoint.
- **
- ** \return A reference to the current dpoint plus \a dp.
- */
-
- exact_type&
- operator+=(const self_type& dp)
+ /// Dpoints equal.
+ bool
+ operator==(const Exact &p) const
{
- return this->exact().plus_assign_dp(dp.exact());
+ mlc_dispatch(op_equal_p)(p);
}
- /*! \brief Subtract a dpoint \a dp from the current dpoint.
- **
- ** \return A reference to the current point minus \a dp.
- */
- exact_type&
- operator-=(const self_type& dp)
+ /// Dpoints not equal.
+ bool
+ operator!=(const Exact &p) const
{
- return this->exact().minus_assign_dp(dp.exact());
+ mlc_dispatch(op_not_equal_p)(p);
}
- /*! \brief Add a dpoint \a dp to the current dpoint.
- **
- ** \return The value of the current point plus \a dp.
- */
-
- exact_type
- operator+(const self_type& dp) const
+ static std::string
+ name()
{
- return this->exact().plus_dp(dp.exact());
+ return std::string("dpoint<") + Exact::name() + ">";
}
- /*! \brief Subtract a dpoint \a dp from the current dpoint.
- **
- ** \return The value of the current point minus \a dp.
- */
+ protected:
- exact_type
- operator-(const self_type& dp) const
- {
- return this->exact().minus_dp(dp.exact());
- }
+ dpoint()
+ {}
+ };
- /*! \brief Test if two dpoints have the same coordinates.
- **
- ** \arg dp A dpoint.
- **
- ** \return True if \a dp and the current point have the same
- ** coordinate, false otherwise.
- */
- bool
- operator==(const self_type& dp) const
+ template<class Exact>
+ inline std::ostream&
+ operator<<(std::ostream& o, const dpoint<Exact> &p)
{
- for (unsigned i = 0; i < dim; ++i)
- if (dp.nth(i) != nth(i))
- return false;
- return true;
+ o << "(";
+ for (unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ {
+ o << p.nth(dim);
+ if (dim + 1 < oln_dim_val(Exact))
+ o << ",";
+ }
+ o << ")";
+ return o;
}
- /*! \brief Test if two dpoints do not have the same coordinates.
- **
- ** \arg dp A dpoint.
- **
- ** \return False if \a dp and the current point have the same
- ** coordinate, true otherwise.
- */
- bool
- operator!=(const self_type& dp) const
- {
- for (unsigned i = 0; i < dim; ++i)
- if (dp.nth(i) != nth(i))
- return true;
- return false;
- }
- /*! \brief Test if all the dpoint coordinates are set to zero.
+ /*! \class Abstract dpoint with dimension.
**
- ** \return True if all the coordinates of the current dpoint
- ** are set to zero.
+ ** This class provides an implementation.
+ ** \see oln::dpoint
*/
-
- bool
- is_centered(void) const
+ template<class Exact>
+ struct dpoint_nd : public dpoint<Exact>
{
- for (unsigned i = 0; i < dim; ++i)
- if (nth(i) != 0)
- return false;
- return true;
- }
+ public:
- /// Return the norm of the current dpoint.
+ /// Give the value of the nth coordinate of the dpoint.
+ coord
+ nth_impl(const unsigned dim) const;
- ntg::float_d
- norm2(void) const
- {
- double norm = 0;
+ /// Return a reference to the nth coordinate of the dpoint.
+ coord&
+ nth_impl(const unsigned dim);
- for (unsigned i = 0; i < dim; ++i)
- norm += nth(i) * nth(i);
- return sqrt(norm);
- }
+ /// Add a delta dpoint \a dp to the current dpoint
+ Exact &
+ op_plus_assign_impl(const Exact& dp);
- /// Return the square of the norm of the current dpoint.
- ntg::float_d
- sqr_norm2(void) const
- {
- double norm = 0;
+ /// Subtract a delta dpoint \a dp from the current dpoint.
+ Exact&
+ op_minus_assign_impl(const Exact &dp);
+
+ /// Subtract a dpoint \a p from the current dpoint.
+ Exact
+ op_minus_impl(const Exact &p) const;
+
+
+ /// Addition of a delta dpoint \a dp and the current dpoint.
+ Exact
+ op_plus_impl(const Exact &dp) const;
+
+
+ /// Opposite of the current dpoint coordinates
+ Exact
+ op_minus_impl() const;
+
+
+ /// Dpoints equal.
+ bool
+ op_equal_impl(const Exact &p) const;
+
+
+ /// Dpoints not equal.
+ bool
+ op_not_equal_impl(const Exact &p) const;
+
- for (unsigned i = 0; i < dim; ++i)
- norm += nth(i) * nth(i);
- return norm;
- }
static std::string
name()
{
- return std::string("dpoint<") +
- Exact::name() + ">";
+ return std::string("dpoint_nd<") + Exact::name() + ">";
}
protected:
- dpoint()
+ dpoint_nd()
{}
-
- private:
-
- coord coord_[dim];
+ coord coord_[oln_dim_val(Exact)];
};
} // end of abstract
- /*! \brief Internal purpose only.
- */
+
+
+
namespace internal
{
/*! \class default_less< abstract::dpoint<Exact> >
**
- ** The specialized version for < abstract::dpoint<Exact> >.
+ ** The specialized version for abstract::dpoint.
*/
-
-
template<class Exact>
struct default_less< abstract::dpoint<Exact> >
{
@@ -265,13 +237,18 @@
/*! \brief Test if the coordinates of a dpoint l
** are not greater than the coordinates of a dpoint r.
**
+ ** \arg l A dpoint.
+ **
+ ** \arg r Another dpoint.
+ **
** \return True if the coordinates of l are not greater
** than the coordinates of r.
*/
+
bool operator()(const abstract::dpoint<Exact>& l,
const abstract::dpoint<Exact>& r) const
{
- for (unsigned i = 0; i < abstract::dpoint<Exact>::dim; ++i)
+ for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
if (l.nth(i) < r.nth(i))
return true;
else if (l.nth(i) > r.nth(i))
@@ -279,11 +256,10 @@
return false;
}
};
-
} // internal
-
-
} // end of oln
+#include "dpoint.hxx"
+
#endif // ! OLENA_CORE_ABSTRACT_DPOINT_HH
Index: olena/oln/core/macros.hh
--- olena/oln/core/macros.hh Sat, 02 Aug 2003 17:02:58 +0200 burrus_n
(oln/c/39_macros.hh 1.5 600)
+++ olena/oln/core/macros.hh Mon, 13 Sep 2004 21:59:49 +0200 van-vl_n
(oln/c/39_macros.hh 1.5 600)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2003, 2004 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
@@ -39,4 +39,16 @@
# define for_all_remaining(p) \
if (p == mlc::end) {} else while(++(p), ((p) != mlc::end))
+
+
+# define oln_point_type(E) typename oln::prop<E>::point_type
+# define oln_point_type_(E) oln::prop<E>::point_type
+
+# define oln_dpoint_type(E) typename oln::prop<E>::dpoint_type
+# define oln_dpoint_type_(E) oln::prop<E>::dpoint_type
+
+
+# define oln_dim_val(E) oln::prop<E>::dim
+# define oln_dim_val_(E) oln::prop<E>::dim
+
#endif // OLENA_CORE_MACROS_HH
Index: olena/oln/core/point1d.hh
--- olena/oln/core/point1d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/c/32_point1d.hh 1.15 600)
+++ olena/oln/core/point1d.hh Mon, 13 Sep 2004 21:57:57 +0200 van-vl_n
(oln/c/32_point1d.hh 1.15 600)
@@ -28,143 +28,38 @@
#ifndef OLENA_CORE_POINT1D_HH
# define OLENA_CORE_POINT1D_HH
-# include <oln/config/system.hh>
-# include <ntg/core/predecls.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/point.hh>
-# include <iostream>
+# include "point_nd.hh"
namespace oln {
+ template <unsigned Dim>
+ struct point;//fwd decl
- // fwd decl
- class dpoint1d;
- class point1d;
-
-
- /*! \class point_traits<point1d>
+ /*! \class Concrete point 1.
**
- ** The specialized version for point1d.
+ ** Provides syntactic sugar.
*/
-
template<>
- struct point_traits<point1d> : public
point_traits<abstract::point<point1d> >
+ struct point<1>: public abstract::point_nd<point<1> >
{
- enum { dim = 1 };
- typedef dpoint1d dpoint_type;
- };
-
- /*! \class point1d
- **
- ** Subclass of abstract::point, declaration of point
- ** for image1d. To instantiate a point1d on an
- ** oln::image1d<ntg::rgb_8> for example, use the
- ** macro oln_point_type.\n
- ** oln_point_type(oln::image1d<ntg::rgb_8>) p();\n
- ** or\n
- ** oln_point_type(oln::image1d<ntg::rgb_8>) p(1);
- */
-
- class point1d : public abstract::point<point1d>
+ point()
+ {}
+ point(coord col)
{
- public:
-
- typedef abstract::point<point1d> super_type;
- typedef point_traits<point1d>::dpoint_type dpoint_type;
-
- friend class abstract::point<point1d>;
-
- point1d();
-
- /// The coordinate of the point1d is set to \a col.
-
- point1d(coord col);
-
- /// Return the value of the point1d coordinate.
-
- coord
- col() const;
-
- /// Return a reference to the point1d coordinate.
-
- coord&
- col();
+ coord_[0] = col;
+ }
+ coord col() const { return coord_[0]; }
+ coord& col() { return coord_[0]; }
static std::string
name()
{
- return "point1d";
+ return "point<1>";
}
-
- protected:
-
-
- /*! \brief Return a point1d whose coordinate is equal to
- ** \a dp coordinate plus the current point1d coordinate.
- */
-
- point1d
- plus_dp(const dpoint1d& dp) const;
-
- /*! \brief Return a point1d whose coordinate is equal to
- ** the current point1d coordinate minus \a dp coordinate.
- */
-
- point1d
- minus_dp(const dpoint1d& dp) const;
-
- /*! \brief Return a reference to the current point1d
- ** plus \a dp.
- */
-
- point1d&
- plus_assign_dp(const dpoint1d& dp);
-
- /*! \brief Return a reference to the current point1d
- ** minus \a dp.
- */
-
- point1d&
- minus_assign_dp(const dpoint1d& dp);
-
- /*! \brief Return a dpoint1d whose coordinate is equal
- ** to the current point1d coordinate minus \a p coordinate.
- */
-
- dpoint1d
- minus_p(const point1d& p) const;
-
- /*! \brief Return a point1d whose coordinate is equal to
- ** the opposite of the current point1d coordinate.
- */
-
- point1d
- minus() const;
-
};
- namespace internal
- {
-
- /*! \class default_less<point1d>
- **
- ** The specialized version for point1d.
- */
-
- template<>
- struct default_less<point1d> : public default_less<point1d::super_type>
- {
- };
- } // internal
-
-
+/// Depreciated. Use point<1> instead.
+ typedef point<1> point1d;
} // oln
-/// Write on an output stream \a o the coordinate of the point1d \a p.
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point1d& p);
-
-# include <oln/core/point1d.hxx>
-
#endif // ! OLENA_CORE_POINT1D_HH
Index: olena/oln/core/point2d.hh
--- olena/oln/core/point2d.hh Sun, 11 Apr 2004 19:23:53 +0200 thivol_d
(oln/c/30_point2d.hh 1.15 600)
+++ olena/oln/core/point2d.hh Mon, 13 Sep 2004 21:57:57 +0200 van-vl_n
(oln/c/30_point2d.hh 1.15 600)
@@ -28,150 +28,50 @@
#ifndef OLENA_CORE_POINT2D_HH
# define OLENA_CORE_POINT2D_HH
-# include <oln/core/coord.hh>
-# include <oln/core/point1d.hh>
-# include <iostream>
+
+# include "point_nd.hh"
+
namespace oln {
- // fwd decl
- class dpoint2d;
- class point2d;
- /*! \class point_traits<point2d>
- **
- ** The specialized version for point2d.
- */
+ template<class Exact>
+ struct prop; // fwd declaration
- template<>
- struct point_traits<point2d>: public
point_traits<abstract::point<point2d> >
- {
- enum { dim = 2 };
- typedef dpoint2d dpoint_type;
- };
+ template <unsigned Dim>
+ struct point;//fwd decl
- /*! \class point2d
+ /*! \class Concrete point 2.
**
- ** Subclass of abstract::point, declaration of point
- ** for image2d. To instantiate a dpoint2d on an
- ** oln::image2d<ntg::rgb_8> for example, use the
- ** macro oln_point_type(I).\n
- ** oln_point_type(oln::image2d<ntg::rgb_8>) p();\n
- ** or\n
- ** oln_point_type(oln::image2d<ntg::rgb_8>) p(1, 2);
+ ** Provides syntactic sugar.
*/
-
- class point2d : public abstract::point<point2d >
+ template <>
+ struct point<2>: public abstract::point_nd<point<2> >
{
- public:
-
- typedef abstract::point< point2d > super_type;
- typedef point_traits<point2d>::dpoint_type dpoint_type;
-
- friend class abstract::point< point2d >;
-
- point2d();
-
- /// The coordinates of the point2d are set to \a row and \a col.
-
- point2d(coord row, coord col);
-
- /// The coordinates of the point2d are set to \a p and \a col.
-
- point2d(const point1d& p, coord col);
-
- /// Return Give the value of the point2d row coordinate.
-
- coord
- row() const;
-
- /// Return a reference to the point2d row coordinate.
-
- coord&
- row();
-
- /// Return the value of the point2d col coordinate.
+ point()
+ {}
+ point(coord row, coord col)
+ {
+ coord_[0] = row;
+ coord_[1] = col;
+ }
- coord
- col() const;
+ coord row() const { return coord_[0]; }
+ coord& row() { return coord_[0]; }
- /// Return a reference to the point2d col coordinate.
+ coord col() const { return coord_[1]; }
+ coord& col() { return coord_[1]; }
- coord&
- col();
static std::string
name()
{
- return "point2d";
+ return "point<2>";
}
-
- protected:
-
- /*! \brief Return a point2d whose coordinates are equal to
- ** \a dp coordinates plus the current point2d coordinates.
- */
-
- point2d
- plus_dp(const dpoint2d& dp) const;
-
- /*! \brief Return a point2d whose coordinates are equal to
- ** the current point2d coordinates minus \a dp coordinates.
- */
-
- point2d
- minus_dp(const dpoint2d& dp) const;
-
- /*! \brief Return a reference to the current point2d
- ** plus \a dp.
- */
-
- point2d&
- plus_assign_dp(const dpoint2d& dp);
-
- /*! \brief Return a reference to the current point2d
- ** minus \a dp.
- */
-
- point2d&
- minus_assign_dp(const dpoint2d& dp);
-
- /*! \brief Return a dpoint2d whose coordinates are equal
- ** to the current point2d coordinates minus \a p coordinates.
- */
-
- dpoint2d
- minus_p(const point2d& p) const;
-
- /*! \brief Return a point2d whose coordinates are equal to
- ** the opposite of the current point2d coordinates.
- */
-
- point2d
- minus() const;
-
};
- namespace internal
- {
-
- /*! \class default_less<point2d>
- **
- ** The specialized version for point2d.
- */
-
- template<>
- struct default_less<point2d> :
- public default_less<point2d::super_type>
- {};
- } // internal
+ /// Depreciated. Use point<2> instead.
+ typedef point<2> point2d;
} // oln
-/// Write on an output stream \a o the coordinates of the point2d \a p.
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point2d& p);
-
-# include <oln/core/point2d.hxx>
-
#endif // ! OLENA_CORE_POINT2D_HH
Index: olena/oln/core/point3d.hh
--- olena/oln/core/point3d.hh Sun, 11 Apr 2004 19:23:53 +0200 thivol_d
(oln/c/28_point3d.hh 1.17 600)
+++ olena/oln/core/point3d.hh Mon, 13 Sep 2004 21:57:57 +0200 van-vl_n
(oln/c/28_point3d.hh 1.17 600)
@@ -28,166 +28,48 @@
#ifndef OLENA_CORE_POINT3D_HH
# define OLENA_CORE_POINT3D_HH
-# include <ntg/core/predecls.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/point2d.hh>
-# include <iostream>
+# include "point_nd.hh"
namespace oln {
+ template <unsigned Dim>
+ struct point;//fwd decl
- // fwd decl
- class dpoint3d;
- class point3d;
-
- /*! \class point_traits<point3d>
+ /*! \class Concrete point 3.
**
- ** The specialized version for point3d.
+ ** Provides syntactic sugar.
*/
-
template<>
- struct point_traits<point3d>: public
point_traits<abstract::point<point3d> >
+ struct point<3>: public abstract::point_nd<point<3> >
{
- enum { dim = 3 };
- typedef dpoint3d dpoint_type;
- };
-
- /*! \class point3d
- **
- ** Subclass of abstract::point, declaration of point
- ** for image3d. To instantiate a point3d on an
- ** oln::image3d<ngt::rgb_8> for example, use the
- ** macro oln_point_type(I).\n
- ** oln_point_type(oln::image3d<ngt::rgb_8>) p();\n
- ** or\n
- ** oln_point_type(oln::image3d<ngt::rgb_8>) p(1, 2, 3);
- */
-
- class point3d : public abstract::point< point3d >
+ point()
+ {}
+ point(coord slice, coord row, coord col)
{
- public:
-
- typedef abstract::point< point3d > super_type;
- typedef point_traits<point3d>::dpoint_type dpoint_type;
-
- friend class abstract::point< point3d >;
-
-
- point3d();
-
- /// The coordinates of the point3d are set to \a slice, \a row, and
\a col.
-
- point3d(coord slice, coord row, coord col);
-
- /// The coordinates of the point3d are set to \a p, and \a slice.
-
- point3d(const point2d& p, coord slice);
-
- /// Return the value of the point3d slice coordinate.
-
- coord
- slice() const;
-
- /// Return a reference to the value of the point3d slice coordinate.
-
- coord&
- slice();
-
- /// Return the value of the point3d row coordinate.
-
- coord
- row() const;
-
- /// Return a reference to the point3d row coordinate.
-
- coord&
- row();
-
- /// Return the value of the point3d col coordinate.
+ coord_[0] = slice;
+ coord_[1] = row;
+ coord_[2] = col;
+ }
- coord
- col() const;
+ coord slice() const { return coord_[0]; }
+ coord& slice() { return coord_[0]; }
- /// Return a reference to the point3d col coordinate.
+ coord row() const { return coord_[1]; }
+ coord& row() { return coord_[1]; }
- coord&
- col();
+ coord col() const { return coord_[2]; }
+ coord& col() { return coord_[2]; }
static std::string
name()
{
- return "point3d";
+ return "point<3>";
}
-
- protected:
-
- /*! \brief Return a point3d whose coordinates are equal to
- ** \a dp coordinates plus the current point3d coordinates.
- */
-
- point3d
- plus_dp(const dpoint3d& dp) const;
-
- /*! \brief Return a point3d whose coordinates are equal to
- ** the current point3d coordinates minus \a dp coordinates.
- */
-
- point3d
- minus_dp(const dpoint3d& dp) const;
-
- /*! \brief Return a reference to the current point3d
- ** plus \a dp.
- */
-
- point3d&
- plus_assign_dp(const dpoint3d& dp);
-
- /*! \brief Return a reference to the current point3d
- ** minus \a dp.
- */
-
- point3d&
- minus_assign_dp(const dpoint3d& dp);
-
- /*! \brief Return a dpoint3d whose coordinates are equal
- ** to the current point3d coordinates minus \a p coordinates.
- */
-
- dpoint3d
- minus_p(const point3d& p) const;
-
- /*! \brief Return a point3d whose coordinates are equal to
- ** the opposite of the current point3d coordinates.
- */
-
- point3d
- minus() const;
-
- };
-
- namespace internal
- {
-
- /*! \class default_less<point3d>
- **
- ** The specialized version for point3d.
- */
-
- template<>
- struct default_less<point3d> : public default_less<point3d::super_type>
- {
};
- } // end of internal
-
+ /// Depreciated. Use point<3> instead.
+ typedef point<3> point3d;
} // end of oln
-/// Write on an output stream \a o the coordinates of the point3d \a p.
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point3d& p);
-
-# include <oln/core/point3d.hxx>
-
#endif // ! OLENA_CORE_POINT3D_HH
Index: olena/oln/core/abstract/point.hh
--- olena/oln/core/abstract/point.hh Thu, 11 Mar 2004 17:12:19 +0100
thivol_d (oln/c/33_point.hh 1.16 600)
+++ olena/oln/core/abstract/point.hh Mon, 13 Sep 2004 21:58:51 +0200
van-vl_n (oln/c/33_point.hh 1.16 600)
@@ -24,190 +24,114 @@
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
-
#ifndef OLENA_CORE_ABSTRACT_POINT_HH
# define OLENA_CORE_ABSTRACT_POINT_HH
# include <mlc/type.hh>
-# include <ntg/utils/debug.hh>
# include <oln/core/coord.hh>
+# include <oln/core/macros.hh>
# include <iostream>
# include <sstream>
namespace oln
{
- namespace abstract {
- template<class Exact>
- struct point; // fwd declaration
-
- template<class Exact>
- struct dpoint; // fwd declaration
- } // end of abstract
template<class Exact>
- struct point_traits; // fwd declaration
+ struct prop; // fwd declaration
- /*! \class point_traits<abstract::point<Exact> >
- **
- ** The specialized implementation for abstract::point.
- */
+ namespace abstract {
template<class Exact>
- struct point_traits<abstract::point<Exact> >
- {
+ struct dpoint; // fwd declaration
- };
- namespace abstract {
- /*! \class point
+ /*! \class Abstract point.
**
- ** The abstract class from whom derives all the others
- ** point classes.
+ ** This class provides an interface.
+ ** \see oln::point
*/
-
template<class Exact>
struct point : public mlc_hierarchy::any<Exact>
{
-
public:
- typedef point<Exact> self_type;
- typedef Exact exact_type;
- typedef typename point_traits<Exact>::dpoint_type dpoint_type;
-
- enum { dim = point_traits<Exact>::dim };
-
- /// Return the current point casted in exact_type.
-
- const exact_type&
- point_ref() const
- {
- return this->exact();
- }
-
/// Give the value of the nth coordinate of the point.
-
coord
nth(const unsigned dim) const
{
- return coord_[dim];
+ mlc_dispatch(nth)(dim);
}
/// Return a reference to the nth coordinate of the point.
-
coord&
nth(const unsigned dim)
{
- return coord_[dim];
+ mlc_dispatch(nth)(dim);
}
- /*! \brief Add a delta point \a dp to the current point
- **
- ** \return The current point plus \a dp.
- */
-
- exact_type&
- operator+=(const abstract::dpoint<dpoint_type>& dp)
+ /// Add a delta point \a dp to the current point
+ Exact &
+ operator+=(const oln_dpoint_type(Exact) &dp)
{
- return this->exact().plus_assign_dp(dp.exact());
+ mlc_dispatch(op_plus_assign)(dp);
}
- /*! \brief Subtract a delta point \a dp from the current point.
- **
- ** \return The current point minus \a dp.
- */
-
- exact_type&
- operator-=(const abstract::dpoint<dpoint_type>& dp)
+ /// Subtract a delta point \a dp from the current point.
+ Exact&
+ operator-=(const oln_dpoint_type(Exact) &dp)
{
- return this->exact().minus_assign_dp(dp.exact());
+ mlc_dispatch(op_minus_assign)(dp);
}
- /*! \brief Subtract a point \a p from the current point.
- **
- ** \return A reference to this current point minus \a p.
- */
-
- dpoint_type
- operator-(const self_type& p) const
+ /// Subtract a point \a p from the current point.
+ oln_dpoint_type(Exact)
+ operator-(const Exact &p) const
{
- return this->exact().minus_p(p.exact());
+ mlc_dispatch(op_minus)(p);
}
- /*! \brief Give the result of the addition of
- ** a delta point \a dp and the current point
- **
- ** \return The result of the addition of \a dp and the current point.
- */
-
- exact_type
- operator+(const abstract::dpoint<dpoint_type>& dp) const
+ /// Addition of a delta point \a dp and the current point.
+ Exact
+ operator+(const oln_dpoint_type(Exact) &dp) const
{
- return this->exact().plus_dp(dp.exact());
+ mlc_dispatch(op_plus)(dp);
}
- /*! \brief Give the result of the subtraction of
- ** a delta point \a dp and the current point.
- **
- ** \return The result of the subtraction of \a dp and the current
point.
- */
-
-
- exact_type
- operator-(const abstract::dpoint<dpoint_type>& dp) const
+ /// Subtraction of a delta point \a dp and the current point.
+ Exact
+ operator-(const oln_dpoint_type(Exact) &dp) const
{
- return this->exact().minus_dp(dp.exact());
+ mlc_dispatch(op_minus)(dp);
}
- /*! \brief Return a point whose coordinates are
- ** the opposite of the current point coordinates
- */
-
- exact_type
+ /// Opposite of the current point coordinates
+ Exact
operator-() const
{
- return this->exact().minus();
+ mlc_dispatch(op_minus)();
}
-
- /*! \brief Test if \a p and the current point have the same
coordinates
- **
- ** \return True if \a p and the current point have the same
coordinates,
- ** false otherwise.
- */
-
+ /// Points equal.
bool
- operator==(const self_type& p) const
+ operator==(const Exact &p) const
{
- for (unsigned i = 0; i < dim; ++i)
- if (p.nth(i) != nth(i))
- return false;
- return true;
+ mlc_dispatch(op_equal_p)(p);
}
- /*! \brief Test if \a p and the current point do
- ** not have the same coordinates.
- **
- ** \return False if \a p and the current point have
- ** the same coordinates, true otherwise.
- */
-
+ /// Points not equal.
bool
- operator!=(const self_type& p) const
+ operator!=(const Exact &p) const
{
- for (unsigned i = 0; i < dim; ++i)
- if (p.nth(i) != nth(i))
- return true;
- return false;
+ mlc_dispatch(op_not_equal_p)(p);
}
-
- static std::string name()
+ static std::string
+ name()
{
return std::string("point<") + Exact::name() + ">";
}
@@ -216,20 +140,102 @@
point()
{}
+ };
- private:
- /*! \brief The coordinates of the point are stored
- ** in this array.
+ template<class Exact>
+ inline std::ostream&
+ operator<<(std::ostream& o, const point<Exact> &p)
+ {
+ o << "(";
+ for (unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ {
+ o << p.nth(dim);
+ if (dim + 1 < oln_dim_val(Exact))
+ o << ",";
+ }
+ o << ")";
+ return o;
+ }
+
+
+
+ /*! \class Abstract point with dimension.
+ **
+ ** This class provides an implementation.
+ ** \see oln::point
*/
+ template<class Exact>
+ struct point_nd : public point<Exact>
+ {
+ public:
+
+ /// Give the value of the nth coordinate of the point.
+ coord
+ nth_impl(const unsigned dim) const;
+
+ /// Return a reference to the nth coordinate of the point.
+ coord&
+ nth_impl(const unsigned dim);
+
+ /// Add a delta point \a dp to the current point
+ Exact &
+ op_plus_assign_impl(const oln_dpoint_type(Exact)& dp);
+
+
+ /// Subtract a delta point \a dp from the current point.
+ Exact&
+ op_minus_assign_impl(const oln_dpoint_type(Exact) &dp);
+
+ /// Subtract a point \a p from the current point.
+ oln_dpoint_type(Exact)
+ op_minus_impl(const Exact &p) const;
- coord coord_[dim];
+ /// Addition of a delta point \a dp and the current point.
+ Exact
+ op_plus_impl(const oln_dpoint_type(Exact) &dp) const;
+
+
+ /// Subtraction of a delta point \a dp and the current point.
+ Exact
+ op_minus_impl(const oln_dpoint_type(Exact) &dp) const;
+
+
+ /// Opposite of the current point coordinates
+ Exact
+ op_minus_impl() const;
+
+
+ /// Points equal.
+ bool
+ op_equal_impl(const Exact &p) const;
+
+
+ /// Points not equal.
+ bool
+ op_not_equal_impl(const Exact &p) const;
+
+
+
+ static std::string
+ name()
+ {
+ return std::string("point_nd<") + Exact::name() + ">";
+ }
+
+ protected:
+
+ point_nd()
+ {}
+ coord coord_[oln_dim_val(Exact)];
};
} // end of abstract
+
+
namespace internal
{
@@ -237,7 +243,6 @@
**
** The specialized version for abstract::point.
*/
-
template<class Exact>
struct default_less< abstract::point<Exact> >
{
@@ -256,7 +261,7 @@
bool operator()(const abstract::point<Exact>& l,
const abstract::point<Exact>& r) const
{
- for (unsigned i = 0; i < abstract::point<Exact>::dim; ++i)
+ for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
if (l.nth(i) < r.nth(i))
return true;
else if (l.nth(i) > r.nth(i))
@@ -264,10 +269,10 @@
return false;
}
};
-
} // internal
-
} // end of oln
+#include "point.hxx"
+
#endif // ! OLENA_CORE_ABSTRACT_POINT_HH
Index: olena/oln/core/point_nd.hh
--- olena/oln/core/point_nd.hh Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
+++ olena/oln/core/point_nd.hh Mon, 13 Sep 2004 21:57:57 +0200 van-vl_n
(oln/w/30_point_nd.h 644)
@@ -0,0 +1,54 @@
+// Copyright (C) 2004 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.
+
+#ifndef OLENA_CORE_POINT_HH
+# define OLENA_CORE_POINT_HH
+
+# include "abstract/point.hh"
+
+namespace oln {
+
+ /// \class Concrete point for dimension grater than 3.
+ template <unsigned Dim>
+ struct point : public abstract::point_nd<point<Dim> >
+ {
+
+ //FIXME: to be complete
+ static std::string
+ name()
+ {
+ std::ostringstream s;
+ s << Dim;
+ return std::string("point<") + s.str() + ">";
+ }
+
+ };
+
+ template <unsigned Dim>
+ struct dpoint; //fwd decl
+
+
+ template <unsigned Dim>
+ struct prop<point<Dim> >
+ {
+ enum {dim = Dim};
+ typedef dpoint<Dim> dpoint_type;
+ };
+
+} // oln
+
+#endif // ! OLENA_CORE_POINT_HH
Index: olena/oln/core/dpoint_nd.hh
--- olena/oln/core/dpoint_nd.hh Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
+++ olena/oln/core/dpoint_nd.hh Mon, 13 Sep 2004 21:58:13 +0200 van-vl_n
(oln/w/31_dpoint_nd. 644)
@@ -0,0 +1,44 @@
+// Copyright (C) 2004 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.
+
+#ifndef OLENA_CORE_DPOINT_HH
+# define OLENA_CORE_DPOINT_HH
+
+# include "abstract/dpoint.hh"
+
+namespace oln {
+
+ /// \class Concrete dpoint for dimension grater than 3.
+ template <unsigned Dim>
+ struct dpoint : public abstract::dpoint_nd<dpoint<Dim> >
+ {
+ };
+
+ template <unsigned Dim>
+ struct point; //fwd decl
+
+ template <unsigned Dim>
+ struct prop<dpoint<Dim> >
+ {
+ enum {dim = Dim};
+ typedef point<Dim> point_type;
+ };
+
+
+} // oln
+
+#endif // ! OLENA_CORE_DPOINT_HH
Index: olena/oln/core/abstract/point.hxx
--- olena/oln/core/abstract/point.hxx Mon, 13 Sep 2004 22:07:05 +0200
van-vl_n ()
+++ olena/oln/core/abstract/point.hxx Mon, 13 Sep 2004 21:58:47 +0200
van-vl_n (oln/w/32_point.hxx 644)
@@ -0,0 +1,133 @@
+// Copyright (C) 2004 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.
+
+
+namespace oln {
+ namespace abstract {
+
+ /// Give the value of the nth coordinate of the point.
+ template<class Exact>
+ coord point_nd<Exact>::nth_impl(const unsigned dim) const
+ {
+ assert(0 <= dim);
+ assert(dim < oln_dim_val(Exact));
+ return coord_[dim];
+ }
+
+ /// Return a reference to the nth coordinate of the point.
+ template<class Exact>
+ coord&
+ point_nd<Exact>::nth_impl(const unsigned dim)
+ {
+ assert(0 <= dim);
+ assert(dim < oln_dim_val(Exact));
+ return coord_[dim];
+ }
+
+
+ /// Add a delta point \a dp to the current point
+ template<class Exact>
+ Exact &
+ point_nd<Exact>::op_plus_assign_impl(const oln_dpoint_type(Exact)& dp)
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ coord_[dim] += dp.nth(dim);
+ return this->exact();
+ }
+
+ /// Subtract a delta point \a dp from the current point.
+ template<class Exact>
+ Exact&
+ point_nd<Exact>::op_minus_assign_impl(const oln_dpoint_type(Exact) &dp)
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ coord_[dim] -= dp.nth(dim);
+ return this->exact();
+ }
+
+ /// Subtract a point \a p from the current point.
+ template<class Exact>
+ oln_dpoint_type(Exact)
+ point_nd<Exact>::op_minus_impl(const Exact &p) const
+ {
+ oln_dpoint_type(Exact) res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = coord_[dim] - p.nth(dim);
+ return res;
+ }
+
+
+ /// Addition of a delta point \a dp and the current point.
+ template<class Exact>
+ Exact
+ point_nd<Exact>::op_plus_impl(const oln_dpoint_type(Exact) &dp) const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = coord_[dim] + dp.nth(dim);
+ return res;
+ }
+
+
+ /// Subtraction of a delta point \a dp and the current point.
+ template<class Exact>
+ Exact
+ point_nd<Exact>::op_minus_impl(const oln_dpoint_type(Exact) &dp) const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = coord_[dim] - dp.nth(dim);
+ return res;
+ }
+
+
+ /// Opposite of the current point coordinates
+ template<class Exact>
+ Exact
+ point_nd<Exact>::op_minus_impl() const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = - coord_[dim];
+ return res;
+ }
+
+ /// Points equal.
+ template<class Exact>
+ bool
+ point_nd<Exact>::op_equal_impl(const Exact &p) const
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ if (coord_[dim] != p.nth(dim))
+ return false;
+ return true;
+ }
+
+
+ /// Points not equal.
+ template<class Exact>
+ bool
+ point_nd<Exact>::op_not_equal_impl(const Exact &p) const
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ if (coord_[dim] == p.nth(dim))
+ return true;
+ return false;
+ }
+ } // end namespace abstract
+} // end namespace abstract
+
Index: olena/oln/core/abstract/dpoint.hxx
--- olena/oln/core/abstract/dpoint.hxx Mon, 13 Sep 2004 22:07:05 +0200
van-vl_n ()
+++ olena/oln/core/abstract/dpoint.hxx Mon, 13 Sep 2004 21:58:47 +0200
van-vl_n (oln/w/33_dpoint.hxx 644)
@@ -0,0 +1,120 @@
+// Copyright (C) 2004 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.
+
+
+namespace oln {
+ namespace abstract {
+
+ /// Give the value of the nth coordinate of the dpoint.
+ template<class Exact>
+ coord dpoint_nd<Exact>::nth_impl(const unsigned dim) const
+ {
+ assert(0 <= dim);
+ assert(dim < oln_dim_val(Exact));
+ return coord_[dim];
+ }
+
+ /// Return a reference to the nth coordinate of the dpoint.
+ template<class Exact>
+ coord&
+ dpoint_nd<Exact>::nth_impl(const unsigned dim)
+ {
+ assert(0 <= dim);
+ assert(dim < oln_dim_val(Exact));
+ return coord_[dim];
+ }
+
+
+ /// Add a delta dpoint \a dp to the current dpoint
+ template<class Exact>
+ Exact &
+ dpoint_nd<Exact>::op_plus_assign_impl(const Exact &dp)
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ coord_[dim] += dp.nth(dim);
+ return this->exact();
+ }
+
+ /// Subtract a delta dpoint \a dp from the current dpoint.
+ template<class Exact>
+ Exact&
+ dpoint_nd<Exact>::op_minus_assign_impl(const Exact &dp)
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ coord_[dim] -= dp.nth(dim);
+ return this->exact();
+ }
+
+ /// Subtract a dpoint \a p from the current dpoint.
+ template<class Exact>
+ Exact
+ dpoint_nd<Exact>::op_minus_impl(const Exact &p) const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = coord_[dim] - p.nth(dim);
+ return res;
+ }
+
+
+ /// Subtract a dpoint \a p from the current dpoint.
+ template<class Exact>
+ Exact
+ dpoint_nd<Exact>::op_plus_impl(const Exact &p) const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = coord_[dim] + p.nth(dim);
+ return res;
+ }
+
+ /// Opposite of the current dpoint coordinates
+ template<class Exact>
+ Exact
+ dpoint_nd<Exact>::op_minus_impl() const
+ {
+ Exact res;
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ res.nth(dim) = - coord_[dim];
+ return res;
+ }
+
+ /// Dpoints equal.
+ template<class Exact>
+ bool
+ dpoint_nd<Exact>::op_equal_impl(const Exact &p) const
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ if (coord_[dim] != p.nth(dim))
+ return false;
+ return true;
+ }
+
+
+ /// Dpoints not equal.
+ template<class Exact>
+ bool
+ dpoint_nd<Exact>::op_not_equal_impl(const Exact &p) const
+ {
+ for(unsigned dim = 0; dim < oln_dim_val(Exact); ++dim)
+ if (coord_[dim] == p.nth(dim))
+ return true;
+ return false;
+ }
+ } // end namespace abstract
+} // end namespace abstract
+
Index: olena/oln/core/dpoint1d.hxx
--- olena/oln/core/dpoint1d.hxx Wed, 06 Aug 2003 15:28:37 +0200 david
(oln/d/26_dpoint1d.h 1.8 600)
+++ olena/oln/core/dpoint1d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,110 +0,0 @@
-// Copyright (C) 2001, 2002, 2003 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_DPOINT1D_HXX
-# define OLENA_CORE_DPOINT1D_HXX
-
-# include <oln/core/point1d.hh>
-# include <iostream>
-
-namespace oln {
-
- inline coord
- dpoint1d::col() const
- {
- return nth(0);
- }
-
- inline coord&
- dpoint1d::col()
- {
- return nth(0);
- }
-
- inline
- dpoint1d::dpoint1d()
- {
- col() = 0;
- }
-
- inline
- dpoint1d::dpoint1d(coord c)
- {
- col() = c;
- }
-
- inline
- dpoint1d::dpoint1d(const point1d& p) : super_type(p)
- {
- }
-
- inline dpoint1d
- dpoint1d::minus() const
- {
- dpoint1d dp(-col());
- return dp;
- }
-
- inline dpoint1d&
- dpoint1d::plus_assign_dp(const dpoint1d& dp)
- {
- col() += dp.col();
- return *this;
- }
-
- inline dpoint1d&
- dpoint1d::minus_assign_dp(const dpoint1d& dp)
- {
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint1d
- dpoint1d::plus_dp(const dpoint1d& dp) const
- {
- dpoint1d tmp = *this;
- tmp += dp;
- return tmp;
- }
-
- inline dpoint1d
- dpoint1d::minus_dp(const dpoint1d& dp) const
- {
- dpoint1d tmp = *this;
- tmp -= dp;
- return tmp;
- }
-
-} // end of oln
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint1d& dp)
-{
- return o << '(' << dp.col() << ')';
-}
-
-#endif // ! OLENA_CORE_DPOINT1D_HXX
Index: olena/oln/core/dpoint2d.hxx
--- olena/oln/core/dpoint2d.hxx Mon, 28 Jul 2003 09:21:59 +0200 david
(oln/d/24_dpoint2d.h 1.6 600)
+++ olena/oln/core/dpoint2d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,126 +0,0 @@
-// Copyright (C) 2001, 2002 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_DPOINT2D_HXX
-# define OLENA_CORE_DPOINT2D_HXX
-
-# include <oln/core/point2d.hh>
-# include <iostream>
-
-namespace oln {
-
- inline coord
- dpoint2d::row() const
- {
- return nth(0);
- }
-
- inline coord&
- dpoint2d::row()
- {
- return nth(0);
- }
-
- inline coord
- dpoint2d::col() const
- {
- return nth(1);
- }
-
- inline coord&
- dpoint2d::col()
- {
- return nth(1);
- }
-
- inline
- dpoint2d::dpoint2d()
- {
- row() = 0;
- col() = 0;
- }
-
- inline
- dpoint2d::dpoint2d(coord r, coord c)
- {
- row() = r;
- col() = c;
- }
-
- inline
- dpoint2d::dpoint2d(const point2d& p) : super_type(p)
- {
- }
-
- inline dpoint2d
- dpoint2d::minus() const
- {
- dpoint2d dp(-row(), -col());
- return dp;
- }
-
- inline dpoint2d&
- dpoint2d::plus_assign_dp(const dpoint2d& dp)
- {
- row() += dp.row();
- col() += dp.col();
- return *this;
- }
-
- inline dpoint2d&
- dpoint2d::minus_assign_dp(const dpoint2d& dp)
- {
- row() -= dp.row();
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint2d
- dpoint2d::plus_dp(const dpoint2d& dp) const
- {
- dpoint2d tmp = *this;
- tmp += dp;
- return tmp;
- }
-
- inline dpoint2d
- dpoint2d::minus_dp(const dpoint2d& dp) const
- {
- dpoint2d tmp = *this;
- tmp -= dp;
- return tmp;
- }
-
-} // end of oln
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint2d& dp)
-{
- return o << '(' << dp.row() << ',' << dp.col() << ')';
-}
-
-#endif // ! OLENA_CORE_DPOINT2D_HXX
Index: olena/oln/core/dpoint3d.hxx
--- olena/oln/core/dpoint3d.hxx Mon, 28 Jul 2003 09:21:59 +0200 david
(oln/d/22_dpoint3d.h 1.6 600)
+++ olena/oln/core/dpoint3d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,142 +0,0 @@
-// Copyright (C) 2001, 2002 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_DPOINT3D_HXX
-# define OLENA_CORE_DPOINT3D_HXX
-
-# include <oln/core/point3d.hh>
-# include <iostream>
-
-namespace oln {
-
- inline coord
- dpoint3d::slice() const
- {
- return nth(0);
- }
-
- inline coord&
- dpoint3d::slice()
- {
- return nth(0);
- }
-
- inline coord
- dpoint3d::row() const
- {
- return nth(1);
- }
-
- inline coord&
- dpoint3d::row()
- {
- return nth(1);
- }
-
- inline coord
- dpoint3d::col() const
- {
- return nth(2);
- }
-
- inline coord&
- dpoint3d::col()
- {
- return nth(2);
- }
-
- inline
- dpoint3d::dpoint3d()
- {
- slice() = 0;
- row() = 0;
- col() = 0;
- }
-
- inline
- dpoint3d::dpoint3d(coord s, coord r, coord c)
- {
- slice() = s;
- row() = r;
- col() = c;
- }
-
- inline
- dpoint3d::dpoint3d(const point3d& p) : super_type(p)
- {
- }
-
- inline dpoint3d
- dpoint3d::minus() const
- {
- dpoint3d dp(-slice(), -row(), -col());
- return dp;
- }
-
- inline dpoint3d&
- dpoint3d::plus_assign_dp(const dpoint3d& dp)
- {
- slice() += dp.slice();
- row() += dp.row();
- col() += dp.col();
- return *this;
- }
-
- inline dpoint3d&
- dpoint3d::minus_assign_dp(const dpoint3d& dp)
- {
- slice() -= dp.slice();
- row() -= dp.row();
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint3d
- dpoint3d::plus_dp(const dpoint3d& dp) const
- {
- dpoint3d tmp = *this;
- tmp += dp;
- return tmp;
- }
-
- inline dpoint3d
- dpoint3d::minus_dp(const dpoint3d& dp) const
- {
- dpoint3d tmp = *this;
- tmp -= dp;
- return tmp;
- }
-
-} // end of oln
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::dpoint3d& dp)
-{
- return o << '(' << dp.slice() << ',' << dp.row() << ',' << dp.col()
<< ')';
-}
-
-#endif // ! OLENA_CORE_DPOINT3D_HXX
Index: olena/oln/core/point1d.hxx
--- olena/oln/core/point1d.hxx Wed, 30 Jul 2003 14:05:25 +0200 burrus_n
(oln/c/31_point1d.hx 1.6 600)
+++ olena/oln/core/point1d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,112 +0,0 @@
-// Copyright (C) 2001, 2002, 2003 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_POINT1D_HXX
-# define OLENA_CORE_POINT1D_HXX
-
-# include <oln/core/dpoint1d.hh>
-# include <iostream>
-
-namespace oln {
-
- inline
- point1d::point1d()
- {
- nth(0) = 0;
- }
-
- inline
- point1d::point1d(coord col)
- {
- nth(0) = col;
- }
-
- inline coord
- point1d::col() const
- {
- return nth(0);
- }
-
- inline coord&
- point1d::col()
- {
- return nth(0);
- }
-
- inline point1d&
- point1d::plus_assign_dp(const dpoint1d& dp)
- {
- col() += dp.col();
- return *this;
- }
-
- inline point1d&
- point1d::minus_assign_dp(const dpoint1d& dp)
- {
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint1d
- point1d::minus_p(const point1d& p) const
- {
- dpoint1d dp(col() - p.col());
- return dp;
- }
-
- inline point1d
- point1d::plus_dp(const dpoint1d& dp) const
- {
- point1d p = *this;
- p += dp;
- return p;
- }
-
- inline point1d
- point1d::minus_dp(const dpoint1d& dp) const
- {
- point1d p = *this;
- p -= dp;
- return p;
- }
-
- inline point1d
- point1d::minus() const
- {
- point1d p(-col());
- return p;
- }
-
-} // end of oln
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point1d& p)
-{
- return o << '(' << p.col() << ')';
-}
-
-#endif // ! OLENA_CORE_POINT1D_HXX
Index: olena/oln/core/point2d.hxx
--- olena/oln/core/point2d.hxx Sun, 11 Apr 2004 19:23:53 +0200 thivol_d
(oln/c/29_point2d.hx 1.8 600)
+++ olena/oln/core/point2d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,141 +0,0 @@
-// Copyright (C) 2001, 2002, 2004 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_POINT2D_HXX
-# define OLENA_CORE_POINT2D_HXX
-
-# include <oln/core/point1d.hh>
-# include <oln/core/dpoint2d.hh>
-# include <iostream>
-
-
-namespace oln {
-
- inline
- point2d::point2d()
- {
- nth(0) = 0;
- nth(1) = 0;
- }
-
- inline
- point2d::point2d(coord row, coord col)
- {
- nth(0) = row;
- nth(1) = col;
- }
-
- inline
- point2d::point2d(const point1d& p, coord row)
- {
- nth(0) = row;
- nth(1) = p.col();
- }
-
- inline coord
- point2d::row() const
- {
- return nth(0);
- }
-
- inline coord&
- point2d::row()
- {
- return nth(0);
- }
-
- inline coord
- point2d::col() const
- {
- return nth(1);
- }
-
- inline coord&
- point2d::col()
- {
- return nth(1);
- }
-
- inline point2d&
- point2d::plus_assign_dp(const dpoint2d& dp)
- {
- row() += dp.row();
- col() += dp.col();
- return *this;
- }
-
- inline point2d&
- point2d::minus_assign_dp(const dpoint2d& dp)
- {
- row() -= dp.row();
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint2d
- point2d::minus_p(const point2d& p) const
- {
- dpoint2d dp(row() - p.row(), col() - p.col());
- return dp;
- }
-
- inline point2d
- point2d::plus_dp(const dpoint2d& dp) const
- {
- point2d p = *this;
- p += dp;
- return p;
- }
-
- inline point2d
- point2d::minus_dp(const dpoint2d& dp) const
- {
- point2d p = *this;
- p -= dp;
- return p;
- }
-
- inline point2d
- point2d::minus() const
- {
- point2d p(-row(), -col());
- return p;
- }
-
-
-} // end of oln
-
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point2d& p)
-{
- return o << '(' << p.row() << ',' << p.col() << ')';
-}
-
-
-
-#endif // ! OLENA_CORE_POINT2D_HXX
Index: olena/oln/core/point3d.hxx
--- olena/oln/core/point3d.hxx Sun, 11 Apr 2004 19:23:53 +0200 thivol_d
(oln/c/27_point3d.hx 1.7 600)
+++ olena/oln/core/point3d.hxx Mon, 13 Sep 2004 22:07:05 +0200 van-vl_n ()
@@ -1,160 +0,0 @@
-// Copyright (C) 2001, 2002, 2004 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_POINT3D_HXX
-# define OLENA_CORE_POINT3D_HXX
-
-# include <oln/core/point2d.hh>
-# include <oln/core/dpoint3d.hh>
-# include <iostream>
-
-
-namespace oln {
-
-
- inline
- point3d::point3d()
- {
- nth(0) = 0;
- nth(1) = 0;
- nth(2) = 0;
- }
-
- inline
- point3d::point3d(coord slice, coord row, coord col)
- {
- nth(0) = slice;
- nth(1) = row;
- nth(2) = col;
- }
-
- inline
- point3d::point3d(const point2d& p, coord slice)
- {
- nth(0) = slice;
- nth(1) = p.row();
- nth(2) = p.col();
- }
-
- inline coord
- point3d::slice() const
- {
- return nth(0);
- }
-
- inline coord&
- point3d::slice()
- {
- return nth(0);
- }
-
- inline coord
- point3d::row() const
- {
- return nth(1);
- }
-
- inline coord&
- point3d::row()
- {
- return nth(1);
- }
-
- inline coord
- point3d::col() const
- {
- return nth(2);
- }
-
- inline coord&
- point3d::col()
- {
- return nth(2);
- }
-
- inline point3d&
- point3d::plus_assign_dp(const dpoint3d& dp)
- {
- slice() += dp.slice();
- row() += dp.row();
- col() += dp.col();
- return *this;
- }
-
- inline point3d&
- point3d::minus_assign_dp(const dpoint3d& dp)
- {
- slice() -= dp.slice();
- row() -= dp.row();
- col() -= dp.col();
- return *this;
- }
-
- inline dpoint3d
- point3d::minus_p(const point3d& p) const
- {
- dpoint3d dp(slice() - p.slice(),
- row() - p.row(),
- col() - p.col());
- return dp;
- }
-
- inline point3d
- point3d::plus_dp(const dpoint3d& dp) const
- {
- point3d p = *this;
- p += dp;
- return p;
- }
-
- inline point3d
- point3d::minus_dp(const dpoint3d& dp) const
- {
- point3d p = *this;
- p -= dp;
- return p;
- }
-
- inline point3d
- point3d::minus() const
- {
- point3d p(-slice(), -row(), -col());
- return p;
- }
-
-} // end of oln
-
-
-inline std::ostream&
-operator<<(std::ostream& o, const oln::point3d& p)
-{
- return o << '(' << p.slice() << ',' << p.row() << ',' << p.col() << ')';
-}
-
-
-
-#endif // ! OLENA_CORE_POINT3D_HXX
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* olena/oln/core/dpoint1d.hh: Correct type definition problems.
* olena/oln/core/abstract/dpoint.hh: Likewise.
* olena/oln/core/point_nd.hh: Likewise.
* olena/oln/core/dpoint_nd.hh: Likewise.
* olena/oln/core/macros.hh: Add new macros.
* olena/oln/core/neighborhood1d.hh: Restart from scratch.
* olena/oln/core/neighborhood2d.hh: Likewise.
* olena/oln/core/neighborhood3d.hh: Likewise.
* olena/oln/core/abstract/neighborhood.hh: Likewise.
* olena/oln/core/abstract/point.hh: Likewise.
* olena/oln/core/abstract/struct_elt.hh: Likewise.
* olena/oln/core/dim3d.hh: Likewise.
* olena/oln/core/dim2d.hh: Likewise.
* olena/oln/core/dim1d.hh: Likewise.
* olena/oln/core/abstract/dim.hh: Likewise.
* olena/oln/core/default_props.hh: New file. Definition of default
properties.
Index: olena/oln/core/dpoint1d.hh
--- olena/oln/core/dpoint1d.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/d/27_dpoint1d.h 1.14.2.1 600)
+++ olena/oln/core/dpoint1d.hh Tue, 14 Sep 2004 10:11:38 +0200 palma_g (oln/d/27_dpoint1d.h 1.14.2.1 600)
@@ -28,7 +28,8 @@
#ifndef OLENA_CORE_DPOINT1D_HH
# define OLENA_CORE_DPOINT1D_HH
-# include <oln/core/abstract/dpoint_nd.hh>
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/dpoint_nd.hh>
namespace oln {
Index: olena/oln/core/abstract/dpoint.hh
--- olena/oln/core/abstract/dpoint.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/d/28_dpoint.hh 1.20.2.1 600)
+++ olena/oln/core/abstract/dpoint.hh Tue, 14 Sep 2004 10:33:53 +0200 palma_g (oln/d/28_dpoint.hh 1.20.2.1 600)
@@ -24,8 +24,8 @@
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_ABSTRACT_DPOINT_HH
-# define OLENA_CORE_ABSTRACT_DPOINT_HH
+#ifndef OLN_CORE_ABSTRACT_DPOINT_HH
+# define OLN_CORE_ABSTRACT_DPOINT_HH
# include <mlc/type.hh>
# include <oln/core/coord.hh>
@@ -38,7 +38,7 @@
{
template<class Exact>
- struct prop; // fwd declaration
+ struct props; // fwd declaration
namespace abstract {
@@ -223,43 +223,43 @@
- namespace internal
- {
-
- /*! \class default_less< abstract::dpoint<Exact> >
- **
- ** The specialized version for abstract::dpoint.
- */
- template<class Exact>
- struct default_less< abstract::dpoint<Exact> >
- {
-
- /*! \brief Test if the coordinates of a dpoint l
- ** are not greater than the coordinates of a dpoint r.
- **
- ** \arg l A dpoint.
- **
- ** \arg r Another dpoint.
- **
- ** \return True if the coordinates of l are not greater
- ** than the coordinates of r.
- */
+// namespace internal
+// {
- bool operator()(const abstract::dpoint<Exact>& l,
- const abstract::dpoint<Exact>& r) const
- {
- for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
- if (l.nth(i) < r.nth(i))
- return true;
- else if (l.nth(i) > r.nth(i))
- return false;
- return false;
- }
- };
- } // internal
+// /*! \class default_less< abstract::dpoint<Exact> >
+// **
+// ** The specialized version for abstract::dpoint.
+// */
+// template<class Exact>
+// struct default_less< abstract::dpoint<Exact> >
+// {
+
+// /*! \brief Test if the coordinates of a dpoint l
+// ** are not greater than the coordinates of a dpoint r.
+// **
+// ** \arg l A dpoint.
+// **
+// ** \arg r Another dpoint.
+// **
+// ** \return True if the coordinates of l are not greater
+// ** than the coordinates of r.
+// */
+
+// bool operator()(const abstract::dpoint<Exact>& l,
+// const abstract::dpoint<Exact>& r) const
+// {
+// for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
+// if (l.nth(i) < r.nth(i))
+// return true;
+// else if (l.nth(i) > r.nth(i))
+// return false;
+// return false;
+// }
+// };
+// } // internal
} // end of oln
#include "dpoint.hxx"
-#endif // ! OLENA_CORE_ABSTRACT_DPOINT_HH
+#endif // ! OLN_CORE_ABSTRACT_DPOINT_HH
Index: olena/oln/core/macros.hh
--- olena/oln/core/macros.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/c/39_macros.hh 1.5.2.1 600)
+++ olena/oln/core/macros.hh Tue, 14 Sep 2004 11:39:32 +0200 palma_g (oln/c/39_macros.hh 1.5.2.1 600)
@@ -41,14 +41,27 @@
-# define oln_point_type(E) typename oln::prop<E>::point_type
-# define oln_point_type_(E) oln::prop<E>::point_type
+# define oln_point_type(E) typename oln::props<E>::point_type
+# define oln_point_type_(E) oln::props<E>::point_type
-# define oln_dpoint_type(E) typename oln::prop<E>::dpoint_type
-# define oln_dpoint_type_(E) oln::prop<E>::dpoint_type
+# define oln_dpoint_type(E) typename oln::props<E>::dpoint_type
+# define oln_dpoint_type_(E) oln::props<E>::dpoint_type
-# define oln_dim_val(E) oln::prop<E>::dim
-# define oln_dim_val_(E) oln::prop<E>::dim
+# define oln_dim_val(E) oln::props<E>::dim_value
+# define oln_dim_val_(E) oln::props<E>::dim_value
+
+# define oln_concrete_type(E) typename oln::props<E>::concrete_type
+# define oln_concrete_type_(E) oln::props<E>::concrete_type
+
+# define oln_neighborhood_type(E) typename oln::props<E>::neighborhood_type
+# define oln_neighborhood_type_(E) oln::props<E>::neighborhood_type
+
+# define oln_window_type(E) typename oln::props<E>::window_type
+# define oln_window_type_(E) oln::props<E>::window_type
+
+# define oln_flat_se_type(E) typename oln::props<E>::window_type
+# define oln_flat_se_type_(E) oln::props<E>::flat_se_type
+
#endif // OLENA_CORE_MACROS_HH
Index: olena/oln/core/neighborhood1d.hh
--- olena/oln/core/neighborhood1d.hh Fri, 13 Aug 2004 19:03:16 +0200 levill_r (oln/c/37_neighborho 1.20 600)
+++ olena/oln/core/neighborhood1d.hh Tue, 14 Sep 2004 12:39:29 +0200 palma_g (oln/c/37_neighborho 1.21 640)
@@ -1,12 +1,13 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
+// 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.
//
@@ -25,196 +26,44 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_NEIGHBORHOOD1D_HH
-# define OLENA_CORE_NEIGHBORHOOD1D_HH
+#ifndef OLN_CORE_NEIGHBORHOOD1D_HH
+# define OLN_CORE_NEIGHBORHOOD1D_HH
-# include <oln/core/abstract/neighborhoodnd.hh>
-# include <oln/core/winiter.hh>
-# include <oln/core/accum.hh>
-# include <oln/core/window1d.hh>
-# include <algorithm>
+# include <oln/core/dpoint1d.hh>
+# include <oln/core/neighborhood_nd.hh>
namespace oln {
- class neighborhood1d; // forward declaration
-
- /*!
- ** \brief Traits for neighborhood1d.
- */
template<>
- struct struct_elt_traits<neighborhood1d>: public
- struct_elt_traits<abstract::neighborhoodnd<neighborhood1d> >
- {
- enum { dim = 1 }; ///< Dimension.
- typedef point1d point_type; ///< Type of point.
- typedef dpoint1d dpoint_type; ///< Type of dpoint (move).
- typedef winiter< neighborhood1d > iter_type; ///< Type of iterator.
- typedef winneighb< neighborhood1d > neighb_type; ///< Type of neighbor.
- typedef window1d win_type; ///< Type of window.
- };
-
- /*!
- ** \brief Neighborhood 1 dimension.
- **
- ** It looks like structuring elements but here, when
- ** you add an element, you add its opposite.
- ** Points (dpoint) have 1 dimension.
- **
- */
- class neighborhood1d :
- public abstract::neighborhoodnd< neighborhood1d >
- {
- public:
-
- typedef abstract::neighborhoodnd< neighborhood1d > super_type;
- ///< Super type.
- typedef neighborhood1d self_type; ///< Self type.
-
- /*!
- ** \brief The associate image's type of iterator (move point).
- ** \warning Prefer the macros oln_iter_type(Pointable) and
- ** oln_iter_type_(Pointable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::iter_type iter_type;
- typedef struct_elt_traits< self_type >::neighb_type neighb_type;
-
- /*!
- ** \brief The associate image's type of dpoint (move point).
- ** \warning Prefer the macros oln_dpoint_type(Pointable) and
- ** oln_dpoint_type_(Pointable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::dpoint_type dpoint_type;
-
- friend class abstract::window_base<abstract::neighborhood<neighborhood1d>, neighborhood1d>;
-
- /*!
- ** \brief Add a dpoint (move point) to the neighborhood.
- ** \arg dp The new point.
- **
- ** Add a new member to the neighborhood. This point must be of 1
- ** dimension.
- */
- neighborhood1d&
- add(const dpoint_type& dp)
+ struct neighborhood<1> : public abstract::neighborhood_nd< neighborhood<1> >
{
- this->exact().add_(dp);
- return this->exact().add_(-dp);
- }
-
- /*!
- ** \brief Add a point by coordinates to the neighborhood.
- ** \arg col The coordinate of the new point (1 dimension).
- **
- ** Add a new member by its coordinates to the neighborhood.
- ** The coordinates are only the column number because the neighborhood has
- ** 1 dimension.
- */
- neighborhood1d&
- add(coord col)
- {
- return this->add(dpoint_type(col));
- }
+ typedef abstract::neighborhood_nd< neighborhood<1> > super;
- /*!
- ** \brief Construct a neighborhood of 1 dimension.
- */
- neighborhood1d() : super_type()
- {}
-
- /*!
- ** \brief Construct a neighborhood of 1 dimension.
- ** \arg size Reserve 'size' elements for the neighborhood.
- */
- neighborhood1d(unsigned size) : super_type(size)
- {}
-
- /*!
- ** \brief Construct a neighborhood of 1 dimension.
- ** \arg n Add 'n' elements to the neighborhood.
- ** \arg crd Coordinates of the 'n' elements.
- */
- neighborhood1d(unsigned n, const coord crd[]) : super_type()
+ neighborhood& add(coord index)
{
- for (unsigned i = 0; i < n; ++i)
- add(dpoint_type(crd[i]));
- }
-
- /// Return the name of the type.
- static std::string
- name()
- {
- return std::string("neighborhood1d");
- }
-
- protected:
-
- /*!
- ** \brief Update delta.
- ** \arg dp a move point.
- ** \return Delta.
- **
- ** If the point is the biggest element of the neighborhood,
- ** then this point is assigned to delta.
- */
- coord
- delta_update_(const dpoint_type& dp)
- {
- delta_(abs(dp.col()));
- return delta_;
+ // FIXME: below, "this->super::" is required for the call
+ // to "add" to be resolved!
+ return this->super::add(dpoint1d(index));
}
};
+ typedef neighborhood<1> neighborhood1d;
- // standard neighborhood
-
- /*!
- ** \brief Create a neighborhood (1 dimension) with 1 element : 1.
- ** \return The new neighborhood.
- */
- inline const neighborhood1d&
- neighb_c2()
+ const neighborhood1d c2()
{
- static const coord crd[] = { 1 };
- static const neighborhood1d neighb(1, crd);
- return neighb;
- }
-
- /*!
- ** \brief Create a neighborhood (1 dimension).
- ** \arg width The width.
- ** \return The new neighborhood.
- ** \pre width >= 3.
- ** \pre width % 2 == 1.
- **
- ** Add elements of coordinates 1, ..., width / 2.
- */
- inline neighborhood1d
- mk_neighb_segment(unsigned width)
+ static bool flower = true;
+ static neighborhood1d nbh;
+ if (flower)
{
- precondition(width>= 3 && (width % 2) == 1);
- neighborhood1d neighb(width);
- int half_ncols = width / 2;
- for (coord col = 1; col <= half_ncols; ++col)
- neighb.add(col);
- return neighb;
+ nbh.add(-1).add(1);
+ flower = false;
}
-
- /*!
- ** \brief Convert a neighborhood (1 dimension) to a window (1 dimension).
- ** \arg n The neighborhood to convert.
- ** \return The new window.
- */
- inline window1d
- mk_win_from_neighb(const neighborhood1d& n)
- {
- window1d win(n.card());
- for (unsigned i = 0; i < n.card(); ++i)
- win.add(n.dp(i));
- return win;
+ return nbh;
}
-} // end of oln
+} // end of namespace oln
+
-#endif // OLENA_CORE_NEIGHBORHOOD1D_HH
+#endif // ndef PROTO_OLN_CORE_NEIGHBORHOOD1D_HH
Index: olena/oln/core/neighborhood2d.hh
--- olena/oln/core/neighborhood2d.hh Fri, 13 Aug 2004 19:03:16 +0200 levill_r (oln/c/36_neighborho 1.22 600)
+++ olena/oln/core/neighborhood2d.hh Tue, 14 Sep 2004 12:39:40 +0200 palma_g (oln/c/36_neighborho 1.23 640)
@@ -1,12 +1,13 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
+// 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.
//
@@ -25,233 +26,56 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_NEIGHBORHOOD2D_HH
-# define OLENA_CORE_NEIGHBORHOOD2D_HH
+#ifndef OLN_CORE_NEIGHBORHOOD2D_HH
+# define OLN_CORE_NEIGHBORHOOD2D_HH
-# include <oln/core/abstract/neighborhoodnd.hh>
-# include <oln/core/winiter.hh>
-# include <oln/core/accum.hh>
-# include <oln/core/window2d.hh>
-# include <oln/io/readable.hh>
-# include <algorithm>
+# include <oln/core/neighborhood_nd.hh>
+# include <oln/core/dpoint2d.hh>
-namespace oln {
- class neighborhood2d; // forward declaration
+namespace oln {
- /*!
- ** \brief Traits for neighborhood2d.
- */
template<>
- struct struct_elt_traits<neighborhood2d>: public
- struct_elt_traits<abstract::neighborhoodnd<neighborhood2d> >
- {
- enum { dim = 2 }; ///< Dimension.
- typedef point2d point_type; ///< Type of point.
- typedef dpoint2d dpoint_type; ///< Type of dpoint (move).
- typedef winiter< neighborhood2d > iter_type; ///< Type of iterator.
- typedef winneighb< neighborhood2d > neighb_type; ///< Type of neighbor.
- typedef window2d win_type; ///< Type of window.
- };
-
- /*!
- ** \brief Neighborhood 2 dimensions.
- **
- ** It looks like structuring elements but here, when
- ** you add an element, you add its opposite.
- ** Points have 2 dimensions.
- **
- */
- class neighborhood2d :
- public abstract::neighborhoodnd< neighborhood2d >
+ struct neighborhood<2> : public abstract::neighborhood_nd< neighborhood<2> >
{
- public:
-
- typedef abstract::neighborhoodnd< neighborhood2d > super_type;
- ///< Super type.
- typedef neighborhood2d self_type; ///< Self type.
-
- /*!
- ** \brief The associate image's type of iterator.
- ** \warning Prefer the macros oln_iter_type(Iterable) and
- ** oln_iter_type_(Iterable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::iter_type iter_type;
-
- typedef struct_elt_traits< self_type >::neighb_type neighb_type;
-
- /*!
- ** \brief The associate image's type of dpoint (move point).
- ** \warning Prefer the macros oln_dpoint_type(Pointable) and
- ** oln_dpoint_type_(Pointable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::dpoint_type dpoint_type;
-
- friend class abstract::window_base<abstract::neighborhood<neighborhood2d>, neighborhood2d>;
-
- /*!
- ** \brief Add a dpoint (move point) to the neighborhood.
- ** \arg dp The new point.
- **
- ** Add a new member to the neighborhood. This point must be of 2
- ** dimensions.
- */
- neighborhood2d&
- add(const dpoint_type& dp)
+ neighborhood& add(coord row, coord col)
{
- this->exact().add_(dp);
- return this->exact().add_(-dp);
+ // FIXME: below, "this->super::" is required for the call
+ // to "add" to be resolved!
+ return this->add(dpoint2d(row, col));
}
- /*!
- ** \brief Add a point by coordinates to the neighborhood.
- ** \arg row The coordinates of the new point.
- ** \arg col The coordinates of the new point.
- **
- ** Add a new member by its coordinates to the neighborhood.
- ** The coordinates have 2 dimensions.
- */
- neighborhood2d&
- add(coord row, coord col)
- {
- return this->add(dpoint_type(row, col));
- }
+ };
- /*!
- ** \brief Construct a neighborhood of 2 dimensions.
- */
- neighborhood2d() : super_type()
- {}
-
- /*!
- ** \brief Construct a neighborhood of 2 dimensions.
- ** \arg size Reserve 'size' elements for the neighborhood.
- */
- neighborhood2d(unsigned size) : super_type(size)
- {}
-
- /*!
- ** \brief Construct a neighborhood of 2 dimensions.
- ** \arg n Add 'n' elements to the neighborhood.
- ** \arg crd Coordinates of the 'n' elements.
- */
- neighborhood2d(unsigned n, const coord crd[]) : super_type(n)
- {
- for (unsigned i = 0; i < 2 * n; i += 2)
- add(dpoint_type(crd[i], crd[i+1]));
- }
+ typedef neighborhood<2> neighborhood2d;
- // Constructor used in io functions.
- neighborhood2d(const io::internal::anything& r) : super_type()
+ const neighborhood2d c4()
{
- r.assign(*this);
- }
-
- /// Return the name of the type.
- static std::string
- name()
+ static bool flower = true;
+ static neighborhood2d nbh;
+ if (flower)
{
- return std::string("neighborhood2d");
+ nbh.add(-1,0).add(0,-1).add(0,1).add(1,0);
+ flower = false;
}
-
- protected:
-
- /*!
- ** \brief Update delta.
- ** \arg dp a deplacement point.
- ** \return Delta.
- **
- ** If the point is the biggest element of the neighborhood,
- ** then this point is assigned to delta.
- */
- coord
- delta_update_(const dpoint_type& dp)
- {
- delta_(abs(dp.row()));
- delta_(abs(dp.col()));
- return delta_;
+ return nbh;
}
- };
-
- // std neighbs
-
- /*!
- ** \brief Create a neighborhood (2 dimension) with 0,1, 1,0.
- ** \return The new neighborhood.
- */
- inline const neighborhood2d&
- neighb_c4()
+ const neighborhood2d c8()
{
- static const coord crd[] = { 0,1, 1,0 };
- static const neighborhood2d neighb(2, crd);
- return neighb;
- }
-
-
- /*!
- ** \brief Create a neighborhood (2 dimension) with 4 coordinates:
- ** 0,1, 1,1, 1,0, 1,-1.
- ** \return The new neighborhood.
- */
- inline const neighborhood2d&
- neighb_c8()
+ static bool flower = true;
+ static neighborhood2d nbh;
+ if (flower)
{
- static const coord crd[] = { 0,1, 1,1, 1,0, 1,-1 };
- static const neighborhood2d neighb(4, crd);
- return neighb;
+ nbh = c4();
+ nbh.add(-1,-1).add(-1,1).add(1,-1).add(1,1);
+ flower = false;
}
-
- // mk_neighb's
-
- /*!
- ** \brief Create a rectangular neighborhood (2 dimensions).
- ** \arg nrows Number of row.
- ** \arg ncols Number of column.
- ** \return The new neighborhood (2d).
- ** \pre nrows >= 3.
- ** \pre nrows % 2 == 1.
- ** \pre ncols >= 3.
- ** \pre ncols % 2 == 1.
- */
- inline neighborhood2d
- mk_neighb_rectangle(unsigned nrows, unsigned ncols)
- {
- precondition(nrows >= 3 && (nrows % 2) == 1);
- precondition(ncols >= 3 && (ncols % 2) == 1);
- neighborhood2d neighb(nrows * ncols);
- int half_nrows = nrows / 2, half_ncols = ncols / 2;
- for (coord row = - half_nrows; row <= half_nrows; ++row)
- for (coord col = (row <= 0)? 1 : 0; col <= half_ncols; ++col)
- neighb.add(row, col);
- return neighb;
+ return nbh;
}
- /*!
- ** \brief Create a square neighborhood (2 dimensions).
- ** \arg width Number of colunm and row.
- ** \return The new neighborhood (2d).
- */
- inline neighborhood2d
- mk_neighb_square(unsigned width)
- {
- return mk_neighb_rectangle(width, width);
- }
- /*!
- ** \brief Convert a neighborhood (2 dimensions) to a window (2 dimensions).
- ** \arg n The neighborhood to convert.
- ** \return The new window.
- */
- inline window2d
- mk_win_from_neighb(const neighborhood2d& n)
- {
- window2d win(n.card());
- for (unsigned i = 0; i < n.card(); ++i)
- win.add(n.dp(i));
- return win;
- }
+} // end of namespace oln
-} // end of oln
-#endif // OLENA_CORE_NEIGHBORHOOD2D_HH
+#endif // ndef PROTO_OLN_CORE_NEIGHBORHOOD2D_HH
Index: olena/oln/core/neighborhood3d.hh
--- olena/oln/core/neighborhood3d.hh Fri, 13 Aug 2004 19:03:16 +0200 levill_r (oln/c/35_neighborho 1.21 600)
+++ olena/oln/core/neighborhood3d.hh Tue, 14 Sep 2004 12:40:28 +0200 palma_g (oln/c/35_neighborho 1.21 640)
@@ -1,12 +1,13 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
+// 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.
//
@@ -28,105 +29,24 @@
#ifndef OLENA_CORE_NEIGHBORHOOD3D_HH
# define OLENA_CORE_NEIGHBORHOOD3D_HH
-# include <oln/core/abstract/neighborhoodnd.hh>
-# include <oln/core/winiter.hh>
-# include <oln/core/accum.hh>
-# include <oln/core/window3d.hh>
-# include <algorithm>
+
+# include <oln/core/neighborhood_nd.hh>
+# include <oln/core/dpoint2d.hh>
namespace oln {
- class neighborhood3d; // forward declaration
- /*!
- ** \brief Traits for neighborhood3d.
- */
template<>
- struct struct_elt_traits<neighborhood3d>: public
- struct_elt_traits<abstract::neighborhoodnd<neighborhood3d> >
- {
- enum { dim = 3 }; ///< Dimension.
- typedef point3d point_type; ///< Type of point.
- typedef dpoint3d dpoint_type; ///< Type of dpoint (move).
- typedef winiter< neighborhood3d > iter_type; ///< Type of iterator.
- typedef winneighb< neighborhood3d > neighb_type; ///< Type of neighbor.
- typedef window3d win_type; ///< Type of window.
- };
-
- /*!
- ** \brief Neighborhood 3 dimensions.
- **
- ** It looks like structuring elements but here, when
- ** you add an element, you add its opposite.
- ** Points have 3 dimensions.
- **
- */
- class neighborhood3d :
- public abstract::neighborhoodnd< neighborhood3d >
- {
- public:
-
- typedef abstract::neighborhoodnd< neighborhood3d > super_type;
- ///< Super type.
- typedef neighborhood3d self_type; ///< Self type.
-
- /*!
- ** \brief The associate image's type of iterator.
- ** \warning Prefer the macros oln_iter_type(Iterable) and
- ** oln_iter_type_(Iterable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::iter_type iter_type;
- typedef struct_elt_traits< self_type >::neighb_type neighb_type;
-
- /*!
- ** \brief The associate image's type of dpoint (move point).
- ** \warning Prefer the macros oln_dpoint_type(Pointable) and
- ** oln_dpoint_type_(Pointable) (the same without the 'typename' keyword)
- */
- typedef struct_elt_traits< self_type >::dpoint_type dpoint_type;
-
- friend class abstract::window_base<abstract::neighborhood<neighborhood3d>, neighborhood3d>;
-
- /*!
- ** \brief Add a dpoint (move point) to the neighborhood.
- ** \arg dp The new point.
- **
- ** Add a new member to the neighborhood. This point must be of 3
- ** dimensions.
- */
- neighborhood3d&
- add(const dpoint_type& dp)
+ struct neighborhood<3> : public abstract::neighborhood_nd< neighborhood<3> >
{
- this->exact().add_(dp);
- return this->exact().add_(-dp);
- }
-
- /*!
- ** \brief Add a point by coordinates to the neighborhood.
- ** \arg slice The coordinates of the new point.
- ** \arg row The coordinates of the new point.
- ** \arg col The coordinates of the new point.
- **
- ** Add a new member by its coordinates to the neighborhood.
- ** The coordinates have 3 dimensions.
- */
- neighborhood3d&
- add(coord slice, coord row, coord col)
+ neighborhood& add(coord slice, coord row, coord col)
{
return this->add(dpoint3d(slice, row, col));
}
-
/*!
** \brief Construct a neighborhood of 3 dimensions.
*/
- neighborhood3d() : super_type()
- {}
-
- /*!
- ** \brief Construct a neighborhood of 3 dimensions.
- ** \arg size Reserve 'size' elements for the neighborhood.
- */
- neighborhood3d(unsigned size) : super_type(size)
+ neighborhood()
{}
/*!
@@ -134,40 +54,15 @@
** \arg n Add 'n' elements to the neighborhood.
** \arg crd Coordinates of the 'n' elements.
*/
- neighborhood3d(unsigned n, const coord crd[]) : super_type()
+ neighborhood(unsigned n, const coord crd[]) : super_type()
{
for (unsigned i = 0; i < 3 * n; i += 3)
- add(dpoint_type(crd[i], crd[i+1], crd[i+2]));
+ add(crd[i], crd[i+1], crd[i+2]);
}
-
- /// Return the name of the type.
- static std::string
- name()
- {
- return std::string("neighborhood3d");
- }
-
- protected:
-
- /*!
- ** \brief Update delta.
- ** \arg dp a deplacement point.
- ** \return Delta.
- **
- ** If the point is the biggest element of the neighborhood,
- ** then this point is assigned to delta.
- */
- coord
- delta_update_(const dpoint_type& dp)
- {
- delta_(abs(dp.slice()));
- delta_(abs(dp.row()));
- delta_(abs(dp.col()));
- return delta_;
- }
-
};
+ typedef neighborhood<3> neighborhood3d;
+
// std neighb
/*!
Index: olena/oln/core/abstract/neighborhood.hh
--- olena/oln/core/abstract/neighborhood.hh Mon, 29 Mar 2004 09:53:11 +0200 odou_s (oln/c/38_neighborho 1.23 600)
+++ olena/oln/core/abstract/neighborhood.hh Tue, 14 Sep 2004 12:41:25 +0200 palma_g (oln/c/38_neighborho 1.24 640)
@@ -1,12 +1,13 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
+// 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.
//
@@ -25,254 +26,55 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
-# define OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#ifndef OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+# define OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
-# include <mlc/type.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/struct_elt.hh>
+#include <oln/core/abstract/dpoint_set.hh>
+#include <oln/core/abstract/flat_se.hh>
namespace oln {
namespace abstract {
- template<class Exact>
- struct neighborhood; // forward declaration
- } // end of abstract
- /*!
- ** \brief Traits for abstract::neighborhood.
- */
- template<class Exact>
- struct struct_elt_traits<abstract::neighborhood<Exact> >
- {
- typedef abstract::neighborhood<Exact> abstract_type;
- };
-
- namespace abstract
- {
-
- /*!
- **
- ** \brief Neighborhood.
- **
- ** It looks like structuring elements but here, when
- ** you add an element, you add its opposite.
- ** This abstract class defines several virtual methods for his
- ** subclasses. Its goal is to deal with a set of deplacement points.
- **
- */
- template<class Exact>
- struct neighborhood : public mlc_hierarchy::any<Exact>
- {
- typedef Exact exact_type; ///< Set the exact type.
- typedef neighborhood<Exact> self_type; ///< Set its type.
-
- /*!
- ** \brief The associate image's type of iterator.
- ** \warning Prefer the macros oln_iter_type(Iterable) and
- ** oln_iter_type_(Iterable) (the same without the 'typename' keyword)
- */
- typedef typename struct_elt_traits<Exact>::iter_type iter_type;
-
- typedef typename struct_elt_traits<Exact>::neighb_type neighb_type;
- ///< Set the neighborhood type.
- typedef typename struct_elt_traits<Exact>::win_type win_type;
- ///< Set the window type.
-
- /*!
- ** \brief The associate image's type of dpoint (move point).
- ** \warning Prefer the macros oln_dpoint_type(Pointable) and
- ** oln_dpoint_type_(Pointable) (the same without the 'typename' keyword)
- */
- typedef typename struct_elt_traits<Exact>::dpoint_type dpoint_type;
-
- typedef typename struct_elt_traits<Exact>::abstract_type abstract_type;
- ///< Set the abstract type.
-
- enum { dim = struct_elt_traits<Exact>::dim };
- ///< Set the dim of the points of the neighborhood.
-
- /// Return the name of the type.
- static std::string
- name()
+ template <typename E>
+ struct neighborhood: public dpoint_set<E>
{
- return std::string("neighborhood<") + Exact::name() + ">";
- }
-
- /*!
- ** \brief Test if the set of points contains this one.
- ** \arg dp a dpoint (deplacement point).
- ** \return True if the set of points contains this dpoint.
- */
- bool
- has(const abstract::dpoint<dpoint_type>& dp) const
- {
- return this->exact().has_(dp.exact());
- }
-
- /*!
- ** \brief Get the number of points.
- ** \return The number of points.
- */
- unsigned
- card() const
- {
- return this->exact().card_();
- }
-
- /*!
- ** \brief Test if the neighborhood is centered.
- ** \return True if it's centered.
- **
- ** Neighborhood are centered when they contains at least one
- ** element.
- */
- bool
- is_centered() const
- {
- return this->exact().is_centered_();
- }
-
- /*!
- ** \brief Get the nth element of the neighborhood.
- ** \arg i The nth.
- ** \return The nth dpoint.
- */
- const dpoint_type
- dp(unsigned i) const
- {
- return this->exact()[i];
- }
-
- /*!
- ** \brief Compare two sets of structuring elements.
- ** \arg win The structuring elements to compare.
- ** \return True if they are the same.
- */
- bool
- operator==(const self_type& win) const
- {
- return this->exact().is_equal(win.exact());
- }
-
- /*!
- ** \brief Get the delta of the neighborhood.
- ** \return Delta.
- **
- ** Delta is the biggest element of the neighborhood.
- */
- coord
- delta() const
- {
- return this->exact().get_delta();
- }
-
- /*!
- ** \brief Get the nth element of the neighborhood.
- ** \arg i The nth.
- ** \return The nth dpoint.
- */
- const dpoint_type
- operator[](unsigned i) const
- {
- return this->exact().at(i);
- }
-
/*!
** \brief Add a point to the neighborhood.
** \arg dp The new point.
+ ** \pre !dp.is_centered().
**
** Add a new member to the neighborhood.
*/
- exact_type&
- add(const abstract::dpoint<dpoint_type>& dp)
+ E& add_impl(const oln_dpoint_type(E)& dp)
{
- this->exact().add_(dp.exact());
- return this->exact().add_(-dp.exact());
+ precondition(!dp.is_centered());
+ this->sdps_.insert(dp);
+ this->sdps_.insert(-dp);
+ this->change_ = true;
+ return this->exact();
}
-
- // obsolete
-// exact_type
-// operator-() const
-// {
-// return this->exact();
-// }
-
- protected:
-
- /*!
- ** \brief Set neighborhood to opposite.
- **
- ** Each point of neighborhood is assigned to its opposite.
- **
- */
- void
- sym()
- {
- this->exact().sym_();
- }
-
- /*!
- ** \brief Do nothing, used only by sub-classes
- */
- neighborhood()
- {}
- };
-
- } // end of abstract
-
- /*!
- ** \brief Compute intersection between two neighborhood
- */
- template<class E>
- inline E
- inter(const abstract::neighborhood<E> &lhs,
- const abstract::neighborhood<E> &rhs)
+ const oln_flat_se_type(E) flat_se() const
{
- E neighb;
- for (unsigned j = 0; j < rhs.card(); ++j)
- if (lhs.has(rhs.dp(j)) && ! neighb.has(rhs.dp(j)))
- neighb.add(rhs.dp(j));
- return neighb;
+ oln_flat_se_type(E) win;
+ win.clone(*this);
+ return win;
}
- /*!
- ** \brief Compute union between two neighborhood
- */
- template<class E>
- inline E
- uni(const abstract::neighborhood<E> &lhs,
- const abstract::neighborhood<E> &rhs)
+ // backward compatibility
+ const oln_window_type(E) window() const
{
- E neighb;
- for (unsigned j = 0; j < rhs.card(); ++j)
- if (! neighb.has(rhs.dp(j)))
- neighb.add(rhs.dp(j));
- for (unsigned j = 0; j < lhs.card(); ++j)
- if (! neighb.has(lhs.dp(j)))
- neighb.add(lhs.dp(j));
- return neighb;
+ return flat_se();
}
- /*!
- ** \brief Construct a window from a neighborhood.
- */
- template<class E>
- inline typename struct_elt_traits<E>::win_type
- mk_win_from_neighb(const abstract::neighborhood<E>& n)
- {
- typename struct_elt_traits<E>::win_type win(n.card());
- for (unsigned i = 0; i < n.card(); ++i)
- win.add(n.dp(i));
- return win;
- }
-
-# define oln_neighb_type(Neighbable) \
-typename Neighbable::neighb_type
+ protected:
+ neighborhood() {}
+ };
+ } // end of namespace abstract
-} // end of oln
+} // end of namespace oln
-#endif // OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#endif // !OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
Index: olena/oln/core/abstract/point.hh
--- olena/oln/core/abstract/point.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/c/33_point.hh 1.16.2.1 600)
+++ olena/oln/core/abstract/point.hh Tue, 14 Sep 2004 10:02:23 +0200 palma_g (oln/c/33_point.hh 1.16.2.1 600)
@@ -236,40 +236,40 @@
- namespace internal
- {
+// namespace internal
+// {
- /*! \class default_less< abstract::point<Exact> >
- **
- ** The specialized version for abstract::point.
- */
- template<class Exact>
- struct default_less< abstract::point<Exact> >
- {
-
- /*! \brief Test if the coordinates of a point l
- ** are not greater than the coordinates of a point r.
- **
- ** \arg l A point.
- **
- ** \arg r Another point.
- **
- ** \return True if the coordinates of l are not greater
- ** than the coordinates of r.
- */
-
- bool operator()(const abstract::point<Exact>& l,
- const abstract::point<Exact>& r) const
- {
- for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
- if (l.nth(i) < r.nth(i))
- return true;
- else if (l.nth(i) > r.nth(i))
- return false;
- return false;
- }
- };
- } // internal
+// /*! \class default_less< abstract::point<Exact> >
+// **
+// ** The specialized version for abstract::point.
+// */
+// template<class Exact>
+// struct default_less< abstract::point<Exact> >
+// {
+
+// /*! \brief Test if the coordinates of a point l
+// ** are not greater than the coordinates of a point r.
+// **
+// ** \arg l A point.
+// **
+// ** \arg r Another point.
+// **
+// ** \return True if the coordinates of l are not greater
+// ** than the coordinates of r.
+// */
+
+// bool operator()(const abstract::point<Exact>& l,
+// const abstract::point<Exact>& r) const
+// {
+// for (unsigned i = 0; i < oln_dim_val(Exact); ++i)
+// if (l.nth(i) < r.nth(i))
+// return true;
+// else if (l.nth(i) > r.nth(i))
+// return false;
+// return false;
+// }
+// };
+// } // internal
} // end of oln
Index: olena/oln/core/abstract/struct_elt.hh
--- olena/oln/core/abstract/struct_elt.hh Mon, 29 Mar 2004 09:53:11 +0200 odou_s (oln/c/25_structelt. 1.24 600)
+++ olena/oln/core/abstract/struct_elt.hh Tue, 14 Sep 2004 11:10:52 +0200 palma_g (oln/c/25_structelt. 1.25 640)
@@ -25,53 +25,21 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_STRUCT_ELT_HH
-# define OLENA_CORE_STRUCT_ELT_HH
+#ifndef OLN_CORE_ABSTRACT_STRUCT_ELT_HH
+# define OLN_CORE_ABSTRACT_STRUCT_ELT_HH
-# include <mlc/type.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-
-namespace oln {
-
- namespace abstract {
- template<class Exact>
- struct struct_elt; // forwarding declaration
-
- } // end of abstract
-
- template<class Exact>
- struct struct_elt_traits;
-
- /*!
- ** \brief Traits for abstract::struct_elt.
- */
- template<class Exact>
- struct struct_elt_traits<abstract::struct_elt<Exact> >
+# include <oln/core/abstract/dpoint_set.hh>
+# include <oln/core/macros.hh>
+namespace oln
{
- typedef abstract::struct_elt<Exact> abstract_type;
- ///< Defines the abstract type of the structuring element.
- };
+ template <typename Exact>
+ struct props;
- namespace abstract {
-
- /*!
- ** Structuring elements (set of dpoints).
- **
- ** This abstract class defines several virtual methods for its
- ** subclasses. Its goal is to deal with a set of 'move' points.
- */
+ namespace abstract
+ {
template<class Exact>
- struct struct_elt : public mlc_hierarchy::any< Exact >
+ struct struct_elt: public dpoint_set<Exact>
{
- enum { dim = struct_elt_traits<Exact>::dim };
- ///< Set the dim of the image from which points com.
-
- typedef struct_elt<Exact> self_type;
- ///< Set the exact self type of the class.
- typedef typename struct_elt_traits<Exact>::abstract_type abstract_type;
- ///< Set the abstract type of hisself.
-
/// Return the name of the type.
static std::string
name()
@@ -79,33 +47,6 @@
return std::string("struct_elt<") + Exact::name() + ">";
}
- typedef typename struct_elt_traits<Exact>::point_type point_type;
- ///< Set the point type of the image from which points come.
- typedef typename struct_elt_traits<Exact>::dpoint_type dpoint_type;
- ///< Set the dpoint type.
- typedef Exact exact_type;
-
- /*!
- ** \brief Test if the set of points contains this one.
- ** \arg dp a dpoint (deplacement point).
- ** \return True if the set of points contains this dpoint.
- */
- bool
- has(const abstract::dpoint<dpoint_type>& dp) const
- {
- return this->exact().has_(dp.exact());
- }
-
- /*!
- ** \brief Get the number of points.
- ** \return The number of points.
- */
- unsigned
- card() const
- {
- return this->exact().card_();
- }
-
/*!
** \brief Test if the structuring elements is centered.
** \return True if it's centered.
@@ -115,103 +56,50 @@
bool
is_centered() const
{
- return this->exact().is_centered_();
+ return dispatch(is_centered)();
}
- /*!
- ** \brief Add a point to the structuring elements.
- **
- ** Add a new member to the structuring elements.
- **
- ** \warning Here for convenience (see morpho algorithms).
- ** Work with w_windows (associate a default weight set to 1).
- */
- exact_type&
- add(const abstract::dpoint<dpoint_type>& dp)
+ oln_concrete_type(Exact) image() const
{
- return this->exact().add_dp(dp);
+ return oln_dispatch(image)();
}
- /*!
- ** \brief Get the nth structuring element.
- ** \arg i The nth.
- ** \return The nth dpoint.
- */
- dpoint_type
- dp(unsigned i) const
- {
- return this->exact().at(i);
- }
-
- /*!
- ** \brief Compare two sets of structuring elements.
- ** \arg win The structuring elements to compare.
- ** \return True if they are the same.
- */
- bool
- operator==(const self_type& win) const
- {
- return this->exact().is_equal(win.exact());
- }
-
- /*!
- ** \brief Get the delta of the structuring elements.
- ** \return Delta.
- **
- ** Delta is the biggest element of the structuring elements.
- */
- coord
- delta() const
- {
- return this->exact().get_delta();
- }
-
- /*!
- ** \brief Get the nth structuring element.
- ** \arg i The nth.
- ** \return The nth dpoint.
- */
- const dpoint_type
- operator[](unsigned i) const
- {
- return this->exact().at(i);
- }
+ };
/*!
- ** \brief Set structuring elements to opposite.
- **
- ** Each point of structuring elements is assigned to its opposite.
+ ** \brief Compute intersection between two se.
*/
- exact_type
- operator-() const
- {
- exact_type win(this->exact());
- win.sym();
+ template<class E>
+ inline E
+ inter(const abstract::struct_elt<E>& lhs, const abstract::struct_elt<E>& rhs)
+ {
+ E win;
+ for (unsigned i = 0; i < lhs.card(); ++i)
+ if (rhs.has(lhs.dp(i)))
+ win.add(lhs.dp(i));
+ for (unsigned j = 0; j < rhs.card(); ++j)
+ if (! win.has(rhs.dp(j)) && lhs.has(rhs.dp(j)))
+ win.add(rhs.dp(j));
return win;
}
- protected:
-
/*!
- ** \brief Set structuring elements to opposite.
- **
- ** Each point of structuring elements is assigned to its opposite.
+ ** \brief Compute union between two se.
*/
- void
- sym()
- {
- return this->exact().sym_();
+ template<class E>
+ inline E
+ uni(const abstract::struct_elt<E>& lhs, const abstract::struct_elt<E>& rhs)
+ {
+ E win;
+ for (unsigned i = 0; i < lhs.card(); ++i)
+ win.add(lhs.dp(i));
+ for (unsigned j = 0; j < rhs.card(); ++j)
+ if (! win.has(rhs.dp(j)))
+ win.add(rhs.dp(j));
+ return win;
}
- /*!
- ** \brief Do nothing, used only by sub-classes
- */
- struct_elt()
- {}
-
- };
- } // end of abstract
-
-} // end of oln
+ } // !abstract
+} // !oln
-#endif // ! OLENA_CORE_STRUCT_ELT_HH
+#endif // ! OLN_CORE_STRUCT_ELT_HH
Index: olena/oln/core/point_nd.hh
--- olena/oln/core/point_nd.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/w/30_point_nd.h 1.1 644)
+++ olena/oln/core/point_nd.hh Tue, 14 Sep 2004 10:12:00 +0200 palma_g (oln/w/30_point_nd.h 1.1 644)
@@ -18,7 +18,7 @@
#ifndef OLENA_CORE_POINT_HH
# define OLENA_CORE_POINT_HH
-# include "abstract/point.hh"
+# include <oln/core/abstract/point.hh>
namespace oln {
Index: olena/oln/core/dpoint_nd.hh
--- olena/oln/core/dpoint_nd.hh Mon, 13 Sep 2004 22:08:03 +0200 van-vl_n (oln/w/31_dpoint_nd. 1.1 644)
+++ olena/oln/core/dpoint_nd.hh Tue, 14 Sep 2004 11:24:16 +0200 palma_g (oln/w/31_dpoint_nd. 1.1 644)
@@ -18,7 +18,9 @@
#ifndef OLENA_CORE_DPOINT_HH
# define OLENA_CORE_DPOINT_HH
-# include "abstract/dpoint.hh"
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/default_props.hh>
+# include <oln/core/dim_nd.hh>
namespace oln {
@@ -32,10 +34,8 @@
struct point; //fwd decl
template <unsigned Dim>
- struct prop<dpoint<Dim> >
+ struct props<dpoint<Dim> >: public default_props<dim<Dim> >
{
- enum {dim = Dim};
- typedef point<Dim> point_type;
};
Index: olena/oln/core/dim3d.hh
--- olena/oln/core/dim3d.hh Tue, 14 Sep 2004 12:53:38 +0200 palma_g ()
+++ olena/oln/core/dim3d.hh Mon, 13 Sep 2004 10:59:57 +0200 palma_g (oln/v/45_dim3d.hh 1.1 644)
@@ -0,0 +1,66 @@
+#ifndef PROTO_OLN_CORE_DIM3D_HH
+# define PROTO_OLN_CORE_DIM3D_HH
+
+# include <oln/core/abstract/dim.hh>
+
+namespace oln {
+
+ // fwd decls:
+
+ template <typename T> struct image3d;
+ struct image3d_size;
+ struct point3d;
+ struct dpoint3d;
+ struct fwd_iter3d;
+ struct bkd_iter3d;
+ struct neighborhood3d;
+ struct window3d;
+ struct fwd_niter3d;
+ // FIXME: to be continued
+
+
+ struct dim3d;
+
+ template <typename E>
+ struct props;
+
+ template <>
+ struct props <dim3d>
+ {
+ template <typename T>
+ struct concrete_type {
+ typedef image3d<T> ret;
+ };
+
+ enum { linbuf_value = false };
+
+ enum { dim_value = 3 };
+ typedef dim3d dim_type;
+
+ typedef image3d_size image_size_type;
+
+ typedef point3d point_type;
+ typedef dpoint3d dpoint_type;
+
+ typedef fwd_iter3d iter_type;
+ typedef fwd_iter3d fwd_iter_type;
+ typedef bkd_iter3d bkd_iter_type;
+
+ typedef neighborhood3d neighborhood_type;
+ typedef window3d window_type;
+
+ typedef fwd_niter3d niter_type;
+ typedef fwd_niter3d fwd_niter_type;
+// typedef bkd_niter3d bkd_niter_type;
+
+ // FIXME: to be continued
+ };
+
+ struct dim3d : public abstract::dim< dim3d >
+ {
+ };
+
+} // end of namespace oln
+
+
+#endif // ndef PROTO_OLN_CORE_DIM3D_HH
Index: olena/oln/core/dim2d.hh
--- olena/oln/core/dim2d.hh Tue, 14 Sep 2004 12:53:38 +0200 palma_g ()
+++ olena/oln/core/dim2d.hh Fri, 10 Sep 2004 18:18:59 +0200 palma_g (oln/v/46_dim2d.hh 1.1 600)
@@ -0,0 +1,66 @@
+#ifndef PROTO_OLN_CORE_DIM2D_HH
+# define PROTO_OLN_CORE_DIM2D_HH
+
+# include <oln/core/abstract/dim.hh>
+
+namespace oln {
+
+ // fwd decls:
+
+ template <typename T> struct image2d;
+ struct image2d_size;
+ struct point2d;
+ struct dpoint2d;
+ struct fwd_iter2d;
+ struct bkd_iter2d;
+ struct neighborhood2d;
+ struct window2d;
+ struct fwd_niter2d;
+ // FIXME: to be continued
+
+
+ struct dim2d;
+
+ template <typename E>
+ struct props;
+
+ template <>
+ struct props <dim2d>
+ {
+ template <typename T>
+ struct concrete_type {
+ typedef image2d<T> ret;
+ };
+
+ enum { linbuf_value = false };
+
+ enum { dim_value = 2 };
+ typedef dim2d dim_type;
+
+ typedef image2d_size image_size_type;
+
+ typedef point2d point_type;
+ typedef dpoint2d dpoint_type;
+
+ typedef fwd_iter2d iter_type;
+ typedef fwd_iter2d fwd_iter_type;
+ typedef bkd_iter2d bkd_iter_type;
+
+ typedef neighborhood2d neighborhood_type;
+ typedef window2d window_type;
+
+ typedef fwd_niter2d niter_type;
+ typedef fwd_niter2d fwd_niter_type;
+// typedef bkd_niter2d bkd_niter_type;
+
+ // FIXME: to be continued
+ };
+
+ struct dim2d : public abstract::dim< dim2d >
+ {
+ };
+
+} // end of namespace oln
+
+
+#endif // ndef PROTO_OLN_CORE_DIM2D_HH
Index: olena/oln/core/dim1d.hh
--- olena/oln/core/dim1d.hh Tue, 14 Sep 2004 12:53:38 +0200 palma_g ()
+++ olena/oln/core/dim1d.hh Tue, 14 Sep 2004 11:00:22 +0200 palma_g (oln/w/14_dim1d.hh 1.1 600)
@@ -0,0 +1,38 @@
+// Copyright (C) 2004 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 OLN_CORE_DIM1D_HH
+# define OLN_CORE_DIM1D_HH
+
+
+namespace oln
+{
+ typedef dim<1> dim1d;
+} // end of namespace oln
+
+
+#endif // ndef OLN_CORE_DIM1D_HH
Index: olena/oln/core/abstract/dim.hh
--- olena/oln/core/abstract/dim.hh Tue, 14 Sep 2004 12:53:38 +0200 palma_g ()
+++ olena/oln/core/abstract/dim.hh Tue, 14 Sep 2004 10:50:36 +0200 palma_g (oln/w/23_dim.hh 1.1 600)
@@ -0,0 +1,21 @@
+#ifndef OLN_CORE_ABSTRACT_DIM_HH
+# define OLN_CORE_ABSTRACT_DIM_HH
+
+# include <mlc/type.hh>
+
+
+namespace oln {
+ namespace abstract {
+
+ template <typename E>
+ struct dim : public mlc_hierarchy::any<E>
+ {
+ protected:
+ dim() {}
+ };
+
+ } // abstract
+} // oln
+
+
+#endif // !OLN_CORE_ABSTRACT_DIM_HH
Index: olena/oln/core/default_props.hh
--- olena/oln/core/default_props.hh Tue, 14 Sep 2004 12:53:38 +0200 palma_g ()
+++ olena/oln/core/default_props.hh Tue, 14 Sep 2004 11:39:05 +0200 palma_g (oln/w/34_default_pr 644)
@@ -0,0 +1,62 @@
+// Copyright (C) 2004 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 OLN_CORE_DEFAULT_PROPS
+# define OLN_CORE_DEFAULT_PROPS
+# include <oln/core/macros.hh>
+
+namespace oln {
+
+ template <class Dim>
+ struct default_props
+ {
+ // enum { linbuf_value = oln_linbuf_value(Dim) };
+ enum { dim_value = oln_dim_val(Dim) };
+
+ typedef Dim dim_type;
+ // typedef oln_image_size_type(Dim) image_size_type;
+
+ typedef oln_point_type(Dim) point_type;
+ typedef oln_dpoint_type(Dim) dpoint_type;
+
+ // typedef oln_iter_type(Dim) iter_type;
+ // typedef oln_fwd_iter_type(Dim) fwd_iter_type;
+ //typedef oln_bkd_iter_type(Dim) bkd_iter_type;
+
+ typedef oln_neighborhood_type(Dim) neighborhood_type;
+ typedef oln_window_type(Dim) window_type;
+ typedef oln_flat_se_type(Dim) flat_se_type;
+
+ typedef oln_concrete_type(Dim) concrete_type;
+ // typedef oln_niter_type(Dim) niter_type;
+// typedef oln_fwd_niter_type(Dim) fwd_niter_type;
+//
+ // typedef oln_bkd_niter_type(Dim) bkd_niter_type;
+ };
+} // !oln
+
+#endif // OLN_CORE_DEFAULT_PROPS
--
Giovanni Palma
EPITA - promo 2005 - LRDE
Mob. : +33 (0)6 60 97 31 74