Index: olena/ChangeLog from Niels Van Vliet niels@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::image1dntg::rgb_8 for example, use the - ** macro oln_dpoint_type(I).\n - ** oln_dpoint_type(oln::image1dntg::rgb_8) p();\n - ** or\n - ** oln_dpoint_type(oln::image1dntg::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_lessdpoint1d::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::image2dntg::rgb_8 for example, use the - ** macro oln_dpoint_type(I).\n - ** oln_dpoint_type(oln::image2dntg::rgb_8) dp();\n - ** or\n - ** oln_dpoint_type(oln::image2dntg::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_lessdpoint2d::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::image3dntg::rgb_8 for example, use the - ** macro oln_dpoint_type(I).\n - ** oln_dpoint_type(oln::image3dntg::rgb_8) dp();\n - ** or\n - ** oln_dpoint_type(oln::image3dntg::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_lessdpoint3d::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::image1dntg::rgb_8 for example, use the - ** macro oln_point_type.\n - ** oln_point_type(oln::image1dntg::rgb_8) p();\n - ** or\n - ** oln_point_type(oln::image1dntg::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_lesspoint1d::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::image2dntg::rgb_8 for example, use the - ** macro oln_point_type(I).\n - ** oln_point_type(oln::image2dntg::rgb_8) p();\n - ** or\n - ** oln_point_type(oln::image2dntg::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_lesspoint2d::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::image3dngt::rgb_8 for example, use the - ** macro oln_point_type(I).\n - ** oln_point_type(oln::image3dngt::rgb_8) p();\n - ** or\n - ** oln_point_type(oln::image3dngt::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_lesspoint3d::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
Ok. (Mistakes have been corrected by giovanni in the next checkin).