Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add geom routine for Box.
* mln/geom/max_col.hh:
(mln_coord(B::point) max_col(const Box<B>& b)) New.
* mln/geom/max_row.hh:
(mln_coord(B::point) max_row(const Box<B>& b)) New.
* mln/geom/min_col.hh:
(mln_coord(B::point) min_col(const Box<B>& b)) New.
* mln/geom/min_row.hh:
(mln_coord(B::point) min_row(const Box<B>& b)) New.
* mln/geom/ncols.hh:
(unsigned ncols(const Box<B>& b)) New.
* mln/geom/nrows.hh:
(unsigned nrows(const Box<B>& b)) New.
---
max_col.hh | 12 ++++++++++++
max_row.hh | 13 +++++++++++++
min_col.hh | 13 +++++++++++++
min_row.hh | 16 ++++++++++++++++
ncols.hh | 12 ++++++++++++
nrows.hh | 11 +++++++++++
6 files changed, 77 insertions(+)
Index: trunk/milena/mln/geom/max_col.hh
===================================================================
--- trunk/milena/mln/geom/max_col.hh (revision 1795)
+++ trunk/milena/mln/geom/max_col.hh (revision 1796)
@@ -46,6 +46,9 @@
template <typename I>
mln_coord(I) max_col(const Image<I>& ima);
+ /// Give the maximum col of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) max_col(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +60,15 @@
return exact(ima).bbox().pmax().col();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) max_col(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmax().col();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/nrows.hh
===================================================================
--- trunk/milena/mln/geom/nrows.hh (revision 1795)
+++ trunk/milena/mln/geom/nrows.hh (revision 1796)
@@ -47,6 +47,10 @@
template <typename I>
unsigned nrows(const Image<I>& ima);
+ /// Give the number of rows of a box 2d or 3d.
+ template <typename B>
+ unsigned nrows(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -58,6 +62,13 @@
return geom::max_row(ima) - geom::min_row(ima) + 1;
}
+ template <typename B>
+ unsigned nrows(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return geom::max_row(b) - geom::min_row(b) + 1;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/min_row.hh
===================================================================
--- trunk/milena/mln/geom/min_row.hh (revision 1795)
+++ trunk/milena/mln/geom/min_row.hh (revision 1796)
@@ -35,6 +35,9 @@
# include <mln/core/concept/image.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/int.hh>
+# include <mln/metal/equal.hh>
namespace mln
{
@@ -46,6 +49,10 @@
template <typename I>
mln_coord(I) min_row(const Image<I>& ima);
+ /// Give the minimum row of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) min_row(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +64,15 @@
return exact(ima).bbox().pmin().row();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) min_row(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmin().row();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/max_row.hh
===================================================================
--- trunk/milena/mln/geom/max_row.hh (revision 1795)
+++ trunk/milena/mln/geom/max_row.hh (revision 1796)
@@ -47,6 +47,10 @@
mln_coord(I) max_row(const Image<I>& ima);
+ /// Give the maximum row of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) max_row(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
template <typename I>
@@ -57,6 +61,15 @@
return exact(ima).bbox().pmax().row();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) max_row(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmax().row();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/ncols.hh
===================================================================
--- trunk/milena/mln/geom/ncols.hh (revision 1795)
+++ trunk/milena/mln/geom/ncols.hh (revision 1796)
@@ -47,6 +47,10 @@
template <typename I>
unsigned ncols(const Image<I>& ima);
+ /// Give the number of cols of a box 2d or 3d.
+ template <typename B>
+ unsigned ncols(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -58,6 +62,14 @@
return geom::max_col(ima) - geom::min_col(ima) + 1;
}
+
+ template <typename B>
+ unsigned ncols(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return geom::max_col(b) - geom::min_col(b) + 1;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/min_col.hh
===================================================================
--- trunk/milena/mln/geom/min_col.hh (revision 1795)
+++ trunk/milena/mln/geom/min_col.hh (revision 1796)
@@ -46,6 +46,10 @@
template <typename I>
mln_coord(I) min_col(const Image<I>& ima);
+ /// Give the minimum column of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) min_col(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +61,15 @@
return exact(ima).bbox().pmin().col();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) min_col(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmin().col();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Debug tiled_image2d.
* sandbox/garrigues/tiled_image2d/block.hh: Remove the union, to use a
block with a value type of milena.
* sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh: in a
milena's point2d, we have p[0] = row index, p[1] = col index, update
to respect this.
* sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh: likewise,
(unsigned image2d_lrtb::size(unsigned nrows, unsigned ncols)) New.
* sandbox/garrigues/tiled_image2d/tiled_image2d.cc: Test the type with
a big image.
* sandbox/garrigues/tiled_image2d/tiled_image2d.hh: Allocate enough
space for the image. Fixme : some debug will be removed later.
---
block.hh | 13 +++++++++----
layout/image2d/lrtb.hh | 15 ++++++++++-----
layout/page2d/lrtb.hh | 2 +-
tiled_image2d.cc | 13 +++++++++++--
tiled_image2d.hh | 33 +++++++++++++++++++++++----------
5 files changed, 54 insertions(+), 22 deletions(-)
Index: trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh (revision 1795)
@@ -38,11 +38,14 @@
# include <mln/core/box2d.hh>
# include <mln/core/inplace.hh>
# include <mln/core/init.hh>
+# include <mln/core/line_piter.hh>
+
+# include <mln/geom/size2d.hh>
+
# include <mln/border/thickness.hh>
# include <mln/value/set.hh>
# include <mln/fun/i2v/all_to.hh>
-# include <mln/core/line_piter.hh>
# include <fcntl.h>
# include "support/lru.hh"
@@ -52,7 +55,8 @@
# include "page.hh"
// FIXME : give the side's side of the square of the block.
-# define SIDE 128
+# define BLOCK_SIDE 128
+# define BLOCK_SIZE (BLOCK_SIDE * BLOCK_SIDE)
namespace mln
{
@@ -68,10 +72,10 @@
template <typename T>
struct data_< tiled_image2d<T> >
{
- typedef block<T, SIDE * SIDE> block;
+ typedef block<T, BLOCK_SIZE> block;
typedef mmap_backend<block> backend;
typedef lru_support<backend> support;
- typedef layout2d<SIDE, SIDE> layout;
+ typedef layout2d<BLOCK_SIDE, BLOCK_SIDE> layout;
data_(const box2d& b);
~data_();
@@ -149,12 +153,12 @@
typedef mln::value::set<T> vset;
/// Block type.
- typedef block<T, SIDE * SIDE> block;
+ typedef block<T, BLOCK_SIZE> block;
/// Support type.
typedef lru_support<mmap_backend<block> > support;
/// Layout type
- typedef layout2d<SIDE, SIDE> layout;
+ typedef layout2d<BLOCK_SIDE, BLOCK_SIDE> layout;
/// Page type
typedef page<T, layout> page;
@@ -238,11 +242,20 @@
data_< tiled_image2d<T> >::data_(const box2d& b)
: b_ (b),
// FIXME : hard coded path.
- support_(*new support(*new backend( open("/tmp/milena_tiled.image", O_RDWR | O_CREAT | O_TRUNC, 0664), b.npoints()) ))
- {
- std::cout << b.npoints() * sizeof(T) << std::endl;
+ support_(*new support(
+ *new backend( open("/tmp/milena_tiled.image", O_RDWR | O_CREAT | O_TRUNC, 0664),
+ layout::image_layout::size(geom::nrows(b), geom::ncols(b))),
+ 1500 // Fixme : size of lru cache.
+ )
+ )
+ {
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) << " block dans l'image." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) << " o au total." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) / 1024. << " Ko au total." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) / (1024 * 1024.) << " Mo au total." << std::endl;
+
char a = 0;
- lseek(support_.backend_.fd_, b.npoints() * sizeof(T) - 1, SEEK_SET);
+ lseek(support_.backend_.fd_, layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T), SEEK_SET);
write(support_.backend_.fd_, &a, 1);
}
Index: trunk/milena/sandbox/garrigues/tiled_image2d/block.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/block.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/block.hh (revision 1795)
@@ -37,20 +37,25 @@
struct block : public Object< block<T, size> > {
typedef T value_type;
enum { nitems = size, nbytes = size * sizeof(T) };
- union {
- char bytes[nbytes];
- T array[nitems];
- };
+
+ char bytes[nitems];
+
+// union {
+// char bytes[nbytes];
+// T array[nitems];
+// };
T& operator[](unsigned p)
{
assert(p < nitems);
+ T* array = (T*)(void*) bytes;
return array[p];
}
const T& operator[](unsigned p) const
{
assert(p < nbytes);
+ T* array = (T*)(void*) bytes;
return array[p];
}
};
Index: trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc (revision 1795)
@@ -32,14 +32,23 @@
#include "tiled_image2d.hh"
+#include <mln/core/cast_image.hh>
+
#include <mln/level/fill.hh>
+#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
+#include <mln/debug/iota.hh>
+#include <mln/io/pgm/save.hh>
int main()
{
using namespace mln;
- tiled_image2d<int> ima(10700, 10700);
+ std::cout << "allocate the image." << std::endl;
+ tiled_image2d<value::int_u8> ima(1024 * 1024, 1024 * 1.5);
+ std::cout << "fill the image." << std::endl;
+ debug::iota(ima);
- level::fill(ima, 6);
+ std::cout << "save the image." << std::endl;
+ io::pgm::save(ima, "test.pgm");
}
Index: trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh (revision 1795)
@@ -41,7 +41,7 @@
static unsigned pixel_at(const point2d& p)
{
- return p[1] * width + p[0];
+ return p[0] * width + p[1];
}
};
Index: trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh (revision 1795)
@@ -36,30 +36,35 @@
namespace layout {
template<unsigned W, unsigned H>
- struct image2d_lrtb : public Object<image2d_lrtb<W, H> > {
+ struct image2d_lrtb {
enum { dim = 2, page_width = W, page_height = H };
template<typename Image>
static unsigned size(const Image& im) {
const typename Image::domain_type& d = im.domain();
- return (d.len(0) / page_width ) * (d.len(1) / page_height);
+ return (1 + d.len(0) / page_width ) * (1 + d.len(1) / page_height);
+ }
+
+
+ static unsigned size(unsigned nrows, unsigned ncols) {
+ return (1 + ncols / page_width ) * (1 + nrows / page_height);
}
template<typename Image>
static unsigned page_at(const Image& im, const point2d& p)
{
- return (p[1] / page_height) * (im.domain().len(0) / page_width) + p[0] / page_width;
+ unsigned n = (p[0] / page_height) * (1 + im.domain().len(1) / page_width) + (p[1] / page_width);
+ return n;
};
static point2d changeref(const point2d& p)
{
- return point2d(p[0] % page_width, p[1] % page_height);
+ return point2d(p[0] % page_height, p[1] % page_width);
}
};
}
-
} // end of namespace mln
#endif
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix some typos, add existant tests.
* sandbox/pellegrin/set/Makefile: Remove.
* sandbox/pellegrin/set/core/concept/point_set.hh: Modified.
* sandbox/pellegrin/set/core/internal/multi_set.hh,
* sandbox/pellegrin/set/core/internal/uni_set.hh: New.
* sandbox/pellegrin/set/core/line2d.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_run.hh,
* sandbox/pellegrin/set/core/p_runs.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/pellegrin/set/core/pset_if.hh: Modify an #include and add a
semi-colon after the trait struct.
* sandbox/pellegrin/set/multi_set.hh: Remove.
* sandbox/pellegrin/set/test: New folder containing tests.
* sandbox/pellegrin/set/test/Makefile,
* sandbox/pellegrin/set/test/test.sh,
* sandbox/pellegrin/set/test/detest.sh: New, for the compilation.
* sandbox/pellegrin/set/test/p_bgraph.cc,
* sandbox/pellegrin/set/test/p_priority_queue.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc,
* sandbox/pellegrin/set/test/p_queue.cc,
* sandbox/pellegrin/set/test/p_queue_fast.cc,
* sandbox/pellegrin/set/test/p_runs.cc,
* sandbox/pellegrin/set/test/p_set.cc,
* sandbox/pellegrin/set/test/pset_if.cc: New tests.
* sandbox/pellegrin/set/test_set.cc: Remove.
* sandbox/pellegrin/set/trait/point_set.hh: Minor fix.
* sandbox/pellegrin/set/uni_set.hh: Remove.
---
core/concept/point_set.hh | 8 -
core/internal/multi_set.hh | 176 +++++++++++++++++++++++++++++++
core/internal/uni_set.hh | 176 +++++++++++++++++++++++++++++++
core/line2d.hh | 4
core/p_array.hh | 4
core/p_bgraph.hh | 4
core/p_graph.hh | 4
core/p_line_graph.hh | 4
core/p_priority_queue.hh | 10 -
core/p_priority_queue_fast.hh | 4
core/p_priority_queue_fast_with_array.hh | 8 -
core/p_queue.hh | 4
core/p_queue_fast.hh | 4
core/p_run.hh | 4
core/p_runs.hh | 4
core/p_set.hh | 4
core/pset_if.hh | 4
test/Makefile | 16 ++
test/detest.sh | 17 ++
test/p_bgraph.cc | 85 ++++++++++++++
test/p_priority_queue.cc | 98 +++++++++++++++++
test/p_priority_queue_fast.cc | 98 +++++++++++++++++
test/p_priority_queue_fast_with_array.cc | 105 ++++++++++++++++++
test/p_queue.cc | 57 ++++++++++
test/p_queue_fast.cc | 57 ++++++++++
test/p_runs.cc | 82 ++++++++++++++
test/p_set.cc | 57 ++++++++++
test/pset_if.cc | 53 +++++++++
test/test.sh | 18 +++
trait/point_set.hh | 2
30 files changed, 1130 insertions(+), 41 deletions(-)
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test/detest.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 1794)
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if ! [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i.bak $mln_path/core/$i;
+done
+
+rm -v $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/detest.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue_fast.cc
+ *
+ * \brief Tests on mln::p_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue_fast.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue_fast<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ mln::p_priority_queue_fast<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 1794)
@@ -0,0 +1,85 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/p_bgraph.cc
+/// \brief Tests on mln::p_bgraph (the psite based on boost-graph).
+
+#include "../core/p_bgraph.hh"
+#include <mln/core/point2d.hh>
+#include <mln/util/internal/boost_graph.hh>
+#include <boost/typeof/std/utility.hpp>
+
+struct empty {};
+
+int main()
+{
+ /*--------------.
+ | boost_graph. |
+ `--------------*/
+
+ using namespace mln;
+ typedef util::internal::boost_graph<point2d, util::empty> Graph;
+
+ // Make convenient labels for the vertices
+ const int num_vertices = 5;
+
+ // writing out the edges in the graph
+ typedef std::pair<int, int> Edge;
+ Edge edge_array[] = {
+ Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2),
+ Edge(2, 4), Edge(1, 3), Edge(3, 4)
+ };
+
+ const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]);
+ // declare a graph object
+ Graph g(num_vertices);
+
+ // add the edges to the graph object
+ for (int i = 0; i < num_edges; ++i)
+ boost::add_edge(edge_array[i].first, edge_array[i].second, g);
+
+ g[0] = make::point2d(0, 0);
+ g[1] = make::point2d(0, 1);
+ g[2] = make::point2d(1, 0);
+ g[3] = make::point2d(1, 1);
+ g[4] = make::point2d(0, 2);
+
+ /*-----------.
+ | p_bgraph. |
+ `-----------*/
+
+ /// Creation
+ p_bgraph<point2d> pset(&g);
+
+ /// Iterator
+ p_bgraph_piter_<point2d> p(pset);
+
+ for (p.start(); p.is_valid(); p.next())
+ std::cout << p << std::endl;
+
+ return 0;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue.cc
+ *
+ * \brief Tests on mln::p_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue.cc
+ *
+ * \brief Tests on mln::p_priority_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/test.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 1794)
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i $mln_path/core/$i.bak;
+ cp -v ../core/$i $mln_path/core/;
+done
+
+touch $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/test.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_runs.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 1794)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_runs.cc
+ *
+ * \brief Test on mln::p_runs_ and related tools.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_runs.hh>
+
+
+template <typename Pset>
+void parc(const Pset& pset)
+{
+ mln_fwd_piter(Pset) it_(pset);
+ for_all(it_)
+ std::cout << it_ << std::endl;
+
+ mln_bkd_piter(Pset) rit_(pset);
+ for_all(rit_)
+ std::cout << rit_ << std::endl;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d p, q, r;
+ p = make::point2d(2, 4);
+ q = make::point2d(18, 42);
+ r = make::point2d(50, 76);
+
+ // Pset test
+ p_runs_<point2d> ps;
+ p_runs_<point2d> ps2;
+
+ ps.insert(p_run<point2d>(p, 7));
+ mln_assertion(ps.npoints() == 7);
+
+ ps.insert(p_run<point2d>(q, 5));
+ mln_assertion(ps.npoints() == 12);
+
+ ps.insert(p_run<point2d>(r, 2));
+
+ ps.insert(p_run<point2d>(make::point2d(17,40), 6));
+
+ // Psite declaration
+ runs_psite<point2d> site(ps, 5, 0);
+ runs_psite<point2d> site2(ps, 5, 1);
+
+ mln_assertion(ps.has(site));
+ mln_assertion(!ps2.has(site2));
+
+
+ parc(ps);
+}
Index: trunk/milena/sandbox/pellegrin/set/test/pset_if.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 1794)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_pset_if.cc
+ *
+ * \brief Tests on mln::pset_if.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_set.hh>
+#include <mln/core/pset_if.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/convert/to_p_set.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ box2d box_8x8 = make::box2d(8, 8);
+ mln_assertion((box_8x8 | fun::p2b::chess).npoints() == 32);
+
+ {
+ p_set<point2d> s = convert::to_p_set(box_8x8 | fun::p2b::chess);
+ std::cout << (box_8x8 | fun::p2b::chess) << std::endl;
+ std::cout << s << std::endl;
+ }
+}
Index: trunk/milena/sandbox/pellegrin/set/test/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 1794)
@@ -0,0 +1,16 @@
+all:
+ ./test.sh
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_bgraph.cc -o bgraph
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue.cc -o priority_queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue_fast.cc -o priority_queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue_fast_with_array.cc -o priority_queue_fast_with_array
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue.cc -o queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue_fast.cc -o queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_runs.cc -o runs
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_set.cc -o set
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ pset_if.cc -o pset_if
+ ./detest.sh
+
+clean:
+ rm -vf bgraph priority_queue priority_queue_fast priority_queue_fast_with_array \
+ queue queue_fast runs set pset_if
Index: trunk/milena/sandbox/pellegrin/set/test/p_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_p_set.cc
+ *
+ * \brief Tests on mln::p_set.
+ */
+
+#include <iterator>
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_set.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_set<point2d> ps;
+ ps
+ .insert(make::point2d(6, 9))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(5, 1));
+ mln_assertion(ps.npoints() == 3);
+
+ std::cout << ps.bbox() << std::endl;
+
+ std::copy(ps.vect().begin(), ps.vect().end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision 1794)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast_with_array.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast_with_array.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast_with_array.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue_fast_with_array<point2d, unsigned, 20> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 1);
+
+ q.push_force (p1, 3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 2);
+
+ q.push_force (p2, 5);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 3);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/trait/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1794)
@@ -49,7 +49,7 @@
template <typename P> struct p_line_graph;
template <typename P, typename T> struct p_priority_queue;
template <typename P, typename T> struct p_priority_queue_fast;
- template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_queue;
template <typename P> struct p_queue_fast;
template <typename P> struct p_run;
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -64,7 +64,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/util/internal/boost_graph.hh>
# include <mln/core/bgraph_psite.hh>
# include <mln/core/p_bgraph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -57,7 +57,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_run.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1794)
@@ -36,7 +36,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
# include <mln/core/point_pair.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/* FIXME: This class shares a lot with p_graph. Factor as much as
@@ -67,7 +67,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/concept/function.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1794)
@@ -38,7 +38,7 @@
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/point_iterator.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -96,7 +96,6 @@
bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Inclusion test between point sets \p lhs and \p rhs.
*
* \param[in] lhs A point set (included?).
@@ -108,7 +107,6 @@
bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Strict inclusion test between point sets \p lhs and \p
* rhs.
*
@@ -121,7 +119,6 @@
bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Print a point set \p pset into the output stream \p
* ostr.
*
@@ -136,7 +133,6 @@
std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
-
# ifndef MLN_INCLUDE_ONLY
// fwd decl
@@ -245,8 +241,6 @@
} // end of namespace mln
-
# include <mln/core/ops.hh>
-
#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1794)
@@ -41,7 +41,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -60,7 +60,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -58,13 +58,13 @@
namespace trait
{
- template <typename P>
- struct point_set_< p_priority_queue<P> >
- : public default_point_set_< p_priority_queue<P> >
+ template <typename P, typename T>
+ struct point_set_< p_priority_queue<P, T> >
+ : public default_point_set_< p_priority_queue<P, T> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_runs.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/p_run.hh>
# include <mln/accu/bbox.hh>
# include <mln/util/lazy_set.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_array.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1794)
@@ -44,27 +44,27 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
{
// Fwd decls.
- template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P, typename T, typename S>
+ template <typename P, typename T, unsigned S>
struct point_set_< p_priority_queue_fast_with_array<P, T, S> >
: public default_point_set_< p_priority_queue_fast_with_array<P, T, S> >
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MULTI_SET_HH
+# define MULTI_SET_HH
+
+/*! \file sandbox/pellegrin/set/multi_set.hh
+ *
+ * \brief Definition of a point multi-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical multi-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class multi_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef multi_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef multi_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ multi_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ multi_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ multi_set<P>::multi_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ multi_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ multi_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ multi_set<P>&
+ multi_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ multi_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ multi_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ multi_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef UNI_SET_HH
+# define UNI_SET_HH
+
+/*! \file sandbox/pellegrin/set/uni_set.hh
+ *
+ * \brief Definition of a point uni-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical uni-set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class uni_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef uni_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef uni_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ uni_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ uni_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ uni_set<P>::uni_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ uni_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ uni_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ uni_set<P>&
+ uni_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ uni_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ uni_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ uni_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1794)
@@ -34,7 +34,7 @@
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/// \file mln/core/p_graph.hh
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0
19 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Icp : n dim, refactored, uses p_array, vec -> rounded point proc.
* mln/core/point.hh: Fix convertion to vec.
* mln/algebra/quat.hh: Fix namespace.
* mln/algebra/vec.hh: add to_point procedure.
* sandbox/jardonnet/test/icp.cc,
* sandbox/jardonnet/registration/quat7.hh,
* sandbox/jardonnet/registration/cloud.hh,
* sandbox/jardonnet/registration/jacobi.hh,
* sandbox/jardonnet/registration/icp.hh,
* sandbox/jardonnet/registration/projection.hh,
* sandbox/jardonnet/registration/quat/all.hh,
* sandbox/jardonnet/registration/quat/rotation.hh: Update for p_array and n dim (not ready yet).
* sandbox/jardonnet/registration/quat/interpol.hh: Remove. Provided by qut.hh
mln/algebra/quat.hh | 24 ++++-----
mln/algebra/vec.hh | 12 ++++
sandbox/jardonnet/registration/cloud.hh | 37 ++++++++------
sandbox/jardonnet/registration/icp.hh | 35 ++++++++------
sandbox/jardonnet/registration/jacobi.hh | 10 ++--
sandbox/jardonnet/registration/projection.hh | 33 ++++++-------
sandbox/jardonnet/registration/quat/all.hh | 1
sandbox/jardonnet/registration/quat/rotation.hh | 21 +++++---
sandbox/jardonnet/registration/quat7.hh | 60 ++++++++++++++----------
sandbox/jardonnet/test/icp.cc | 4 -
10 files changed, 136 insertions(+), 101 deletions(-)
Index: mln/core/point.hh
Index: mln/algebra/quat.hh
--- mln/algebra/quat.hh (revision 1791)
+++ mln/algebra/quat.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/algebra/quat.hh
*
- * \brief Define a class for quaternion values.
+ * \brief Define a class for quaternion algebra values.
*/
# include <cmath>
@@ -44,12 +44,13 @@
# include <mln/algebra/vec.hh>
# include <mln/norm/l2.hh>
+//FIXME: pow, exp etc... are def here and in value::...
namespace mln
{
// Fwd decls.
- namespace value { class quat; }
+ namespace algebra { class quat; }
namespace literal { struct zero_t; struct one_t; }
@@ -114,16 +115,15 @@
- namespace value
+ namespace algebra
{
- // FIXME doesn't compile
-
+ // FIXME value::Vectorial ??? value ???
class quat
:
- public Vectorial< quat >
+ public value::Vectorial< quat >
,
- public internal::value_like_< algebra::vec<4, float>, // Equivalent.
+ public value::internal::value_like_< algebra::vec<4, float>, // Equivalent.
algebra::vec<4, float>, // Encoding.
algebra::vec<4, float>, // Interoperation.
quat > // Exact.
@@ -606,7 +606,7 @@
quat slerp_2(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = p * value::pow(p.conj() * q, h);
+ quat tmp = p * pow(p.conj() * q, h);
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -615,7 +615,7 @@
quat slerp_3(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = value::pow(p * q.conj(), 1 - h) * q;
+ quat tmp = pow(p * q.conj(), 1 - h) * q;
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -624,7 +624,7 @@
quat slerp_4(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = value::pow(q * p.conj(), h) * p;
+ quat tmp = pow(q * p.conj(), h) * p;
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -633,7 +633,7 @@
quat slerp_5(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = q * value::pow(q.conj() * p, 1 - h);
+ quat tmp = q * pow(q.conj() * p, 1 - h);
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -641,7 +641,7 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::value
+ } // end of namespace mln::algebra
} // end of namespace mln
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 1791)
+++ mln/algebra/vec.hh (working copy)
@@ -549,6 +549,18 @@
return tmp;
}
+
+ template <typename P, unsigned n>
+ inline
+ P
+ to_point(const vec<n,float>& v)
+ {
+ P tmp;
+ for (unsigned i = 0; i < P::dim; ++i)
+ tmp[i] = round(v[i]);
+ return tmp;
+ }
+
# endif // MLN_INCLUDE_ONLY
} // end of namespace mln::algebra
Index: sandbox/jardonnet/test/icp.cc
--- sandbox/jardonnet/test/icp.cc (revision 1791)
+++ sandbox/jardonnet/test/icp.cc (working copy)
@@ -1,4 +1,4 @@
-#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
@@ -9,7 +9,7 @@
{
using namespace mln;
- image2d< value::rgb8 > img;
+ image3d< value::rgb8 > img;
registration::icp(img,img);
}
Index: sandbox/jardonnet/registration/quat7.hh
--- sandbox/jardonnet/registration/quat7.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat7.hh (working copy)
@@ -6,6 +6,7 @@
# include <algorithm>
# include <mln/algebra/mat.hh>
+# include <mln/core/p_array.hh>
# include "quat/all.hh"
# include "jacobi.hh"
@@ -49,16 +50,17 @@
namespace mln
{
+ template <unsigned n>
struct quat7
{
- value::quat _qR;
- vec3f _qT;
+ algebra::quat _qR;
+ algebra::vec<n,float> _qT;
quat7()
{
}
- quat7(const value::quat& qR, const vec3f& qT) :
+ quat7(const algebra::quat& qR, const algebra::vec<n,float>& qT) :
_qR(qR),
_qT(qT)
{
@@ -76,19 +78,21 @@
// quat7 is an object-function
- vec3f operator()(const vec3f& v) const
+ algebra::vec<n,float> operator()(const algebra::vec<n,float>& v) const
{
return rotate(_qR, v) + _qT;
}
- void apply_on(const std::vector< vec3f >& input, std::vector< vec3f >& output) const
+ template <typename P>
+ void apply_on(const p_array<P>& input, p_array<P>& output) const
{
- assert(input.size() == output.size());
+ assert(input.npoints() == output.npoints());
assert(_qR.is_unit());
- std::transform(input.begin(), input.end(),
- output.begin(),
- *this);
+ //FIXME utiliser equivalent pour p_array
+ //std::transform(input.begin(), input.end(),
+ // output.begin(),
+ // *this);
}
};
@@ -107,42 +111,48 @@
}
- quat7 match(const vecs_t& P,
- const vec3f& mu_P,
- const vecs_t& Xk,
- const vec3f& mu_Xk)
+ template <typename P>
+ quat7<P::dim> match(const p_array<P>& C,
+ const algebra::vec<P::dim,float>& mu_C,
+ const p_array<P>& Xk,
+ const algebra::vec<P::dim,float>& mu_Xk)
{
- assert(P.size() == Xk.size());
+ assert(C.npoints() == Xk.npoints());
// qR
- algebra::mat<3,3,float> Ck;
- for (unsigned i = 0; i < P.size(); ++i)
- Ck += make::mat(P[i] - mu_P) * trans(make::mat(Xk[i] - mu_Xk));
- Ck /= P.size();
+ //FIXME : use P::dim ?
+ algebra::mat<P::dim,P::dim,float> Mk;
+ for (unsigned i = 0; i < C.npoints(); ++i)
+ {
+ algebra::vec<P::dim,float> Ci = C[i];
+ algebra::vec<P::dim,float> Xki = Xki;
+ Mk += make::mat(Ci - mu_C) * trans(make::mat(Xki - mu_Xk));
+ }
+ Mk /= C.npoints();
- const algebra::mat<3,3,float> Ak = Ck - trans(Ck);
+ const algebra::mat<P::dim,P::dim,float> Ak = Mk - trans(Mk);
const float v[3] = {Ak(1,2), Ak(2,0), Ak(0,1)};
const algebra::mat<3,1,float> D = make::mat<3,1,3,float>(v); // FIXME why <...>
algebra::mat<4,4,float> Qk;
- Qk(0,0) = tr(Ck);
+ Qk(0,0) = tr(Mk);
put(trans(D), 0,1, Qk);
put(D, 1,0, Qk);
- put(Ck + trans(Ck) - algebra::mat<3,3,float>::identity() * tr(Ck), 1,1, Qk);
+ put(Mk + trans(Mk) - algebra::mat<P::dim,P::dim,float>::identity() * tr(Mk), 1,1, Qk);
- value::quat qR;
+ algebra::quat qR;
jacobi(Qk, qR);
// qT
- const vec3f qT = mu_Xk - rotate(qR, mu_P);
+ const algebra::vec<P::dim,float> qT = mu_Xk - rotate(qR, mu_C);
- return quat7(qR, qT);
+ return quat7<P::dim>(qR, qT);
}
-}
+} //end of namespace mln
#endif // ndef QUAT7_HH
Index: sandbox/jardonnet/registration/cloud.hh
--- sandbox/jardonnet/registration/cloud.hh (revision 1791)
+++ sandbox/jardonnet/registration/cloud.hh (working copy)
@@ -8,6 +8,7 @@
# include <sstream>
# include <mln/algebra/vec.hh>
+# include <mln/core/p_array.hh>
namespace mln
{
@@ -15,32 +16,36 @@
namespace registration
{
- typedef algebra::vec<3, float> vec3f;
-
-
- vec3f center(const std::vector< vec3f >& vecs)
+ template <typename P>
+ P center(const p_array<P>& a)
+ {
+ algebra::vec<P::dim,float> c;
+ for (size_t i = 0; i < a.npoints(); ++i)
{
- vec3f c;
- for (size_t i = 0; i < vecs.size(); ++i)
- c += vecs[i];
- return c / vecs.size();
+ algebra::vec<P::dim,float> ai = a[i];
+ c += ai;
+ }
+
+ return algebra::to_point<P>(c / a.npoints());
}
- // FIXME : move
- float sqr_norm(const vec3f& v)
+ // FIXME : move //exist for P?
+ template <typename P>
+ float sqr_norm(const P& v)
{
return v[1] * v[1] + v[2] * v[2] + v[3] * v[3];
}
- float rms(const std::vector< vec3f >& vecs1,
- const std::vector< vec3f >& vecs2)
+ template <typename P>
+ float rms(const p_array<P>& a1,
+ const p_array<P>& a2)
{
- assert(vecs1.size() == vecs2.size());
+ assert(a1.npoints() == a2.npoints());
float f = 0.f;
- for (size_t i = 0; i < vecs1.size(); ++i)
- f += sqr_norm(vecs1[i] - vecs2[i]);
- return f / vecs1.size();
+ for (size_t i = 0; i < a1.npoints(); ++i)
+ f += sqr_norm(a1[i] - a2[i]);
+ return f / a1.npoints();
}
}
Index: sandbox/jardonnet/registration/jacobi.hh
--- sandbox/jardonnet/registration/jacobi.hh (revision 1791)
+++ sandbox/jardonnet/registration/jacobi.hh (working copy)
@@ -7,14 +7,16 @@
// from num. rec. in C
+namespace mln
+{
#define rotateJacobi(a,i,j,k,l) g=a(i,j);h=a(k,l);a(i,j)=g-s*(h+g*tau); \
a(k,l)=h+s*(g-h*tau);
-void jacobi(mln::algebra::mat<4,4,float> a, mln::value::quat& q)
+ void jacobi(algebra::mat<4,4,float> a, algebra::quat& q)
{
float dd, d[4];
- mln::algebra::mat<4,4,float> v;
+ algebra::mat<4,4,float> v;
int j,iq,ip,i = 0;
float tresh,theta,tau,t,sm,s,h,g,c,b[4],z[4];
for (ip=0;ip<4;ip++) {
@@ -39,7 +41,7 @@
iq = ip;
dd = d[ip];
}
- q = mln::value::quat(v(0,iq),
+ q = algebra::quat(v(0,iq),
v(1,iq),
v(2,iq),
v(3,iq));
@@ -103,6 +105,6 @@
}
}
-
+}
#endif // ndef JACOBI_HH
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 1791)
+++ sandbox/jardonnet/registration/icp.hh (working copy)
@@ -33,12 +33,12 @@
* \brief image registration
*/
-# include <mln/value/quat.hh>
+# include <mln/algebra/quat.hh>
# include <mln/algebra/vec.hh>
-typedef mln::algebra::vec<3, float> vec3f;
-typedef std::vector< vec3f > vecs_t;
+//typedef mln::algebra::vec<3, float> vec3f;
+//typedef mln::p_array< vec3f > vecs_t;
#include "cloud.hh"
#include "quat7.hh"
@@ -65,39 +65,44 @@
namespace impl
{
+ template <typename P>
inline
void
- icp_(const vecs_t& P,
- const vecs_t& X)
+ icp_(const p_array<P>& C,
+ const p_array<P>& X)
{
trace::entering("registration::impl::icp_");
unsigned int k;
- quat7 old_qk, qk;
+ quat7<P::dim> old_qk, qk;
float err, err_bis;
- vecs_t Pk(P.size()), Xk(Pk.size());
- vec3f mu_P = center(P), mu_Xk;
+ p_array<P> Ck, Xk;
+ Ck.reserve(C.npoints());
+ Xk.reserve(Ck.npoints());
+ algebra::vec<P::dim,float> mu_C = center(C), mu_Xk;
const float epsilon = 1e-3;
//step 1
k = 0;
- Pk = P;
+ Ck = C;
do {
//step 2 FIXME : etienne
- projection::de_base(Pk, X, Xk, mu_Xk, err_bis);
+ projection::de_base(Ck, X, Xk, err_bis);
+
+ mu_Xk = center(Xk);
// step 3
old_qk = qk;
- qk = match(P, mu_P, Xk, mu_Xk);
+ qk = match(C, mu_C, Xk, mu_Xk);
// step 4
- qk.apply_on(P, Pk); // Pk+1 = qk(P)
+ qk.apply_on(C, Ck); // Ck+1 = qk(C)
- // err = d(Pk+1,Xk)
- err = rms(Pk, Xk);
+ // err = d(Ck+1,Xk)
+ err = rms(Ck, Xk);
++k;
} while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
@@ -119,7 +124,7 @@
mln_precondition(exact(cloud).has_data());
mln_precondition(exact(surface).has_data());
- vecs_t a,b; // FIXME : to built.
+ p_array<mln_point(I)> a,b; // FIXME : to built.
impl::icp_(a, b);
Index: sandbox/jardonnet/registration/projection.hh
--- sandbox/jardonnet/registration/projection.hh (revision 1791)
+++ sandbox/jardonnet/registration/projection.hh (working copy)
@@ -10,40 +10,37 @@
namespace projection
{
- template <class Pk_t, class X_t, class Xk_t>
+ template <typename P>
void de_base(// input
- const Pk_t& Pk,
- const X_t& X,
+ const p_array<P>& Ck,
+ const p_array<P>& X,
// inout
- Xk_t& Xk,
- // output
- algebra::vec<3, float>& mu_Xk,
+ p_array<P>& Xk,
float& err)
{
- assert(Pk.size() == Xk.size());
+ assert(Ck.npoints() == Xk.npoints());
err = 0.f;
- mu_Xk = make::vec(0,0,0);
- for (size_t i = 0; i < Pk.size(); ++i)
+ for (size_t i = 0; i < Ck.npoints(); ++i)
{
- algebra::vec<3,float> best_x = X[0];
- float best_d = norm::l2(Pk[i] - best_x);
- for (size_t j = 1; j < X.size(); ++j)
+ algebra::vec<P::dim,float> Cki = Ck[i];
+ algebra::vec<P::dim,float> best_x = X[0];
+ float best_d = norm::l2(Cki - best_x);
+ for (size_t j = 1; j < X.npoints(); ++j)
{
- float d = norm::l2(Pk[i] - X[j]);
+ algebra::vec<P::dim,float> Xj = X[j];
+ float d = norm::l2(Cki - Xj);
if (d < best_d)
{
best_d = d;
- best_x = X[j];
+ best_x = Xj;
}
}
- Xk[i] = best_x;
- mu_Xk += Xk[i];
+ Xk.hook_()[i] = algebra::to_point<P>(best_x);
err += best_d;
}
- mu_Xk /= Pk.size();
- err /= Pk.size();
+ err /= Ck.npoints();
}
}
Index: sandbox/jardonnet/registration/quat/all.hh
--- sandbox/jardonnet/registration/quat/all.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat/all.hh (working copy)
@@ -2,7 +2,6 @@
# define QUAT_ALL_HH
-# include "interpol.hh"
# include "rotation.hh"
Index: sandbox/jardonnet/registration/quat/rotation.hh
--- sandbox/jardonnet/registration/quat/rotation.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat/rotation.hh (working copy)
@@ -10,26 +10,30 @@
# include <mln/algebra/vec.hh>
# include <mln/make/vec.hh>
# include <mln/make/mat.hh>
-# include <mln/value/quat.hh>
+# include <mln/algebra/quat.hh>
+# include "misc.hh"
// FIXME: rotation should be an abstract class
// and derived classes encapsulate either a quaternion or a algebra::matrix
namespace mln
{
- vec3f rotate(const value::quat& q, const vec3f& p)
+ // FIXME : quat is not appriate here
+ template <unsigned n>
+ algebra::vec<n,float> rotate(const algebra::quat& q, const algebra::vec<n,float>& p)
{
- return (q * value::quat(0. ,p) * q.inv()).v();
+ return (q * algebra::quat(0. ,p) * q.inv()).v();
}
-
- bool check_rotation(const algebra::mat<3,3,float>& mat,
- const value::quat& q)
+ //FIXME : check if correct with n != 3
+ template <unsigned n>
+ bool check_rotation(const algebra::mat<n,n,float>& mat,
+ const algebra::quat& q)
{
assert(q.is_unit());
- vec3f
+ algebra::vec<n,float>
tmp = make::vec(rand(), rand(), rand()),
p = tmp / norm::l2(tmp),
p_rot_1 = rotate(q, p),
@@ -38,7 +42,8 @@
}
- algebra::mat<3,3,float> quat2mat(const value::quat& q)
+ //FIXME : switch to n dim.
+ algebra::mat<3,3,float> quat2mat(const algebra::quat& q)
{
assert(q.is_unit());
float
1
0
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update test on rgb/hsi conversion.
* milena/doc/tutorial/image_types.txt: Augment.
* milena/mln/value/rgb.hh (red_t, green_t, blue_t): New.
* milena/sandbox/vigouroux/moyenne.cc: Update.
doc/tutorial/image_types.txt | 80 ++++++++++++++++++++++++++++++++++++++++---
mln/value/rgb.hh | 4 ++
sandbox/vigouroux/moyenne.cc | 55 +++++++++++++----------------
3 files changed, 106 insertions(+), 33 deletions(-)
Index: milena/doc/tutorial/image_types.txt
--- milena/doc/tutorial/image_types.txt (revision 1790)
+++ milena/doc/tutorial/image_types.txt (working copy)
@@ -236,23 +236,95 @@
** methods
-*** values
+*** about the image variable
+**** has_data
+
+sig is:
bool has_data() const
-// FIXME: ? better name is is_allocated Nota bene: is_initialized means "has relevant data"!
+is "is_allocated" / "is_ready" a better name?
+
+Nota bene: "is_initialized" is consistent with the "initialize"
+routine; yet, it means "has relevant data", which is not really
+what it meant!
+
+**** name_it(string)
+
+Later...
+
+*** about definition domain
+
+**** domain
const pset& domain() const
+
+**** has & owns_
+
bool has(const psite& p) const
bool owns_(const psite& p) const
-const box_<point>& bbox() const
-std::size_t npoints() const
+Major question: is ima.has(p) equivalent to ima.domain().has(p)? or
+(if it is equivalent) do we feature a specific method has_extended()?
+
+Remember that in the case of a window, we want to write:
+
+for_all(p)
+ for_all(q)
+ if (ima.has(q))
+ ..
+
+so that there is a decoupling between a window and an image. More
+precisely a site q of a window centered at p can lay outside the
+definition domain, thus we need the "has" test. Such a decoupling is
+great since we can reuse some window or neighborhood definition over a
+domain which is compatible but restricted. This is also true for a
+graph on which some window (resp. neighborhood) is defined and can be
+applied over a sub-graph.
+
+The owns_ method is weird because it is only internal.
+
+**** suggestion
+
+"has(p)" means that there is a value for p. The set of sites p that
+verify "has(p) = true" is the "extended domain." Some image types
+features such an extension; some other do not.
+
+We always have:
+ ima.domain().has(p) => ima.has(p)
+
+If the image ima does not extend the definition domain, we have:
+ ima.domain().has(p) <=> ima.has(p)
+
+A site p is in the extended domain iff:
+ ima.has(p) and not ima.domain().has(p).
+
+*** about data access
rvalue operator()(const psite& p) const
lvalue operator()(const psite& p)
+*** about destination space
+
const vset& destination() const // was: values()
+*** obsolete methods
+
+**** bbox
+
+const box_<point>& bbox() const
+
+too ambiguous because we want a bounding box:
+- either precise or approximative (larger)
+- on a grid (if possible)
+- on the space (if sites are located)
+
+remember that some image have sites that are not localized (and then a
+bbox, if it exists, can only be a index range for instance)
+
+**** npoints
+
+std::size_t npoints() const
+is useless since the user can write ima.domain().nsites()
* properties
Index: milena/mln/value/rgb.hh
--- milena/mln/value/rgb.hh (revision 1790)
+++ milena/mln/value/rgb.hh (working copy)
@@ -162,6 +162,10 @@
{
public:
+ typedef int_u<n> red_t;
+ typedef int_u<n> green_t;
+ typedef int_u<n> blue_t;
+
/// \{ Acces to red/green/blue component.
int_u<n> red() const { return this->v_[0]; }
int_u<n>& red() { return this->v_[0]; }
Index: milena/sandbox/vigouroux/moyenne.cc
--- milena/sandbox/vigouroux/moyenne.cc (revision 1790)
+++ milena/sandbox/vigouroux/moyenne.cc (working copy)
@@ -1,7 +1,9 @@
#include "color/my_hsi.hh"
#include "color/rgb_to_hsi.hh"
-#include <mln/display/save_and_show.hh>
-#include <mln/value/rgb.hh>
+
+#include <cmath>
+
+#include <mln/core/image2d.hh>
#include <mln/value/rgb8.hh>
#include <mln/io/ppm/load.hh>
@@ -9,43 +11,43 @@
#include <mln/math/round.hh>
#include <mln/level/transform.hh>
-#include <mln/core/image2d.hh>
-#include <cmath>
-#include <iostream>
-template <typename I, typename O>
-float rms (const I& ima, O& out)
+template <typename I1, typename I2>
+float rms(const mln::Image<I1>& ima1_, const mln::Image<I2>& ima2_)
{
- mln::value::rgb8 c1;
- mln::value::rgb8 c2;
- float distred = 0;
- float distgreen = 0;
- float distblue = 0;
- float sum = 0;
- float nb = 0;
- float moy = 0;
+ const I1& ima1 = exact(ima1_);
+ const I2& ima2 = exact(ima2_);
+
+ mln_precondition(ima1.has_data() && ima2.has_data());
+
+ double sum = 0, nb = 0;
- mln_piter(I) p(out.domain());
+ mln_piter(I1) p(ima1.domain());
for_all(p)
{
- c1 = ima(p);
- c2 = out(p);
- distred = c2.red() - c1.red();
- distgreen = c2.green() - c1.green();
+ mln_value(I1) c1 = ima1(p);
+ mln_value(I2) c2 = ima2(p);
+ double
+ distred = c2.red() - c1.red(),
+ distgreen = c2.green() - c1.green(),
distblue = c2.blue() - c1.blue();
++nb;
sum += distred * distred + distblue * distblue + distgreen * distgreen;
}
- moy = std::sqrt(sum / nb);
- return (moy);
+
+ if (nb = 0)
+ return 0;
+
+ return std::sqrt(sum / nb);
}
+
int main()
{
using namespace mln;
- using value::int_u8;
+
image2d<value::rgb8> lena;
io::ppm::load(lena, "../../img/lena.ppm");
@@ -55,12 +57,7 @@
image2d<value::rgb8> lena_rgb = level::transform(lena_hsi,
fun::v2v::f_hsi_to_rgb_3x8);
-
- float err = rms(lena, lena_rgb);
-
+ double err = rms(lena, lena_rgb);
std::cout << "err: " << err << std::endl;
-
- display::save_and_show (lena_rgb, "display", 50);
- return (0);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix some mistakes, Add.
* sandbox/pellegrin/set/core/line2d.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/pellegrin/set/core/pset_if.hh: traits are up-to-date
(or not, i have to check it with theo) and add the fwd decls.
* sandbox/pellegrin/set/core/p_run.hh: New.
* sandbox/pellegrin/set/core/p_runs.hh: New.
* sandbox/pellegrin/set/core/runs_psite.hh: Remove (not a point_set).
---
line2d.hh | 8
p_array.hh | 6
p_bgraph.hh | 18 -
p_graph.hh | 6
p_line_graph.hh | 15
p_priority_queue.hh | 8
p_priority_queue_fast.hh | 8
p_priority_queue_fast_with_array.hh | 10
p_queue.hh | 6
p_queue_fast.hh | 6
p_run.hh | 250 ++++++++++++++++
p_runs.hh | 541 ++++++++++++++++++++++++++++++++++++
p_set.hh | 6
pset_if.hh | 7
14 files changed, 860 insertions(+), 35 deletions(-)
Index: trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1790)
@@ -44,19 +44,23 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T> struct p_priority_queue_fast;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <typename P, typename T>
+ struct point_set_< p_priority_queue_fast<P, T> >
+ : public default_point_set_< p_priority_queue_fast<P, T> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1790)
@@ -25,8 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_BGRAPH_P_HH
-# define MLN_CORE_BGRAPH_P_HH
+#ifndef MLN_CORE_P_BGRAPH_HH
+# define MLN_CORE_P_BGRAPH_HH
+
+/// \file mln/core/p_bgraph.hh
+/// \brief Definition of a point set based on a boost graph.
# include <utility>
@@ -36,22 +39,21 @@
# include <mln/util/internal/boost_graph.hh>
# include <mln/core/bgraph_psite.hh>
# include <mln/core/p_bgraph_piter.hh>
+# include <mln/trait/point_set.hh>
-
-/// \file mln/core/p_bgraph.hh
-/// \brief Definition of a point set based on a boost graph.
-
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_bgraph;
template<typename P> class p_bgraph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_bgraph<P> > : public default_point_set_< p_bgraph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
@@ -229,4 +231,4 @@
} // end of mln
-#endif // MLN_CORE_BGRAPH_P_HH
+#endif // MLN_CORE_P_BGRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_run.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1790)
@@ -0,0 +1,250 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_RUN_HH
+# define MLN_CORE_P_RUN_HH
+
+/*! \file mln/core/p_run.hh
+ *
+ * \brief Definition of a point set class based on std::set.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_run;
+ template <typename P> struct p_run_fwd_piter_;
+ template <typename P> struct p_run_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_run<P> > : public default_point_set_< p_run<P> >
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class in run.
+ *
+ * This is a mathematical set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo Test if \p P being a Point_Site is ok.
+ */
+ template <typename P>
+ class p_run : public internal::point_set_base_< P, p_run<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_run_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_run_bkd_piter_<P> bkd_piter;
+
+ /// Constructor without argument.
+ p_run();
+
+ /// Constructor.
+ p_run(const P& start, std::size_t len);
+
+ /// Set the starting point.
+ void set_run(const P& start, std::size_t len);
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the length of the run.
+ std::size_t length() const;
+
+ /// Return the \p i-th point.
+ P operator[](unsigned i) const;
+
+ /// Return the first point.
+ const P& first() const;
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ /// Set a relation order to p_run.
+ bool operator<(const p_run<P>& rhs) const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+
+ /// The first point of the run.
+ P p_;
+
+ /// The length of the run.
+ std::size_t len_;
+
+ /// For internal use.
+ bool is_valid_;
+ };
+
+ template <typename P>
+ std::ostream& operator<<(std::ostream& out, const p_run<P>& pr)
+ {
+ out << "Run: (" << pr.first() << ", " << pr.length() << ")";
+ return out;
+ }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_run<P>::p_run()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ inline
+ p_run<P>::p_run(const P& start, std::size_t len)
+ : p_(start),
+ len_(len)
+ {
+ mln_precondition(len != 0);
+ P p = start;
+ bb_.init();
+ bb_.take(p);
+ p[P::dim - 1] += len - 1;
+ bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run<P>::set_run(const P& start, std::size_t len)
+ {
+ mln_precondition(len != 0);
+ p_ = start;
+ len_ = len;
+ P p = start;
+ bb_.init();
+ bb_.take(p);
+ p[P::dim - 1] += len - 1;
+ bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run<P>::has(const P& p) const
+ {
+ mln_precondition(is_valid_);
+ bool res = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(res = (res && p[i] == p_[i])))
+ return false;
+ return (p[P::dim - 1] >= p_[P::dim - 1]
+ && p[P::dim - 1] < p_[P::dim - 1] + (signed)len_);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::npoints() const
+ {
+ mln_precondition(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::length() const
+ {
+ mln_precondition(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ P
+ p_run<P>::operator[](unsigned i) const
+ {
+ mln_precondition(is_valid_);
+ mln_precondition(i < npoints());
+ P p = p_;
+ p[P::dim - 1] += i;
+ return p;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_run<P>::first() const
+ {
+ return p_;
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ p_run<P>::bbox() const
+ {
+ mln_precondition(is_valid_);
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run<P>::operator<(const p_run<P>& rhs) const
+ {
+ return (this->p_ < rhs.p_)
+ || (this->p_ == rhs.p_ && this->len_ < rhs.len_);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+# include <mln/core/p_run_piter.hh>
+
+#endif // ! MLN_CORE_P_RUN_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1790)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_LINE_GRAPH_P_HH
-# define MLN_CORE_LINE_GRAPH_P_HH
+#ifndef MLN_CORE_P_LINE_GRAPH_HH
+# define MLN_CORE_P_LINE_GRAPH_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
@@ -35,11 +35,12 @@
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
# include <mln/core/point_pair.hh>
+# include <mln/trait/point_set.hh>
+
/* FIXME: This class shares a lot with p_graph. Factor as much as
possible. */
-
/// \file mln/core/p_line_graph.hh
/// \brief Definition of a point set based on line graph.
@@ -54,14 +55,15 @@
// Nothing.
};
-
+ // Fwd decl.
+ template <typename P> struct p_line_graph;
template<typename P> class p_line_graph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_line_graph<P> > : public default_point_set_< p_line_graph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
@@ -172,5 +174,4 @@
} // end of mln
-
-#endif // MLN_CORE_P_GRAPH_HH
+#endif // MLN_CORE_P_LINE_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1790)
@@ -35,6 +35,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/concept/function.hh>
+# include <mln/trait/point_set.hh>
namespace mln
@@ -48,11 +49,11 @@
namespace trait
{
- template <typename P>
- struct point_set_< pset_if<> > : public default_point_set_<P>
+ template <typename S, typename F>
+ struct point_set_< pset_if<S, F> > : public default_point_set_< pset_if<S, F> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1790)
@@ -37,12 +37,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -50,9 +52,9 @@
{
template <typename P>
- struct point_set_< p_array<P> > : public default_point_set_<P>
+ struct point_set_< p_array<P> > : public default_point_set_< p_array<P> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1790)
@@ -41,12 +41,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_queue;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -54,10 +56,10 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_queue<P> > : public default_point_set_< p_queue<P> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1790)
@@ -44,11 +44,14 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T> struct p_priority_queue;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -56,10 +59,11 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_priority_queue<P> >
+ : public default_point_set_< p_priority_queue<P> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_runs.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1790)
@@ -0,0 +1,541 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_RUNS_HH
+# define MLN_CORE_P_RUNS_HH
+
+/*! \file mln/core/p_runs.hh
+ *
+ * \brief Definition of mln::internal::p_runs_ class and its iterators
+ * (for internal use only).
+ */
+
+# include <utility>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/point_iterator_base.hh>
+# include <mln/core/runs_psite.hh>
+# include <mln/core/p_run.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/lazy_set.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration
+ template <typename P> struct p_runs;
+ template <typename P> struct p_runs_fwd_piter_;
+ template <typename P> struct p_runs_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_runs<P> > : public default_point_set_< p_runs<P> >
+ {
+ typedef trait::point_set::arity::multiple arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief p_runs_ class represent a point set used in run_image_ class.
+ *
+ * Parameter \c P is the type of the image point.
+ */
+ template <typename P>
+ class p_runs_ : public internal::point_set_base_< runs_psite<P>, p_runs_<P> >
+ {
+ public:
+
+// typedef util::lazy_set_<p_run<P> > container;
+ typedef p_runs_fwd_piter_<P> fwd_piter;
+ typedef p_runs_bkd_piter_<P> bkd_piter;
+
+ /// Constructor without arguments.
+ p_runs_();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const runs_psite<P>& ps) const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Give the number of points.
+ typename std::size_t npoints() const;
+
+ /// Insert a range, start at point \p p wit len \p len.
+ void insert(const p_run<P>& pr);
+
+ /// Return the number of runs.
+ unsigned nruns() const;
+
+ /// Return the len of the range starting at point \p p.
+ unsigned range_len_(const P& p) const;
+
+ /// Return the i-th run of the list of runs
+ const p_run<P>& operator[](unsigned i) const;
+
+ /// Return the size of the data in memory.
+ unsigned size_mem() const;
+
+ /// Finalize the lazy_set (internal use)
+ void finalize();
+
+// /// Return the container of the pset (internal use only).
+// const container& con() const;
+
+ protected:
+
+ /// Number of points.
+ typename std::size_t npoints_;
+
+ /// Points container
+ util::lazy_set_<p_run<P> > con_;
+
+ /// Exact bounding box.
+ accu::bbox<P> fb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_<P>::p_runs_() :
+ npoints_(0)
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_<P>::has(const runs_psite<P>& ps) const
+ {
+ if (ps.p_of_run() < nruns()
+ && ps.p_in_run() < con_[ps.p_of_run()].length())
+ return (ps == con_[ps.p_of_run()][ps.p_in_run()]);
+ else
+ return false;
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_runs_<P>::bbox() const
+ {
+ return fb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ typename std::size_t
+ p_runs_<P>::npoints() const
+ {
+ return npoints_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_<P>::insert(const p_run<P>& pr)
+ {
+ typename std::vector<p_run<P> >::const_iterator iter = con_.vect().begin();
+ while (iter != con_.vect().end() && iter->first() < pr.first())
+ ++iter;
+
+ if (iter != con_.vect().begin())
+ {
+ typename std::vector<p_run<P> >::const_iterator prec = iter;
+ --prec;
+ bool equal = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(equal = equal && (prec->first()[i] == pr.first()[i])))
+ break;
+ if (equal)
+ mln_assertion(prec->first()[P::dim - 1] + (signed)prec->length()
+ <= pr.first()[P::dim - 1]);
+ }
+
+ if (iter != con_.vect().end())
+ {
+ bool equal = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(equal = equal && ((*iter).first()[i] == pr.first()[i])))
+ break;
+ if (equal)
+ mln_assertion(pr.first()[P::dim - 1] + (signed)pr.length()
+ <= iter->first()[P::dim - 1]);
+ }
+ con_.insert(pr);
+
+ // update box
+ fb_.take(pr.bbox().pmin());
+ fb_.take(pr.bbox().pmax());
+ // update size
+ npoints_ += pr.npoints();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::nruns() const
+ {
+ return con_.nelements();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::range_len_(const P& p) const
+ {
+ unsigned i;
+ for (i = 0; i < con_.size(); ++i)
+ {
+ if (con_[i].first == p)
+ return con_[i].second;
+ }
+ mln_assertion(i < con_.size());
+
+ //Hack
+ return (con_[i].second);
+ }
+
+ template <typename P>
+ inline
+ const p_run<P>&
+ p_runs_<P>::operator[](unsigned i) const
+ {
+ return con_[i];
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::size_mem() const
+ {
+ if (con_.get_mode())
+ return nruns() * (sizeof(P) + sizeof(unsigned));
+ else
+ return 2 * nruns() * (sizeof(P) + sizeof(unsigned));
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_<P>::finalize()
+ {
+ con_.set_const_mode(true);
+ }
+
+
+// template <typename P>
+// const typename p_runs_<P>::container&
+// p_runs_<P>::con() const
+// {
+// return con_;
+// }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ /*! \brief Factorization class for p_runs_iterator_.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ * Parameter \c E is the exact type of the iterator
+ */
+ template <typename P, typename E>
+ class p_runs_piter_ : public internal::point_iterator_base_< runs_psite<P>, E >
+ {
+ public:
+
+ /// Convertion into a point.
+ operator P () const;
+
+ /// Reference to the corresponding point.
+ const P& to_point() const;
+
+ /// Access to the current point coordinates.
+ mln_coord(P) operator[](unsigned i) const;
+
+ protected:
+
+ /// Current point.
+ P p_;
+
+ /// Point set container.
+ const p_runs_<P>& con_;
+
+ p_runs_piter_(const p_runs_<P>& pset);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename E>
+ inline
+ p_runs_piter_<P, E>::p_runs_piter_(const p_runs_<P>& pset) :
+ con_(pset)
+ {
+ }
+
+ template <typename P, typename E>
+ inline
+ p_runs_piter_<P, E>::operator P () const
+ {
+ return this->to_point();
+ }
+
+ template <typename P, typename E>
+ inline
+ const P&
+ p_runs_piter_<P, E>::to_point() const
+ {
+ mln_precondition(exact(this)->is_valid());
+ return p_;
+ }
+
+ template <typename P, typename E>
+ inline
+ mln_coord(P)
+ p_runs_piter_<P, E>::operator[] (unsigned i) const
+ {
+ mln_precondition(exact(this)->is_valid());
+ return p_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /*! \brief Forward iterator on p_runs_ point set.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ */
+ template <typename P>
+ class p_runs_fwd_piter_ : public p_runs_piter_<P, p_runs_fwd_piter_<P> >
+ {
+ typedef p_runs_piter_<P, p_runs_fwd_piter_<P> > super;
+ public:
+
+ p_runs_fwd_piter_(const p_runs_<P>& pset);
+
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ /// Convertion into a point-site.
+ operator runs_psite<P> () const;
+
+ protected:
+
+ unsigned i_;
+
+ p_run_fwd_piter_<P> it_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_fwd_piter_<P>::p_runs_fwd_piter_(const p_runs_<P>& pset) :
+ super(pset)
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_fwd_piter_<P>::is_valid() const
+ {
+ return i_ < this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::invalidate()
+ {
+ i_ = this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::start()
+ {
+ i_ = 0;
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::next_()
+ {
+ mln_precondition(this->is_valid());
+ it_.next();
+ if (!it_.is_valid())
+ {
+ ++i_;
+ if (is_valid())
+ {
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ }
+ else
+ return;
+ }
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ p_runs_fwd_piter_<P>::operator runs_psite<P> () const
+ {
+ return runs_psite<P>(this->con_, it_.ind(), i_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /*! \brief Backward iterator on p_runs_ point set.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ */
+ template <typename P>
+ class p_runs_bkd_piter_ : public p_runs_piter_<P, p_runs_bkd_piter_<P> >
+ {
+ typedef p_runs_piter_<P, p_runs_bkd_piter_<P> > super;
+ public:
+
+ p_runs_bkd_piter_(const p_runs_<P>& pset);
+
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ /// Convertion into a point-site.
+ operator runs_psite<P> () const;
+
+ protected:
+
+ unsigned i_;
+
+ p_run_bkd_piter_<P> it_;
+};
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_bkd_piter_<P>::p_runs_bkd_piter_(const p_runs_<P>& pset) :
+ super(pset)
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_bkd_piter_<P>::is_valid() const
+ {
+ return i_ < this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::invalidate()
+ {
+ i_ = this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::start()
+ {
+ i_ = this->con_.nruns() - 1;
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::next_()
+ {
+ mln_precondition(this->is_valid());
+ it_.next();
+ if (!it_.is_valid())
+ {
+ --i_;
+ if (is_valid())
+ {
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ }
+ else
+ return;
+ }
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ p_runs_bkd_piter_<P>::operator runs_psite<P> () const
+ {
+ return runs_psite<P>(this->con_, it_.ind(), i_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_RUNS_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1790)
@@ -37,16 +37,20 @@
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_array.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_set;
+
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_set<P> > : public default_point_set_< p_set<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1790)
@@ -44,21 +44,25 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <typename P, typename T, typename S>
+ struct point_set_< p_priority_queue_fast_with_array<P, T, S> >
+ : public default_point_set_< p_priority_queue_fast_with_array<P, T, S> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1790)
@@ -39,16 +39,20 @@
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
+ // Fwd decl.
+ template <typename P> struct line2d;
+
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <>
+ struct point_set_<line2d> : public default_point_set_<line2d>
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1790)
@@ -34,6 +34,8 @@
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
+# include <mln/trait/point_set.hh>
+
/// \file mln/core/p_graph.hh
/// \brief Definition of a point set based on graph.
@@ -41,13 +43,15 @@
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_graph;
template<typename P> class p_graph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_graph<P> > : public default_point_set_< p_graph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1790)
@@ -42,12 +42,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_queue_fast;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -55,9 +57,9 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_queue_fast<P> > : public default_point_set_< p_queue_fast<P> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Caroline Vigouroux <vigour_c(a)epita.fr>
rms.
* moyenne.cc: rms.
---
moyenne.cc | 79 ++++++++++++++++++-------------------------------------------
1 file changed, 24 insertions(+), 55 deletions(-)
Index: trunk/milena/sandbox/vigouroux/moyenne.cc
===================================================================
--- trunk/milena/sandbox/vigouroux/moyenne.cc (revision 1788)
+++ trunk/milena/sandbox/vigouroux/moyenne.cc (revision 1789)
@@ -1,5 +1,3 @@
-#include <mln/core/image2d.hh>
-#include <mln/value/int_u8.hh>
#include "color/my_hsi.hh"
#include "color/rgb_to_hsi.hh"
#include <mln/display/save_and_show.hh>
@@ -11,68 +9,36 @@
#include <mln/math/round.hh>
#include <mln/level/transform.hh>
-#include <mln/core/w_window2d_float.hh>
-#include <mln/border/thickness.hh>
-#include <mln/linear/convolve.hh>
-
-# include <mln/display/save.hh>
-# include <mln/display/show.hh>
-
#include <mln/core/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-#include <mln/make/pixel.hh>
#include <cmath>
#include <iostream>
-// template <typename I, typename O, typename W>
-// float moyenne (I& ima, O& out, W& win)
-// {
-// mln::value::rgb8 c2;
-// mln_piter(I) p(out.domain());
-// mln_qixter(I, W) q(ima, win, p);
-// for_all(p)
-// {
-// for_all(q)
-// {
-// q.val()
-// }
-// out(p) = c2;
-// }
-
-// return ();
-// }
-
-template <typename I, typename O, typename W>
-float moyenne (I& ima, O& out, W& win)
+template <typename I, typename O>
+float rms (const I& ima, O& out)
{
- mln::value::hsi_3x8 c_hsi;
+ mln::value::rgb8 c1;
mln::value::rgb8 c2;
float distred = 0;
float distgreen = 0;
float distblue = 0;
float sum = 0;
- float nb_ct = 0;
+ float nb = 0;
float moy = 0;
mln_piter(I) p(out.domain());
- mln_qixter(I, W) q(ima, win, p);
for_all(p)
{
- for_all(q)
- {
- c_hsi = mln::fun::v2v::f_rgb_to_hsi_3x8(q.val());
- c2 = mln::fun::v2v::f_hsi_to_rgb_3x8(c_hsi);
- distred = c2.red() - q.val().red();
- distgreen = c2.green() - q.val().green();
- distblue = c2.blue() - q.val().blue();
- }
- nb_ct += 3;
+ c1 = ima(p);
+ c2 = out(p);
+ distred = c2.red() - c1.red();
+ distgreen = c2.green() - c1.green();
+ distblue = c2.blue() - c1.blue();
+
+ ++nb;
sum += distred * distred + distblue * distblue + distgreen * distgreen;
- out(p) = c2;
}
- moy = sqrt(sum / nb_ct);
- std::cout << "nb_point: " << nb_ct / 3 << std::endl;
+ moy = std::sqrt(sum / nb);
return (moy);
}
@@ -80,18 +46,21 @@
{
using namespace mln;
using value::int_u8;
- image2d<mln::value::rgb8> lena;
+ image2d<value::rgb8> lena;
io::ppm::load(lena, "../../img/lena.ppm");
- image2d<mln::value::hsi_3x8> inter(lena.domain());
- image2d<mln::value::rgb8> out(lena.domain());
- const image2d<mln::value::rgb8> input = exact(lena);
- float lol;
- win::rectangle2d rect(3, 3);
- lol = moyenne(input, out, rect);
+ image2d<value::hsi_3x8> lena_hsi = level::transform(lena,
+ fun::v2v::f_rgb_to_hsi_3x8);
+
+ image2d<value::rgb8> lena_rgb = level::transform(lena_hsi,
+ fun::v2v::f_hsi_to_rgb_3x8);
+
+
+ float err = rms(lena, lena_rgb);
- std::cout << "moyenne: " << lol << std::endl;
+ std::cout << "err: " << err << std::endl;
- display::save_and_show (out, "display", 50);
+ display::save_and_show (lena_rgb, "display", 50);
+ return (0);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Commit of Sandbox.
* mln/core/internal/point_set_base.hh: Header.
* mln/core/line2d.hh: No append in line2d.
* mln/core/p_graph.hh: Typos.
* mln/util/lazy_set.hh: Disambiguization.
* sandbox/pellegrin/cond_inheritance/Makefile: .
* sandbox/pellegrin/cond_inheritance/concept/point_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/multi_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh: .
* sandbox/pellegrin/cond_inheritance/internal/uni_set.hh: .
* sandbox/pellegrin/cond_inheritance/p_array.hh: .
* sandbox/pellegrin/cond_inheritance/p_set.hh: .
* sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc: .
* sandbox/pellegrin/first_test.cc: .
* sandbox/pellegrin/set/Makefile: .
* sandbox/pellegrin/set/core/concept/point_set.hh: New.
* sandbox/pellegrin/set/core/concept: New.
* sandbox/pellegrin/set/core/internal: New.
* sandbox/pellegrin/set/core/line2d.hh: New.
* sandbox/pellegrin/set/core/p_array.hh: New.
* sandbox/pellegrin/set/core/p_bgraph.hh: New.
* sandbox/pellegrin/set/core/p_graph.hh: New.
* sandbox/pellegrin/set/core/p_line_graph.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh: New.
* sandbox/pellegrin/set/core/p_queue.hh: New.
* sandbox/pellegrin/set/core/p_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_set.hh: New.
* sandbox/pellegrin/set/core/pset_if.hh: New.
* sandbox/pellegrin/set/core/runs_psite.hh: New.
* sandbox/pellegrin/set/core: New.
* sandbox/pellegrin/set/multi_set.hh: .
* sandbox/pellegrin/set/test_set.cc: .
* sandbox/pellegrin/set/trait/point_set.hh: New.
* sandbox/pellegrin/set/trait: New.
* sandbox/pellegrin/set/types_de_points.txt: New.
* sandbox/pellegrin/set/uni_set.hh: .
---
mln/core/internal/point_set_base.hh | 1
mln/core/line2d.hh | 3
mln/core/p_graph.hh | 4
mln/util/lazy_set.hh | 4
sandbox/pellegrin/cond_inheritance/Makefile | 24
sandbox/pellegrin/cond_inheritance/concept/point_set.hh | 2
sandbox/pellegrin/cond_inheritance/internal/multi_set.hh | 2
sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh | 2
sandbox/pellegrin/cond_inheritance/internal/uni_set.hh | 2
sandbox/pellegrin/cond_inheritance/p_array.hh | 5
sandbox/pellegrin/cond_inheritance/p_set.hh | 5
sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc | 4
sandbox/pellegrin/first_test.cc | 2
sandbox/pellegrin/set/Makefile | 26
sandbox/pellegrin/set/core/concept/point_set.hh | 252 ++++++
sandbox/pellegrin/set/core/line2d.hh | 208 +++++
sandbox/pellegrin/set/core/p_array.hh | 245 ++++++
sandbox/pellegrin/set/core/p_bgraph.hh | 232 ++++++
sandbox/pellegrin/set/core/p_graph.hh | 258 +++++++
sandbox/pellegrin/set/core/p_line_graph.hh | 176 ++++
sandbox/pellegrin/set/core/p_priority_queue.hh | 361 ++++++++++
sandbox/pellegrin/set/core/p_priority_queue_fast.hh | 361 ++++++++++
sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh | 347 +++++++++
sandbox/pellegrin/set/core/p_queue.hh | 309 ++++++++
sandbox/pellegrin/set/core/p_queue_fast.hh | 316 ++++++++
sandbox/pellegrin/set/core/p_set.hh | 191 +++++
sandbox/pellegrin/set/core/pset_if.hh | 226 ++++++
sandbox/pellegrin/set/core/runs_psite.hh | 192 +++++
sandbox/pellegrin/set/multi_set.hh | 8
sandbox/pellegrin/set/test_set.cc | 4
sandbox/pellegrin/set/trait/point_set.hh | 110 +++
sandbox/pellegrin/set/types_de_points.txt | 14
sandbox/pellegrin/set/uni_set.hh | 8
33 files changed, 3824 insertions(+), 80 deletions(-)
Index: trunk/milena/mln/core/internal/point_set_base.hh
===================================================================
--- trunk/milena/mln/core/internal/point_set_base.hh (revision 1787)
+++ trunk/milena/mln/core/internal/point_set_base.hh (revision 1788)
@@ -45,7 +45,6 @@
/*! \internal A base class for point set classes.
* \p P is a point site type.
- *
*/
template <typename P, typename E>
struct point_set_base_ : public Point_Set<E>
Index: trunk/milena/mln/core/p_graph.hh
===================================================================
--- trunk/milena/mln/core/p_graph.hh (revision 1787)
+++ trunk/milena/mln/core/p_graph.hh (revision 1788)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_GRAPH_P_HH
-# define MLN_CORE_GRAPH_P_HH
+#ifndef MLN_CORE_P_GRAPH_HH
+# define MLN_CORE_P_GRAPH_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
Index: trunk/milena/mln/core/line2d.hh
===================================================================
--- trunk/milena/mln/core/line2d.hh (revision 1787)
+++ trunk/milena/mln/core/line2d.hh (revision 1788)
@@ -71,9 +71,6 @@
/// Give the exact bounding box.
const box_<point2d>& bbox() const;
- /// Append a point \p p.
- line2d& append(const point2d& p);
-
/// Return the corresponding std::vector of points.
const std::vector<point2d>& vect() const;
Index: trunk/milena/mln/util/lazy_set.hh
===================================================================
--- trunk/milena/mln/util/lazy_set.hh (revision 1787)
+++ trunk/milena/mln/util/lazy_set.hh (revision 1788)
@@ -220,7 +220,7 @@
s_.insert(elt);
if (needs_update_ == false)
needs_update_ = true;
- return internal::force_exact< lazy_set_<E> >(*this);
+ return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
@@ -233,7 +233,7 @@
std::remove(s_.begin(), s_.end(), elt);
if (needs_update_ == false)
needs_update_ = true;
- return internal::force_exact< lazy_set_<E> >(*this);
+ return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
Index: trunk/milena/sandbox/pellegrin/first_test.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/first_test.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/first_test.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -26,8 +26,8 @@
// Public License.
-#ifndef __MULTI_SET_HH__
-# define __MULTI_SET_HH__
+#ifndef MULTI_SET_HH
+# define MULTI_SET_HH
/*! \file sandbox/pellegrin/set/multi_set.hh
*
@@ -173,4 +173,4 @@
} // end of namespace mln
-#endif // ! __MULTI_SET_HH__
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/trait/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1788)
@@ -0,0 +1,110 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_POINT_SET_HH
+# define MLN_TRAIT_POINT_SET_HH
+
+/*! \file mln/trait/point_set.hh
+ *
+ * \brief Properties of point_set classes.
+ */
+
+# include <string>
+# include <mln/trait/undef.hh>
+
+# define mln_trait_point_set_arity(P) typename mln::trait::point_set< P >::arity
+# define mln_trait_point_set_has_speed(P) typename mln::trait::point_set< P >::has_speed
+
+namespace mln
+{
+
+ struct line2d;
+ template <typename P> struct p_array;
+ template <typename P> struct p_bgraph;
+ template <typename P> struct p_graph;
+ template <typename P> struct p_line_graph;
+ template <typename P, typename T> struct p_priority_queue;
+ template <typename P, typename T> struct p_priority_queue_fast;
+ template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P> struct p_queue;
+ template <typename P> struct p_queue_fast;
+ template <typename P> struct p_run;
+ template <typename P> struct p_runs_;
+ template <typename P> struct p_set;
+ template <typename S, typename F> struct pset_if;
+
+ namespace trait
+ {
+
+ namespace point_set
+ {
+
+ struct arity
+ {
+ struct any {};
+ struct unique : any
+ { std::string name() const { return "arity::unique"; } };
+ struct multiple : any
+ { std::string name() const { return "arity::multiple"; } };
+ };
+
+ struct has_speed
+ {
+ struct any {};
+ struct slow : any
+ { std::string name() const { return "has_speed::slow"; } };
+ struct fast : any
+ { std::string name() const { return "has_speed::fast"; } };
+ };
+
+ } // end of namespace mln::trait::point_set
+
+ template <typename P>
+ struct undefined_point_set_
+ {
+ typedef undef arity; // unique or multiple
+ typedef undef has_speed; // slow or fast
+ };
+
+ template <typename P>
+ struct point_set_ : public undefined_point_set_<P>
+ {
+ };
+
+ template <typename P>
+ struct default_point_set_ : public undefined_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ };
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -26,8 +26,8 @@
// Public License.
-#ifndef __UNI_SET_HH__
-# define __UNI_SET_HH__
+#ifndef UNI_SET_HH
+# define UNI_SET_HH
/*! \file sandbox/pellegrin/set/uni_set.hh
*
@@ -173,4 +173,4 @@
} // end of namespace mln
-#endif // ! __UNI_SET_HH__
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/types_de_points.txt
===================================================================
--- trunk/milena/sandbox/pellegrin/set/types_de_points.txt (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/types_de_points.txt (revision 1788)
@@ -0,0 +1,14 @@
+mln::line2d: uni, fast
+mln::p_array< P >: multi, fast
+mln::p_bgraph< P >: uni, fast
+mln::p_graph< P >: uni, fast
+mln::p_line_graph< P >: uni, fast
+mln::p_priority_queue< P, T >: uni, slow
+mln::p_priority_queue_fast< P, T >: uni, fast
+mln::p_priority_queue_fast_with_array< P, T, S >: multi, fast
+mln::p_queue< P >: multi, slow
+mln::p_queue_fast< P >: multi, fast
+mln::p_run< P >: uni, fast
+mln::p_runs_< P >: multi, fast
+mln::p_set< P >: uni, fast
+mln::pset_if< S, F >: uni, slow
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1788)
@@ -0,0 +1,361 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
+
+/*! \file mln/core/p_priority_queue_fast.hh
+ *
+ * \brief Definition of a point set class based on p_queue_fast with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue_fast.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point fast queue class (based on std::map and p_queue_fast).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T>
+ class p_priority_queue_fast : public internal::point_set_base_< P, p_priority_queue_fast<P, T> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue_fast();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue_fast<P, T>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue_fast<P, T>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::map<const T, p_queue_fast<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>::p_priority_queue_fast()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ std::copy((*it).second.vect().begin(), (*it).second.vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::bb_update_() const
+ {
+ bb_.init();
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ for (unsigned i = 0; i < (*it).second.npoints (); ++i)
+ bb_.take((*it).second[i]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue_fast<P, T>::has(const P& p) const
+ {
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if ((*it).second.has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue_fast<P, T>::is_empty() const
+ {
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T>
+ inline
+ size_t
+ p_priority_queue_fast<P, T>::npoints() const
+ {
+ unsigned res = 0;
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ res += (*it).second.npoints();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ const box_<P>&
+ p_priority_queue_fast<P, T>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>&
+ p_priority_queue_fast<P, T>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>&
+ p_priority_queue_fast<P, T>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::pop()
+ {
+ typename std::map<T, p_queue_fast<P> >::reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ return (*it).second.pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::front() const
+ {
+ mln_precondition(! q_.empty());
+
+ typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ break;
+ return (*it).second.front ();
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::clear()
+ {
+ typename std::map<T, p_queue_fast<P> >::iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ (*it).second.clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ const std::vector<P>&
+ p_priority_queue_fast<P, T>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+
+ typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin ();
+ unsigned cpt = 0;
+
+ for (; it != q_.rend (); ++it)
+ {
+ if (!(*it).second.is_empty ())
+ for (cpt = 0; cpt < (*it).second.npoints (); ++cpt)
+ {
+ if (i == 0)
+ return (*it).second[cpt];
+ --i;
+ }
+ }
+ return (*it).second[cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1788)
@@ -0,0 +1,232 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_BGRAPH_P_HH
+# define MLN_CORE_BGRAPH_P_HH
+
+# include <utility>
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/internal/boost_graph.hh>
+# include <mln/core/bgraph_psite.hh>
+# include <mln/core/p_bgraph_piter.hh>
+
+
+
+/// \file mln/core/p_bgraph.hh
+/// \brief Definition of a point set based on a boost graph.
+
+namespace mln
+{
+
+ template<typename P> class p_bgraph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_bgraph
+ : public internal::point_set_base_< graph_psite<P>, p_bgraph<P> >
+ {
+ typedef util::internal::boost_graph<P, util::empty> graph;
+
+ /// Point_Site associated type.
+ typedef bgraph_psite<P> psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_bgraph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_bgraph_piter_<P> bkd_piter;
+
+ /// Graph vertex/edge identifier
+ typedef typename graph::vertex_descriptor node_id;
+ typedef typename graph::edge_descriptor edge_id;
+
+ /// Graph vertex/edge iterator
+ typedef typename graph::vertex_iterator node_iterator;
+ typedef typename graph::edge_iterator edge_iterator;
+ typedef std::pair<node_iterator, node_iterator> node_iterators;
+
+
+ /// Construct a graph psite set from a graph of points.
+ /// \p gr is a pointer on a boost graph.
+ /// This boost graph must have been allocated dynamically.
+ p_bgraph (graph* gr);
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ /// Return the graph point (FIXME site?) from an index
+ const P& point_from_id(const node_id& id) const;
+ P& point_from_id(const node_id& id);
+
+ /// Return the point contained in the first node adjacent
+ // to the edge id \a e.
+ const P& node1(const edge_id& e) const;
+ /// Return the point contained in the second node adjacent
+ /// to the edge id \a e.
+ const P& node2(const edge_id& e) const;
+
+ /// Return the graph associated to the p_bgraph domain:
+ const graph& to_graph() const;
+ graph& to_graph();
+
+
+ private:
+ graph* gr_;
+ box_<P> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_bgraph<P>::p_bgraph (typename p_bgraph<P>::graph* gr)
+ : gr_ (gr)
+ {
+ mln_precondition(gr != 0);
+ // FIXME: Warning: if the underlying graph is updated later, this
+ // won't be taken into account by this p_bgraph!
+ accu::bbox<P> a;
+
+ for (node_iterators iter = boost::vertices(*gr_);
+ iter.first != iter.second;
+ ++iter.first)
+ a.take((*gr_)[*iter.first]);
+ bb_ = a.to_result();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_bgraph<P>::npoints() const
+ {
+ return boost::num_vertices(*gr_);
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_bgraph<P>::nlines() const
+ {
+ return boost::num_edges(gr_->nedges());
+ }
+
+ template<typename P>
+ inline
+ const box_<P>&
+ p_bgraph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_bgraph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.pg() == this) &&
+ // Check that the node id of P belongs to the range of valid node ids.
+ (p.id() < this->npoints());
+ }
+
+
+ template <typename P>
+ const P&
+ p_bgraph<P>::point_from_id(const typename p_bgraph<P>::node_id& id) const
+ {
+ return this->gr_->operator[](id);
+ }
+
+ template <typename P>
+ P&
+ p_bgraph<P>::point_from_id(const typename p_bgraph<P>::node_id& id)
+ {
+ return this->gr_->operator[](id);
+ }
+
+
+ /// FIXME: Compare to p_bgraph, here we are loosing the vertex ordering
+ /// information. Is it bad??
+ template <typename P>
+ const P&
+ p_bgraph<P>::node1(const typename p_bgraph<P>::edge_id& e) const
+ {
+ return this->point_from_id(source(e, *this->gr_));
+ }
+
+ /// FIXME: same as node1...
+ template <typename P>
+ const P&
+ p_bgraph<P>::node2(const typename p_bgraph<P>::edge_id& e) const
+ {
+ return this->point_from_id(target(e, *this->gr_));
+ }
+
+ template <typename P>
+ const typename p_bgraph<P>::graph&
+ p_bgraph<P>::to_graph() const
+ {
+ return *this->gr_;
+ }
+
+ template <typename P>
+ typename p_bgraph<P>::graph&
+ p_bgraph<P>::to_graph()
+ {
+ return *this->gr_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_BGRAPH_P_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1788)
@@ -0,0 +1,309 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_QUEUE_HH
+# define MLN_CORE_P_QUEUE_HH
+
+/*! \file mln/core/p_queue.hh
+ *
+ * \brief Definition of a point set class based on std::deque.
+ */
+
+# include <vector>
+# include <deque>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::deque).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ * \todo Add a parameter flag to choose another policy for "push"
+ * (i.e., no-op if multiple or allow multiple insertions).
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P>
+ class p_queue : public internal::point_set_base_< P, p_queue<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_queue();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_queue<P>& push_force(const P& p);
+
+ /// Push a point \p p in the queue.
+ p_queue<P>& push(const P& p);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point and pop (remove) the front point \p p
+ /// from the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::deque<P> q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_queue<P>::p_queue()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(q_.size());
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::bb_update_() const
+ {
+ bb_.init();
+ for (unsigned i = 0; i < q_.size(); ++i)
+ bb_.take(q_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue<P>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < q_.size(); ++i)
+ if (q_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue<P>::is_empty() const
+ {
+ return (q_.empty());
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_queue<P>::npoints() const
+ {
+ return q_.size();
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_queue<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_queue<P>&
+ p_queue<P>::push_force(const P& p)
+ {
+ q_.push_back(p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ p_queue<P>&
+ p_queue<P>::push(const P& p)
+ {
+ mln_precondition(! has(p));
+ // FIXME: Our choice is "error if multiple insertions"
+ return this->push_force(p);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::pop()
+ {
+ q_.pop_front();
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::front() const
+ {
+ mln_precondition(! q_.empty());
+ return q_.front();
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::clear()
+ {
+ q_.clear();
+ vect_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_queue<P>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return q_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_QUEUE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1788)
@@ -0,0 +1,361 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_HH
+
+/*! \file mln/core/p_priority_queue.hh
+ *
+ * \brief Definition of a point set class based on p_queue with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point priority queue class (based on p_queue and std::map).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T>
+ class p_priority_queue : public internal::point_set_base_< P, p_priority_queue<P, T> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue<P, T>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue<P, T>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::map<const T, p_queue<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>::p_priority_queue()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ std::copy((*it).second.vect().begin(), (*it).second.vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::bb_update_() const
+ {
+ bb_.init();
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ for (unsigned i = 0; i < (*it).second.npoints (); ++i)
+ bb_.take((*it).second[i]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue<P, T>::has(const P& p) const
+ {
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if ((*it).second.has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue<P, T>::is_empty() const
+ {
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T>
+ inline
+ size_t
+ p_priority_queue<P, T>::npoints() const
+ {
+ unsigned res = 0;
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ res += (*it).second.npoints();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ const box_<P>&
+ p_priority_queue<P, T>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>&
+ p_priority_queue<P, T>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>&
+ p_priority_queue<P, T>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::pop()
+ {
+ typename std::map<T, p_queue<P> >::reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ return (*it).second.pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::front() const
+ {
+ mln_precondition(! q_.empty());
+
+ typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ break;
+ return (*it).second.front ();
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::clear()
+ {
+ typename std::map<T, p_queue<P> >::iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ (*it).second.clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ const std::vector<P>&
+ p_priority_queue<P, T>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+
+ typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin ();
+ unsigned cpt = 0;
+
+ for (; it != q_.rend (); ++it)
+ {
+ if (!(*it).second.is_empty ())
+ for (cpt = 0; cpt < (*it).second.npoints (); ++cpt)
+ {
+ if (i == 0)
+ return (*it).second[cpt];
+ --i;
+ }
+ }
+ return (*it).second[cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1788)
@@ -0,0 +1,176 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_LINE_GRAPH_P_HH
+# define MLN_CORE_LINE_GRAPH_P_HH
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/graph.hh>
+# include <mln/core/line_graph_psite.hh>
+# include <mln/core/p_line_graph_piter.hh>
+# include <mln/core/point_pair.hh>
+
+/* FIXME: This class shares a lot with p_graph. Factor as much as
+ possible. */
+
+
+/// \file mln/core/p_line_graph.hh
+/// \brief Definition of a point set based on line graph.
+
+namespace mln
+{
+
+ // FIXME: Dummy specialization, only to have this first version of
+ // our code compile.
+ template <typename P>
+ struct box_< point_pair<P> > : public Box< box_<P> >
+ {
+ // Nothing.
+ };
+
+
+ template<typename P> class p_line_graph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_line_graph
+ : public internal::point_set_base_< line_graph_psite<P>, p_line_graph<P> >
+ {
+ typedef util::graph<P> graph;
+
+ /// Construct a line graph psite set from a graph of points.
+ p_line_graph (graph& gr);
+
+ /// Point_Site associated type.
+ typedef line_graph_psite<P> psite;
+
+ /// Point associated type.
+ typedef point_pair<P> point;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_line_graph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_line_graph_piter_<P> bkd_piter;
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ // FIXME: Dummy.
+ const box_<point>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ // FIXME: Should be private.
+ graph gr_;
+ // FIXME: (Roland) Is it really useful/needed?
+ /* 2007-12-19: It seems so, since graph_image must implement a
+ method named bbox(). Now the question is: should each image
+ type have a bounding box? In particular, an image whose sites
+ are actually /pairs of points/! */
+ // FIXME: Dummy.
+ box_<point> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_line_graph<P>::p_line_graph (util::graph<P>& gr)
+ : gr_ (gr)
+ {
+ // FIXME: Dummy initialization of bb_.
+// // FIXME: Warning: if the underlying graph is updated later, this
+// // won't be taken into account by this p_line_graph!
+// accu::bbox<point> a;
+// for (util::edge_id e = 0; e < nlines(); ++e)
+// a.take(point(gr_.node_data(gr_.edge(e).n1()),
+// gr_.node_data(gr_.edge(e).n2())));
+// bb_ = a.to_result();
+ }
+
+ // FIXME: Rename to npsites? In fact, this depends on the
+ // interface expected from models of Point_Sets.
+ template<typename P>
+ inline
+ std::size_t
+ p_line_graph<P>::npoints() const
+ {
+ return this->gr_.nnodes();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_line_graph<P>::nlines() const
+ {
+ return this->gr_.nedges();
+ }
+
+ template<typename P>
+ inline
+ const box_< point_pair<P> >&
+ p_line_graph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_line_graph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.plg() == this) &&
+ // Check that the edge id of P belongs to the range of valid edge ids.
+ (p.id() < gr_.nedges());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_P_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1788)
@@ -0,0 +1,226 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_PSET_IF_HH
+# define MLN_CORE_PSET_IF_HH
+
+/*! \file mln/core/pset_if.hh
+ *
+ * \brief Definition of the restriction of a point set w.r.t. a predicate.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename S, typename F> struct pset_if;
+ template <typename S, typename F> struct pset_if_fwd_piter_;
+ template <typename S, typename F> struct pset_if_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< pset_if<> > : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Restrict a point set \p pset to points that verify \p f.
+ *
+ * \param[in] pset A point set.
+ * \param[in] f A function from point to Boolean.
+ * \return A subset of points.
+ */
+ template <typename S, typename F>
+ pset_if<S, F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f);
+
+
+
+ /*! \brief Generic subset class.
+ *
+ * Parameter \c S is a point set type; parameter F is a function
+ * from point to Boolean.
+ */
+ template <typename S, typename F>
+ class pset_if : public internal::point_set_base_< mln_psite(S), pset_if<S,F> >
+ {
+ typedef pset_if<S,F> self_;
+ typedef internal::point_set_base_<mln_psite(S), self_> super_;
+ public:
+
+ typedef mln_psite(super_) psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef pset_if_fwd_piter_<S,F> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef mln::internal::fixme bkd_piter;
+
+
+ /// Constructor with a point set \p pset and a predicate \p f.
+ pset_if(const S& pset, const F& f);
+
+ /// Constructor without argument.
+ pset_if();
+
+
+ /// Test if \p p belongs to the subset.
+ bool has(const psite& p) const;
+
+ /// Give a bounding box of the subset.
+ const box_<mln_point(S)>& bbox() const;
+
+ /// Give the number of points of the subset.
+ std::size_t npoints() const;
+
+ /// Give the primary overset.
+ const S& overset() const;
+
+ /// Test predicate on point site \p p.
+ bool pred(const psite& p) const;
+
+ /// Give the predicate function.
+ const F& predicate() const;
+
+ protected:
+
+ S pset_;
+ F f_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename S, typename F>
+ inline
+ pset_if<S, F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f)
+ {
+ pset_if<S, F> tmp(exact(pset), exact(f));
+ return tmp;
+ }
+
+
+ // pset_if<S,F>
+
+ template <typename S, typename F>
+ inline
+ bool
+ pset_if<S,F>::has(const psite& p) const
+ {
+ return pset_.has(p) && f_(p);
+ }
+
+ template <typename S, typename F>
+ inline
+ const box_<mln_point(S)>&
+ pset_if<S,F>::bbox() const
+ {
+ return pset_.bbox();
+ }
+
+ template <typename S, typename F>
+ inline
+ const S&
+ pset_if<S,F>::overset() const
+ {
+ return pset_;
+ }
+
+ template <typename S, typename F>
+ inline
+ bool
+ pset_if<S,F>::pred(const psite& p) const
+ {
+ return f_(p);
+ }
+
+ template <typename S, typename F>
+ inline
+ pset_if<S,F>::pset_if(const S& pset, const F& f)
+ : pset_(pset),
+ f_(f)
+ {
+ }
+
+ template <typename S, typename F>
+ inline
+ pset_if<S,F>::pset_if()
+ {
+ }
+
+ template <typename S, typename F>
+ inline
+ const F&
+ pset_if<S,F>::predicate() const
+ {
+ return f_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/pset_if_piter.hh>
+
+
+
+namespace mln
+{
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename F>
+ std::size_t
+ pset_if<S,F>::npoints() const
+ {
+ std::size_t n = 0;
+ fwd_piter p(*this);
+ for_all(p)
+ ++n;
+ return n;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PSET_IF_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1788)
@@ -0,0 +1,191 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_SET_HH
+# define MLN_CORE_P_SET_HH
+
+/*! \file mln/core/p_set.hh
+ *
+ * \brief Definition of a point set class based on std::set.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_array.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class based on std::set.
+ *
+ * This is a mathematical set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo Test if \p P being a Point_Site is ok.
+ */
+ template <typename P>
+ class p_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ p_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_set<P>::p_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ p_set<P>&
+ p_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ p_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ p_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1788)
@@ -0,0 +1,347 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
+
+/*! \file mln/core/p_priority_queue_fast_with_array.hh
+ *
+ * \brief Definition of a point set class based on p_queue with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue_fast.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::vector and p_queue_fast).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T, unsigned S>
+ class p_priority_queue_fast_with_array : public internal::point_set_base_< P, p_priority_queue_fast_with_array<P, T, S> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue_fast_with_array();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ unsigned npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue_fast_with_array<P, T, S>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue_fast_with_array<P, T, S>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::vector<p_queue_fast<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>::p_priority_queue_fast_with_array()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ q_.reserve(S);
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(q_));
+ for (unsigned i = 0; i < S; ++i)
+ q_[i].clear ();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ for (unsigned i = 0; i < S; ++i)
+ std::copy(q_[i].vect().begin(), q_[i].vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::bb_update_() const
+ {
+ bb_.init();
+
+ for (unsigned i = 0; i < S; ++i)
+ for (unsigned j = 0; j < q_[i].npoints (); ++j)
+ bb_.take(q_[i][j]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T, unsigned S>
+ inline
+ bool
+ p_priority_queue_fast_with_array<P, T, S>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < S; ++i)
+ if (q_[i].has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ bool
+ p_priority_queue_fast_with_array<P, T, S>::is_empty() const
+ {
+ for (unsigned i = 0; i < S; ++i)
+ if (!q_[i].is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ unsigned
+ p_priority_queue_fast_with_array<P, T, S>::npoints() const
+ {
+ unsigned res = 0;
+
+ for (unsigned i = 0; i < S; ++i)
+ if (!q_[i].is_empty ())
+ res += q_[i].npoints();
+
+ return res;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const box_<P>&
+ p_priority_queue_fast_with_array<P, T, S>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>&
+ p_priority_queue_fast_with_array<P, T, S>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ mln_assertion(!q_[prio].is_empty ());
+ return *this;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>&
+ p_priority_queue_fast_with_array<P, T, S>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::pop()
+ {
+ for (unsigned i = S - 1; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ return q_[i].pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::front() const
+ {
+ mln_precondition(! is_empty());
+
+ for (unsigned i = S - 1; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ return q_[i].front ();
+ return q_[0].front ();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::clear()
+ {
+ for (unsigned i = 0; i < S; ++i)
+ q_[i].clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const std::vector<P>&
+ p_priority_queue_fast_with_array<P, T, S>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::operator[](unsigned n) const
+ {
+ mln_precondition(n < npoints());
+ unsigned i = S - 1;
+ unsigned cpt = 0;
+
+ for (; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ for (cpt = 0; cpt < q_[i].npoints (); ++cpt, --n)
+ if (n == 0)
+ return q_[i][cpt];
+ mln_assertion (false);
+ return q_[i][cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
Index: trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (revision 1788)
@@ -0,0 +1,192 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_RUNS_PSITE_HH
+# define MLN_CORE_RUNS_PSITE_HH
+
+/*! \file mln/core/runs_psite.hh
+ *
+ * \brief Definition of class mln::runs_psite_ for internal use only
+ */
+
+# include <mln/core/concept/point_site.hh>
+
+
+namespace mln
+{
+ // Fwd decl.
+ template <typename P> class p_runs_;
+
+ /*! \brief Psite class used in run_image_.
+ *
+ * Parameter \c P is the type of the image point.
+ */
+ template <typename P>
+ class runs_psite : public Point_Site< runs_psite<P> >
+ {
+ public:
+
+ typedef mln_mesh(P) mesh;
+ enum { dim = P::dim };
+ typedef P point;
+ typedef mln_dpoint(P) dpoint;
+ typedef mln_coord(P) coord;
+
+ runs_psite(const p_runs_<P>& pr, unsigned in_run, unsigned of_run);
+
+ operator P () const;
+
+ /// Return the point at the start of the current run.
+ P& range_start_();
+
+ /// Return the point at the start of the current run.
+ const P& range_start_() const;
+
+ /// Return the position of this psite in the point set.
+ unsigned p_of_run() const;
+
+ /// Return the position of this psite in the point set.
+ unsigned& p_of_run();
+
+ /// Return the position of this psite in the current range.
+ unsigned p_in_run() const;
+
+ /// Return the position of this psite in the current range.
+ unsigned& p_in_run();
+
+ /// Reference to the corresponding point.
+ const P& to_point() const;
+
+ /// Give the i-th coordinate of the corresponding point.
+ mln_coord(P) operator[](unsigned i) const;
+
+ protected:
+
+ /// Start of the psite range.
+ const p_runs_<P>& pr_;
+
+ /// Position in the psite range.
+ unsigned p_in_run_;
+
+ /// Position of the psite in the point set.
+ unsigned p_of_run_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ runs_psite<P>::runs_psite(const p_runs_<P>& pr, unsigned in_run, unsigned of_run)
+ : pr_(pr),
+ p_in_run_(in_run),
+ p_of_run_(of_run)
+ {
+ mln_precondition(of_run < pr.nruns());
+ mln_precondition(in_run < pr[of_run].length());
+ }
+
+ template <typename P>
+ inline
+ runs_psite<P>::operator P() const
+ {
+ return pr_[p_of_run_][p_in_run_];
+ }
+
+ template <typename P>
+ inline
+ const P&
+ runs_psite<P>::range_start_() const
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ P&
+ runs_psite<P>::range_start_()
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ runs_psite<P>::p_of_run() const
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ runs_psite<P>::p_of_run()
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ runs_psite<P>::p_in_run() const
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ runs_psite<P>::p_in_run()
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ runs_psite<P>::to_point() const
+ {
+ static P p = pr_[p_of_run_][p_in_run_];
+ return p;
+ }
+
+ template <typename P>
+ inline
+ mln_coord(P)
+ runs_psite<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < dim);
+ return pr_[p_of_run_][p_in_run_][i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+# include <mln/core/p_runs.hh>
+
+#endif // ! MLN_CORE_INTERNAL_RUNS_PSITE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1788)
@@ -0,0 +1,208 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_LINE2D_HH
+# define MLN_CORE_LINE2D_HH
+
+/*! \file mln/core/line2d.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/core/box2d.hh>
+# include <mln/math/all.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief 2D line point set class.
+ */
+ class line2d : public internal::point_set_base_< point2d, line2d >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<point2d> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<point2d> bkd_piter;
+
+
+ /// Constructor from point \p beg to point \p end.
+ line2d(const point2d& beg, const point2d& end);
+
+
+ /// Test is \p p belongs to this point set.
+ bool has(const point2d& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<point2d>& bbox() const;
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<point2d>& vect() const;
+
+ /// Return the \p i-th point.
+ const point2d& operator[](unsigned i) const;
+
+ protected:
+
+ point2d beg_, end_;
+ std::vector<point2d> vect_;
+ box2d bb_;
+
+ void compute_();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ line2d::line2d(const point2d& beg, const point2d& end)
+ : beg_(beg),
+ end_(end)
+ {
+ compute_();
+ }
+
+ inline
+ void
+ line2d::compute_()
+ {
+ // vect_
+ dpoint2d dp = end_ - beg_;
+ int
+ srow = math::sign(dp.row()), drow = math::abs(dp.row()), ddrow = 2 * drow,
+ scol = math::sign(dp.col()), dcol = math::abs(dp.col()), ddcol = 2 * dcol,
+ row = beg_.row(),
+ col = beg_.col();
+ if ( dcol > drow )
+ {
+ int e = ddrow - dcol;
+ for (int i = 0; i < dcol; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ row += srow;
+ e -= ddcol;
+ }
+ col += scol;
+ e += ddrow;
+ }
+ }
+ else
+ {
+ int e = ddcol - drow;
+ for (int i = 0; i < drow; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ col += scol;
+ e -= ddrow;
+ }
+ row += srow;
+ e += ddcol;
+ }
+ }
+ vect_.push_back(make::point2d(row, col));
+ // bb_
+ bb_.pmin() = make::point2d(math::min(beg_.row(), end_.row()),
+ math::min(beg_.col(), end_.col()));
+ bb_.pmax() = make::point2d(math::max(beg_.row(), end_.row()),
+ math::max(beg_.col(), end_.col()));
+ }
+
+ inline
+ bool
+ line2d::has(const point2d& p) const
+ {
+ if (! bb_.has(p))
+ return false;
+ // FIXME: Optimize!
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] == p)
+ return true;
+ return false;
+ }
+
+ inline
+ std::size_t
+ line2d::npoints() const
+ {
+ return vect_.size();
+ }
+
+ inline
+ const box2d&
+ line2d::bbox() const
+ {
+ return bb_;
+ }
+
+ inline
+ const std::vector<point2d>&
+ line2d::vect() const
+ {
+ return vect_;
+ }
+
+ inline
+ const point2d&
+ line2d::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_LINE2D_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1788)
@@ -0,0 +1,245 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_ARRAY_HH
+# define MLN_CORE_P_ARRAY_HH
+
+/*! \file mln/core/p_array.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_array<P> > : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class based on std::vector.
+ *
+ * This is a multi-set of points.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints(). FIXME: Explain!
+ *
+ * \todo Make it work with P being a Point_Site.
+ */
+ template <typename P>
+ class p_array : public internal::point_set_base_< P, p_array<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_array();
+
+ /// Constructor from a vector \p vect.
+ p_array(const std::vector<P>& vect);
+
+ /// Reserve \p n cells.
+ void reserve(std::size_t n);
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Append a point \p p.
+ p_array<P>& append(const P& p);
+
+ /// Clear this set.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Hook to data.
+ std::vector<P>& hook_();
+
+ protected:
+
+ std::vector<P> vect_;
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+
+ void update_bb_() const;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_array<P>::p_array()
+ {
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ p_array<P>::p_array(const std::vector<P>& vect)
+ : vect_(vect)
+ {
+ bb_needs_update_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::reserve(std::size_t n)
+ {
+ vect_.reserve(n);
+ }
+
+ template <typename P>
+ inline
+ std::vector<P>&
+ p_array<P>::hook_()
+ {
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::update_bb_() const
+ {
+ bb_.init();
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ bb_.take(vect_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_array<P>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_array<P>::npoints() const
+ {
+ return vect_.size();
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_array<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ update_bb_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_array<P>&
+ p_array<P>::append(const P& p)
+ {
+ vect_.push_back(p);
+ if (! bb_needs_update_)
+ bb_needs_update_ = true;
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::clear()
+ {
+ vect_.clear();
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_array<P>::vect() const
+ {
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_array<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+# include <mln/core/p_array_piter.hh>
+
+
+#endif // ! MLN_CORE_P_ARRAY_HH
Index: trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1788)
@@ -0,0 +1,252 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_POINT_SET_HH
+# define MLN_CORE_CONCEPT_POINT_SET_HH
+
+/*! \file mln/core/concept/point_set.hh
+ *
+ * \brief Definition of the concept of mln::Point_Set.
+ *
+ * \todo Think about adding an 'insert' method (not so easy because of
+ * pset_if...)
+ */
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/concept/point_iterator.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Point_Set;
+
+
+ /// Point_Set category flag type.
+ template <>
+ struct Point_Set<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation classes of point sets.
+ *
+ * \see mln::doc::Point_Set for a complete documentation of this
+ * class contents.
+ */
+ template <typename E>
+ struct Point_Set : public Object<E>
+ {
+ typedef Point_Set<void> category;
+
+ /*
+ typedef mesh;
+
+ typedef point;
+ typedef psite;
+
+ typedef fwd_piter;
+ typedef bkd_piter;
+
+ bool has(const psite& p) const;
+ const box_<point>& bbox() const;
+ std::size_t npoints() const;
+ */
+
+ protected:
+ Point_Set();
+ };
+
+
+ /*! \brief Equality test between point sets \p lhs and \p rhs.
+ *
+ * \param[in] lhs A point set.
+ * \param[in] rhs Another point set.
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Inclusion test between point sets \p lhs and \p rhs.
+ *
+ * \param[in] lhs A point set (included?).
+ * \param[in] rhs Another point set (includer?).
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Strict inclusion test between point sets \p lhs and \p
+ * rhs.
+ *
+ * \param[in] lhs A point set (strictly included?).
+ * \param[in] rhs Another point set (includer?).
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Print a point set \p pset into the output stream \p
+ * ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] pset A point set.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename S>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // fwd decl
+ template <typename P> struct box_;
+
+ template <typename E>
+ inline
+ Point_Set<E>::Point_Set()
+ {
+ typedef mln_mesh(E) mesh;
+
+ typedef mln_point(E) point;
+ typedef mln_psite(E) psite;
+
+ typedef mln_fwd_piter(E) fwd_piter;
+ typedef mln_bkd_piter(E) bkd_piter;
+
+ typedef mln_trait_point_set_arity(P) arity;
+ typedef mln_trait_point_set_has_speed(P) has_speed;
+
+ bool (E::*m1)(const psite& p) const = & E::has;
+ m1 = 0;
+ const box_<point>& (E::*m2)() const = & E::bbox;
+ m2 = 0;
+ std::size_t (E::*m3)() const = & E::npoints;
+ m3 = 0;
+ }
+
+
+ // operators
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator==(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+
+ // easy test:
+ if (lhs.npoints() != rhs.npoints())
+ return false;
+
+ // exhaustive test:
+ mln_fwd_piter(Sl) pl(lhs);
+ mln_fwd_piter(Sr) pr(rhs);
+ for (pl.start(), pr.start();
+ pl.is_valid() && pr.is_valid();
+ pl.next(), pr.next())
+ if (pl != pr)
+ return false; // difference found
+
+ // both sets are equal only if both browsings are completed
+ // at the same time:
+ return ! pl.is_valid() && ! pr.is_valid();
+ }
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator<=(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+
+ // easy test:
+ if (lhs.npoints() > rhs.npoints())
+ return false;
+
+ // exhaustive test:
+ mln_piter(Sl) pl(lhs);
+ for_all(pl)
+ if (! rhs.has(pl))
+ return false;
+
+ return true;
+ }
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator<(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+ return lhs <= rhs && lhs.npoints() != rhs.npoints();
+ }
+
+
+ template <typename S>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset_)
+ {
+ const S& pset = exact(pset_);
+ ostr << '{';
+ mln_piter(S) p(pset);
+ for_all(p)
+ ostr << p;
+ return ostr << '}';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+# include <mln/core/ops.hh>
+
+
+#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1788)
@@ -0,0 +1,258 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_GRAPH_HH
+# define MLN_CORE_P_GRAPH_HH
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/graph.hh>
+# include <mln/core/graph_psite.hh>
+# include <mln/core/p_graph_piter.hh>
+
+/// \file mln/core/p_graph.hh
+/// \brief Definition of a point set based on graph.
+
+namespace mln
+{
+
+ template<typename P> class p_graph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_graph
+ : public internal::point_set_base_< graph_psite<P>, p_graph<P> >
+ {
+ typedef util::graph<P> graph;
+
+ /// Construct a graph psite set from a graph of points.
+ p_graph (graph& gr);
+
+ /// Point_Site associated type.
+ typedef graph_psite<P> psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_graph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_graph_piter_<P> bkd_piter;
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ /// Return the graph point (FIXME site?) from an index
+ const P& point_from_id(const util::node_id& id) const;
+ P& point_from_id(const util::node_id& id);
+
+
+ /// Return the point contained in the first node adjacent
+ // to the edge id \a e.
+ const P& node1(const util::edge_id& e) const;
+ /// Return the point contained in the second node adjacent
+ /// to the edge id \a e.
+ const P& node2(const util::edge_id& e) const;
+
+ /// Return true if the psites lhs and rhs are adjacent, or equal.
+ bool adjacent_or_equal(const psite& lhs, const psite& rhs) const;
+
+ /// Return true if the nodes lhs and rhs are adjacent, or equal
+ bool adjacent_or_equal(const util::node_id& lhs,
+ const util::node_id& rhs) const;
+
+ /// Return the graph associated to the p_graph domain:
+ const graph& to_graph() const;
+ graph& to_graph();
+
+
+ private:
+ graph gr_;
+ // FIXME: (Roland) Is it really useful/needed?
+ /* 2007-12-19: It seems so, since graph_image must implement a method
+ named bbox(). Now the question is: should each image type have a
+ bounding box? */
+ box_<P> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_graph<P>::p_graph (util::graph<P>& gr)
+ : gr_ (gr)
+ {
+ // FIXME: Warning: if the underlying graph is updated later, this
+ // won't be taken into account by this p_graph!
+ accu::bbox<P> a;
+ for (unsigned i = 0; i < npoints(); ++i)
+ a.take(gr_.node_data(i));
+ bb_ = a.to_result();
+ }
+
+ // FIXME: Rename to npsites? In fact, this depends on the
+ // interface expected from models of Point_Sets.
+ template<typename P>
+ inline
+ std::size_t
+ p_graph<P>::npoints() const
+ {
+ return this->gr_.nnodes();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_graph<P>::nlines() const
+ {
+ return this->gr_.nedges();
+ }
+
+ template<typename P>
+ inline
+ const box_<P>&
+ p_graph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_graph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.pg() == this) &&
+ // Check that the node id of P belongs to the range of valid node ids.
+ (p.id() < gr_.nnodes());
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::point_from_id(const util::node_id& id) const
+ {
+ return this->gr_.node_data(id);
+ }
+
+ template <typename P>
+ P&
+ p_graph<P>::point_from_id(const util::node_id& id)
+ {
+ return this->gr_.node_data(id);
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::node1(const util::edge_id& e) const
+ {
+ util::node_id n1 = this->gr_.edge(e).n1();
+ return this->point_from_id(n1);
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::node2(const util::edge_id& e) const
+ {
+ util::node_id n2 = this->gr_.edge(e).n2();
+ return this->point_from_id(n2);
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_graph<P>::adjacent_or_equal(const psite& lhs, const psite& rhs) const
+ {
+ assert (&lhs.pg() == this && rhs.pg() == this);
+ return adjacent_or_equal(lhs.id(), rhs.id());
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_graph<P>::adjacent_or_equal(const util::node_id& lhs,
+ const util::node_id& rhs) const
+ {
+ // FIXME: Likewise, this is inefficient.
+
+ assert (lhs < this->npoints());
+ assert (rhs < this->npoints());
+
+ if (rhs == lhs)
+ return true;
+
+ // Check whether the iterator is among the neighbors of P_REF_.
+ typedef std::vector<util::node_id> adjacency_type;
+ const adjacency_type& lhs_neighbs = gr_.nodes()[lhs]->edges;
+
+ adjacency_type::const_iterator j =
+ std::find (lhs_neighbs.begin(), lhs_neighbs.end(), rhs);
+ if (j != lhs_neighbs.end())
+ return true;
+
+ return false;
+ }
+
+ template <typename P>
+ const typename p_graph<P>::graph&
+ p_graph<P>::to_graph() const
+ {
+ return this->gr_;
+ }
+
+ template <typename P>
+ typename p_graph<P>::graph&
+ p_graph<P>::to_graph()
+ {
+ return this->gr_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_P_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1788)
@@ -0,0 +1,316 @@
+// Copyright (C) 2007 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_QUEUE_FAST_HH
+# define MLN_CORE_P_QUEUE_FAST_HH
+
+/*! \file mln/core/p_queue_fast.hh
+ *
+ * \brief Definition of a point set class faster but needs more memory
+ * space.
+ */
+
+# include <vector>
+# include <deque>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::deque).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P>
+ class p_queue_fast : public internal::point_set_base_< P, p_queue_fast<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_queue_fast();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_queue_fast<P>& push_force(const P& p);
+
+ /// Push a point \p p in the queue.
+ p_queue_fast<P>& push(const P& p);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::vector<P> q_;
+ std::size_t begin_;
+ std::size_t end_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_queue_fast<P>::p_queue_fast()
+ {
+ // vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ begin_ = 0;
+ end_ = 0;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(q_.size());
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::bb_update_() const
+ {
+ bb_.init();
+ for (std::size_t i = this->begin_; i < this->end_; ++i)
+ bb_.take(q_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue_fast<P>::has(const P& p) const
+ {
+ for (unsigned i = this->begin_; i < this->end_; ++i)
+ if (q_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue_fast<P>::is_empty() const
+ {
+ return (this->begin_ == this->end_);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_queue_fast<P>::npoints() const
+ {
+ mln_precondition(this->end_ >= this->begin_);
+ return (this->end_ - this->begin_);
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_queue_fast<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_queue_fast<P>&
+ p_queue_fast<P>::push_force(const P& p)
+ {
+ q_.push_back(p);
+ ++this->end_;
+ if (! vect_needs_update_)
+ {
+ // vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ p_queue_fast<P>&
+ p_queue_fast<P>::push(const P& p)
+ {
+ mln_precondition(! this->has(p));
+ // FIXME: Our choice is "error if multiple insertions"
+ return this->push_force(p);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::pop()
+ {
+ ++this->begin_;
+// q_.pop_front();
+// if (! vect_needs_update_)
+// {
+// vect_needs_update_ = true;
+// bb_needs_update_ = true;
+// }
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::front() const
+ {
+ mln_precondition(! this->is_empty());
+ return q_[begin_];
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::clear()
+ {
+ this->end_ = begin_;
+// q_.clear();
+// vect_.clear();
+// vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_queue_fast<P>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return q_[begin_ + i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_QUEUE_FAST_HH
Index: trunk/milena/sandbox/pellegrin/set/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/Makefile (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/Makefile (revision 1788)
@@ -1,26 +1,2 @@
-All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
- -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
- -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
- -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
- -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
- -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
- -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
- -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
- -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
- -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
- -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
- -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
- -Wmissing-braces -Wmissing-field-initializers \
- -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
- -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
- -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
- -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
- -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
- -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
- -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
- -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
- -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
- -Wwrite-strings \
-
all:
- g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test
+ g++-4.2 -ansi -pedantic -I../../.. test_has.cc -o test_has
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -27,7 +27,7 @@
/*! \file sandbox/pellegrin/set/test_set.cc
*
- * \brief test my work on set.
+ * \brief Test my work on set.
*/
#include <mln/core/image2d.hh>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -27,7 +27,7 @@
/*! \file sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
*
- * \brief test my work on conditional inheritance.
+ * \brief Test my work on conditional inheritance.
*/
#include <iostream>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -43,9 +43,8 @@
/*! \brief Point set class.
*
* This is a mathematical uni-set of points. The
- * parameter \p P shall be a Point type.
+ * parameter \p E shall be a Point type.
*
- * \todo All.
*/
template <typename E>
class p_set: public internal::point_set_base<p_set<E>, E>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -43,9 +43,8 @@
/*! \brief Point set class.
*
* This is a mathematical multi-set of points. The
- * parameter \p P shall be a Point type.
+ * parameter \p E shall be a Point type.
*
- * \todo All.
*/
template <typename E>
class p_array : public internal::point_set_base<p_array<E>, E>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 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
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 1788)
@@ -1,26 +1,2 @@
-All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
- -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
- -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
- -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
- -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
- -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
- -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
- -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
- -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
- -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
- -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
- -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
- -Wmissing-braces -Wmissing-field-initializers \
- -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
- -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
- -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
- -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
- -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
- -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
- -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
- -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
- -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
- -Wwrite-strings \
-
all:
g++-4.2 -ansi -pedantic -I../../.. -I. test_cond_inherit.cc -o test
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix auto name substitution for vec and metal::math.
* tests/metal_pow.cc,
* tests/all.cc,
* mln/trait/value_.hh,
* mln/metal/math/pow.hh,
* mln/metal/math/max.hh,
* mln/metal/math/all.hh,
* mln/metal/math/sqrt.hh,
* mln/metal/all.hh,
* mln/value/graylevel.hh,
* mln/value/graylevel_f.hh,
* mln/value/float01_.hh,
* mln/value/int_s.hh,
* mln/value/internal/gray_.hh,
* mln/value/internal/gray_f.hh,
* mln/value/int_u.hh,
* mln/value/int_u_sat.hh,
* mln/value/label.hh: metal/math had been wrongly substitute by algebra/math.
* mln/trait/ch_value.hh,
* mln/core/h_vec.hh: wrong namespace for vec.
mln/core/h_vec.hh | 4 ++--
mln/metal/all.hh | 2 +-
mln/metal/math/all.hh | 10 +++++-----
mln/metal/math/max.hh | 8 ++++----
mln/metal/math/pow.hh | 8 ++++----
mln/metal/math/sqrt.hh | 6 +++---
mln/trait/ch_value.hh | 2 +-
mln/trait/value_.hh | 4 ++--
mln/value/float01_.hh | 2 +-
mln/value/graylevel.hh | 10 +++++-----
mln/value/graylevel_f.hh | 2 +-
mln/value/int_s.hh | 6 +++---
mln/value/int_u.hh | 2 +-
mln/value/int_u_sat.hh | 4 ++--
mln/value/internal/gray_.hh | 6 +++---
mln/value/internal/gray_f.hh | 6 +++---
mln/value/label.hh | 2 +-
tests/all.cc | 2 +-
tests/metal_pow.cc | 8 ++++----
19 files changed, 47 insertions(+), 47 deletions(-)
Index: tests/metal_pow.cc
--- tests/metal_pow.cc (revision 1786)
+++ tests/metal_pow.cc (working copy)
@@ -27,12 +27,12 @@
/*! \file tests/metal_pow.cc
*
- * \brief Test on mln::algebra::math.
+ * \brief Test on mln::metal::math.
*/
#include <iostream>
#include <mln/core/contract.hh>
-#include <mln/algebra/math/pow.hh>
+#include <mln/metal/math/pow.hh>
int main()
@@ -40,8 +40,8 @@
using namespace mln;
using namespace mln::metal;
- int res = algebra::math::pow_int<2,3>::value;
+ int res = metal::math::pow_int<2,3>::value;
mln_assertion(res == 8);
- std::cout << algebra::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
+ std::cout << metal::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
}
Index: tests/all.cc
--- tests/all.cc (revision 1786)
+++ tests/all.cc (working copy)
@@ -48,7 +48,7 @@
#include <mln/math/all.hh>
//#include <mln/set/all.hh>
#include <mln/draw/all.hh>
-#include <mln/algebra/math/all.hh>
+#include <mln/metal/math/all.hh>
#include <mln/metal/all.hh>
#include <mln/morpho/all.hh>
#include <mln/io/pfm/all.hh>
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1786)
+++ mln/trait/ch_value.hh (working copy)
@@ -45,7 +45,7 @@
{
// Fwd decl.
- namespace metal { template <unsigned n, typename T> class vec; }
+ namespace algebra { template <unsigned n, typename T> class vec; }
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1786)
+++ mln/trait/value_.hh (working copy)
@@ -37,11 +37,11 @@
# include <string>
# include <mln/metal/int.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/if.hh>
# include <mln/trait/value/all.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
Index: mln/core/h_vec.hh
--- mln/core/h_vec.hh (revision 1786)
+++ mln/core/h_vec.hh (working copy)
@@ -134,7 +134,7 @@
return *this;
}
- namespace metal
+ namespace algebra
{
// Immersion of a vector in its homogeneous space.
@@ -149,7 +149,7 @@
return tmp;
}
- } // end of namespace mln::metal
+ } // end of namespace mln::algebra
template <unsigned d, typename C>
Index: mln/metal/math/pow.hh
--- mln/metal/math/pow.hh (revision 1786)
+++ mln/metal/math/pow.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_POW_HH
# define MLN_METAL_MATH_POW_HH
-/*! \file mln/algebra/math/pow.hh
+/*! \file mln/metal/math/pow.hh
*
* \brief Definition of the 'power' static function.
*/
@@ -37,8 +37,8 @@
# include <mln/metal/int.hh>
-# define mlc_pow(X, N) typename mln::algebra::math::pow< X, N >::ret
-# define mlc_pow_int(x, n) mln::algebra::math::pow_int< x, n >::value
+# define mlc_pow(X, N) typename mln::metal::math::pow< X, N >::ret
+# define mlc_pow_int(x, n) mln::metal::math::pow_int< x, n >::value
@@ -105,7 +105,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/math/max.hh
--- mln/metal/math/max.hh (revision 1786)
+++ mln/metal/math/max.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_MAX_HH
# define MLN_METAL_MATH_MAX_HH
-/*! \file mln/algebra/math/max.hh
+/*! \file mln/metal/math/max.hh
*
* \brief Definition of the 'max' static function.
*/
@@ -36,8 +36,8 @@
# include <mln/metal/bool.hh>
# include <mln/metal/int.hh>
-# define mlc_max(X, Y) typename mln::algebra::math::max< X, Y >::ret
-# define mlc_max_int(x, y) mln::algebra::math::max_int< x, y >::value
+# define mlc_max(X, Y) typename mln::metal::math::max< X, Y >::ret
+# define mlc_max_int(x, y) mln::metal::math::max_int< x, y >::value
namespace mln
{
@@ -69,7 +69,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/math/all.hh
--- mln/metal/math/all.hh (revision 1786)
+++ mln/metal/math/all.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_ALL_HH
# define MLN_METAL_MATH_ALL_HH
-/*! \file mln/algebra/math/all.hh
+/*! \file mln/metal/math/all.hh
*
* \brief Include all static mathematical functions.
*/
@@ -43,7 +43,7 @@
/// Namespace of static mathematical functions.
namespace math
{
- /// \internal Implementation namespace of algebra::math namespace.
+ /// \internal Implementation namespace of metal::math namespace.
namespace impl {}
}
@@ -53,9 +53,9 @@
-# include <mln/algebra/math/pow.hh>
-# include <mln/algebra/math/sqrt.hh>
-# include <mln/algebra/math/max.hh>
+# include <mln/metal/math/pow.hh>
+# include <mln/metal/math/sqrt.hh>
+# include <mln/metal/math/max.hh>
// ...
Index: mln/metal/math/sqrt.hh
--- mln/metal/math/sqrt.hh (revision 1786)
+++ mln/metal/math/sqrt.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_SQRT_HH
# define MLN_METAL_MATH_SQRT_HH
-/*! \file mln/algebra/math/sqrt.hh
+/*! \file mln/metal/math/sqrt.hh
*
* \brief Definition of the 'sqrt' static function.
*/
@@ -82,7 +82,7 @@
{
};
- } // end of namespace mln::algebra::math::impl
+ } // end of namespace mln::metal::math::impl
template <int n>
struct sqrt_int : impl::sqrt_int_if_< n, (n >= 0) >
@@ -102,7 +102,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 1786)
+++ mln/metal/all.hh (working copy)
@@ -77,7 +77,7 @@
# include <mln/algebra/vec.hh>
# include <mln/algebra/mat.hh>
-# include <mln/algebra/math/all.hh>
+# include <mln/metal/math/all.hh>
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1786)
+++ mln/value/graylevel.hh (working copy)
@@ -38,8 +38,8 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
-# include <mln/algebra/math/max.hh>
+# include <mln/metal/math/pow.hh>
+# include <mln/metal/math/max.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -513,7 +513,7 @@
inline
graylevel<n>::graylevel(const literal::medium_gray_t&)
{
- this->v_ = algebra::math::pow_int<2, n - 1>::value;
+ this->v_ = metal::math::pow_int<2, n - 1>::value;
}
template <unsigned n>
@@ -521,7 +521,7 @@
graylevel<n>&
graylevel<n>::operator=(const literal::medium_gray_t&)
{
- this->v_ = algebra::math::pow_int<2, n - 1>::value;
+ this->v_ = metal::math::pow_int<2, n - 1>::value;
return *this;
}
@@ -555,7 +555,7 @@
float
graylevel<n>::to_float() const
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
return float(this->v_) / denom;
}
Index: mln/value/graylevel_f.hh
--- mln/value/graylevel_f.hh (revision 1786)
+++ mln/value/graylevel_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1786)
+++ mln/value/float01_.hh (working copy)
@@ -35,7 +35,7 @@
# include <iostream>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/value/int_u.hh>
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1786)
+++ mln/value/int_s.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -180,7 +180,7 @@
inline
int_s<n>::int_s(int i)
{
- static const int max = algebra::math::pow_int<2, n-1>::value - 1;
+ static const int max = metal::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
@@ -192,7 +192,7 @@
int_s<n>&
int_s<n>::operator=(int i)
{
- static const int max = algebra::math::pow_int<2, n-1>::value - 1;
+ static const int max = metal::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
Index: mln/value/internal/gray_.hh
--- mln/value/internal/gray_.hh (revision 1786)
+++ mln/value/internal/gray_.hh (working copy)
@@ -37,8 +37,8 @@
# include <iostream>
# include <cmath>
-# include <mln/algebra/math/max.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/max.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/concept/integer.hh>
@@ -312,7 +312,7 @@
inline
gray_<n>::operator graylevel_f() const
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
return graylevel_f(float(this->v_) / denom);
}
Index: mln/value/internal/gray_f.hh
--- mln/value/internal/gray_f.hh (revision 1786)
+++ mln/value/internal/gray_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -225,7 +225,7 @@
template <unsigned n>
gray_f::gray_f(const gray_<n>& rhs)
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
}
@@ -233,7 +233,7 @@
gray_f&
gray_f::operator=(const gray_<n>& rhs)
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
return *this;
}
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1786)
+++ mln/value/int_u.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/concept/integer.hh>
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1786)
+++ mln/value/int_u_sat.hh (working copy)
@@ -34,7 +34,7 @@
* behavior.
*/
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -59,7 +59,7 @@
struct value_< mln::value::int_u_sat<n> >
{
// FIXME: Overhaul these traits (see other value traits).
- static const std::size_t card = algebra::math::pow_int<2, n>::value;
+ static const std::size_t card = metal::math::pow_int<2, n>::value;
static const mln::value::int_u_sat<n> min() { return 0; }
static const mln::value::int_u_sat<n> max() { return card - 1; }
static const unsigned nbits = n;
Index: mln/value/label.hh
--- mln/value/label.hh (revision 1786)
+++ mln/value/label.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Define a generic class for labels.
*/
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/concept/symbolic.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/convert.hh>
1
0
Caroline Vigouroux wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2008-03-19 Caroline Vigouroux <vigour_c(a)epita.fr>
>
> correct structures.
> * my_cmy.hh: correction.
> * my_hsi.hh: correction.
> * my_hsl.hh: correction.
> * my_hsv.hh: correction.
> * my_xyz.hh: correction.
> * my_yiq.hh: correction.
> * my_yuv.hh: correction.
> * rgb_to_hsi.hh: correction.
IMHO 'correction' is a bit too vague. Don't hesitate to be more precise.
The idea is that by reading your Changelog we can easily know what
you've done.
By the way, repeating N-times the same message is useless, you can use
this formant :
* file1,
* file2,
* file3: Common changelog message.
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
1
0