Commit 5011b2c1 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Cleanup extension with image, forcing it to be const.

	* mln/core/image/extension_ima.hh (todo): Remove; obsolete.
	(ctor): Add const for extension.
	(change_extension): Remove.
	(extension): Remove the mutable version.
	(init_): Remove the mutable version.
	(init_): Make it robust to constness.
	* mln/core/routine/extend.hh: Upgrade file doc style.
	(extend): Remove overload for mutable extension.

	Misc.
	
	* mln/core/site_set/p_priority.hh: Upgrade file doc style.
	(insert): New overload for a priority queue.
	* mln/make/double_neighb2d.hh: Upgrade file doc style.
	* mln/make/box2d.hh (todo): New.
	* mln/labeling/compute.hh: Fix commentary.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3164 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 94996ead
2009-01-19 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Cleanup extension with image, forcing it to be const.
* mln/core/image/extension_ima.hh (todo): Remove; obsolete.
(ctor): Add const for extension.
(change_extension): Remove.
(extension): Remove the mutable version.
(init_): Remove the mutable version.
(init_): Make it robust to constness.
* mln/core/routine/extend.hh: Upgrade file doc style.
(extend): Remove overload for mutable extension.
Misc.
* mln/core/site_set/p_priority.hh: Upgrade file doc style.
(insert): New overload for a priority queue.
* mln/make/double_neighb2d.hh: Upgrade file doc style.
* mln/make/box2d.hh (todo): New.
* mln/labeling/compute.hh: Fix commentary.
2009-01-16 Guillaume Lazzara <z@lrde.epita.fr>
 
Small fixes.
......@@ -31,15 +31,9 @@
/// \file mln/core/image/extension_ima.hh
///
/// Definition of a morpher that extends the domain of an image
/// with a function.
///
/// \todo Use an envelop as lvalue to test extension writing.
///
/// \todo Handle the couple of cases: either J is value_io::read_write
/// or value_io::read_only; then ext_io can be read_write...
/// with an image.
# include <mln/core/internal/image_identity.hh>
# include <mln/data/fill_with_value.hh>
......@@ -57,7 +51,7 @@ namespace mln
template <typename I, typename J>
struct data< extension_ima<I, J> >
{
data(I& ima, J& ext);
data(I& ima, const J& ext);
I ima_;
J ext_;
......@@ -80,7 +74,7 @@ namespace mln
// extended domain
typedef trait::image::ext_domain::extendable ext_domain;
typedef trait::image::ext_value::multiple ext_value;
typedef trait::image::ext_io::read_only ext_io; // FIXME: Too restrictive?
typedef trait::image::ext_io::read_only ext_io;
};
template <typename I, typename J, typename V>
......@@ -118,11 +112,11 @@ namespace mln
extension_ima();
/// Constructor from an image \p ima and a function \p ext.
extension_ima(I& ima, J& ext);
extension_ima(I& ima, const J& ext);
/// Deferred initialization from an image \p ima and a function \p
/// ext.
void init_(I& ima, J& ext);
void init_(I& ima, const J& ext);
/// Test if \p p is valid.
......@@ -139,14 +133,7 @@ namespace mln
/// Read-only access to the extension domain (image).
mlc_const(J)& extension() const;
/// Mutable access to the extension domain (image). This domain
/// can be modified if J a read-write image type.
J& extension();
/// Change the value in the extension domain (image).
void change_extension(const mln_value(I)& v);
const J& extension() const;
};
......@@ -158,10 +145,6 @@ namespace mln
template <typename J, typename I>
void init_(tag::extension_t, J& target, const extension_ima<I,J>& model);
template <typename J, typename I>
void init_(tag::extension_t, J& target, const extension_ima<I,const J>& model);
# ifndef MLN_INCLUDE_ONLY
......@@ -173,9 +156,9 @@ namespace mln
template <typename I, typename J>
inline
data< extension_ima<I, J> >::data(I& ima, J& ext)
data< extension_ima<I, J> >::data(I& ima, const J& ext)
: ima_(ima),
ext_(ext)
ext_(const_cast<J&>(ext))
{
}
......@@ -191,7 +174,7 @@ namespace mln
template <typename I, typename J>
inline
extension_ima<I, J>::extension_ima(I& ima, J& ext)
extension_ima<I, J>::extension_ima(I& ima, const J& ext)
{
init_(ima, ext);
}
......@@ -199,7 +182,7 @@ namespace mln
template <typename I, typename J>
inline
void
extension_ima<I, J>::init_(I& ima, J& ext)
extension_ima<I, J>::init_(I& ima, const J& ext)
{
this->data_ = new internal::data< extension_ima<I, J> >(ima, ext);
}
......@@ -255,35 +238,17 @@ namespace mln
template <typename I, typename J>
inline
mlc_const(J)&
const J&
extension_ima<I, J>::extension() const
{
mln_precondition(this->is_valid());
return this->data_->ext_;
}
template <typename I, typename J>
inline
J&
extension_ima<I, J>::extension()
{
mln_precondition(this->is_valid());
return this->data_->ext_;
}
template <typename I, typename J>
inline
void
extension_ima<I, J>::change_extension(const mln_value(I)& v)
{
mlc_equal(mln_trait_image_value_io(J),
trait::image::value_io::read_write)::check();
data::fill_with_value(v);
}
// init_
template <typename I, typename J, typename M>
inline
void init_(tag::image_t, extension_ima<I,J>& target, const M& model)
{
I ima;
......@@ -294,15 +259,13 @@ namespace mln
}
template <typename J, typename I>
inline
void init_(tag::extension_t, J& target, const extension_ima<I,J>& model)
{
target = model.extension();
}
template <typename J, typename I>
void init_(tag::extension_t, J& target, const extension_ima<I,const J>& model)
{
target = model.extension();
typedef mlc_unconst(J) J_;
J_& ext_ = const_cast<J_&>(model.extension());
J_& target_ = const_cast<J_&>(target);
target_ = ext_;
}
# endif // ! MLN_INCLUDE_ONLY
......
// Copyright (C) 2008 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -28,15 +28,13 @@
#ifndef MLN_CORE_ROUTINE_EXTEND_HH
# define MLN_CORE_ROUTINE_EXTEND_HH
/*!
* \file mln/core/routine/extend.hh
*
* \brief Definition of a morpher that extends the extended domain of an image.
*
* \todo Use the 'instant' mechanism.
* \todo Deal with ambiguities.
* \todo Check that there is no extension yet (except "extendable").
*/
/// \file mln/core/routine/extend.hh
///
/// Definition of a morpher that extends the extended domain of an image.
///
/// \todo Use the 'instant' mechanism.
/// \todo Deal with ambiguities.
/// \todo Check that there is no extension yet (except "extendable").
# include <mln/core/image/extension_ima.hh>
# include <mln/core/image/extension_fun.hh>
......@@ -65,10 +63,6 @@ namespace mln
extension_ima<const I, const J>
extend(const Image<I>& ima, const Image<J>& ext);
template <typename I, typename J>
extension_ima<I, J>
extend(Image<I>& ima, Image<J>& ext);
/// Routines for domain extension with a value.
......@@ -119,15 +113,6 @@ namespace mln
return tmp;
}
template <typename I, typename J>
extension_ima<I, J>
extend(Image<I>& ima, Image<J>& ext)
{
mlc_converts_to(mln_value(J), mln_value(I))::check();
extension_ima<I, J> tmp(exact(ima), exact(ext));
return tmp;
}
// With a value.
......
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -28,12 +29,9 @@
#ifndef MLN_CORE_P_PRIORITY_HH
# define MLN_CORE_P_PRIORITY_HH
/*! \file mln/core/site_set/p_priority.hh
*
* \brief Definition of a priority queue of sites.
*
* \todo Rename file as p_priority.hh
*/
/// \file mln/core/site_set/p_priority.hh
///
/// Definition of a priority queue of sites.
# include <map>
# include <mln/core/site_set/p_double.hh>
......@@ -126,6 +124,9 @@ namespace mln
/// Insert a pair \p p_e (priority p, element e).
void insert(const i_element& p_e);
/// Insert elements from another priority queue.
void insert(const p_priority<P,Q>& other);
/// Pop (remove) from the queue an element with highest priority.
/// If several elements have this priority, the least recently
......@@ -175,6 +176,7 @@ namespace mln
/// Return the size of this site set in memory.
std::size_t memory_size() const;
protected:
typedef std::map<P, Q, util::ord<P> > q_type_;
......@@ -252,6 +254,24 @@ namespace mln
this->push(p_e.first, p_e.second); // Also test invariants.
}
template <typename P, typename Q>
inline
void
p_priority<P,Q>::insert(const p_priority<P,Q>& other)
{
mln_invariant(run_());
typename q_type_::const_iterator i;
for (i = other.q_.begin(); i != other.q_.end(); ++i)
{
P priority = i->first;
p_.insert(priority);
const Q& q_p = i->second;
q_[priority] += q_p;
}
n_ += other.n_;
mln_invariant(run_());
}
template <typename P, typename Q>
inline
void
......
......@@ -210,7 +210,7 @@ namespace mln
return convert::to< util::array<mln_result(A)> >(accus);
}
} // end of namespace mln::labeling::impl::internal
} // end of namespace mln::labeling::impl::generic
} // end of namespace mln::labeling::impl
......
......@@ -32,6 +32,9 @@
/// \file mln/make/box2d.hh
///
/// Routines to construct an mln::box2d.
///
/// \todo Accept long int as args and test overflow (out of def::coord
/// bounds).
# include <mln/core/alias/box2d.hh>
......
// Copyright (C) 2008 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -28,12 +28,11 @@
#ifndef MLN_MAKE_DOUBLE_NEIGHB2D_HH
# define MLN_MAKE_DOUBLE_NEIGHB2D_HH
/*! \file mln/make/double_neighb2d.hh
*
* \brief Routine to create a double neighborhood.
*
* \todo Add overload with 'when_*' being Neighborhood<N>...
*/
/// \file mln/make/double_neighb2d.hh
///
/// Routine to create a double neighborhood.
///
/// \todo Add overload with 'when_*' being Neighborhood<N>...
# include <mln/convert/to.hh>
# include <mln/core/alias/window2d.hh>
......
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