URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
ChangeLog:
2008-09-18 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix many errors in core/image tests.
* milena/mln/convert/to_p_set.hh: Update doc.
* milena/mln/make/w_window.hh,
* milena/mln/convert/to_p_set.hh,
* milena/mln/convert/to_w_window.hh,
* milena/mln/convert/to_window.hh: rename mln_dpoint to mln_dpsite.
* milena/mln/core/internal/run_image.hh,
* milena/mln/core/image/mono_rle_image.hh,
* milena/mln/core/image/mono_obased_rle_image.hh,
* milena/mln/core/image/rle_image.hh,
* milena/mln/core/image/obased_rle_image.hh:
Rename size_mem() to memory_size().
Rename p_of_run() to index().
* milena/mln/core/image/plain.hh: add missing init_().
* milena/mln/core/internal/run_image.hh,
* milena/mln/core/image/mono_rle_image.hh,
* milena/mln/core/image/mono_obased_rle_image.hh,
* milena/mln/core/image/rle_image.hh,
* milena/mln/core/image/value_enc_image.hh:
Use p_set_of and p_run instead of p_runs_.
* milena/mln/estim/sum.hh:
Fully specify the types in template parameters.
* milena/mln/geom/bbox.hh: Add support for weighted_windows.
---
convert/to_p_set.hh | 32 ++++++++++++------------
convert/to_w_window.hh | 11 ++++----
convert/to_window.hh | 13 +++++----
core/image/image1d.hh | 1
core/image/mono_obased_rle_image.hh | 48 ++++++++++++++++++++++--------------
core/image/mono_rle_image.hh | 43 +++++++++++++++++++++-----------
core/image/obased_rle_image.hh | 12 ++++-----
core/image/plain.hh | 8 +++---
core/image/rle_image.hh | 20 +++++++--------
core/image/value_enc_image.hh | 22 ++++++++--------
core/internal/run_image.hh | 30 +++++++++++-----------
estim/sum.hh | 4 +--
geom/bbox.hh | 20 ++++++++++++---
make/w_window.hh | 4 +--
14 files changed, 153 insertions(+), 115 deletions(-)
Index: branches/cleanup-2008/milena/mln/core/image/obased_rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/obased_rle_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/obased_rle_image.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -72,7 +72,7 @@
p_runs_<P> domain_;
/// Return the size of the data in memory.
- unsigned size_mem() const;
+ unsigned memory_size() const;
/// Finalize the domain (internal use).
void finalize();
@@ -172,9 +172,9 @@
template <typename P, typename T>
inline
unsigned
- data_< obased_rle_image<P,T> >::size_mem() const
+ data_< obased_rle_image<P,T> >::memory_size() const
{
- return domain_.size_mem() + bbox_.size()
+ return domain_.memory_size() + bbox_.size()
* (sizeof(T) + sizeof(box<P>) + sizeof(std::vector<unsigned>))
+ (sizeof(unsigned) + sizeof(T)) * domain_.nruns();
}
@@ -230,7 +230,7 @@
const
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
@@ -239,7 +239,7 @@
obased_rle_image<P, T>::operator() (const runs_psite<P>& site)
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh (revision 2338)
@@ -35,9 +35,9 @@
# include <mln/core/internal/image_primary.hh>
-# include <mln/core/pset_array.hh>
-# include <mln/core/pset_array_psite.hh>
-# include <mln/core/p_runs.hh>
+# include <mln/core/site_set/p_array.hh>
+# include <mln/core/site_set/p_run.hh>
+# include <mln/core/site_set/p_set_of.hh>
# include <vector>
# include <mln/util/tracked_ptr.hh>
@@ -62,7 +62,7 @@
std::vector<T> values_;
/// domain of the image
- pset_array< p_runs_<P> > domain_;
+ p_array< p_set_of< p_run<P> > > domain_;
};
} // end of namespace mln::internal
@@ -99,7 +99,7 @@
*/
template <typename P, typename T>
class value_enc_image :
- public internal::image_primary< pset_array< p_runs_<P> >,
+ public internal::image_primary< P, p_array< p_set_of< p_run<P> >
>,
value_enc_image<P, T> >
{
public:
@@ -110,8 +110,8 @@
typedef const T rvalue;
/// Domain related typedefs
- typedef pset_array_psite< runs_psite<P> > psite;
- typedef pset_array< p_runs_<P> > pset;
+ typedef p_array< p_set_of< p_run<P> > > pset;
+ typedef mln_psite(pset) psite;
/// Skeleton.
typedef value_enc_image< tag::psite_<P>, tag::value_<T> >
skeleton;
@@ -119,7 +119,7 @@
value_enc_image();
/// Add a new set of ranges to the image.
- void insert(const p_runs_<P>& ps, T value);
+ void insert(const p_set_of< p_run<P> >& ps, T value);
/// Add a new range to the image
void insert(const p_run<P>& pr, T value);
@@ -175,7 +175,7 @@
template <typename P, typename T>
inline
void
- value_enc_image<P, T>::insert(const p_runs_<P>& ps, T value)
+ value_enc_image<P, T>::insert(const p_set_of<p_run<P> >& ps, T
value)
{
if (!this->has_data())
this->data_ = new internal::data< value_enc_image<P,T> >();
@@ -201,7 +201,7 @@
this->data_->domain_[i].insert(pr);
else
{
- p_runs_<P> ps = p_runs_<P> ();
+ p_set_of< p_run<P> > ps = p_set_of< p_run<P> >();
ps.insert(pr);
this->data_->domain_.insert(ps);
this->data_->values_.push_back(value);
@@ -226,7 +226,7 @@
{
mln_precondition(this->has(site));
- return this->data_->values_[site.to_index()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/image/rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/rle_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/rle_image.hh (revision 2338)
@@ -34,8 +34,8 @@
*/
# include <mln/core/internal/run_image.hh>
-# include <mln/core/p_runs.hh>
-# include <mln/core/runs_psite.hh>
+# include <mln/core/site_set/p_set_of.hh>
+# include <mln/core/site_set/p_run.hh>
# include <mln/value/set.hh>
# include <vector>
@@ -59,10 +59,10 @@
std::vector<T> values_;
/// domain of the image
- p_runs_<P> domain_;
+ p_set_of< p_run<P> > domain_;
/// Return the size of the data in memory.
- unsigned size_mem() const;
+ unsigned memory_size() const;
/// Finalize the domain (internal use).
void finalize();
@@ -108,8 +108,8 @@
typedef T value;
typedef T& lvalue;
typedef const T rvalue;
- typedef runs_psite<P> psite;
- typedef p_runs_<P> pset;
+ typedef p_set_of< p_run<P> > pset;
+ typedef mln_psite(pset) psite;
/// Skeleton.
@@ -152,9 +152,9 @@
template <typename P, typename T>
inline
unsigned
- data< rle_image<P,T> >::size_mem() const
+ data< rle_image<P,T> >::memory_size() const
{
- return sizeof(T) * values_.size() + domain_.size_mem();
+ return sizeof(T) * values_.size() + domain_.memory_size();
}
template <typename P, typename T>
@@ -202,7 +202,7 @@
const
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
@@ -211,7 +211,7 @@
rle_image<P, T>::operator() (const runs_psite<P>& site)
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007.2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,8 +34,8 @@
*/
# include <mln/core/internal/run_image.hh>
-# include <mln/core/p_runs.hh>
-# include <mln/core/runs_psite.hh>
+# include <mln/core/site_set/p_run.hh>
+# include <mln/core/site_set/p_set_of.hh>
# include <mln/core/site_set/box.hh>
# include <mln/value/set.hh>
# include <mln/core/image/mono_rle_image.hh>
@@ -64,13 +64,14 @@
std::vector<T> values_;
/// domain of the image
- p_runs_<P> domain_;
+ p_set_of< p_run<P> > domain_;
/// Return the size of the data in memory.
- unsigned size_mem() const;
+ unsigned memory_size() const;
/// Finalize the domain (internal use).
void finalize();
+
};
} // end of namespace mln::internal
@@ -113,24 +114,27 @@
typedef T value;
typedef T& lvalue;
typedef const T rvalue;
- typedef runs_psite<P> psite;
- typedef p_runs_<P> pset;
+ typedef p_set_of< p_run<P> > pset;
+ typedef mln_psite(pset) psite;
/// Skeleton.
typedef mono_obased_rle_image< tag::psite_<P>, tag::value_<T> >
skeleton;
-
+ /// Constructor.
mono_obased_rle_image(const std::set<T>& values);
+ /// Initialize an empty image.
+ void init_(const std::set<T>& values);
+
/// Add a new range to the image.
void insert(const p_run<P>& pr, T value);
/// Read-only access to the image value located at point \p p.
- const T operator()(const runs_psite<P>& site) const;
+ const T operator()(const mln_psite(pset)& site) const;
/// Read-write access to the image value located at point \p p.
- T& operator()(const runs_psite<P>& site);
+ T& operator()(const mln_psite(pset)& site);
/// Test if this image has been initialized.
bool has_data() const;
@@ -161,9 +165,9 @@
template <typename P, typename T>
inline
unsigned
- data< mono_obased_rle_image<P,T> >::size_mem() const
+ data< mono_obased_rle_image<P,T> >::memory_size() const
{
- return domain_.size_mem() * 2 + sizeof(T) * (values_.size() + ima_.size());
+ return domain_.memory_size() * 2 + sizeof(T) * (values_.size() + ima_.size());
}
template <typename P, typename T>
@@ -183,6 +187,14 @@
inline
mono_obased_rle_image<P, T>::mono_obased_rle_image(const std::set<T>&
values)
{
+ init_(values);
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ mono_obased_rle_image<P, T>::init_(const std::set<T>& values)
+ {
this->data_ = new internal::data< mono_obased_rle_image<P,T>
>(values);
}
@@ -199,8 +211,8 @@
void
mono_obased_rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
- mln_assertion(this->data_->values_.size() == 0 ||
this->data_->domain_.nruns() == 0 ||
- pr.first() > this->data_->domain_[this->data_->domain_.nruns() -
1].first());
+ mln_assertion(this->data_->values_.size() == 0 ||
this->data_->domain_.nsites() == 0 ||
+ pr[0] > this->data_->domain_[this->data_->domain_.nsites() -
1].start());
this->data_->domain_.insert(pr);
this->data_->values_.push_back(value);
unsigned i;
@@ -214,19 +226,19 @@
template <typename P, typename T>
inline
const T
- mono_obased_rle_image<P, T>::operator() (const runs_psite<P>& site)
const
+ mono_obased_rle_image<P, T>::operator() (const mln_psite(pset)& site) const
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
inline
T&
- mono_obased_rle_image<P, T>::operator() (const runs_psite<P>& site)
+ mono_obased_rle_image<P, T>::operator() (const mln_psite(pset)& site)
{
mln_precondition(this->has(site));
- return this->data_->values_[site.p_of_run()];
+ return this->data_->values_[site.index()];
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/image/plain.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/plain.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/plain.hh (revision 2338)
@@ -147,7 +147,7 @@
: super_()
{
mln_precondition(rhs.has_data());
- init(rhs.data_->ima_);
+ init_(rhs.data_->ima_);
}
template <typename I>
@@ -155,7 +155,7 @@
plain<I>::plain(const I& ima)
{
mln_precondition(ima.has_data());
- init(ima);
+ init_(ima);
}
template <typename I>
@@ -176,7 +176,7 @@
if (&rhs == this)
return *this;
this->destroy();
- init(rhs.data_->ima_);
+ init_(rhs.data_->ima_);
return *this;
}
@@ -187,7 +187,7 @@
{
mln_precondition(ima.has_data());
this->destroy();
- init(ima);
+ init_(ima);
return *this;
}
Index: branches/cleanup-2008/milena/mln/core/image/image1d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2338)
@@ -136,7 +136,6 @@
/// Return type of read-write access.
typedef T& lvalue;
-
/// Skeleton.
typedef image1d< tag::value_<T> > skeleton;
Index: branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007,2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,8 +34,8 @@
*/
# include <mln/core/internal/run_image.hh>
-# include <mln/core/p_runs.hh>
-# include <mln/core/runs_psite.hh>
+# include <mln/core/site_set/p_run.hh>
+# include <mln/core/site_set/p_set_of.hh>
# include <mln/value/set.hh>
# include <vector>
@@ -59,13 +59,14 @@
T value_;
/// domain of the image
- p_runs_<P> domain_;
+ p_set_of< p_run<P> > domain_;
/// Return the size of the data in memory.
- unsigned size_mem() const;
+ unsigned memory_size() const;
/// Finalize the domain (internal use).
void finalize();
+
};
} // end of namespace mln::internal
@@ -109,24 +110,28 @@
typedef T value;
typedef T& lvalue;
typedef const T rvalue;
- typedef runs_psite<P> psite;
- typedef p_runs_<P> pset;
+ typedef p_set_of< p_run<P> > pset;
+ typedef mln_psite(pset) psite;
/// Skeleton.
typedef mono_rle_image< tag::psite_<P>, tag::value_<T> > skeleton;
+ /// Constructor
mono_rle_image(const T& val);
+ /// Initialize an empty image.
+ void init_(const T& val);
+
/// Add a new range to the image.
void insert(const p_run<P>& pr);
/// Read-only access to the image value located at point \p p.
- rvalue operator() (const runs_psite<P>& site) const;
+ rvalue operator() (const mln_psite(pset)& site) const;
/// Read-write access to the image value located at point \p p.
- lvalue operator() (const runs_psite<P>& site);
+ lvalue operator() (const mln_psite(pset)& site);
/// Test if this image has been initialized.
bool has_data() const;
@@ -157,9 +162,9 @@
template <typename P, typename T>
inline
unsigned
- data< mono_rle_image<P,T> >::size_mem() const
+ data< mono_rle_image<P,T> >::memory_size() const
{
- return sizeof(T) + domain_.size_mem();
+ return sizeof(T) + domain_.memory_size();
}
template <typename P, typename T>
@@ -176,6 +181,14 @@
inline
mono_rle_image<P, T>::mono_rle_image(const T& val)
{
+ init_(val);
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ mono_rle_image<P, T>::init_(const T& val)
+ {
this->data_ = new internal::data< mono_rle_image<P,T> >(val);
}
@@ -192,15 +205,15 @@
void
mono_rle_image<P, T>::insert(const p_run<P>& pr)
{
- if (this->data_->domain_.nruns() != 0)
- mln_assertion(pr.first() >
this->data_->domain_[this->data_->domain_.nruns() - 1].first());
+ if (this->data_->domain_.nsites() != 0)
+ mln_assertion(pr[0] >
this->data_->domain_[this->data_->domain_.nsites() - 1].start());
this->data_->domain_.insert(pr);
}
template <typename P, typename T>
inline
typename mono_rle_image<P, T>::rvalue
- mono_rle_image<P, T>::operator() (const runs_psite<P>& site) const
+ mono_rle_image<P, T>::operator() (const mln_psite(pset)& site) const
{
mln_precondition(this->has(site));
return this->data_->value_;
@@ -209,7 +222,7 @@
template <typename P, typename T>
inline
typename mono_rle_image<P, T>::lvalue
- mono_rle_image<P, T>::operator() (const runs_psite<P>& site)
+ mono_rle_image<P, T>::operator() (const mln_psite(pset)& site)
{
mln_precondition(this->has(site));
return this->data_->value_;
Index: branches/cleanup-2008/milena/mln/core/internal/run_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/internal/run_image.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/core/internal/run_image.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,8 +34,8 @@
*/
# include <mln/core/internal/image_primary.hh>
-# include <mln/core/p_runs.hh>
-# include <mln/core/runs_psite.hh>
+# include <mln/core/site_set/p_run.hh>
+# include <mln/core/site_set/p_set_of.hh>
namespace mln
{
@@ -49,7 +49,7 @@
* Parameter \c E is the Exact type of the image.
*/
template <typename T, typename P, typename E>
- class run_image_ : public internal::image_primary< p_runs_<P>, E >
+ class run_image_ : public internal::image_primary< P, p_set_of< p_run<P>
>, E >
{
protected:
run_image_();
@@ -79,13 +79,13 @@
*
* \return The corresponding point.
*/
- P point_at(const runs_psite<P>& ps) const;
+ P point_at(const mln_psite(p_set_of< p_run<P> >)& ps) const;
/*! \brief Tell if the image has the given point site.
*
* \return True if the image has the point site, else false.
*/
- bool has(const runs_psite<P>& ps) const;
+ bool has(const mln_psite(p_set_of< p_run<P> >)& ps) const;
};
# ifndef MLN_INCLUDE_ONLY
@@ -101,7 +101,7 @@
float
run_image_<T, P, E>::compression() const
{
- return float(exact(this)->data_->size_mem()) /
+ return float(exact(this)->data_->memory_size()) /
float (sizeof(T) * exact(this)->data_->domain_.bbox().nsites());
}
@@ -116,26 +116,26 @@
template <typename T, typename P, typename E>
inline
P
- run_image_<T, P, E>::point_at(const runs_psite<P>& ps) const
+ run_image_<T, P, E>::point_at(const mln_psite(p_set_of< p_run<P>
>)& ps) const
{
const E* ima = exact(this);
- mln_precondition(ps.p_of_run() < ima->data_->domain_.nruns());
- mln_precondition(ps.p_in_run() <
ima->data_->domain_[ps.p_of_run()].length());
- return ima->data_->domain_[ps.p_of_run()][ps.p_in_run()];
+ mln_precondition(ps.index() < ima->data_->domain_.nsites());
+ mln_precondition(ps.p().index() <
ima->data_->domain_[ps.index()].length());
+ return ima->data_->domain_[ps.index()][ps.p().index()];
}
template <typename T, typename P, typename E>
inline
bool
- run_image_<T, P, E>::has(const runs_psite<P>& ps) const
+ run_image_<T, P, E>::has(const mln_psite(p_set_of< p_run<P> >)&
ps) const
{
const E* ima = exact(this);
if (!ima->has_data())
return false;
else
- return (ps.p_of_run() < ima->data_->domain_.nruns()
- && ps.p_in_run() < ima->data_->domain_[ps.p_of_run()].length()
- && ima->data_->domain_[ps.p_of_run()][ps.p_in_run()] == ps);
+ return (ps.index() < ima->data_->domain_.nsites()
+ && ps.p().index() < ima->data_->domain_[ps.index()].length()
+ && ima->data_->domain_[ps.index()][ps.p().index()] == ps);
}
# endif // ! MLN_INCLUDE_ONLY
Index: branches/cleanup-2008/milena/mln/make/w_window.hh
===================================================================
--- branches/cleanup-2008/milena/mln/make/w_window.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/make/w_window.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -68,7 +68,7 @@
const F& wei = exact(wei_);
mln_precondition(! win.is_empty());
typedef mln_dpsite(W) D;
- typedef mln_point(D) P;
+ typedef mln_psite(D) P;
mln::w_window<D, mln_result(F)> w_win;
mln_qiter(W) q(win, P::origin);
for_all(q)
Index: branches/cleanup-2008/milena/mln/convert/to_window.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_window.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/convert/to_window.hh (revision 2338)
@@ -80,8 +80,8 @@
window<mln_dpsite(S)> to_window(const Site_Set<S>& pset);
/// Convert an std::set \p s of delta-sites into a window.
- template <typename D>
- window<D> to_window(const std::set<D>& s);
+ template <typename D, typename C>
+ window<D> to_window(const std::set<D, C>& s);
# ifndef MLN_INCLUDE_ONLY
@@ -147,7 +147,8 @@
mln_precondition(ima.has_data());
// FIXME: Check that ima is binary!
typedef mln_dpsite(I) D;
- typedef mln_psite(D) P;
+ typedef mln_site(D) P;
+
window<D> win;
mln_piter(I) p(ima.domain());
for_all(p)
@@ -171,14 +172,14 @@
| std::set-to-window conversions. |
`---------------------------------*/
- template <typename D>
+ template <typename D, typename C>
inline
- window<D> to_window(const std::set<D>& s)
+ window<D> to_window(const std::set<D, C>& s)
{
// FIXME: Was: mln::metal::is_a<D, Dpoint>::check();
mln::metal::is_a<D, Delta_Point_Site>::check();
window<D> win;
- for (typename std::set<D>::const_iterator i = s.begin();
+ for (typename std::set<D, C>::const_iterator i = s.begin();
i != s.end(); ++i)
win.insert(*i);
return win;
Index: branches/cleanup-2008/milena/mln/convert/to_p_set.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_p_set.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/convert/to_p_set.hh (revision 2338)
@@ -51,27 +51,28 @@
namespace convert
{
- /// Convert a neighborhood \p nbh into a point set.
+ /// Convert a neighborhood \p nbh into a site set.
template <typename N>
p_set<mln_psite(N)>
to_p_set(const Neighborhood<N>& nbh);
- /// Convert a binary image \p ima into a point set.
+ /// Convert a binary image \p ima into a site set.
template <typename I>
p_set<mln_psite(I)>
to_p_set(const Image<I>& ima);
- /// Convert a Window \p win into a point set.
+ /// Convert a Window \p win into a site set.
template <typename W>
p_set<mln_psite(W)>
to_p_set(const Window<W>& win);
- /// Convert an std::set \p s of points into a point set.
- template <typename P>
+ /// Convert an std::set \p s of sites into a site set.
+ /// C is the comparison functor.
+ template <typename P, typename C>
p_set<P>
- to_p_set(const std::set<P>& s);
+ to_p_set(const std::set<P, C>& s);
- /// Convert any point set \p ps into a 'mln::p_set' point set.
+ /// Convert any site set \p ps into a 'mln::p_set' site set.
template <typename S>
p_set<mln_psite(S)>
to_p_set(const Site_Set<S>& ps);
@@ -81,12 +82,11 @@
template <typename N>
inline
- p_set<mln_point(N)>
+ p_set<mln_psite(N)>
to_p_set(const Neighborhood<N>& nbh_)
{
const N& nbh = exact(nbh_);
- typedef mln_dpoint(N) D;
- typedef mln_point(N) P;
+ typedef mln_psite(N) P;
p_set<P> pset;
mln_niter(N) n(nbh, P::origin);
for_all(n)
@@ -105,7 +105,6 @@
// FIXME: Check that ima is binary!
// mln::metal::templated_by<mln_value(I), bool >::check();
- typedef mln_dpsite(I) D;
typedef mln_psite(I) P;
p_set<P> pset;
mln_piter(I) p(ima.domain());
@@ -117,10 +116,10 @@
template <typename W>
inline
- p_set<mln_site(W)>
+ p_set<mln_psite(W)>
to_p_set(const Window<W>& win)
{
- typedef mln_site(W) P;
+ typedef mln_psite(W) P;
p_set<P> pset;
mln_qiter(W) q(exact(win), P::origin);
for_all(q)
@@ -128,14 +127,15 @@
return pset;
}
- template <typename P>
+ template <typename P, typename C>
inline
p_set<P>
- to_p_set(const std::set<P>& s)
+ to_p_set(const std::set<P, C>& s)
{
+ P titi;
mln::metal::is_a<P, Point_Site>::check();
p_set<P> pset;
- for (typename std::set<P>::const_iterator i = s.begin();
+ for (typename std::set<P, C>::const_iterator i = s.begin();
i != s.end(); ++i)
pset.insert(*i);
return pset;
Index: branches/cleanup-2008/milena/mln/convert/to_w_window.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_w_window.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/convert/to_w_window.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -36,7 +36,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/w_window.hh>
-
namespace mln
{
@@ -45,20 +44,22 @@
/// Convert an image \p input into a weighted window.
template <typename I>
- w_window<mln_dpsite(I), mln_value(I)> to_w_window(const Image<I>&
input);
+ w_window<mln_dpsite(I), mln_value(I)>
+ to_w_window(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- w_window<mln_dpsite(I), mln_value(I)> to_w_window(const Image<I>&
input_)
+ w_window<mln_dpsite(I), mln_value(I)>
+ to_w_window(const Image<I>& input_)
{
const I& input = exact(input_);
mln_precondition(input.has_data());
// FIXME: Check that input is scalar?
typedef mln_dpsite(I) D;
- typedef mln_point(D) P;
+ typedef mln_psite(D) P;
w_window<D, mln_value(I)> w_win;
mln_piter(I) p(input.domain());
for_all(p)
Index: branches/cleanup-2008/milena/mln/estim/sum.hh
===================================================================
--- branches/cleanup-2008/milena/mln/estim/sum.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/estim/sum.hh (revision 2338)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -70,7 +70,7 @@
mln_sum(mln_value(I)) sum(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return level::compute<accu::sum>(input);
+ return level::compute<accu::sum, I>(input);
}
template <typename I, typename S>
Index: branches/cleanup-2008/milena/mln/geom/bbox.hh
===================================================================
--- branches/cleanup-2008/milena/mln/geom/bbox.hh (revision 2337)
+++ branches/cleanup-2008/milena/mln/geom/bbox.hh (revision 2338)
@@ -41,9 +41,10 @@
* \todo Add the weighted_window case.
*/
-# include <mln/core/concept/box.hh>
+# include <mln/core/site_set/box.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
# include <mln/literal/zero.hh>
# include <mln/accu/bbox.hh>
@@ -66,7 +67,11 @@
/// Compute the precise bounding box of a window \p win.
template <typename W>
- box<mln_site(W)> bbox(const Window<W>& win);
+ box<mln_psite(W)> bbox(const Window<W>& win);
+
+ /// Compute the precise bounding box of a weighted window \p win.
+ template <typename W>
+ box<mln_psite(W)> bbox(const Weighted_Window<W>& win);
@@ -136,9 +141,9 @@
}
template <typename W>
- box<mln_site(W)> bbox(const Window<W>& win)
+ box<mln_psite(W)> bbox(const Window<W>& win)
{
- typedef mln_site(W) P;
+ typedef mln_psite(W) P;
accu::bbox<P> b;
mln_qiter(W) q(exact(win), literal::origin);
for_all(q)
@@ -146,6 +151,13 @@
return b;
}
+ template <typename W>
+ box<mln_psite(W)> bbox(const Weighted_Window<W>& win)
+ {
+ return bbox(exact(win).win());
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom