Index: ChangeLog
from Christophe Berger <christophe(a)lrde.epita.fr>
* oln/core/abstract/point.hh: Fix point type.
* oln/core/3d/dpoint3d.hh: New.
* oln/core/3d/point3d.hh: Add operators (+-) implementations.
* oln/basics3d.hh: Add new header inclusion.
* oln/makefile.src: Add new file.
basics3d.hh | 1
core/3d/dpoint3d.hh | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
core/3d/point3d.hh | 22 ++++++++
core/abstract/point.hh | 11 ++--
makefile.src | 1
5 files changed, 163 insertions(+), 3 deletions(-)
Index: oln/core/abstract/point.hh
--- oln/core/abstract/point.hh (revision 95)
+++ oln/core/abstract/point.hh (working copy)
@@ -94,7 +94,7 @@
**
** \return True if both points are the same, false otherwise.
*/
- bool operator==(const point& rhs) const
+ bool operator==(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
@@ -104,7 +104,7 @@
**
** \return True if both points are different, false otherwise.
*/
- bool operator!=(const point& rhs) const
+ bool operator!=(const exact_type& rhs) const
{
return ! this->operator==(rhs);
}
@@ -118,7 +118,7 @@
return this->exact().impl_plus(dp);
}
- const dpoint_type operator-(const point& rhs) const
+ const dpoint_type operator-(const exact_type& rhs) const
{
return this->exact().impl_minus(rhs);
}
@@ -126,6 +126,11 @@
protected:
point() {}
+
+ /*! \brief Cpy constructor (protected, empty).
+ */
+ point(const exact_type& pt) {}
+
};
} // end of namespace abstract
Index: oln/core/3d/dpoint3d.hh
--- oln/core/3d/dpoint3d.hh (revision 0)
+++ oln/core/3d/dpoint3d.hh (revision 0)
@@ -0,0 +1,131 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_3D_DPOINT3D_HH
+# define OLENA_CORE_3D_DPOINT3D_HH
+
+# include <iostream>
+
+# include <oln/core/coord.hh>
+
+// FIXME: there's an assumption here: we do not need inheritance for
+// dpoints. so abstract::dpoint does not exist...
+
+// FIXME: doc!
+
+namespace oln {
+
+ struct point3d;
+
+ struct dpoint3d
+ {
+ dpoint3d()
+ {
+ }
+
+ dpoint3d(coord_t slice_, coord_t row_, coord_t col_) :
+ slice_(slice_),
+ row_(row_),
+ col_(col_)
+ {
+ }
+
+ dpoint3d(const dpoint3d& rhs) :
+ slice_(rhs.slice_),
+ row_(rhs.row_),
+ col_(rhs.col_)
+ {
+ }
+
+ dpoint3d& operator=(const dpoint3d& rhs)
+ {
+ if (&rhs == this)
+ return *this;
+ this->slice_ = rhs.slice_;
+ this->row_ = rhs.row_;
+ this->col_ = rhs.col_;
+ return *this;
+ }
+
+ bool operator==(const dpoint3d& rhs) const
+ {
+ return this->row_ == rhs.row_ && this->col_ == rhs.col_ &&
this->slice_ == rhs.slice_;
+ }
+
+ bool operator!=(const dpoint3d& rhs) const
+ {
+ return ! this->operator==(rhs);
+ }
+
+ const dpoint3d operator+(const dpoint3d& rhs) const
+ {
+ dpoint3d tmp(this->slice() + rhs.slice(), this->row() + rhs.row(),
this->col() + rhs.col());
+ return tmp;
+ }
+
+ const point3d operator+(const point3d& rhs) const;
+
+ const dpoint3d operator-() const
+ {
+ dpoint3d tmp(-this->slice(), -this->row(), -this->col());
+ return tmp;
+ }
+
+ const coord_t row() const { return row_; }
+ const coord_t col() const { return col_; }
+ const coord_t slice() const { return slice_; }
+
+ coord_t& row() { return row_; }
+ coord_t& col() { return col_; }
+ coord_t& slice() { return slice_; }
+
+ protected:
+ coord_t slice_, row_, col_;
+ };
+
+} // end of namespace oln
+
+
+std::ostream& operator<<(std::ostream& ostr, const oln::dpoint3d& dp)
+{
+ return ostr << '(' << dp.slice() << ',' <<
dp.row() << ',' << dp.col() << ')';
+}
+
+# include <oln/core/3d/point3d.hh>
+
+namespace oln {
+
+ const point3d dpoint3d::operator+(const point3d& rhs) const
+ {
+ point3d tmp(this->slice() + rhs.slice(), this->row() + rhs.row(),
this->col() + rhs.col());
+ return tmp;
+ }
+
+}
+
+
+#endif // ! OLENA_CORE_3D_DPOINT3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 95)
+++ oln/core/3d/point3d.hh (working copy)
@@ -92,6 +92,8 @@
this->row_ == rhs.row_ and
this->col_ == rhs.col_;
}
+ const point3d impl_plus(const dpoint3d& rhs) const;
+ const dpoint3d impl_minus(const point3d& rhs) const;
const coord_t slice() const { return slice_; }
const coord_t row() const { return row_; }
@@ -114,4 +116,24 @@
}
+# include <oln/core/3d/dpoint3d.hh>
+
+
+namespace oln {
+
+ const point3d point3d::impl_plus(const dpoint3d& rhs) const
+ {
+ point3d tmp(this->slice() + rhs.slice(), this->row() + rhs.row(),
this->col() + rhs.col());
+ return tmp;
+ }
+
+ const dpoint3d point3d::impl_minus(const point3d& rhs) const
+ {
+ dpoint3d tmp(this->slice() - rhs.slice(), this->row() - rhs.row(),
this->col() - rhs.col());
+ return tmp;
+ }
+
+} // end of namespace oln
+
+
#endif // ! OLENA_CORE_3D_POINT3D_HH
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 95)
+++ oln/basics3d.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/3d/size3d.hh>
# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/dpoint3d.hh>
# include <oln/core/3d/image3d.hh>
#endif // ! OLENA_BASICS3D_HH
Index: oln/makefile.src
--- oln/makefile.src (revision 95)
+++ oln/makefile.src (working copy)
@@ -36,6 +36,7 @@
core/3d/fwd_piter3d.hh \
core/3d/image3d.hh \
core/3d/point3d.hh \
+ core/3d/dpoint3d.hh \
core/3d/size3d.hh \
core/abstract/data_storage.hh \
core/abstract/dpoint.hh \