Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Draft canvas : 3 versions (Two_pass).
* oln/canvas/queue_based.hh: New.
* oln/canvas/parallel.hh: New.
* oln/canvas/two_pass_until_stability.hh: New.
* oln/canvas/two_pass.hh: .
* oln/canvas/until_stability.hh: New.
parallel.hh | 42 ++++++++++++++++++++++++++
queue_based.hh | 54 ++++++++++++++++++++++++++++++++++
two_pass.hh | 62 ++++++++++++++++++++++++++++++++++++---
two_pass_until_stability.hh | 69 ++++++++++++++++++++++++++++++++++++++++++++
until_stability.hh | 58 ++++++++++++++++++++++++++++++++++++
5 files changed, 281 insertions(+), 4 deletions(-)
Index: oln/canvas/queue_based.hh
--- oln/canvas/queue_based.hh (revision 0)
+++ oln/canvas/queue_based.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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 receiv 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 OLN_CANVAS_QUEUE_BASED_HH
+# define OLN_CANVAS_QUEUE_BASED_HH
+
+namespace canvas
+{
+
+ template <typename F, typename I>
+ void queue_based(F f, I input)
+ {
+ queue q;
+
+ f.init(input);
+
+ oln_piter(I) p1(input.points());
+ for_all(p1)
+ f.enqueue(p1, q, input);
+
+ while ( !q.empty() ) do
+ {
+ oln_piter(I) p = q.deq();
+ f.loop(p, input);
+ }
+
+ f.final(input);
+ }
+
+#endif // ! OLN_CANVAS_QUEUE_BASED_HH
Index: oln/canvas/parallel.hh
--- oln/canvas/parallel.hh (revision 0)
+++ oln/canvas/parallel.hh (revision 0)
@@ -0,0 +1,42 @@
+// 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 receiv 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 OLN_CANVAS_PARALLEL_HH
+# define OLN_CANVAS_PARALLEL_HH
+
+namespace canvas
+{
+
+ template <typename F, typename I>
+ void parallel(F f, I input)
+ {
+
+ }
+
+}
+
+#endif // ! OLN_CANVAS_PARALLEL_HH
Index: oln/canvas/two_pass_until_stability.hh
--- oln/canvas/two_pass_until_stability.hh (revision 0)
+++ oln/canvas/two_pass_until_stability.hh (revision 0)
@@ -0,0 +1,69 @@
+// 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 receiv 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 OLN_CANVAS_TWO_PASS_UNTIL_STABILITY_HH
+# define OLN_CANVAS_TWO_PASS_UNTIL_STABILITY_HH
+
+namespace canvas
+{
+
+ template <typename F, typename I>
+ void two_pass_until_stability(F f, I input)
+ {
+ bool stability;
+
+ f.init(input);
+
+ for (;;)
+ {
+
+ // first pass
+ oln_fwd_piter(I) p1(input.points());
+ for_all(p1)
+ f.first_pass_body(p1, input);
+
+ // second pass
+ oln_bkd_piter(I) p2(input.points());
+ for_all(p2)
+ f.second_pass_body(p2, input);
+
+ // stability check
+ stability = f.is_stable(input); // Oblige de posseder output.
+ if (stability)
+ return;
+
+ // prepare a new loop iteration
+ f.re_loop(input);
+ }
+
+ f.final(input);
+ }
+
+
+}
+
+#endif // ! OLN_CANVAS_TWO_PASS_UNTIL_STABILITY_HH
Index: oln/canvas/two_pass.hh
--- oln/canvas/two_pass.hh (revision 947)
+++ oln/canvas/two_pass.hh (working copy)
@@ -31,21 +31,75 @@
namespace canvas
{
- template <typename F, typename I>
- void two_pass(F f, I input)
+ namespace v1
{
+ template <template <class> class F,
+ typename I>
+ void two_pass(F<I> f)
+ {
+ mlc::assert_< mlc_is_a(I, Image) >::check();
+
f.init();
- oln_piter(I) p1(input.points());
+ // first pass
+ oln_fwd_piter(I) p1(f.input.points());
for_all(p1)
f.first_pass_body(p1);
- oln_bkd_piter(I) p2(input.points());
+ // second pass
+ oln_bkd_piter(I) p2(f.input.points());
for_all(p2)
f.second_pass_body(p2);
f.final();
}
+ }
+
+ namespace v2
+ {
+ template <typename F, typename I>
+ void two_pass(F f, I input)
+ {
+ mlc::assert_< mlc_is_a(I, Image) >::check();
+
+ f.init(input);
+
+ // first pass
+ oln_fwd_piter(I) p1(input.points());
+ for_all(p1)
+ f.first_pass_body(p1, input);
+
+ // second pass
+ oln_bkd_piter(I) p2(input.points());
+ for_all(p2)
+ f.second_pass_body(p2, input);
+
+ f.final(input);
+ }
+ }
+
+ namespace v3
+ {
+ template <typename F, typename I, typename A>
+ void two_pass(F f, I input, A aux)
+ {
+ mlc::assert_< mlc_is_a(I, Image) >::check();
+
+ f.init(input, aux);
+
+ // first pass
+ oln_fwd_piter(I) p1(input.points());
+ for_all(p1)
+ f.first_pass_body(p1, input, aux);
+
+ // second pass
+ oln_bkd_piter(I) p2(input.points());
+ for_all(p2)
+ f.second_pass_body(p2, input, aux);
+
+ f.final(input, aux);
+ }
+ }
}
Index: oln/canvas/until_stability.hh
--- oln/canvas/until_stability.hh (revision 0)
+++ oln/canvas/until_stability.hh (revision 0)
@@ -0,0 +1,58 @@
+// 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 receiv 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 OLN_CANVAS_UNTIL_STABILITY_HH
+# define OLN_CANVAS_UNTIL_STABILITY_HH
+
+namespace canvas
+{
+
+ template <typename F>
+ void until_stability(F f)
+ {
+ bool stability;
+
+ f.init();
+
+ for (;;)
+ {
+ f.loop_body();
+
+ // stability check
+ stability = f.is_stable();
+ if (stability)
+ return;
+
+ // prepare a new loop iteration
+ f.re_loop();
+ }
+
+ f.final();
+ }
+}
+
+#endif // ! OLN_CANVAS_UNTIL_STABILITY_HH