2138: Provide instantiation macros for module `morpho'.

https://svn.lrde.epita.fr/svn/oln/trunk/swilena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Provide instantiation macros for module `morpho'. * morpho.ixx (instantiate_dilation, instantiate_erosion) (instantiate_gradient, instantiate_closing_area) (instantiate_meyer_wst): New SWIG macros. (instantiate_morpho): Likewise. Use it... * image2d_int_u8.i: ...here, to simplify the wrapping of morpho routines. image2d_int_u8.i | 39 +++++++++------------------------------ morpho.ixx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 58 insertions(+), 34 deletions(-) Index: image2d_int_u8.i --- image2d_int_u8.i (revision 2137) +++ image2d_int_u8.i (working copy) @@ -60,46 +60,25 @@ %include "morpho.ixx" -// Explicit instantiation of this trait for the return type of -// mln::morpho::dilation, mln::morpho::erosion and mln::morpho::gradient. -%template() mln::trait::concrete< mln::image2d< mln::value::int_u<8> > >; - -/* FIXME: Can't we use `mln::value::int8' directlt here (as we can +/* FIXME: Can't we use `mln::value::int8' directly here (as we can use `mln::window2d', which is a really just typedef for - `mln::window< mln::dpoint_<mln::grid::square, int> >')? */ -%template(dilation) mln::morpho::dilation< mln::image2d< mln::value::int_u<8> >, - mln::window2d >; -%template(erosion) mln::morpho::erosion< mln::image2d< mln::value::int_u<8> >, - mln::window2d >; - -%template(gradient) mln::morpho::gradient< mln::image2d< mln::value::int_u<8> >, - mln::window2d >; + `mln::window< mln::dpoint_<mln::grid::square, int> >')? -%template(closing_area) -mln::morpho::closing_area< mln::image2d< mln::value::int_u<8> >, + 2008-08-11: Probably, but we should %include "mln/value/int_u8.hh" + then. */ +instantiate_morpho(mln::image2d< mln::value::int_u<8> >, + mln::window2d, mln::neighb2d, - mln::image2d< mln::value::int_u<8> > >; - -%template() mln::trait::ch_value< mln::image2d< mln::value::int_u<8> >, - mln::value::int_u<8> >; -%template(meyer_wst) mln::morpho::meyer_wst< - mln::value::int_u<8>, - mln::image2d< mln::value::int_u<8> >, - mln::neighb2d - >; + mln::value::int_u<8>) /*---------------------------------------. | image2d<int_u8> and image2d<int_u32>. | `---------------------------------------*/ -// Explicit instantiation of this trait for the return type of meyer_wst32. -%template() mln::trait::ch_value< mln::image2d< mln::value::int_u<8> >, - mln::value::int_u<32> >; -%template(meyer_wst32) mln::morpho::meyer_wst< +instantiate_meyer_wst(meyer_wst32, mln::value::int_u<32>, mln::image2d< mln::value::int_u<8> >, - mln::neighb2d - >; + mln::neighb2d) // FIXME: Rearrange and move this elsewhere. instantiate_image2d(image2d_int_u32, mln::value::int_u<32>) Index: morpho.ixx --- morpho.ixx (revision 2137) +++ morpho.ixx (working copy) @@ -31,9 +31,9 @@ %module morpho -/*---------------------. -| Dilation & erosion. | -`---------------------*/ +/*-----------------------------------. +| Morphological dilation & erosion. | +`-----------------------------------*/ %include "concrete.ixx" @@ -45,7 +45,22 @@ %include "mln/morpho/dilation.hh" %include "mln/morpho/erosion.hh" -// FIXME: Add morphological opening & closing. +%define instantiate_dilation(Name, I, W) + // Explicit instantiation of this trait for the return type. + %template() mln::trait::concrete< I >; + %template(Name) mln::morpho::dilation< I, W >; +%enddef + +%define instantiate_erosion(Name, I, W) + %template() mln::trait::concrete< I >; + %template(Name) mln::morpho::erosion< I, W >; +%enddef + +/*----------------------------------. +| Morphological opening & closing. | +`----------------------------------*/ + +// FIXME: Add them. /*------------. | Gradients. | @@ -59,6 +74,12 @@ %include "mln/morpho/gradient.hh" +%define instantiate_gradient(Name, I, W) + // Explicit instantiation of this trait for the return type. + %template() mln::trait::concrete< I >; + %template(Name) mln::morpho::gradient< I, W >; +%enddef + /*-------------------------. | Area closing & opening. | `-------------------------*/ @@ -71,6 +92,10 @@ %include "mln/morpho/closing_area.hh" +%define instantiate_closing_area(Name, I, N) + %template(Name) mln::morpho::closing_area< I, N, I >; +%enddef + /*------------------------------------. | Meyer's Watershed Transform (WST). | `------------------------------------*/ @@ -82,3 +107,23 @@ %} %include "mln/morpho/meyer_wst.hh" + +%define instantiate_meyer_wst(Name, L, I, N) + // Explicit instantiation of this trait for the return type. + %template() mln::trait::ch_value< I, L >; + %template(Name) mln::morpho::meyer_wst< L, I, N >; +%enddef + +/*-------------------------. +| Instantiate everything. | +`-------------------------*/ + +%define instantiate_morpho(I, W, N, L) + instantiate_dilation(dilation, I, W) + instantiate_erosion(erosion, I, W) + instantiate_gradient(gradient, I, W) + instantiate_closing_area(closing_area, I, N) + // FIXME: Could we used `typename I::value' instead of `L' here, and + // remove L from the list of arguments? + instantiate_meyer_wst(meyer_wst, L, I, N) +%enddef
participants (1)
-
Roland Levillain