hop
---
:from: Thierry Geraud <theo(a)lrde.epita.fr>
:server:
:subject: "proto-1.0 52: Make it pass make check"
:groups:
- lrde.olena.patches
---
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
* oln/core/3d/fwd_piter3d.hh: New.
* tests/core/tests/readwrite_image: Fix to pass make check.
* tests/core/tests/image_identity: Likewise.
* oln/fancy/print.hh: Likewise.
* oln/core/1d/array1d.hh: Likewise.
* oln/core/1d/fwd_piter1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/1d/size1d.hh: Likewise.
* oln/core/coord.hh: Likewise.
* oln/core/2d/fwd_piter2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/2d/size2d.hh: Likewise.
* oln/core/3d/size3d.hh: Likewise.
* oln/core/3d/array3d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
oln/core/1d/array1d.hh | 18 ++---
oln/core/1d/fwd_piter1d.hh | 4 -
oln/core/1d/point1d.hh | 1
oln/core/1d/size1d.hh | 4 -
oln/core/2d/fwd_piter2d.hh | 27 ++++----
oln/core/2d/point2d.hh | 1
oln/core/2d/size2d.hh | 4 -
oln/core/3d/array3d.hh | 52 ++++++++-------
oln/core/3d/fwd_piter3d.hh | 129 +++++++++++++++++++++++++++++++++++++++
oln/core/3d/image3d.hh | 5 -
oln/core/3d/point3d.hh | 6 -
oln/core/3d/size3d.hh | 14 +---
oln/core/coord.hh | 4 +
oln/fancy/print.hh | 40 +++++-------
tests/core/tests/image_identity | 1
tests/core/tests/readwrite_image | 26 ++++---
16 files changed, 237 insertions(+), 99 deletions(-)
Index: tests/core/tests/readwrite_image
--- tests/core/tests/readwrite_image (revision 51)
+++ tests/core/tests/readwrite_image (working copy)
@@ -11,23 +11,26 @@
struct dummy_image;
template <>
- struct category_type< dummy_image > { typedef cat::image ret; };
+ struct set_category< dummy_image > { typedef category::image ret; };
template <>
- struct props <cat::image, dummy_image> :
- public default_props < cat::image >
+ struct set_super_type< dummy_image > {
+ typedef abstract::image_with_data< dummy_image > ret;
+ };
+
+ template <>
+ struct set_props <category::image, dummy_image> :
+ public props_of < category::image >
{
- typedef prop_of<abstract::readwrite_image> image_constness;
- typedef prop_of<abstract::image2d> image_dimension;
+ typedef is_a<abstract::readwrite_image> image_constness;
+ typedef is_a<abstract::image2d> image_dimension_type;
typedef size2d size_type;
typedef point2d point_type;
typedef ntg::int_u8 value_type;
- typedef mlc_encoding_type_(value_type) value_storage_type;
- typedef array2d<value_storage_type> value_container_type;
-
- typedef mlc::no_type delegated_type;
+ typedef value_type value_storage_type;
+ typedef array2d<value_storage_type> storage_type;
};
struct dummy_image : public abstract::image_with_data< dummy_image >
@@ -55,7 +58,8 @@
bool check()
{
oln::dummy_image ima(3, 3);
- ima[oln::point2d(0,0)] = 42;
- std::cout << ima[oln::point2d(0,0)].value() << std::endl;
+ oln::point2d p(0,0);
+ ima[p] = 51;
+ std::cout << int(ima[p]) << std::endl;
return false;
}
Index: tests/core/tests/image_identity
--- tests/core/tests/image_identity (revision 51)
+++ tests/core/tests/image_identity (working copy)
@@ -1,7 +1,6 @@
#include <oln/core/abstract/image_identity.hh>
#include <oln/core/2d/image2d.hh>
#include <ntg/real/int_u8.hh>
-#include <oln/core/cats.hh>
template <typename I>
Index: oln/fancy/print.hh
--- oln/fancy/print.hh (revision 51)
+++ oln/fancy/print.hh (working copy)
@@ -38,6 +38,7 @@
# include <oln/core/abstract/image_dimension.hh>
# include <oln/core/1d/point1d.hh>
# include <oln/core/2d/point2d.hh>
+# include <oln/core/3d/point3d.hh>
# include <oln/core/coord.hh>
@@ -104,18 +105,15 @@
template <typename E>
void print(const abstract::image1d<E>& input, std::ostream& ostr)
{
- // FIXME: lacks cleaning
for (coord_t index = 0; index < input.size().nindices(); ++index)
- {
- ostr << internal::pp<oln_type_of(E, value)>(input[point1d(index)])
<< ' ';
- }
+ ostr << internal::pp<oln_type_of(E, value)>(input[point1d(index)])
+ << ' ';
ostr << std::endl;
}
template <typename E>
void print(const abstract::image2d<E>& input, std::ostream& ostr)
{
- // FIXME: lacks cleaning
for (coord_t row = 0; row < input.size().nrows(); ++row)
{
for (coord_t col = 0; col < input.size().ncols(); ++col)
@@ -124,24 +122,22 @@
}
}
- // FIXME: remove comments when dpoint3d are available.
-// template <typename E>
-// void print(const abstract::image3d<E>& input, std::ostream& ostr)
-// {
-// // FIXME: lacks cleaning
-// for (coord_t slice = 0; slice < input.size().nslices(); ++slice)
-// {
-// for (coord_t row = 0; row < input.size().nrows(); ++row)
-// {
-// for (coord_t col = 0; col < input.size().ncols(); ++col)
-// ostr <<
internal::pp<oln_value_type(E)>(input[point3d(slice,row,col)])
-// << ' ';
-// ostr << ", ";
-// }
-// ostr << std::endl;
-// }
-// }
+ template <typename E>
+ void print(const abstract::image3d<E>& input, std::ostream& ostr)
+ {
+ for (coord_t slice = 0; slice < input.size().nslices(); ++slice)
+ {
+ for (coord_t row = 0; row < input.size().nrows(); ++row)
+ {
+ for (coord_t col = 0; col < input.size().ncols(); ++col)
+ ostr << internal::pp<oln_type_of(E,
value)>(input[point3d(slice,row,col)])
+ << ' ';
+ ostr << std::endl;
+ }
+ ostr << "---" << std::endl;
+ }
+ }
} // end of namespace impl
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 51)
+++ oln/core/1d/array1d.hh (working copy)
@@ -116,7 +116,7 @@
void impl_resize(const size1d& s)
{
- precondition(s.nindices() > 0 and
+ precondition(s.nindices() > 0 &&
s.border() >= 0);
invariant_();
this->clear_data();
@@ -134,14 +134,14 @@
bool impl_hold(const point1d& p) const
{
return
- p.index() >= 0 and
+ p.index() >= 0 &&
p.index() < size_.nindices();
}
bool impl_hold_large(const point1d& p) const
{
return
- p.index() >= - size_.border() and
+ p.index() >= - size_.border() &&
p.index() < size_.nindices() + size_.border();
}
@@ -173,13 +173,13 @@
void invariant_() const
{
- invariant((buffer_ != 0 and
- size_.nindices() > 0 and
+ invariant((buffer_ != 0 &&
+ size_.nindices() > 0 &&
size_.border() >= 0)
- or
- (buffer_ == 0 and
- size_.nindices() == 0 and
- size_.border() == 0));
+ ||
+ (buffer_ == 0 &&
+ size_.nindices().is_undefined() &&
+ size_.border().is_undefined()));
}
};
Index: oln/core/1d/fwd_piter1d.hh
--- oln/core/1d/fwd_piter1d.hh (revision 51)
+++ oln/core/1d/fwd_piter1d.hh (working copy)
@@ -88,9 +88,7 @@
void impl_next()
{
precondition(this->p_.index().is_defined());
- precondition(this->p_.index() >= 0 and this->p_.index() <=
this->s_.nindices());
- if (this->p_.index() == this->s_.nindices())
- return;
+ precondition(this->p_.index() >= 0 && this->p_.index() <
this->s_.nindices());
++this->p_.index();
postcondition(this->p_.index().is_defined());
}
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 51)
+++ oln/core/1d/point1d.hh (working copy)
@@ -65,6 +65,7 @@
{
point1d()
{
+ // no initialization here so that index_ is 'undef'
}
point1d(coord_t index_) :
Index: oln/core/1d/size1d.hh
--- oln/core/1d/size1d.hh (revision 51)
+++ oln/core/1d/size1d.hh (working copy)
@@ -39,7 +39,9 @@
struct size1d : public abstract::size< size1d >
{
size1d()
- {}
+ {
+ // no initialization here so that members are 'undef'
+ }
size1d(coord_t nindices_) :
nindices_(nindices_),
Index: oln/core/coord.hh
--- oln/core/coord.hh (revision 51)
+++ oln/core/coord.hh (working copy)
@@ -71,6 +71,10 @@
bool operator==(value_type rhs) const
{
+ if (! this->is_defined())
+ {
+ std::cerr << "oops" << std::endl;
+ }
precondition(this->is_defined());
return value_ == rhs;
}
Index: oln/core/2d/fwd_piter2d.hh
--- oln/core/2d/fwd_piter2d.hh (revision 51)
+++ oln/core/2d/fwd_piter2d.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef PROTO_OLN_CORE_2D_FWD_PITER2D_HH
-# define PROTO_OLN_CORE_2D_FWD_PITER2D_HH
+#ifndef OLENA_CORE_2D_FWD_PITER2D_HH
+# define OLENA_CORE_2D_FWD_PITER2D_HH
# include <mlc/contract.hh>
@@ -76,39 +76,42 @@
{
this->p_.row() = 0;
this->p_.col() = 0;
- postcondition(this->p_.row().is_defined() &&
this->p_.col().is_defined());
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined());
}
bool impl_is_valid() const
{
- precondition(this->p_.row().is_defined() &&
this->p_.col().is_defined());
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined());
return this->p_.row() < this->s_.nrows();
}
void impl_next()
{
- precondition(this->p_.row().is_defined() &&
this->p_.col().is_defined());
- precondition(this->p_.row() >= 0 && this->p_.row() <=
this->s_.nrows()
- &&
- this->p_.col() >= 0 && this->p_.col() <= this->s_.ncols());
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined());
+ precondition(this->p_.row() >= 0 && this->p_.row() <
this->s_.nrows() &&
+ this->p_.col() >= 0 && this->p_.col() < this->s_.ncols());
++this->p_.col();
if (this->p_.col() != this->s_.ncols())
return;
this->p_.col() = 0;
- precondition(this->p_.row() != this->s_.nrows());
++this->p_.row();
- postcondition(this->p_.row().is_defined() &&
this->p_.col().is_defined());
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined());
}
void impl_invalidate()
{
this->p_.row() = this->s_.nrows();
this->p_.col() = this->s_.ncols();
- postcondition(this->p_.row().is_defined() &&
this->p_.col().is_defined());
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined());
}
};
}
-#endif // ndef PROTO_OLN_CORE_2D_FWD_PITER2D_HH
+#endif // ! OLENA_CORE_2D_FWD_PITER2D_HH
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 51)
+++ oln/core/2d/point2d.hh (working copy)
@@ -63,6 +63,7 @@
{
point2d()
{
+ // no initialization here so that row_ and col_ are 'undef'
}
point2d(coord_t row_, coord_t col_) :
Index: oln/core/2d/size2d.hh
--- oln/core/2d/size2d.hh (revision 51)
+++ oln/core/2d/size2d.hh (working copy)
@@ -39,7 +39,9 @@
struct size2d : public abstract::size< size2d >
{
size2d()
- {}
+ {
+ // no initialization here so that members are 'undef'
+ }
size2d(coord_t nrows_, coord_t ncols_) :
nrows_(nrows_),
Index: oln/core/3d/size3d.hh
--- oln/core/3d/size3d.hh (revision 51)
+++ oln/core/3d/size3d.hh (working copy)
@@ -39,12 +39,10 @@
struct size3d : public abstract::size< size3d >
{
- size3d() :
- nslices_(0),
- nrows_(0),
- ncols_(0),
- border_(0)
- {}
+ size3d()
+ {
+ // no initialization here so that members are 'undef'
+ }
size3d(coord_t nslices_, coord_t nrows_, coord_t ncols_) :
nslices_(nslices_),
@@ -84,8 +82,8 @@
bool impl_eq(const size3d& rhs) const
{
- return this->nslices_ == rhs.nslices_ and
- this->nrows_ == rhs.nrows_ and
+ return this->nslices_ == rhs.nslices_ &&
+ this->nrows_ == rhs.nrows_ &&
this->ncols_ == rhs.ncols_;
}
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 51)
+++ oln/core/3d/array3d.hh (working copy)
@@ -127,9 +127,9 @@
void impl_resize(const size3d& s)
{
- precondition(s.nslices() > 0 and
- s.nrows() > 0 and
- s.ncols() > 0 and
+ precondition(s.nslices() > 0 &&
+ s.nrows() > 0 &&
+ s.ncols() > 0 &&
s.border() >= 0);
invariant_();
this->clear_data();
@@ -167,22 +167,22 @@
bool impl_hold(const point3d& p) const
{
return
- p.slice() >= 0 and
- p.slice() < size_.nslices() and
- p.row() >= 0 and
- p.row() < size_.nrows() and
- p.col() >= 0 and
+ p.slice() >= 0 &&
+ p.slice() < size_.nslices() &&
+ p.row() >= 0 &&
+ p.row() < size_.nrows() &&
+ p.col() >= 0 &&
p.col() < size_.ncols();
}
bool impl_hold_large(const point3d& p) const
{
return
- p.slice() >= - size_.border() and
- p.slice() < size_.nslices() + size_.border() and
- p.row() >= - size_.border() and
- p.row() < size_.nrows() + size_.border() and
- p.col() >= - size_.border() and
+ p.slice() >= - size_.border() &&
+ p.slice() < size_.nslices() + size_.border() &&
+ p.row() >= - size_.border() &&
+ p.row() < size_.nrows() + size_.border() &&
+ p.col() >= - size_.border() &&
p.col() < size_.ncols() + size_.border();
}
@@ -219,19 +219,21 @@
void invariant_() const
{
- invariant((buffer_ != 0 and
- array_ != 0 and
- size_.nslices() > 0 and
- size_.nrows() > 0 and
- size_.ncols() > 0 and
+ invariant((buffer_ != 0 &&
+ array_ != 0 &&
+ array2_ != 0 &&
+ size_.nslices() > 0 &&
+ size_.nrows() > 0 &&
+ size_.ncols() > 0 &&
size_.border() >= 0)
- or
- (buffer_ == 0 and
- array_ == 0 and
- size_.nslices() == 0 and
- size_.nrows() == 0 and
- size_.ncols() == 0 and
- size_.border() == 0));
+ ||
+ (buffer_ == 0 &&
+ array_ == 0 &&
+ array2_ == 0 &&
+ size_.nslices().is_undefined() &&
+ size_.nrows().is_undefined() &&
+ size_.ncols().is_undefined() &&
+ size_.border().is_undefined()));
}
};
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 51)
+++ oln/core/3d/image3d.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/3d/array3d.hh>
+# include <oln/core/3d/fwd_piter3d.hh>
/*! \namespace oln
** \brief oln namespace.
@@ -67,8 +68,8 @@
typedef point3d point_type;
typedef T value_type;
-// typedef fwd_piter3d piter_type;
-// typedef fwd_piter3d fwd_piter_type;
+ typedef fwd_piter3d piter_type;
+ typedef fwd_piter3d fwd_piter_type;
// please note that value_storage_type means data_type
// since image3d is an image_with_data
Index: oln/core/3d/fwd_piter3d.hh
--- oln/core/3d/fwd_piter3d.hh (revision 0)
+++ oln/core/3d/fwd_piter3d.hh (revision 0)
@@ -0,0 +1,129 @@
+// 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_FWD_PITER3D_HH
+# define OLENA_CORE_3D_FWD_PITER3D_HH
+
+# include <mlc/contract.hh>
+
+# include <oln/core/abstract/piter.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/size3d.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ struct fwd_piter3d;
+
+ // category
+ template <>
+ struct set_category<fwd_piter3d> { typedef category::piter ret; };
+
+
+ // props
+ template <>
+ struct set_props < category::piter, fwd_piter3d > : public
props_of<category::piter>
+ {
+ typedef point3d point_type;
+ typedef size3d size_type;
+ };
+
+
+
+ struct fwd_piter3d : public abstract::piter< fwd_piter3d >
+ {
+
+ typedef abstract::piter<fwd_piter3d> super_type;
+
+ fwd_piter3d(const size3d& size) :
+ super_type(size)
+ {
+ this->exact_ptr = this;
+ this->invalidate();
+ }
+
+# if defined __GNUC__ && __GNUC__ >= 3
+ friend class abstract::piter< fwd_piter3d >;
+ protected:
+# endif
+
+ void impl_start()
+ {
+ this->p_.row() = 0;
+ this->p_.col() = 0;
+ this->p_.slice() = 0;
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ bool impl_is_valid() const
+ {
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ return this->p_.slice() < this->s_.nslices();
+ }
+
+ void impl_next()
+ {
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ precondition(this->p_.row() >= 0 && this->p_.row() <
this->s_.nrows() &&
+ this->p_.col() >= 0 && this->p_.col() < this->s_.ncols()
&&
+ this->p_.slice() >= 0 && this->p_.slice() <
this->s_.nslices());
+ ++this->p_.col();
+ if (this->p_.col() != this->s_.ncols())
+ return;
+ this->p_.col() = 0;
+ ++this->p_.row();
+ if (this->p_.row() != this->s_.nrows())
+ return;
+ this->p_.row() = 0;
+ ++this->p_.slice();
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ void impl_invalidate()
+ {
+ this->p_.row() = this->s_.nrows();
+ this->p_.col() = this->s_.ncols();
+ this->p_.slice() = this->s_.nslices();
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ };
+}
+
+
+#endif // ! OLENA_CORE_3D_FWD_PITER3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 51)
+++ oln/core/3d/point3d.hh (working copy)
@@ -57,11 +57,9 @@
struct point3d : public abstract::point< point3d >
{
- point3d() :
- slice_(0),
- row_(0),
- col_(0)
+ point3d()
{
+ // no initialization here so that slice_, row_, and col_ are 'undef'
}
point3d(coord_t slice_, coord_t row_, coord_t col_) :