Commit 37cec09d authored by Roland Levillain's avatar Roland Levillain
Browse files

Revive Swilena (again).

	* box2d.i, dpoint2d.i, dynamic_image2d.i, fill.ixx, image2d.ixx,
	* image2d_int.i, image2d_int_u8, morpho.ixx, neighb2d.i,
	* point2d.i, window2d.i: Catch up with current path, names and
	definitions from Milena.
	* python/morpho-fun.py, python/morpho-segm.py: Likewise.
	* morpho.ixx: Use inlined signatures of functions
	mln::morpho::dilation and mln::morpho::erosion to be wrapped,
	instead of inclusions of mln/morpho/dilation.hh and
	mln/morpho/erosion.hh.
	* neighb2d.i: Instantiate base classes of mln::neighb2d.
	* window2d.i: Instantiate bases classes of mln::window2d.
	(insert(int, int)): New method (extension).
	* point2d.i (row, col): Restrict this method (extension) to
	mln::point2d.
	(point<grid::square, def::coord>(int, int)): New ctor (extension).
	* ch_value.ixx (mln): Aesthetic change.
	* python/dynamic-image2d-misc.py (simple_image.is_valid):
	New method.
	* Makefile.am: Remove dead code.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3821 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 45baf217
2009-05-14 Roland Levillain <roland@lrde.epita.fr>
Revive Swilena (again).
* box2d.i, dpoint2d.i, dynamic_image2d.i, fill.ixx, image2d.ixx,
* image2d_int.i, image2d_int_u8, morpho.ixx, neighb2d.i,
* point2d.i, window2d.i: Catch up with current path, names and
definitions from Milena.
* python/morpho-fun.py, python/morpho-segm.py: Likewise.
* morpho.ixx: Use inlined signatures of functions
mln::morpho::dilation and mln::morpho::erosion to be wrapped,
instead of inclusions of mln/morpho/dilation.hh and
mln/morpho/erosion.hh.
* neighb2d.i: Instantiate base classes of mln::neighb2d.
* window2d.i: Instantiate bases classes of mln::window2d.
(insert(int, int)): New method (extension).
* point2d.i (row, col): Restrict this method (extension) to
mln::point2d.
(point<grid::square, def::coord>(int, int)): New ctor (extension).
* ch_value.ixx (mln): Aesthetic change.
* python/dynamic-image2d-misc.py (simple_image.is_valid):
New method.
* Makefile.am: Remove dead code.
2009-05-15 Guillaume Lazzara <lazzara@lrde.epita.fr>
window2d.i: restore the previous version of this file.
......
......@@ -32,27 +32,29 @@
%module box2d
%{
#include "mln/core/box.hh"
#include "mln/core/box2d.hh"
#include "mln/core/site_set/box.hh"
#include "mln/core/alias/box2d.hh"
%}
%include "mln/core/macros.hh";
%include "mln/metal/is_unqualif.hh";
%include "mln/core/box.hh";
%include "mln/core/box2d.hh";
%include "mln/core/site_set/box.hh";
%include "mln/core/alias/box2d.hh";
// Swig tries to wrap everything by default; prevent it from wrapping
// invalid methods (1D and 3D ctors for a box2d).
/* FIXME: Can't we simplify these directives, i.e. use `point2d' and
`int' directly? */
%ignore mln::box_< mln::point_<mln::grid::square, int> >::
box_(typename mln::point_<mln::grid::square, int>::coord);
%ignore mln::box_< mln::point_<mln::grid::square, int> >::
box_(typename mln::point_<mln::grid::square, int>::coord,
typename mln::point_<mln::grid::square, int>::coord,
typename mln::point_<mln::grid::square, int>::coord);
/* FIXME: Can't we simplify these directives, i.e. use `point2d'
directly? Maybe we could use mln_coord()? */
%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> >
::box(typename mln::point<mln::grid::square, mln::def::coord>::coord);
%extend mln::box_
%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> >
::box(typename mln::point<mln::grid::square, mln::def::coord>::coord,
typename mln::point<mln::grid::square, mln::def::coord>::coord,
typename mln::point<mln::grid::square, mln::def::coord>::coord);
%extend mln::box
{
unsigned nrows() const
{
......@@ -68,4 +70,4 @@ box_(typename mln::point_<mln::grid::square, int>::coord,
}
%template(box2d) mln::box_< mln::point_<mln::grid::square, int> >;
%template(box2d) mln::box< mln::point<mln::grid::square, mln::def::coord> >;
......@@ -46,7 +46,7 @@ namespace mln
namespace trait
{
template <typename I, typename L>
template <typename I, typename V>
struct ch_value
{
// Nothing by default.
......
......@@ -33,17 +33,19 @@
%{
#include "mln/core/dpoint.hh"
#include "mln/core/dpoint2d.hh"
#include "mln/core/alias/dpoint2d.hh"
%}
%include "mln/core/dpoint.hh";
%include "mln/core/dpoint2d.hh";
%include "mln/core/alias/dpoint2d.hh";
// Swig tries to wrap everything by default; prevent it from wrapping
// invalid methods (1D and 3D ctors for a point2d).
%ignore mln::dpoint_<mln::grid::square,int>::dpoint_(const literal::one_t&);
%ignore mln::dpoint_<mln::grid::square,int>::operator=(const literal::one_t&);
%ignore mln::dpoint_<mln::grid::square,int>::dpoint_(int);
%ignore mln::dpoint_<mln::grid::square,int>::dpoint_(int, int, int);
%ignore mln::dpoint<mln::grid::square,mln::def::coord>::dpoint(const literal::one_t&);
%ignore mln::dpoint<mln::grid::square,mln::def::coord>::operator=(const literal::one_t&);
%ignore mln::dpoint<mln::grid::square,mln::def::coord>::dpoint(mln::def::coord);
%ignore mln::dpoint<mln::grid::square,mln::def::coord>::dpoint(mln::def::coord,
mln::def::coord,
mln::def::coord);
%template(dpoint2d) mln::dpoint_<mln::grid::square, int>;
%template(dpoint2d) mln::dpoint<mln::grid::square, mln::def::coord>;
......@@ -43,8 +43,8 @@
%{
# include <mln/core/concept/image.hh>
# include <mln/core/box2d.hh>
# include <mln/core/init.hh>
# include <mln/core/alias/box2d.hh>
# include <mln/core/routine/init.hh>
# include <mln/value/set.hh>
%}
......@@ -71,28 +71,44 @@ namespace mln
namespace trait
{
// These traits actually depend on the exact (here dynamic) type
// of the image, therefore we should provide several entry points
// (dynamic_image_ implementations.
template <typename T>
struct image_< dynamic_image2d<T> >
: default_image_< T, dynamic_image2d<T> >
{
// misc
typedef trait::image::category::primary category;
typedef trait::image::access::random access;
typedef trait::image::space::two_d space;
typedef trait::image::size::regular size;
typedef trait::image::support::aligned support;
typedef trait::image::border::none border;
typedef trait::image::data::raw data;
typedef trait::image::io::read_write io;
typedef trait::image::speed::fast speed;
typedef trait::image::speed::slow speed;
typedef trait::image::size::regular size;
// value
typedef trait::image::vw_io::none vw_io;
typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_access::indirect value_access;
typedef trait::image::value_storage::disrupted value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
typedef trait::image::value_alignment::with_grid value_alignment;
typedef trait::image::value_io::read_write value_io;
// site / domain
typedef trait::image::pw_io::read_write pw_io;
typedef trait::image::localization::basic_grid localization;
typedef trait::image::dimension::two_d dimension;
// extended domain
typedef trait::image::ext_domain::none ext_domain;
typedef trait::image::ext_value::irrelevant ext_value;
typedef trait::image::ext_io::irrelevant ext_io;
};
} // end of namespace mln::trait
/* FIXME: Inherit from internal::image_base to factor methods (see
below)? */
below)? Probably not, as internal::image_base contains data
(through a tracked_ptr). */
// \brief A semi-abstract class that serves as an entry point
// (called director by SWIG) for Python code.
//
......@@ -101,14 +117,13 @@ namespace mln
template <typename T>
struct dynamic_image2d : Image< dynamic_image2d<T> >
{
typedef box2d pset;
typedef box2d domain_t;
typedef point2d site;
typedef point2d psite;
typedef point2d point;
typedef dpoint2d dpoint;
typedef mln_fwd_piter(box2d) fwd_piter;
typedef mln_bkd_piter(box2d) bkd_piter;
// End of warning.
typedef fwd_piter piter;
/// Value associated type.
typedef T value;
......@@ -139,14 +154,12 @@ namespace mln
/// 3).
dynamic_image2d(const box2d& b);
// FIXME: Add a virtual dtor?
/// Initialize an empty image.
virtual void init_(const box2d& b);
/// Test if \p p is valid.
virtual bool owns_(const point2d& p) const;
/// Give the set of values of the image.
virtual const vset& values() const;
......@@ -160,25 +173,30 @@ namespace mln
virtual T& operator()(const point2d& p);
// From internal::image_base.
/// Mesh associated type.
typedef mln_mesh(pset) mesh;
/// Coordinate associated type.
typedef mln_coord(point) coord;
/// Test if \p p belongs to the image domain.
virtual bool has(const psite& p) const;
/// Give a bounding box of the image domain.
virtual const box2d& bbox() const;
/// Give the number of points of the image domain.
virtual std::size_t npoints() const;
/// Test if this image has been initialized; default impl.
virtual bool has_data() const;
/// Is this image valid? (dummy method).
virtual bool is_valid() const;
/// Eligible-value-set associated type.
typedef mln::value::set<T> t_eligible_values_set;
// Return the set of the image eligigle values
const t_eligible_values_set& values_eligible() const;
/// Value space associated type.
typedef mln::value::set<
typename mln::value::super_value<T>::ret > t_values_space;
/// Return the value space of the image.
const t_values_space& values_space() const;
// We can set domain_ to protected, otherwise Python subclasses
// won't see it.
pset domain_;
domain_t domain_;
};
......@@ -220,15 +238,6 @@ namespace mln
domain_ = b;
}
template <typename T>
inline
bool
dynamic_image2d<T>::owns_(const point2d& p) const
{
mln_precondition(exact(this)->has_data());
return exact(this)->has(p);
}
template <typename T>
inline
const typename dynamic_image2d<T>::vset&
......@@ -242,7 +251,7 @@ namespace mln
const box2d&
dynamic_image2d<T>::domain() const
{
mln_precondition(this->has_data());
mln_precondition(this->is_valid());
return domain_;
}
......@@ -253,7 +262,7 @@ namespace mln
const T&
dynamic_image2d<T>::operator()(const point2d& p) const
{
// Nothing.
// Dummy.
assert(false);
}
......@@ -264,7 +273,7 @@ namespace mln
T&
dynamic_image2d<T>::operator()(const point2d& p)
{
// Nothing.
// Dummy.
assert(false);
}
......@@ -273,7 +282,7 @@ namespace mln
bool
dynamic_image2d<T>::has(const psite& p) const
{
mln_precondition(exact(this)->has_data());
mln_precondition(this->is_valid());
return exact(this)->domain().has(p);
}
......@@ -282,25 +291,33 @@ namespace mln
const box2d&
dynamic_image2d<T>::bbox() const
{
mln_precondition(exact(this)->has_data());
mln_precondition(this->is_valid());
return exact(this)->domain().bbox();
}
template <typename T>
inline
std::size_t
dynamic_image2d<T>::npoints() const
bool
dynamic_image2d<T>::is_valid() const
{
mln_precondition(exact(this)->has_data());
return exact(this)->domain().npoints();
// Dummy.
return false;
}
template <typename T>
inline
bool
dynamic_image2d<T>::has_data() const
const typename dynamic_image2d<T>::t_eligible_values_set&
dynamic_image2d<T>::values_eligible() const
{
return t_eligible_values_set::the();
}
template <typename T>
inline
const typename dynamic_image2d<T>::t_values_space&
dynamic_image2d<T>::values_space() const
{
return true;
return t_values_space::the();
}
} // end of namespace mln
......@@ -311,7 +328,7 @@ namespace mln
%include "fill.ixx"
%template(fill) mln::level::fill< mln::dynamic_image2d< mln::value::int_u<8> > >;
%template(fill) mln::data::fill< mln::dynamic_image2d< mln::value::int_u<8> > >;
%include "println.ixx"
%template(println) mln::debug::println< mln::dynamic_image2d< mln::value::int_u<8> > >;
......@@ -27,27 +27,24 @@
// Public License.
/// \file fill.ixx
/// \brief A wrapper of mln::level::fill.
/// \brief A wrapper of mln::data::fill.
%module fill
%{
#include "mln/level/fill.hh"
#include "mln/data/fill.hh"
%}
%include "mln/core/macros.hh"
/* FIXME: Wrap mln::level::fill by hand to help swig choose the right
overload of the algorithm. We might just try to use %ignore
statements instead. */
/* Wrap mln::data::fill by hand to help swig choose the right overload
of the algorithm. We might just try to use %ignore statements
instead in a future version. */
namespace mln
{
namespace level
namespace data
{
template <typename I>
void fill(mln::Image<I>& ima, const mln_value(I)& v);
} // end of namespace mln::level
} // end of namespace mln
}
}
......@@ -36,7 +36,7 @@
%import "box2d.i"
%{
#include "mln/core/image2d.hh"
#include "mln/core/image/image2d.hh"
%}
// Shortcuts macros.
......@@ -61,14 +61,14 @@
%include "mln/core/internal/image_primary.hh"
// mln::image2d definition.
%include "mln/core/image2d.hh"
%include "mln/core/image/image2d.hh"
// FIXME: Doc.
%define instantiate_image2d(I, T)
// Instantiate base classes of mln::image2d<T> so that swig knows it
// Instantiate base classes of mln::image2d<T> so that Swig knows it
// derives from mln::Image.
%template() mln::internal::image_primary_< mln::box2d, mln::image2d< T > >;
%template() mln::internal::image_base_< mln::box2d, mln::image2d< T > >;
%template() mln::internal::image_primary< T, mln::box2d, mln::image2d< T > >;
%template() mln::internal::image_base< T, mln::box2d, mln::image2d< T > >;
%template() mln::internal::image_checked_< mln::image2d< T > >;
// Instantiate mln::image2d<T>
%template(I) mln::image2d< T >;
......
......@@ -42,7 +42,7 @@
instantiate_image2d(image2d_int, int)
%include "fill.ixx"
%template(fill) mln::level::fill< mln::image2d<int> >;
%template(fill) mln::data::fill< mln::image2d<int> >;
%include "println.ixx"
%template(println) mln::debug::println< mln::image2d<int> >;
......@@ -50,7 +50,7 @@ instantiate_image2d(image2d_int, int)
%import "window2d.i"
// FIXME: The import directive does not include the `%{ ... %}' clauses.
%{
#include "mln/core/window2d.hh"
#include "mln/core/alias/window2d.hh"
%}
%include "morpho.ixx"
......
......@@ -46,7 +46,7 @@ instantiate_image2d(image2d_int_u8, mln::value::int_u<8>)
%template(save) mln::io::pgm::save< mln::image2d< mln::value::int_u<8> > >;
%include "fill.ixx"
%template(fill) mln::level::fill< mln::image2d< mln::value::int_u<8> > >;
%template(fill) mln::data::fill< mln::image2d< mln::value::int_u<8> > >;
%include "println.ixx"
%template(println) mln::debug::println< mln::image2d< mln::value::int_u<8> > >;
......@@ -54,13 +54,13 @@ instantiate_image2d(image2d_int_u8, mln::value::int_u<8>)
%import "window2d.i"
// FIXME: The import directive does not include the `%{ ... %}' clauses.
%{
#include "mln/core/window2d.hh"
#include "mln/core/alias/window2d.hh"
%}
%import "neighb2d.i"
// FIXME: The import directive does not include the `%{ ... %}' clauses.
%{
#include "mln/core/neighb2d.hh"
#include "mln/core/alias/neighb2d.hh"
%}
%include "morpho.ixx"
......
......@@ -43,8 +43,29 @@
#include "mln/morpho/erosion.hh"
%}
%include "mln/morpho/dilation.hh"
%include "mln/morpho/erosion.hh"
/* Files mln/morpho/dilation.hh and mln/morpho/erosion.hh contains too
much implementation details. Using just
%include "mln/morpho/dilation.hh"
%include "mln/morpho/erosion.hh"
would require a lot of efforts. Use an explicit prototypes
instead. */
namespace mln
{
namespace morpho
{
template <typename I, typename W>
mln_concrete(I)
dilation(const Image<I>& input, const Window<W>& win);
template <typename I, typename W>
mln_concrete(I)
erosion(const Image<I>& input, const Window<W>& win);
}
}
%define instantiate_dilation(Name, I, W)
// Explicit instantiation of this trait for the return type.
......@@ -58,28 +79,28 @@
%template(Name) mln::morpho::erosion< I, W >;
%enddef
/*----------------------------------.
| Morphological closing & opening. |
`----------------------------------*/
/*-----------------------------------------------.
| Morphological (elementary) closing & opening. |
`-----------------------------------------------*/
%{
#include "mln/morpho/closing.hh"
#include "mln/morpho/opening.hh"
#include "mln/morpho/elementary/closing.hh"
#include "mln/morpho/elementary/opening.hh"
%}
%include "mln/morpho/closing.hh"
%include "mln/morpho/opening.hh"
%include "mln/morpho/elementary/closing.hh"
%include "mln/morpho/elementary/opening.hh"
%define instantiate_closing(Name, I, W)
%define instantiate_closing(Name, I, N)
// Explicit instantiation of this trait for the return type.
%template() mln::trait::concrete< I >;
%template(Name) mln::morpho::closing< I, W >;
%template(Name) mln::morpho::elementary::closing< I, N >;
%enddef
%define instantiate_opening(Name, I, W)
%define instantiate_opening(Name, I, N)
// Explicit instantiation of this trait for the return type.
%template() mln::trait::concrete< I >;
%template(Name) mln::morpho::opening< I, W >;
%template(Name) mln::morpho::elementary::opening< I, N >;
%enddef
/*------------.
......@@ -115,19 +136,19 @@
`-------------------------*/
%{
#include "mln/morpho/closing_area.hh"
#include "mln/morpho/opening_area.hh"
#include "mln/morpho/closing/area.hh"
#include "mln/morpho/opening/area.hh"
%}
%include "mln/morpho/closing_area.hh"
%include "mln/morpho/opening_area.hh"
%include "mln/morpho/closing/area.hh"
%include "mln/morpho/opening/area.hh"
%define instantiate_closing_area(Name, I, N)
%template(Name) mln::morpho::closing_area< I, N, I >;
%template(Name) mln::morpho::closing::area< I, N >;
%enddef
%define instantiate_opening_area(Name, I, N)
%template(Name) mln::morpho::opening_area< I, N, I >;
%template(Name) mln::morpho::opening::area< I, N >;
%enddef
/*------------------------------------.
......@@ -140,6 +161,7 @@
%include "mln/morpho/meyer_wst.hh"
// FIXME: Wrap mln::morpho::watershed::flooding instead.
%define instantiate_meyer_wst(Name, L, I, N)
// Explicit instantiation of this trait for the return type.
%template() mln::trait::ch_value< I, L >;
......@@ -154,8 +176,8 @@
instantiate_dilation(dilation, I, W)
instantiate_erosion(erosion, I, W)
instantiate_closing(closing, I, W)
instantiate_opening(opening, I, W)
instantiate_closing(closing, I, N)
instantiate_opening(opening, I, N)
instantiate_gradient(gradient, I, W)
instantiate_gradient_internal(gradient_internal, I, W)
......
......@@ -32,25 +32,57 @@
%module neighb2d
%import "dpoint2d.i"
%import "window2d.i"
%{
#include "mln/core/neighb2d.hh"
#include "mln/core/alias/neighb2d.hh"
%}
%include "mln/metal/is_a.hh"
%include "mln/core/macros.hh"
%include "mln/core/concept/neighborhood.hh"
%include "mln/core/internal/neighborhood_base.hh"
%include "mln/core/neighb.hh"
%include "mln/core/neighb2d.hh"
%include "mln/core/alias/neighb2d.hh"
// Swig tries to wrap everything by default; prevent it from wrapping
// invalid methods (1D and 3D insertions for a neighb2d).
%ignore mln::neighb_< mln::dpoint_<mln::grid::square, int > >::
insert(const typename mln::dpoint_<mln::grid::square, int>::coord&);
%ignore mln::neighb_< mln::dpoint_<mln::grid::square, int > >::
insert(const typename mln::dpoint_<mln::grid::square, int>::coord&,
const typename mln::dpoint_<mln::grid::square, int>::coord&,
const typename mln::dpoint_<mln::grid::square, int>::coord&);
%template(neighb2d) mln::neighb_< mln::dpoint_<mln::grid::square, int > >;
%ignore mln::neighb< mln::window < mln::dpoint<mln::grid::square,mln::def::coord > > >
::insert(const typename mln::dpoint<mln::grid::square,mln::def::coord>::coord&);
%ignore mln::neighb< mln::window < mln::dpoint<mln::grid::square, mln::def::coord > > >
::insert(const typename mln::dpoint<mln::grid::square,mln::def::coord>::coord&,
const typename mln::dpoint<mln::grid::square,mln::def::coord>::coord&,
const typename mln::dpoint<mln::grid::square,mln::def::coord>::coord&);
// Instantiate base classes of mln::neighb2d so that Swig knows it
// derives from mln::Neighborhood.
%template() mln::Neighborhood<
mln::neighb<