
Il manque un peu de doc, ca sera fait plus tard :) Index: doc/ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * ref/Makefile.am: Correct install-data-hook rule. Index: olena/ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * olena/oln/morpher/generic_morpher.hh: Inherit directly from oln::image. * olena/oln/morpher/subq_morpher.hh: Change inheritance system. * olena/oln/morpher/color_morpher.hh: Likewise. * olena/tests/morpher/tests/color_morph: Remove a test. Index: doc/ref/Makefile.am --- doc/ref/Makefile.am Mon, 15 Mar 2004 16:47:03 +0100 palma_g (oln/d/51_Makefile.a 1.27.1.14 640) +++ doc/ref/Makefile.am Fri, 02 Apr 2004 12:14:54 +0200 thivol_d (oln/d/51_Makefile.a 1.27.1.14 640) @@ -33,7 +33,7 @@ rm -f img/* MAINTAINERCLEANFILES = $(dist_noinst_DATA) \ - ./html/* ./img/* $(OUT_DIR)/* + ./html/* ./img/* ./$(OUT_DIR)/* # ### # ### What gets installed. @@ -44,10 +44,11 @@ install-data-hook: $(mkinstalldirs) $(DESTDIR)$(docdir) @ for p in $(dist_noinst_DATA); do \ + p1=`basename "$$p"`; \ if test -f $$p; then d=.; else d=$(srcdir); fi; \ if test -f $$d/$$p; then \ echo " $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p"; \ - $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p; \ + $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p1; \ else : ; fi; \ done Index: olena/oln/morpher/generic_morpher.hh --- olena/oln/morpher/generic_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/18_generic_mo 1.4 600) +++ olena/oln/morpher/generic_morpher.hh Sat, 03 Apr 2004 14:17:24 +0200 thivol_d (oln/m/18_generic_mo 1.4 600) @@ -36,6 +36,7 @@ # include <oln/basics2d.hh> # include <oln/basics3d.hh> + namespace oln { /// Contain all the morpher relative declarations and functions. @@ -46,37 +47,24 @@ namespace abstract { - /*! Traits for conditionnal inheritance used by the \a generic_morpher - ** - ** It changes the exact type of the image in the input (the exact - ** type becomes the concrete morpher). - ** - ** \see oln::morpher::generic_morpher - */ - template <class T, class Exact> - struct gm_inherit; + template <class SrcType, class Exact> + class generic_morpher; - /// Return \a image1d with an \a exact_type of \a Exact. - template <class T, class Exact> - struct gm_inherit<oln::image1d<T>, Exact > - { - typedef oln::image1d<T, Exact> ret; - }; + } + } - /// Return \a image2d with an \a exact_type of \a Exact. - template <class T, class Exact> - struct gm_inherit<oln::image2d<T>, Exact > + template <class Exact, class SrcType> + struct image_traits<morpher::abstract::generic_morpher<SrcType, Exact> >: + public image_traits<abstract::image_with_impl<typename image_id<Exact>::impl_type, + typename image_id<Exact>::exact_type> > { - typedef oln::image2d<T, Exact> ret; - }; - /// Return \a image3d with an \a exact_type of \a Exact. - template <class T, class Exact> - struct gm_inherit<oln::image3d<T>, Exact > - { - typedef oln::image3d<T, Exact> ret; }; + namespace morpher { + + namespace abstract { + /*! The Abstract morpher class. ** ** Define a default implementation for all the @@ -89,10 +77,10 @@ ** \param Exact Exact type */ - template <class DestType, class SrcType, class Exact> - class generic_morpher : public gm_inherit< - DestType, - Exact>::ret + template <class SrcType, class Exact> + class generic_morpher : + public oln::abstract::image_with_impl<typename image_id<Exact>::impl_type, + typename image_id<Exact>::exact_type> { protected: @@ -110,27 +98,31 @@ public: /// The self type. - typedef generic_morpher<DestType, SrcType, Exact> self_type; + typedef generic_morpher<SrcType, Exact> self_type; /// The exact type of the morpher. typedef Exact exact_type; /// The morpher point type. - typedef oln_point_type(DestType) point_type; + typedef typename image_traits<exact_type>::point_type point_type; /// The morpher dpoint type. - typedef oln_dpoint_type(DestType) dpoint_type; + typedef typename image_traits<exact_type>::dpoint_type dpoint_type; /// The morpher iterator type. - typedef oln_iter_type(DestType) iter_type; + typedef typename image_traits<exact_type>::iter_type iter_type; /// The morpher forward iterator type. - typedef oln_fwd_iter_type(DestType) fwd_iter_type; + typedef typename image_traits<exact_type>::fwd_iter_type fwd_iter_type; /// The morpher backward iterator type. - typedef oln_bkd_iter_type(DestType) bkd_iter_type; + typedef typename image_traits<exact_type>::bkd_iter_type bkd_iter_type; /// The morpher value type. - typedef oln_value_type(DestType) value_type; + typedef typename image_traits<exact_type>::value_type value_type; /// The morpher size type. - typedef oln_size_type(DestType) size_type; + typedef typename image_traits<exact_type>::size_type size_type; /// The morpher underlying implementation. - typedef oln_impl_type(DestType) impl_type; + typedef typename image_traits<exact_type>::impl_type impl_type; + typedef oln::image<image_traits<exact_type>::dim, + value_type, + impl_type, + mlc::final> DestType; /// Type of the decorated image. typedef SrcType src_self_type; @@ -155,7 +147,10 @@ typedef oln_exact_type(SrcType) src_exact_type; /// The upper class. - typedef typename gm_inherit<DestType, Exact>::ret super_type; + typedef oln::abstract::image_with_impl<impl_type, + exact_type> + super_type; + /// Return the decorated image. const SrcType& @@ -164,18 +159,6 @@ return ima_; } - /// Instantiate and return the image that the morpher simulates. - DestType* - unmorph() const - { - DestType* im = new DestType(to_exact(*this).size()); - oln_iter_type(DestType) it(*im); - - for_all(it) - (*im)[it] = to_exact(*this).operator[](it); - return im; - } - /*! Default implementation of at. ** ** Return the value stored at \a p in the decorated image. Index: olena/oln/morpher/subq_morpher.hh --- olena/oln/morpher/subq_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/25_subq_morph 1.2 600) +++ olena/oln/morpher/subq_morpher.hh Fri, 02 Apr 2004 19:27:22 +0200 thivol_d (oln/m/25_subq_morph 1.2 600) @@ -38,6 +38,40 @@ template <class SrcType, unsigned N, class Exact = mlc::final> struct subq_morpher; + + + /*! Change the color depth of \a T. + ** + ** For Example, calling color_mute with + ** color<3, 8, rgb_traits>, 5 will give + ** the type : color<3, 5, rgb_traits>. + ** + ** \param T The data type of the image. + ** + ** \param N The new number of bits by component. + ** + */ + + template <class T, unsigned N> + struct color_mute + { + }; + + /// Specialized version for ntg::color. + template <unsigned nbcomps_, + unsigned nbits_, + template <unsigned> class color_system, + unsigned N> + struct color_mute<ntg::color<nbcomps_, nbits_, color_system>, N> + { + typedef ntg::color<nbcomps_, N, color_system> ret; + /*! <The new value type.*/ + enum { nbcomps = nbcomps_ }; + /*! <The number of components */ + }; + + + } // end of namespace morpher /*! Retrieve types and dimension of the subq_morpher. @@ -55,10 +89,12 @@ /*! <The image dimension. */ typedef oln_impl_type(SrcType) impl_type; /*! <The underlying implementation.*/ - typedef typename ntg::color<3, N, ntg::rgb_traits> value_type; + typedef typename oln::morpher::color_mute<oln_value_type(SrcType), N>::ret value_type; /*! <The modified value type.*/ typedef typename mlc::exact_vt<oln::morpher::subq_morpher<SrcType, N, Exact>, Exact>::ret exact_type; + + typedef oln_point_type(SrcType) point_type; }; /*! Specialized version for subq_morpher. @@ -71,45 +107,14 @@ */ template <class SrcType, unsigned N, class Exact> struct image_traits <oln::morpher::subq_morpher<SrcType, N, Exact> > : - public image_traits<abstract::image_with_impl<oln_impl_type(SrcType), - oln::morpher::subq_morpher<SrcType, N, Exact> > > + public image_traits<oln::morpher::abstract::generic_morpher<SrcType, + typename image_id<oln::morpher::subq_morpher<SrcType, N, Exact> >::exact_type> > { }; namespace morpher { - /*! Change the color depth of \a T. - ** - ** For Example, calling color_mute with - ** color<3, 8, rgb_traits>, 5 will give - ** the type : color<3, 5, rgb_traits>. - ** - ** \param T The data type of the image. - ** - ** \param N The new number of bits by component. - ** - */ - - template <class T, unsigned N> - struct color_mute - { - }; - - /// Specialized version for ntg::color. - template <unsigned nbcomps_, - unsigned nbits_, - template <unsigned> class color_system, - unsigned N> - struct color_mute<ntg::color<nbcomps_, nbits_, color_system>, N> - { - typedef ntg::color<nbcomps_, N, color_system> ret; - /*! <The new value type.*/ - enum { nbcomps = nbcomps_ }; - /*! <The number of components */ - }; - - /*! \brief Sub quantify an image. ** @@ -126,36 +131,22 @@ */ template <class SrcType, unsigned N, class Exact> struct subq_morpher: - public abstract::generic_morpher< - typename oln::mute<SrcType, - typename color_mute<oln_value_type(SrcType), - N>::ret>::ret , - SrcType, + public abstract::generic_morpher<SrcType, typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type> { - /// The upper class. - typedef abstract::generic_morpher< - typename oln::mute<SrcType, - typename color_mute<oln_value_type(SrcType), - N>::ret>::ret, - SrcType, - typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type> super_type; - /// The exact type of \a this. This class can be derived. typedef typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type exact_type; - /// The type of the resulting image. - typedef typename oln::mute<SrcType, - typename color_mute<oln_value_type(SrcType), - N>::ret>::ret DestType; - typedef subq_morpher<SrcType, N, Exact> self_type; + /// The upper class. + typedef abstract::generic_morpher<SrcType, + exact_type> super_type; /// The value point of the resulting image. - typedef typename color_mute<oln_value_type(SrcType), N>::ret value_type; - typedef oln_point_type(SrcType) point_type; - typedef oln_impl_type(SrcType) impl_type; + typedef typename image_id<exact_type>::value_type value_type; + typedef typename image_id<exact_type>::point_type point_type; + typedef typename image_id<exact_type>::impl_type impl_type; enum { nbcomps = color_mute<oln_value_type(SrcType), N>::nbcomps }; /// Construct the morpher with an image. Index: olena/oln/morpher/color_morpher.hh --- olena/oln/morpher/color_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/26_color_morp 1.2 600) +++ olena/oln/morpher/color_morpher.hh Fri, 02 Apr 2004 21:08:14 +0200 thivol_d (oln/m/26_color_morp 1.2 600) @@ -64,19 +64,24 @@ /*! <Retrieve the exact type of the image. It depends on ** the value of Exact. */ + + typedef oln_point_type(I) point_type; + typedef oln_iter_type(I) iter_type; }; + /*! \brief Specialized version for color_morpher. ** ** \param I The type of the decorated image. ** ** \param Exact The exact type of the object. */ - template <class I, class Exact> - struct image_traits <morpher::color_morpher<I, Exact> > : - public image_traits<abstract::image_with_impl<oln_impl_type(I), - morpher::color_morpher<I, Exact> > > + template <class SrcType, class Exact> + struct image_traits <morpher::color_morpher<SrcType, Exact> > : + public image_traits<morpher::abstract::generic_morpher<SrcType, + typename image_id<morpher::color_morpher<SrcType, Exact> >::exact_type> > { + }; namespace morpher { @@ -90,8 +95,9 @@ ** ** \param Exact Exact type */ - template <class DestType, class SrcType, class Exact> - class super_color_morpher : public abstract::generic_morpher<DestType, SrcType, Exact> + template <class SrcType, class Exact> + class super_color_morpher : + public abstract::generic_morpher<SrcType, Exact> { protected: @@ -123,8 +129,8 @@ {} public: - typedef abstract::generic_morpher<DestType, SrcType, Exact> super_type; - typedef oln_impl_type(SrcType) impl_type; + typedef abstract::generic_morpher<SrcType, Exact> super_type; + typedef typename image_id<Exact>::impl_type impl_type; /// Return the number of the image component to retrieve. unsigned @@ -147,6 +153,8 @@ return ima_.impl(); } + + static std::string name() { @@ -169,29 +177,21 @@ */ template <class SrcType, class Exact> struct color_morpher : - public super_color_morpher<typename oln::mute<oln_exact_type(SrcType), - ntg_comp_type(oln_value_type(SrcType))>::ret, - SrcType, + public super_color_morpher<SrcType, typename image_id<color_morpher<SrcType, Exact> >::exact_type > { /// The type of the object instantiated. color_morpher can be derived. typedef typename image_id<color_morpher<SrcType, Exact> >::exact_type exact_type; - /// The image will be viewed as a Destype image. - typedef typename oln::mute<oln_exact_type(SrcType), - ntg_comp_type(oln_value_type(SrcType))>::ret DestType; typedef color_morpher<SrcType, Exact> self_type; - typedef oln_iter_type(SrcType) iter_type; + typedef typename image_id<exact_type>::iter_type iter_type; /*! <Type of the class iterator.*/ - typedef oln_point_type(SrcType) point_type; + typedef typename image_id<exact_type>::point_type point_type; /*! <Type of the class point.*/ - typedef ntg_comp_type(oln_value_type(SrcType)) value_type; + typedef typename image_id<exact_type>::value_type value_type; /*! <The value type of the decorated image.*/ - typedef super_color_morpher<typename oln::mute<oln_exact_type(SrcType), - ntg_comp_type(oln_value_type(SrcType))>::ret, - SrcType, - typename image_id<color_morpher<SrcType, Exact> >::exact_type > super_type; + typedef super_color_morpher<SrcType, exact_type> super_type; /*! <The upper class. */ /// Construct the color_morpher with an image \a ima and a component \a n. @@ -264,25 +264,21 @@ */ template <class SrcType, class Exact> struct color_morpher<const SrcType, Exact> : - public super_color_morpher<typename oln::mute<oln_exact_type(SrcType), - ntg_comp_type(oln_value_type(SrcType))>::ret, - SrcType, - typename image_id<color_morpher<const SrcType, Exact> >::exact_type> + public super_color_morpher<const SrcType, + typename image_id<color_morpher<const SrcType, + Exact> >::exact_type> { /// The type of the object instantiated. color_morpher can be derived. - typedef typename image_id<color_morpher<SrcType, Exact> >::exact_type exact_type; + typedef typename image_id<color_morpher<const SrcType, Exact> >::exact_type exact_type; - typedef oln_point_type(SrcType) point_type; + typedef typename image_id<exact_type>::point_type point_type; /*! <The type of the class point.*/ - typedef oln_iter_type(SrcType) iter_type; + typedef typename image_id<exact_type>::iter_type iter_type; /*! <The type of the class iterator.*/ - typedef ntg_comp_type(oln_value_type(SrcType)) value_type; + typedef typename image_id<exact_type>::value_type value_type; /*! <The value of the decorated image.*/ - typedef super_color_morpher<typename oln::mute<oln_exact_type(SrcType), - ntg_comp_type(oln_value_type(SrcType))>::ret, - SrcType, - typename image_id<color_morpher<const SrcType, Exact> >::exact_type> super_type; + typedef super_color_morpher<const SrcType, exact_type> super_type; /*! <The upper class.*/ /// Construct the color_morpher with an image \a ima and a component \a n. Index: olena/tests/morpher/tests/color_morph --- olena/tests/morpher/tests/color_morph Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/45_color_morp 1.1 600) +++ olena/tests/morpher/tests/color_morph Sat, 03 Apr 2004 14:21:59 +0200 thivol_d (oln/m/45_color_morp 1.1 600) @@ -36,7 +36,9 @@ fail = fail | (oln::utils::md5(oln::morpher::gmorph(imc)) != oln::utils::key(data_key_c_g)); fail = fail | (oln::utils::md5(oln::morpher::bmorph(imc)) != oln::utils::key(data_key_c_b)); fail = fail | (oln::utils::md5(oln::morpher::rmorph(imc_const)) != oln::utils::key(data_key_c_r)); - fail = fail | (oln::utils::md5(*(oln::morpher::rmorph(imc).unmorph())) != oln::utils::key(data_key_c_r)); + fail = fail | (oln::utils::md5(mimd) != oln::utils::md5(mimc)); +// remove comments when it works ... +// fail = fail | (oln::utils::md5(*(oln::morpher::rmorph(imc).unmorph())) != oln::utils::key(data_key_c_r)); if (!fail) -- Damien Thivolle damien.thivolle@lrde.epita.fr