Commit 71870263 authored by Nicolas Ballas's avatar Nicolas Ballas
Browse files

Add the image value type in the class image_base_.

	* mln/core/internal/image_base.hh: .
	* mln/core/internal/image_morpher.hh: .
	* mln/core/internal/site_set_iterator_base.hh: .
	* mln/core/internal/image_primary.hh: .
	* mln/core/internal/image_identity.hh: .
	* mln/core/internal/image_domain_morpher.hh: .
	* mln/core/internal/image_value_morpher.hh: .
	* mln/core/site_set/box.hh: fix compile warning.
	* mln/core/site_set/box_piter.hh: .
	* mln/core/image/lazy_image.hh: .
	* mln/core/image/extension_fun.hh: .
	* mln/core/image/cast_image.hh: .
	* mln/core/image/image_if.hh: .
	* mln/core/image/graph_image.hh: .
	* mln/core/image/line_graph_image.hh: .
	* mln/core/image/hexa.hh: .
	* mln/core/image/flat_image.hh: .
	* mln/core/image/interpolated.hh: .
	* mln/core/image/extension_ima.hh: .
	* mln/core/image/bgraph_image.hh: .
	* mln/core/image/t_image.hh: .
	* mln/core/image/image1d.hh: .
	* mln/core/image/image2d.hh: .
	* mln/core/image/fi_adaptor.hh: .
	* mln/core/image/image3d.hh: .
	* mln/core/image/complex_image.hh: .
	* mln/core/image/inplace.hh: .
	* mln/pw/image.hh: .
	* mln/core/image/extension_val.hh: .
	* mln/core/concept/image.hh: .
	* mln/level/fill_with_value.hh: .
	* mln/make/box2d.hh: .
	* mln/border/find.hh: .
	* mln/algebra/vec.hh: fix compile mistakes.
	* tests/core/image/image_if.cc: Update the test.
	* tests/core/image/Makefile.am: Update.
	* tests/core/image/flat_image.cc: New Test.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008@2191 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent bfb6aab8
2008-09-05 Nicolas Ballas <ballas@lrde.epita.fr>
Add the image value type in the class image_base_.
* mln/core/internal/image_base.hh: .
* mln/core/internal/image_morpher.hh: .
* mln/core/internal/site_set_iterator_base.hh: .
* mln/core/internal/image_primary.hh: .
* mln/core/internal/image_identity.hh: .
* mln/core/internal/image_domain_morpher.hh: .
* mln/core/internal/image_value_morpher.hh: .
* mln/core/site_set/box.hh: fix compile warning.
* mln/core/site_set/box_piter.hh: .
* mln/core/image/lazy_image.hh: .
* mln/core/image/extension_fun.hh: .
* mln/core/image/cast_image.hh: .
* mln/core/image/image_if.hh: .
* mln/core/image/graph_image.hh: .
* mln/core/image/line_graph_image.hh: .
* mln/core/image/hexa.hh: .
* mln/core/image/flat_image.hh: .
* mln/core/image/interpolated.hh: .
* mln/core/image/extension_ima.hh: .
* mln/core/image/bgraph_image.hh: .
* mln/core/image/t_image.hh: .
* mln/core/image/image1d.hh: .
* mln/core/image/image2d.hh: .
* mln/core/image/fi_adaptor.hh: .
* mln/core/image/image3d.hh: .
* mln/core/image/complex_image.hh: .
* mln/core/image/inplace.hh: .
* mln/pw/image.hh: .
* mln/core/image/extension_val.hh: .
* mln/core/concept/image.hh: .
* mln/level/fill_with_value.hh: .
* mln/make/box2d.hh: .
* mln/border/find.hh: .
* mln/algebra/vec.hh: fix compile mistakes.
* tests/core/image/image_if.cc: Update the test.
* tests/core/image/Makefile.am: Update.
* tests/core/image/flat_image.cc: New Test.
2008-09-05 Thierry Geraud <thierry.geraud@lrde.epita.fr>
 
Add convert::to and conversion from v2v; fix misc stuff.
......
......@@ -47,6 +47,7 @@
# include <mln/value/ops.hh>
// FIXME: Document.
......@@ -56,14 +57,16 @@ namespace mln
// Forward declarations.
namespace algebra {
template <unsigned n, typename T> class vec;
template <unsigned d, typename C> struct h_vec;
template <unsigned d, typename C> class h_vec;
}
namespace literal {
struct zero_t;
}
namespace trait
{
......@@ -209,7 +212,7 @@ namespace mln
unsigned size() const;
const vec<n, T>& normalize();
/// Constructor; coordinates are set by function \p f.
template <typename F>
vec(const Function_i2v<F>& f);
......@@ -572,12 +575,12 @@ namespace mln
for (unsigned i = 0; i < P::dim; ++i)
tmp[i] = round(v[i]);
return tmp;
}
}
} // end of namespace mln::algebra
# endif // MLN_INCLUDE_ONLY
} // end of namespace mln
......
......@@ -59,16 +59,16 @@ namespace mln
namespace impl
{
template <typename I, typename S, typename E>
template <typename I, typename T, typename S, typename E>
inline
unsigned find__(const mln::internal::image_morpher<I,S,E>& ima)
unsigned find__(const mln::internal::image_morpher<I, T, S, E>& ima)
{
return border::find(*ima.delegatee_());
}
template <typename S, typename E>
template <typename T, typename S, typename E>
inline
unsigned find__(const mln::internal::image_base<S,E>&)
unsigned find__(const mln::internal::image_base<T, S, E>&)
{
return 0;
}
......
......@@ -111,6 +111,29 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
namespace internal
{
template <typename values_browsing_trait, typename E>
struct image_values_interface_check
{
static void run() { /* No Requirement */}
};
template <typename E>
struct image_values_interface_check<
mln::trait::image::value_browsing::value_wise,
E>
{
static void run()
{
void (E::*m)(const typename E::value& old_val,
const typename E::value& new_val) = & E::change_value;
m = 0;
}
};
}
template <typename E>
inline
Image<E>::Image()
......@@ -139,6 +162,7 @@ namespace mln
typedef mln_value(E) value;
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
typedef typename E::t_eligible_value_set t_eligible_value_set;
typedef mln_vset(E) vset;
const vset& (E::*m5)() const = & E::values;
......@@ -152,7 +176,14 @@ namespace mln
const pset& (E::*m8)() const = & E::domain;
m8 = 0;
const t_eligible_value_set& (E::*m9)() const = & E::values_eligible;
m9 = 0;
typedef typename E::skeleton skeleton;
/// Optional interface:
internal::image_values_interface_check<mln_trait_image_value_browsing(E),
E>::run();
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -97,7 +97,7 @@ namespace mln
public internal::image_primary< p_bgraph<P>, bgraph_image<P, V> >
{
typedef mln::internal::image_base< p_bgraph<P>, bgraph_image<P, V> >
typedef mln::internal::image_base< V, p_bgraph<P>, bgraph_image<P, V> >
super_;
/// Value associated type.
......
......@@ -80,7 +80,8 @@ namespace mln
*
*/
template <typename T, typename I>
struct cast_image_ : public internal::image_value_morpher< I, cast_image_<T,I> >
struct cast_image_ :
public internal::image_value_morpher< I, T, cast_image_<T,I> >
{
/// Value associated type.
typedef T value;
......
......@@ -100,7 +100,7 @@ namespace mln
/// Values are stored on the vertices of the graph.
template <unsigned D, typename P, typename V>
struct complex_image :
public internal::image_primary_< p_complex<D, P>, complex_image<D, P, V> >
public internal::image_primary_< V, p_complex<D, P>, complex_image<D,P,V> >
{
/// Super type.
typedef mln::internal::image_base_< p_complex<D, P>,
......
......@@ -88,9 +88,8 @@ namespace mln
// FIXME: Doc!
template <typename I, typename F>
class extension_fun
: public internal::image_identity< I, mln_pset(I), extension_fun<I, F> >,
class extension_fun :
public internal::image_identity< I, mln_pset(I), extension_fun<I, F> >,
private mlc_converts_to(mln_result(F), mln_value(I))::check_t
{
public:
......@@ -102,7 +101,7 @@ namespace mln
/// Return type of read-only access.
typedef mln_value(I) rvalue;
/// Constructor without argument.
extension_fun();
......
......@@ -102,7 +102,7 @@ namespace mln
/// Return type of read-only access.
typedef mln_value(I) rvalue;
/// Constructor without argument.
extension_ima();
......
......@@ -87,14 +87,15 @@ namespace mln
// FIXME: Doc!
template <typename I>
class extension_val : public internal::image_identity< I, mln_pset(I), extension_val<I> >
class extension_val :
public internal::image_identity< I, mln_pset(I), extension_val<I> >
{
public:
/// Skeleton.
typedef extension_val< tag::image_<I> > skeleton;
// FIXME: OK when ch_value?
/// Return type of read-only access.
typedef mln_value(I) rvalue;
......
......@@ -129,7 +129,8 @@ namespace mln
*/
template <typename I>
struct fi_adaptor : public internal::image_primary< box2d, fi_adaptor<I> >
struct fi_adaptor : public internal::image_primary< mln_value(I), box2d,
fi_adaptor<I> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
......
......@@ -37,6 +37,7 @@
*/
# include <mln/core/internal/image_primary.hh>
# include <mln/value/set.hh>
namespace mln
......@@ -78,7 +79,7 @@ namespace mln
// value
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
typedef mln::trait::image::value_browsing::value_wise value_browsing;
typedef trait::image::value_io::read_only value_io;
// site / domain
......@@ -98,7 +99,7 @@ namespace mln
// FIXME: Doc!
template <typename T, typename S>
struct flat_image : public internal::image_primary< S, flat_image<T,S> >
struct flat_image : public internal::image_primary< T, S, flat_image<T,S> >
{
/// Skeleton.
typedef flat_image< tag::value_<T>, tag::pset_<S> > skeleton;
......@@ -149,7 +150,7 @@ namespace mln
/// Change the image value.
void change_value(const T& val);
void change_value(const T& old_val, const T& new_val);
};
......@@ -259,10 +260,11 @@ namespace mln
template <typename T, typename S>
inline
void
flat_image<T,S>::change_value(const T& val)
flat_image<T,S>::change_value(const T& old_val, const T& new_val)
{
mln_precondition(this->has_data());
this->data_->val_ = val;
mln_precondition(old_val == this->data_->val_);
this->data_->val_ = new_val;
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -91,10 +91,11 @@ namespace mln
/// Values are stored on the edges of the graph, not on its vertices.
template <typename P, typename V>
struct graph_image :
public internal::image_primary< p_graph<P>, graph_image<P, V> >
public internal::image_primary< V, p_graph<P>, graph_image<P, V> >
{
/// Super type.
typedef mln::internal::image_base< p_graph<P>, graph_image<P, V> > super_;
typedef mln::internal::image_base<V, p_graph<P>,
graph_image<P, V> > super_;
/// Value associated type.
typedef V value;
......
......@@ -116,7 +116,8 @@ namespace mln
*
*/
template <typename I>
struct hexa : public internal::image_domain_morpher< I, box2d_h, hexa<I> >
struct hexa :
public internal::image_domain_morpher< I, box2d_h, hexa<I> >
{
/// Skeleton.
typedef hexa< tag::image_<I> > skeleton;
......
......@@ -112,7 +112,8 @@ namespace mln
* thickness before and after data.
*/
template <typename T>
struct image1d : public internal::image_primary< box1d, image1d<T> >
struct image1d :
public internal::image_primary< T, box1d, image1d<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box1d pset;
......
......@@ -124,9 +124,9 @@ namespace mln
* thickness around data.
*/
template <typename T>
class image2d : public internal::image_primary< mln::box2d, image2d<T> >
class image2d : public internal::image_primary< T, mln::box2d, image2d<T> >
{
typedef internal::image_primary< mln::box2d, image2d<T> > super_;
typedef internal::image_primary< T, mln::box2d, image2d<T> > super_;
public:
/// Coordinate associated type.
......
......@@ -113,7 +113,7 @@ namespace mln
* thickness around data.
*/
template <typename T>
struct image3d : public internal::image_primary< box3d, image3d<T> >
struct image3d : public internal::image_primary< T, box3d, image3d<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box3d pset;
......
......@@ -90,8 +90,8 @@ namespace mln
*/
template <typename I, typename F>
struct image_if : public internal::image_domain_morpher< I,
p_if<mln_pset(I), F>,
image_if<I, F> >
p_if<mln_pset(I), F>,
image_if<I, F> >
{
/// Skeleton.
typedef image_if< tag::image_<I>, tag::function_<F> > skeleton;
......
......@@ -41,9 +41,9 @@ namespace mln
{
/*! \brief Routine to make temporary objects become mutable.
*
*
* \warning This routine is not safe! FIXME: Explain.
*/
*/
template <typename E>
E& inplace(const Object<E>& temp);
......
......@@ -64,10 +64,12 @@ namespace mln
*
*/
template <typename I>
struct interpolated : public mln::internal::image_identity< I, mln_pset(I), interpolated<I> >
struct interpolated :
public mln::internal::image_identity< I, mln_pset(I), interpolated<I> >
{
typedef mln::internal::image_identity< I, mln_pset(I), interpolated<I> > super_;
typedef mln::internal::image_identity< I, mln_pset(I),
interpolated<I> > super_;
/// Point_Site associated type.
typedef mln_psite(I) psite;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment