Je recommence à poster les diffs, puisque les quakes et autres séries
de diff de 5000 lignes sont terminées :)
has_impl() sur une image dit si l'image possède une implémentation,
autrement dit si elle est prête à être interrogée par l'opérateur [].
C'est pratique notamment quand l'image a été construite par un load,
pour savoir si le load a raté (genre si le fichier existe pas).
D'autre solution sont envisageables pour ce genre de cas, genre lancer
une exception, on pourra en discuter 2min à la prochaine réunion
Olena.
Index: doc/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* demo/convol-gaussian.cc: Check i/o failures.
Index: olena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* oln/core/abstract/image.hh: Make the has_impl() method public.
* oln/utils/copy.hh: Adjust consequently.
* oln/core/abstract/image_with_impl.hh: Likewise.
* oln/core/abstract/image_with_impl.hh: Minor fix.
Index: olena/oln/utils/copy.hh
--- olena/oln/utils/copy.hh Thu, 07 Aug 2003 02:37:23 +0200 burrus_n (oln/i/29_copy.hh 1.6
640)
+++ olena/oln/utils/copy.hh Mon, 25 Aug 2003 11:41:32 +0200 burrus_n (oln/i/29_copy.hh 1.6
640)
@@ -42,7 +42,7 @@
# define OLENA_UTILS_IMAGE_DEEP_COPY \
mlc_init_static_hierarchy(Exact); \
- if (rhs.has_impl_()) \
+ if (rhs.has_impl()) \
*this = rhs.clone()
# ifdef OLENA_CORE_IMAGE1D_HH
Index: doc/demo/convol-gaussian.cc
--- doc/demo/convol-gaussian.cc Fri, 02 May 2003 23:12:39 +0200 burrus_n
(oln/p/14_morpholena 1.5 640)
+++ doc/demo/convol-gaussian.cc Mon, 25 Aug 2003 11:37:07 +0200 burrus_n
(oln/p/14_morpholena 1.5 640)
@@ -7,12 +7,13 @@
int main(void)
{
image2d<int_u8> lena = load(IMGDIR "/lena.pgm");
+ assert(lena.has_impl());
- save(convol::fast::gaussian(lena, float_d(0.50f)),
- "lena-gau.pgm");
- save(convol::fast::gaussian_derivative(lena, float_d(0.50f)),
- "lena-gd1.pgm");
- save(convol::fast::gaussian_second_derivative(lena, float_d(0.50f)),
- "lena-gd2.pgm");
+ assert( save(convol::fast::gaussian(lena, float_d(0.50f)),
+ "lena-gau.pgm") );
+ assert( save(convol::fast::gaussian_derivative(lena, float_d(0.50f)),
+ "lena-gd1.pgm") );
+ assert( save(convol::fast::gaussian_second_derivative(lena, float_d(0.50f)),
+ "lena-gd2.pgm") );
}
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh Thu, 07 Aug 2003 02:08:21 +0200 david
(oln/t/25_image.hh 1.17 640)
+++ olena/oln/core/abstract/image.hh Mon, 25 Aug 2003 11:36:46 +0200 burrus_n
(oln/t/25_image.hh 1.17 640)
@@ -86,6 +86,12 @@
return this->exact().at(p.exact());
}
+ bool
+ has_impl() const
+ {
+ return this->exact().impl() != 0;
+ }
+
exact_type
clone() const
{
@@ -95,14 +101,14 @@
bool
hold(const abstract::point<point_type>& p) const
{
- assertion(has_impl_());
+ assertion(has_impl());
return this->exact().impl()->hold(p.exact());
}
const size_type&
size() const
{
- assertion(has_impl_());
+ assertion(has_impl());
return this->exact().impl()->size();
}
@@ -138,7 +144,7 @@
border_set_width(coord new_border, bool copy_border = false) const
{
precondition(new_border >= 0);
- precondition(has_impl_());
+ precondition(has_impl());
if (border() == new_border)
return; // Nothing to do.
@@ -184,11 +190,6 @@
{}
//image(self_type& rhs) {}
- bool
- has_impl_() const
- {
- return this->exact().impl() != 0;
- }
};
} // end of namespace abstract
Index: olena/oln/core/abstract/image_with_impl.hh
--- olena/oln/core/abstract/image_with_impl.hh Thu, 07 Aug 2003 02:08:21 +0200 david
(oln/t/27_image_with 1.14.1.7 640)
+++ olena/oln/core/abstract/image_with_impl.hh Mon, 25 Aug 2003 11:41:24 +0200 burrus_n
(oln/t/27_image_with 1.14.1.7 640)
@@ -52,7 +52,7 @@
template<class Impl, class Exact>
class image_with_impl:
- public abstract::image_with_type_with_dim_switch<Exact>::ret
+ public image_with_type_with_dim_switch<Exact>::ret
{
public:
typedef typename image_traits<Exact>::point_type point_type;
@@ -65,17 +65,17 @@
typedef image_with_impl<Impl, Exact> self_type;
typedef Exact exact_type;
- typedef image_with_type<typename image_id<Exact>::value_type, Exact>
super_type;
+ typedef typename image_with_type_with_dim_switch<Exact>::ret super_type;
friend class image<exact_type>;
friend class image_with_dim<image_id<Exact>::dim, exact_type>;
- friend class super_type;
+ friend class image_with_type<typename image_id<Exact>::value_type,
Exact>;
// shallow copy
image_with_impl(self_type& rhs)
: super_type(rhs)
{
- assertion(rhs.has_impl_());
+ assertion(rhs.has_impl());
impl_ = rhs.impl();
impl_->ref();
}
@@ -156,7 +156,7 @@
clear();
}
- image_with_impl() : super_type(), impl_(0)
+ image_with_impl() : impl_(0)
{}
image_with_impl(impl_type* impl) :