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
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
fix a bug on rle_encode, add a test.
* olena/tests/core/3dtorle.cc: New test.
* olena/tests/core/rle_image.cc: Update test.
* olena/tests/core/Makefile.am: Update.
* olena/oln/core/gen/rle_image.hh,
* olena/oln/core/gen/rle_encode.hh: fix a bug.
* olena/oln/core/concept/iterator_on_values.hh: change vit.to_point() to vit.to_value().
* olena/oln/core/internal/encoded_image.hh: small modifications.
oln/core/concept/iterator_on_values.hh | 2
oln/core/gen/rle_encode.hh | 20 ++++++-
oln/core/gen/rle_image.hh | 1
oln/core/internal/encoded_image.hh | 2
tests/core/3dtorle.cc | 91 +++++++++++++++++++++++++++++++++
tests/core/Makefile.am | 4 +
tests/core/rle_image.cc | 6 ++
7 files changed, 121 insertions(+), 5 deletions(-)
Index: olena/tests/core/3dtorle.cc
--- olena/tests/core/3dtorle.cc (revision 0)
+++ olena/tests/core/3dtorle.cc (revision 0)
@@ -0,0 +1,91 @@
+// Copyright (C) 2006 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.
+
+#include <cassert>
+#include <cmath>
+#include <oln/core/3d/image3d.hh>
+#include <oln/level/fill.hh>
+#include <oln/debug/print.hh>
+#include <ostream>
+#include <oln/core/gen/rle_image.hh>
+#include <oln/core/gen/rle_encode.hh>
+
+float my_sinus(const oln::point3d& p)
+{
+ return sin(p.sli() + p.row() + p.col());
+}
+
+
+int
+main()
+{
+ using namespace oln;
+
+ // Fill a 3D image with a cos.
+ image3d<float> ima3d(100, 100, 100);
+
+ level::fill(inplace(ima3d), my_sinus);
+
+
+ // Transform it into a 3 states image
+ // value < 0 => -1
+ // value > 0 => 1
+ // value next to 0 => 0
+ image3d<short> ima3s(100, 100, 100);
+ image3d<float>::piter p(ima3d.points());
+ for_all(p)
+ {
+ if (ima3d(p) < 0.05 && ima3d(p) > -0.05)
+ ima3s(p) = 0;
+ else
+ {
+ if (ima3d(p) < 0)
+ ima3s(p) = -1;
+ else
+ ima3s(p) = 1;
+ }
+ }
+
+// oln::debug::print(ima3s);
+// std::cout << std::endl;
+
+ // Encode ima3s into a rle_image
+ rle_image<point3d, short> ima3rle;
+
+
+ ima3rle = rle_encode(ima3s);
+ rle_image<point3d, short>::piter p1(ima3rle.points());
+// std::cout << "start test" << std::endl;
+// for_all(p1)
+// {
+// // std::cout << "point: " << p1.to_point() << std::endl;
+// // std::cout << "3s : " << ima3s(p1) << std::endl;
+// // std::cout << "rle: " << ima3rle(p1) << std::endl;
+// assert(ima3s(p1) == ima3rle(p1));
+// }
+
+}
Index: olena/tests/core/rle_image.cc
--- olena/tests/core/rle_image.cc (revision 953)
+++ olena/tests/core/rle_image.cc (working copy)
@@ -44,6 +44,12 @@
rle2 = rle_encode(ima2d);
+ oln::rle_image<oln::point2d, int>::piter p1(rle2.points());
+ for_all(p1)
+ {
+ assert(ima2d(p1) == rle2(p1));
+ }
+
// oln::debug::print(rle2);
// std::cout << std::endl;
Index: olena/tests/core/Makefile.am
--- olena/tests/core/Makefile.am (revision 953)
+++ olena/tests/core/Makefile.am (working copy)
@@ -35,7 +35,8 @@
sparse_image \
stack \
subset \
- window2d
+ window2d \
+ 3dtorle
# Images and auxiliary structures.
@@ -54,6 +55,7 @@
stack_SOURCES = stack.cc
subset_SOURCES = subset.cc
window2d_SOURCES = window2d.cc
+3dtorle_SOURCES = 3dtorle.cc
# Methods.
at_SOURCES = at.cc
Index: olena/oln/core/gen/rle_image.hh
--- olena/oln/core/gen/rle_image.hh (revision 953)
+++ olena/oln/core/gen/rle_image.hh (working copy)
@@ -85,7 +85,6 @@
void insert(const point& p, unsigned len, value val);
rvalue impl_read(const psite& p) const;
lvalue impl_read_write(const psite& p);
-
};
# ifndef OLN_INCLUDE_ONLY
Index: olena/oln/core/gen/rle_encode.hh
--- olena/oln/core/gen/rle_encode.hh (revision 953)
+++ olena/oln/core/gen/rle_encode.hh (working copy)
@@ -38,6 +38,22 @@
{
/*!
+ ** test if Point p1 and p2 are on the same line
+ */
+ template <typename P>
+ bool
+ on_the_same_line(P p1, P p2)
+ {
+ unsigned dim = mlc_value(typename P::grid::dim);
+ bool same_line = true;
+
+ for (int n = dim - 1; same_line && n > 0; --n)
+ same_line = p1[n] == p2[n];
+ return same_line;
+ }
+
+
+ /*!
** encode an image class to a rle_image
**
** @param input has to respect the Image concept
@@ -49,7 +65,7 @@
rle_encode(const Image<I>& input)
{
rle_image<typename I::point, typename I::value> output;
- typename I::piter p (input.points());
+ typename Image<I>::piter p (input.points());
unsigned len = 1;
/// range point start
typename I::point rstart;
@@ -65,7 +81,7 @@
p.next();
while (p.is_valid())
{
- if (rvalue == input(p))
+ if (rvalue == input(p) && on_the_same_line(rstart, p.to_point()))
++len;
else
{
Index: olena/oln/core/concept/iterator_on_values.hh
--- olena/oln/core/concept/iterator_on_values.hh (revision 953)
+++ olena/oln/core/concept/iterator_on_values.hh (working copy)
@@ -85,7 +85,7 @@
template <typename Exact>
std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Values<Exact>& vit)
{
- return ostr << vit.to_point();
+ return ostr << vit.to_value();
}
# endif
Index: olena/oln/core/internal/encoded_image.hh
--- olena/oln/core/internal/encoded_image.hh (revision 953)
+++ olena/oln/core/internal/encoded_image.hh (working copy)
@@ -78,6 +78,8 @@
# ifndef OLN_INCLUDE_ONLY
+
+
template <typename Exact>
encoded_image_<Exact>::encoded_image_()
{
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add tour3.cc and update.
* doc/tour/tour3.cc: New.
* oln/convert: New directory.
* oln/convert/to_window.hh: New.
* oln/core/internal/f_grid_to_window.hh: New.
* oln/core/internal/f_image_to_window.hh: New.
* doc/tour/tour2.cc: Add some text.
* doc/tour/tour1_extra.cc (include): Fix missing.
(at): Update.
* doc/tour/tour1.cc: Change a word.
* oln/debug/fill.hh (fill_): New.
(fill): Update.
* oln/debug/print.hh (format): Move into...
* oln/debug/format.hh: ...this new file.
* oln/core/1d/window1d.hh: Fix.
* oln/core/1d/image1d.hh,
* oln/core/2d/image2d_b.hh,
* oln/core/3d/image3d.hh (init_): New.
* oln/core/gen/torus_pset.hh (operator Ps): New.
(torus_pset): Fix ctor.
* oln/core/gen/niter_has.hh: Update.
* oln/core/gen/fun_ops.hh (oln_decl_p2v_cmp_): New overload.
* oln/core/concept/image.hh (dpoint): New in Image.
* oln/core/internal/box.hh: Add static check.
* oln/core/internal/op_image_extended_by_nbh.hh (operator I): New.
* oln/core/internal/point_base.hh (point_base_): New ctor overload;
decl only.
* oln/core/internal/op_pset_such_as_fp2b.hh
(pset_such_as_fp2b_fwd_piter_),
(pset_such_as_fp2b_bkd_piter_): New ctor overload.
* oln/core/internal/iterator_on_points_impl.hh
(iterator_on_points_impl_base_): New.
(vec): New.
* oln/core/internal/iterator_on_points_base.hh (point):
Disambiguate.
* oln/level/local.hh: Update.
* oln/level/clone.hh (clone_): New.
(clone): Update.
doc/tour/tour1.cc | 2
doc/tour/tour1_extra.cc | 6
doc/tour/tour2.cc | 47 +++
doc/tour/tour3.cc | 331 ++++++++++++++++++++++++++
oln/convert/to_window.hh | 76 +++++
oln/core/1d/image1d.hh | 10
oln/core/1d/window1d.hh | 2
oln/core/2d/image2d_b.hh | 25 -
oln/core/3d/image3d.hh | 10
oln/core/concept/image.hh | 1
oln/core/gen/fun_ops.hh | 10
oln/core/gen/niter_has.hh | 10
oln/core/gen/torus_pset.hh | 16 -
oln/core/internal/box.hh | 2
oln/core/internal/f_grid_to_window.hh | 118 +++++++++
oln/core/internal/f_image_to_window.hh | 37 ++
oln/core/internal/iterator_on_points_base.hh | 3
oln/core/internal/iterator_on_points_impl.hh | 38 ++
oln/core/internal/op_image_extended_by_nbh.hh | 7
oln/core/internal/op_pset_such_as_fp2b.hh | 17 +
oln/core/internal/point_base.hh | 3
oln/debug/fill.hh | 25 +
oln/debug/format.hh | 76 +++++
oln/debug/print.hh | 18 -
oln/level/clone.hh | 6
oln/level/local.hh | 6
26 files changed, 840 insertions(+), 62 deletions(-)
Index: doc/tour/tour2.cc
--- doc/tour/tour2.cc (revision 952)
+++ doc/tour/tour2.cc (working copy)
@@ -29,12 +29,10 @@
#include <oln/core/2d/image2d.hh>
#include <oln/core/2d/window2d.hh>
-#include <oln/level/fill.hh>
#include <oln/debug/println.hh>
-
// Note to the reader: If you do not have read the tour1.cc file, you
// should have a quick look at it before proceeding with this present
// file. Some important features and practices are described in the
@@ -318,9 +316,52 @@
} // End of 2nd version.
+ std::cout << std::endl;
+
+
+ // Above, p and q behave just like points; for instance, the
+ // following expressions are valid:
+
+ // int r = p.row();
+ // to get the current row value,
+
+ // bool b = img(p);
+ // to get the pixel value at the current point,
+
+ // or point2d pp = p + dp;
+ // where dp is a delta-point to get a point nearby p.
+
+ // Yet, p and q are "more than points" since they allow to
+ // browse/iterate over a set of points, respectivelly, the domain of
+ // 'img' and the window centered at p.
+
+
+ // The domain of 'img' is obtained with "img.points()" and is
+ // provided to the 'p' object so that it knows how to iterate.
+
+ // For a "basic" image, its set of points is an n-dimensional box.
+ // In the 2D space, the box type is called 'box2d'. We also have
+ // 'box1d' and 'box3d' for other dimensions.
+
+ box2d pts = img.points();
+ std::cout << "img points are " << pts << std::endl;
+ // Prints:
+ // img points are { (0, 0) .. (3, 4) }
+
+ // The type of iterators over a point set is obtained with the
+ // expression: "name_of_the_point_set_type::piter", where 'piter'
+ // means "point iterator" for short.
+
+ // The same construction is available for iterators on window
+ // points, whose types are obtained in a similar way with
+ // "name_of_the_window_type::qiter". Here the 'q' in 'qiter'
+ // emphases the fact that a window is not really a set of points but
+ // "a set of dpoints and a center point".
+
- // This last version is:
+ // The second version of our example contrasts with the more
+ // "classical" ones; it is:
// - shorter,
// so it is less error-prone for the developer;
Index: doc/tour/tour3.cc
--- doc/tour/tour3.cc (revision 0)
+++ doc/tour/tour3.cc (revision 0)
@@ -0,0 +1,331 @@
+// Copyright (C) 2001, 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: tour2.cc.
+
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/neighb2d.hh>
+
+#include <oln/core/gen/such_as.hh>
+#include <oln/core/gen/torus_image.hh>
+#include <oln/core/gen/pw_value.hh>
+#include <oln/core/gen/fun_ops.hh>
+
+#include <oln/level/fill.hh>
+#include <oln/debug/fill.hh>
+#include <oln/debug/println.hh>
+
+
+// Note to the reader: you should have read the files tour1.cc and
+// tour2.cc before starting with this present file.
+
+
+
+// We have encapsulated an algorithm into a procedure which is forward
+// declared below so that it can be used in the section 'main'.
+template <typename I> void algo(const I& img);
+
+
+// Some functions that will be useful in the following:
+bool chessboard(oln::point2d p)
+{
+ return (p.row() + p.col()) % 2;
+}
+
+
+
+int main()
+{
+ using namespace oln;
+
+ // First our domain is 2d box:
+ box2d b(point2d(0, 0), point2d(2, 2));
+ // ^^^^ ^^^^
+ // from to
+
+ // We define a binary image with values on that box.
+ image2d<bool> img(b);
+
+ // With an array of Booleans (1 means true, 0 means false)...
+ bool vals[] = { 1, 0, 0,
+ 0, 1, 0,
+ 0, 1, 1 };
+ // ...the debug::fill routine allows for manually initializing
+ // image data:
+ debug::fill(inplace(img), vals);
+ std::cout << "img = " << std::endl;
+ debug::println(img);
+ // img + // | - -
+ // - | -
+ // - | |
+
+ image2d<int> ima(b); // An image of integers with the same
+ box2d::piter p(ima.points()); // domain as img...
+ int i = 0;
+ for_all(p)
+ ima(p) = i++; // ...and manually filled with values.
+
+ std::cout << "ima = " << std::endl;
+ debug::println(ima);
+ // ima =
+ // 0 1 2
+ // 3 4 5
+ // 6 7 8
+
+ /* HERE
+
+ // The algorithm defined at the end of this file is very close to
+ // the one of the tour former file. The major difference is that it
+ // does not rely on a window but on a neighborhood.
+
+ // In image processing, we usually say that "an image has a given
+ // neighborhood" or that "we associate/embed a neighborhood to/into
+ // an image". In Olena, that is really the case: the image can
+ // "have" a neighborhood, meaning that a neighborhood can be added
+ // to an image in order to obtain an "image with a neighborhood".
+
+ // Joining an image with a neighborhood is performed with the
+ // operator '+':
+ algo(ima + c4); // c4 is the 2D neighborhood corresponding to
+ // 4-connectivity; such as many classical
+ // neighborhoods it is provided by Olena.
+ // The result is given below.
+
+ // ---input:
+ // 0 1 2
+ // 1 2 3
+ // 2 3 4
+ // ---output:
+ // 0: 1 1
+ // 1: 0 2 2
+ // 2: 1 3
+ // 1: 0 2 2
+ // 2: 1 1 3 3
+ // 3: 2 2 4
+ // 2: 1 3
+ // 3: 2 2 4
+ // 4: 3 3
+
+ // That was expectable...
+
+
+ // And now for a little test: what is the result of this code?
+ {
+ image2d<int> test(ima.points());
+ level::fill(inplace(test), ima);
+ (test + c4).at(1, 1) = 9;
+ debug::println(test);
+ }
+ // and can you tell why?
+ // The answers are given in the file tour3-test.txt
+
+
+ // Now let us start experimenting the genericity of Olena!
+
+
+ // First, imagine that you want to restrict the domain of ima to a
+ // subset of points, a region or whatever. For instance, the
+ // chessboard function takes a point as argument and returns a
+ // Boolean so it is like a predicate. We can want to consider only
+ // the points of ima "such as" this predicate is verified. The
+ // "such as" mathematical symbol is '|' so let's rock:
+
+ algo((ima | chessboard) + c8);
+ // gives:
+
+ // ---input:
+ // 1
+ // 3 5
+ // 7
+ // ---output:
+ // 1: 3 5
+ // 3: 1 7
+ // 5: 1 7
+ // 7: 3 5
+
+ // where the blanks in printing the input image denote that the
+ // corresponding points do NOT belong to the image domain.
+
+ // Another similar example is based on the binary image created at
+ // the beginning of this tour:
+ algo((ima | img) + c8);
+ // which gives:
+
+ // ---input:
+ // 0
+ // 4
+ // 7 8
+ // ---output:
+ // 0: 4
+ // 4: 0 7 8
+ // 7: 4 8
+ // 8: 4 7
+
+
+
+ // Second, imagine that you want your initial image to get the
+ // geodesy of a torus, that is, a 2D image wrapped on a torus.
+ // Points located at the image boundary have neighbors; for
+ // instance, the point denoted by the 'x' cross below has for
+ // 4-connectivity neighbors: t, l, r, and b (respectively for top,
+ // left, right, and bottom):
+
+ // b o o o
+ // o o o o
+ // t o o o
+ // x r o l
+
+ // Let us try:
+ algo(torus(ima) + c8);
+ // gives:
+
+ // ---input:
+ // 0 1 2
+ // 3 4 5
+ // 6 7 8
+ // ---output:
+ // 0: 8 6 7 2 1 5 3 4
+ // 1: 6 7 8 0 2 3 4 5
+ // 2: 7 8 6 1 0 4 5 3
+ // 3: 2 0 1 5 4 8 6 7
+ // 4: 0 1 2 3 5 6 7 8
+ // 5: 1 2 0 4 3 7 8 6
+ // 6: 5 3 4 8 7 2 0 1
+ // 7: 3 4 5 6 8 0 1 2
+ // 8: 4 5 3 7 6 1 2 0
+
+
+
+ // We can have both the torus geodesy and a sub-domain:
+
+ algo(torus(ima | chessboard) + c8);
+ algo(torus(ima | img) + c8);
+
+ // which respectively give:
+
+ // ---input:
+ // 1
+ // 3 5
+ // 7
+ // ---output:
+ // 1: 7 3 5
+ // 3: 1 5 7
+ // 5: 1 3 7
+ // 7: 3 5 1
+
+ // and:
+
+ // ---input:
+ // 0
+ // 4
+ // 7 8
+ // ---output:
+ // 0: 8 7 4
+ // 4: 0 7 8
+ // 7: 4 8 0
+ // 8: 4 7 0
+
+
+ */
+
+ // Last, the way a predicate is defined can also rely on some image
+ // values. For that the user can on the fly provide an expression
+ // built with the "pw_value" facility, where "pw_" means
+ // "point-wise" for short:
+
+ algo((ima | (pw_value(ima) < 4)) + c4);
+
+ // In this example, "pw_value(ima)" is the function that represents
+ // the point-wise value of the 'ima' image, that is, the function
+ // "p -> ima(p)". This naturally leads to:
+
+ // ---input:
+ // 0 1 2
+ // 3
+ //
+ // ---output:
+ // 0: 1 3
+ // 1: 0 2
+ // 2: 1
+ // 3: 0
+
+
+
+ // From those examples, you should realize that:
+
+
+ // +-----------------------------------------------------------+
+ // | |
+ // | The level of "genericity" provided by Olena is rather |
+ // | high; it means: |
+ // | |
+ // | - taking the image dimension you work on; |
+ // | |
+ // | - having the type of pixel values you need; |
+ // | |
+ // | - choosing the neighborhood you want; |
+ // | |
+ // | - changing the geodesy if you need it; |
+ // | |
+ // | - being able to restrict the image domain; |
+ // | |
+ // | - and many other features that are addressed further |
+ // | in the tour... |
+ // | |
+ // +-----------------------------------------------------------+
+
+}
+
+
+
+
+
+// The algorithm 'algo':
+
+template <typename I>
+void algo(const I& img)
+{
+ std::cout << "---input:" << std::endl;
+ oln::debug::print(img);
+ std::cout << "---output:" << std::endl;
+
+ oln_piter(I) p(img.points()); // p iterates on img points
+ oln_niter(I) n(img, p); // n iterates in img on neighbors of p
+
+ for_all(p)
+ {
+ std::cout << oln::debug::format(img(p))
+ << ':';
+ for_all(n)
+ std::cout << ' '
+ << oln::debug::format(img(n));
+ std::cout << std::endl;
+ }
+
+ std::cout << std::endl;
+}
Index: doc/tour/tour1_extra.cc
--- doc/tour/tour1_extra.cc (revision 952)
+++ doc/tour/tour1_extra.cc (working copy)
@@ -29,6 +29,8 @@
#include <oln/core/1d/image1d.hh>
#include <oln/arith/plus.hh>
+#include <oln/debug/println.hh>
+
int main()
@@ -91,7 +93,7 @@
{
image1d<int> orig(5); // An original image.
for (int i = 0; i < 5; ++i)
- orig(i) = i;
+ orig.at(i) = i;
debug::println(orig);
// 0 1 2 3 4
@@ -160,7 +162,7 @@
{
image1d<int> ima(5);
for (int i = 0; i < 5; ++i)
- ima(i) = i;
+ ima.at(i) = i;
debug::println(ima);
// 0 1 2 3 4
Index: doc/tour/tour1.cc
--- doc/tour/tour1.cc (revision 952)
+++ doc/tour/tour1.cc (working copy)
@@ -311,7 +311,7 @@
// Indeed, the loops above depict the "classical" way to iterate
- // over the contents of a 1D image. The next tour file explains
+ // over the contents of a 1D image. The next tour file introduces
// the solution provided by Olena to write better loops...
Index: oln/convert/to_window.hh
--- oln/convert/to_window.hh (revision 0)
+++ oln/convert/to_window.hh (revision 0)
@@ -0,0 +1,76 @@
+// 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 OLN_CONVERT_TO_WINDOW_HH
+# define OLN_CONVERT_TO_WINDOW_HH
+
+# include <oln/core/concept/image.hh>
+# include <oln/core/internal/f_image_to_window.hh>
+
+
+namespace oln
+{
+
+ namespace convert
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_f_image_to_window(I)
+ to_window(const Binary_Image<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Generic version.
+
+ template <typename I>
+ oln_f_image_to_window(I)
+ to_window(const Binary_Image<I>& input)
+ {
+ oln_f_image_to_window(I) tmp;
+ oln_dpoint(I) dp;
+ oln_piter(I) p(input.points());
+ for_all(p)
+ if (input(p) = true)
+ {
+ dp.vec() = p.vec();
+ // FIXME: Better s.a. dp = p.to_dpoint();
+ tmp.take(dp);
+ }
+ return tmp;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::convert
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CONVERT_TO_WINDOW_HH
Index: oln/debug/fill.hh
--- oln/debug/fill.hh (revision 952)
+++ oln/debug/fill.hh (working copy)
@@ -39,26 +39,37 @@
{
template <typename I, typename V>
- void fill(Mutable_Image<I>& in_out, const V values[]);
-
- template <typename I, typename V>
void fill(inplace_<I> in_out, const V values[]);
# ifndef OLN_INCLUDE_ONLY
- template <typename I>
- void fill(Mutable_Image<I>& in_out, const oln_value(I)& value)
+ namespace impl
+ {
+
+ template <typename I, typename V>
+ void fill_(Mutable_Image<I>& in_out, const V values[])
{
+ unsigned i = 0;
oln_piter(I) p(in_out.points());
for_all(p)
- in_out(p) = value;
+ in_out(p) = values[i++];
}
+ } // end of namespace oln::impl
+
template <typename I, typename V>
void fill(inplace_<I> in_out, const V values[])
{
- fill(in_out.unwrap(), values);
+ impl::fill_(in_out.unwrap(), values);
+ }
+
+ // Guard.
+
+ template <typename I, typename V>
+ void fill(const Image<I>&, const V[])
+ {
+ mlc::abort_<I>::check(); // FIXME: Add err msg.
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/debug/format.hh
--- oln/debug/format.hh (revision 0)
+++ oln/debug/format.hh (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (C) 2006, 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 OLN_DEBUG_FORMAT_HH
+# define OLN_DEBUG_FORMAT_HH
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+ // Fwd decls.
+
+ template <typename T>
+ const T&
+ format(const T& value);
+
+ unsigned
+ format(const unsigned char& value);
+
+ char
+ format(bool value);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ const T& format(const T& value)
+ {
+ return value;
+ }
+
+ unsigned format(const unsigned char& value)
+ {
+ return value;
+ }
+
+ char format(bool value)
+ {
+ return value ? '|' : '-';
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_FORMAT_HH
Index: oln/debug/print.hh
--- oln/debug/print.hh (revision 952)
+++ oln/debug/print.hh (working copy)
@@ -30,6 +30,7 @@
# include <iostream>
# include <oln/core/concept/image.hh>
+# include <oln/debug/format.hh>
# ifdef OLN_ENV_2D
# include <oln/core/2d/point2d.hh>
@@ -53,23 +54,6 @@
namespace impl
{
- template <typename T>
- const T& format(const T& value)
- {
- return value;
- }
-
- unsigned format(const unsigned char& value)
- {
- return value;
- }
-
- char format(bool value)
- {
- return value ? '|' : '-';
- }
-
-
/// Generic version.
template <typename I>
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 952)
+++ oln/core/1d/image1d.hh (working copy)
@@ -108,6 +108,9 @@
template <typename T, typename D>
bool prepare(image1d<T>& target, with_t, const D& dat);
+ template <typename T>
+ bool init_(box1d* this_, const image1d<T>& data);
+
# ifndef OLN_INCLUDE_ONLY
@@ -242,6 +245,13 @@
return box_ok;
}
+ template <typename T>
+ bool init_(box1d* this_, const image1d<T>& data)
+ {
+ *this_ = data.bbox();
+ return true;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
Index: oln/core/1d/window1d.hh
--- oln/core/1d/window1d.hh (revision 952)
+++ oln/core/1d/window1d.hh (working copy)
@@ -36,7 +36,7 @@
{
// FIXME: window1d should be an actual type, not an alias...
- typedef window_<dpoint1d> window1d;
+ typedef gen_window<dpoint1d> window1d;
} // end of namespace oln
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 952)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -114,12 +114,12 @@
std::size_t pad(const dpoint2d& dp) const;
};
-// template <typename T, typename D>
-// bool init_(image2d_b<T>* this_, const D& dat);
-
template <typename T, typename D>
bool prepare(image2d_b<T>& target, with_t, const D& dat);
+ template <typename T>
+ bool init_(box2d* this_, const image2d_b<T>& data);
+
# ifndef OLN_INCLUDE_ONLY
@@ -239,18 +239,6 @@
return this->data_->first.i_pad() * dp.row() + dp.col();
}
-// template <typename T, typename D>
-// bool init_(image2d_b<T>* this_, const D& dat)
-// {
-// precondition(not this_->has_data());
-// box2d b;
-// bool box_ok = init(b, with, dat);
-// postcondition(box_ok);
-// unsigned border = 2; // FIXME: Use init!
-// this_->data__() = new typename image2d_b<T>::data(b.pmin(), b.pmax(), border);
-// return box_ok;
-// }
-
template <typename T, typename D>
bool prepare(image2d_b<T>& target, with_t, const D& dat)
{
@@ -267,6 +255,13 @@
return box_ok;
}
+ template <typename T>
+ bool init_(box2d* this_, const image2d_b<T>& data)
+ {
+ *this_ = data.bbox();
+ return true;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 952)
+++ oln/core/3d/image3d.hh (working copy)
@@ -109,6 +109,9 @@
template <typename T, typename D>
bool prepare(image3d<T>& target, with_t, const D& dat);
+ template <typename T>
+ bool init_(box3d* this_, const image3d<T>& data);
+
# ifndef OLN_INCLUDE_ONLY
@@ -240,6 +243,13 @@
return box_ok;
}
+ template <typename T>
+ bool init_(box3d* this_, const image3d<T>& data)
+ {
+ *this_ = data.bbox();
+ return true;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/torus_pset.hh
--- oln/core/gen/torus_pset.hh (revision 952)
+++ oln/core/gen/torus_pset.hh (working copy)
@@ -76,6 +76,8 @@
torus_pset(const Ps& pset);
void init_pset(const Ps& pset);
+ operator Ps() const;
+
point relocate(const point& p) const;
bool impl_has(const point& p) const;
@@ -105,9 +107,9 @@
: super(pset)
{
mlc::assert_< mlc_is_a(Ps, Point_Set) >::check();
- this->pmin_ = pset.pmin();
+ this->pmin_ = pset.bbox().pmin();
dpoint unit; unit.set_all(1);
- this->size_ = pset.pmax() - pset.pmin() + unit;
+ this->size_ = pset.bbox().pmax() - pset.bbox().pmin() + unit;
}
template <typename Ps>
@@ -115,9 +117,15 @@
current::init_pset(const Ps& pset)
{
this->ps_ = pset;
- this->pmin_ = pset.pmin();
+ this->pmin_ = pset.bbox().pmin();
dpoint unit; unit.set_all(1);
- this->size_ = pset.pmax() - pset.pmin() + unit;
+ this->size_ = pset.bbox().pmax() - pset.bbox().pmin() + unit;
+ }
+
+ template <typename Ps>
+ current::operator Ps() const
+ {
+ return this->ps_;
}
template <typename Ps>
Index: oln/core/gen/niter_has.hh
--- oln/core/gen/niter_has.hh (revision 952)
+++ oln/core/gen/niter_has.hh (working copy)
@@ -69,8 +69,8 @@
{
public:
- template <typename Pl, typename I>
- niter_has_(const Generalized_Point<Pl>& p, const Image_with_Nbh<I>& ima);
+ template <typename I, typename Pl>
+ niter_has_(const Image_with_Nbh<I>& ima, const Generalized_Point<Pl>& p);
void impl_start();
void impl_next();
@@ -87,10 +87,10 @@
# ifndef OLN_INCLUDE_ONLY
template <typename It, typename Ps>
- template <typename Pl, typename I>
- current::niter_has_(const Generalized_Point<Pl>& p, const Image_with_Nbh<I>& ima)
+ template <typename I, typename Pl>
+ current::niter_has_(const Image_with_Nbh<I>& ima, const Generalized_Point<Pl>& p)
:
- super( It(p, ima) ),
+ super( It(ima, p) ),
pset_( ima.points() )
{
}
Index: oln/core/gen/fun_ops.hh
--- oln/core/gen/fun_ops.hh (revision 952)
+++ oln/core/gen/fun_ops.hh (working copy)
@@ -76,6 +76,16 @@
return tmp; \
} \
\
+ template <typename L> \
+ p2v_##Name##_<L, lit_p2v_<oln_argument(L), oln_result(L)> > \
+ operator Sym (const Function_p2v<L>& left, const oln_result(L)& right) \
+ { \
+ mlc::assert_< mlc_is_a(oln_argument(L), Point) >::check(); \
+ lit_p2v_<oln_argument(L), oln_result(L)> right_(right); \
+ p2v_##Name##_<L, lit_p2v_<oln_argument(L), oln_result(L)> > tmp(left, right_); \
+ return tmp; \
+ } \
+ \
struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 952)
+++ oln/core/concept/image.hh (working copy)
@@ -127,6 +127,7 @@
stc_typename(box);
stc_typename(pset);
+ stc_typename(dpoint);
// stc_typename(output); // FIXME: Uncomment!
stc_typename(plain);
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 952)
+++ oln/core/internal/box.hh (working copy)
@@ -306,6 +306,7 @@
box_fwd_piter_<B>::box_fwd_piter_(const Point_Set<Ps>& ps)
: b_(ps.bbox())
{
+ mlc::assert_< mlc_is_a(B, Point_Set) >::check(); // FIXME: Add err msg.
nop_ = b_.pmax();
++nop_[0];
p_ = nop_;
@@ -371,6 +372,7 @@
box_bkd_piter_<B>::box_bkd_piter_(const Point_Set<Ps>& ps)
: b_(ps.bbox())
{
+ mlc::assert_< mlc_is_a(B, Point_Set) >::check(); // FIXME: Add err msg.
nop_ = b_.pmin();
--nop_[0];
p_ = nop_;
Index: oln/core/internal/op_image_extended_by_nbh.hh
--- oln/core/internal/op_image_extended_by_nbh.hh (revision 952)
+++ oln/core/internal/op_image_extended_by_nbh.hh (working copy)
@@ -108,6 +108,8 @@
const nbh& impl_nbhood() const;
nbh& impl_nbhood();
+ operator I() const;
+
protected:
special_op_();
special_op_(I& ima, N& n);
@@ -150,6 +152,11 @@
namespace internal
{
+ template <typename I, typename N>
+ current::operator I() const
+ {
+ return this->image();
+ }
template <typename I, typename N>
current::special_op_()
Index: oln/core/internal/point_base.hh
--- oln/core/internal/point_base.hh (revision 952)
+++ oln/core/internal/point_base.hh (working copy)
@@ -97,8 +97,11 @@
vec_t& vec();
void set_all(const coord& c);
+ // FIXME: Add 'static const Exact& zero();'
+
protected:
point_base_();
+ point_base_(coord val);
vec_t v_;
};
Index: oln/core/internal/f_grid_to_window.hh
--- oln/core/internal/f_grid_to_window.hh (revision 0)
+++ oln/core/internal/f_grid_to_window.hh (revision 0)
@@ -0,0 +1,118 @@
+// 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 OLN_CORE_INTERNAL_F_GRID_TO_WINDOW_HH
+# define OLN_CORE_INTERNAL_F_GRID_TO_WINDOW_HH
+
+# include <oln/core/concept/grid.hh>
+# include <oln/core/gen/window.hh>
+
+
+#define oln_f_grid_to_window(G) typename oln::internal::f_grid_to_window_< G >::ret
+
+
+namespace oln
+{
+
+ /// \{
+ /// Forward declarations.
+
+ // Grid types.
+
+ struct grid1d;
+ struct grid2d;
+ struct grid2d_hex;
+ struct grid2d_tri;
+ struct grid3d;
+ // ...
+
+ // Dpoint types.
+ struct dpoint1d;
+ struct dpoint2d;
+ struct dpoint3d;
+ // ...
+
+ // Window types.
+
+ typedef gen_window<dpoint1d> window1d;
+ typedef gen_window<dpoint2d> window2d;
+ typedef gen_window<dpoint3d> window3d;
+ // ...
+
+ /// \}
+
+
+
+ namespace internal
+ {
+
+ // Fwd decl.
+
+ template <typename G> struct f_grid_to_;
+
+
+ /// \{
+ /// Definitions.
+
+ template <typename G>
+ struct grid_to_window__;
+
+ template <>
+ struct grid_to_window__< grid1d >
+ {
+ typedef window1d ret;
+ };
+
+ template <>
+ struct grid_to_window__< grid2d >
+ {
+ typedef window2d ret;
+ };
+
+ // FIXME: 2D hex/tri...
+
+ template <>
+ struct grid_to_window__< grid3d >
+ {
+ typedef window3d ret;
+ };
+
+ /// \}
+
+
+ template <typename G>
+ struct f_grid_to_window_ : private mlc::assert_< mlc_is_a(G, Grid) >,
+ public grid_to_window__< G >
+ {
+ };
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_GRID_TO_WINDOW_HH
Index: oln/core/internal/op_pset_such_as_fp2b.hh
--- oln/core/internal/op_pset_such_as_fp2b.hh (revision 952)
+++ oln/core/internal/op_pset_such_as_fp2b.hh (working copy)
@@ -209,7 +209,7 @@
{
public:
- pset_such_as_fp2b_fwd_piter_();
+ pset_such_as_fp2b_fwd_piter_(const op_<S, such_as, F>& pset);
pset_such_as_fp2b_fwd_piter_(const Point_Set< op_<S, such_as, F> >& pset);
void impl_start();
@@ -224,6 +224,13 @@
# ifndef OLN_INCLUDE_ONLY
template <typename S, typename F>
+ current::pset_such_as_fp2b_fwd_piter_(const op_<S, such_as, F>& pset)
+ : super(pset.adapted_()),
+ f_(pset.fun_())
+ {
+ }
+
+ template <typename S, typename F>
current::pset_such_as_fp2b_fwd_piter_(const Point_Set< op_<S, such_as, F> >& pset)
: super(exact(pset).adapted_()),
f_(exact(pset).fun_())
@@ -285,6 +292,7 @@
{
public:
+ pset_such_as_fp2b_bkd_piter_(const op_<S, such_as, F>& pset);
pset_such_as_fp2b_bkd_piter_(const Point_Set< op_<S, such_as, F> >& pset);
void impl_start();
@@ -299,6 +307,13 @@
# ifndef OLN_INCLUDE_ONLY
template <typename S, typename F>
+ current::pset_such_as_fp2b_bkd_piter_(const op_<S, such_as, F>& pset)
+ : super(pset.adapted_()),
+ f_(pset.fun_())
+ {
+ }
+
+ template <typename S, typename F>
current::pset_such_as_fp2b_bkd_piter_(const Point_Set< op_<S, such_as, F> >& pset)
: super(exact(pset).adapted_()),
f_(exact(pset).fun_())
Index: oln/core/internal/iterator_on_points_impl.hh
--- oln/core/internal/iterator_on_points_impl.hh (revision 952)
+++ oln/core/internal/iterator_on_points_impl.hh (working copy)
@@ -37,6 +37,22 @@
namespace internal
{
+ // base impl
+
+ template <typename Exact>
+ struct iterator_on_points_impl_base_
+ {
+ private:
+ stc_typename(point);
+ typedef typename point::vec_t vec_t;
+ public:
+ const vec_t& vec() const;
+ vec_t& vec();
+ };
+
+
+ // no-d impl is empty
+
template <unsigned n, typename Exact>
struct iterator_on_points_impl_
{
@@ -45,6 +61,8 @@
// 1d impl
template <typename Exact>
struct iterator_on_points_impl_< 1, Exact >
+ :
+ public iterator_on_points_impl_base_<Exact>
{
private:
stc_typename(coord);
@@ -55,6 +73,8 @@
// 2d impl
template <typename Exact>
struct iterator_on_points_impl_< 2, Exact >
+ :
+ public iterator_on_points_impl_base_<Exact>
{
private:
stc_typename(coord);
@@ -66,6 +86,8 @@
// 3d impl
template <typename Exact>
struct iterator_on_points_impl_< 3, Exact >
+ :
+ public iterator_on_points_impl_base_<Exact>
{
private:
stc_typename(coord);
@@ -77,6 +99,22 @@
# ifndef OLN_INCLUDE_ONLY
+ // base impl
+
+ template <typename Exact>
+ const typename iterator_on_points_impl_base_<Exact>::vec_t&
+ iterator_on_points_impl_base_<Exact>::vec() const
+ {
+ return static_cast<const Exact&>(*this).to_point().vec();
+ }
+
+ template <typename Exact>
+ typename iterator_on_points_impl_base_<Exact>::vec_t&
+ iterator_on_points_impl_base_<Exact>::vec()
+ {
+ return static_cast<const Exact&>(*this).to_point().vec();
+ }
+
// 1d impl
template <typename Exact>
Index: oln/core/internal/iterator_on_points_base.hh
--- oln/core/internal/iterator_on_points_base.hh (revision 952)
+++ oln/core/internal/iterator_on_points_base.hh (working copy)
@@ -69,6 +69,9 @@
: public Iterator_on_Points<Exact>,
public internal::iterator_on_points_impl_<mlc_value(stc_deferred(dim)), Exact>
{
+ public:
+ // Disambiguate.
+ stc_using_from(Iterator_on_Points, point);
protected:
iterator_on_points_base_();
};
Index: oln/core/internal/f_image_to_window.hh
--- oln/core/internal/f_image_to_window.hh (revision 0)
+++ oln/core/internal/f_image_to_window.hh (revision 0)
@@ -0,0 +1,37 @@
+// 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 OLN_CORE_INTERNAL_F_IMAGE_TO_WINDOW_HH
+# define OLN_CORE_INTERNAL_F_IMAGE_TO_WINDOW_HH
+
+# include <oln/core/internal/f_grid_to_window.hh>
+
+
+#define oln_f_image_to_window(I) oln_f_grid_to_window(oln_grid(I))
+
+
+#endif // ! OLN_CORE_INTERNAL_F_IMAGE_TO_WINDOW_HH
Index: oln/level/local.hh
--- oln/level/local.hh (revision 952)
+++ oln/level/local.hh (working copy)
@@ -68,7 +68,7 @@
const oln_point(I)& p)
{
f.init_with(input(p));
- oln_niter(I) n(p, input);
+ oln_niter(I) n(input, p);
for_all(n)
f(input(n));
return f.value();
@@ -85,7 +85,7 @@
f.init_with(input(p));
if (f.value() = true)
return true;
- oln_niter(I) n(p, input);
+ oln_niter(I) n(input, p);
for_all(n)
{
f(input(n)); // FIXME: Change to f.take(input(n))?
@@ -104,7 +104,7 @@
const oln_point(I)& p)
{
f.init_with(input(p));
- oln_niter(I) n(p, input);
+ oln_niter(I) n(input, p);
for_all(n)
{
f(input(n)); // FIXME: Change to f.take(input(n))?
Index: oln/level/clone.hh
--- oln/level/clone.hh (revision 952)
+++ oln/level/clone.hh (working copy)
@@ -50,11 +50,11 @@
// Generic version.
template <typename I>
- oln_plain(I) clone(const Image<I>& input)
+ oln_plain(I) clone_(const Image<I>& input)
{
oln_plain(I) output;
prepare(output, with, input);
- level::fill(output, input);
+ level::fill(inplace(output), input);
return output;
}
@@ -65,7 +65,7 @@
template <typename I>
oln_plain(I) clone(const Image<I>& input)
{
- return impl::clone(input);
+ return impl::clone_(input);
}
# endif // ! OLN_INCLUDE_ONLY
1
0
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
URL: https://svn.lrde.epita.fr/svn/oln/trunk/static
ChangeLog:
2007-04-17 Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Fix duplicated base bug and errors in morphers.
* mini-std.cc: Here.
mini-std.cc | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 167 insertions(+), 19 deletions(-)
Index: trunk/static/samples/mini-std/cpp2/mini-std.cc
===================================================================
- --- trunk/static/samples/mini-std/cpp2/mini-std.cc (revision 950)
+++ trunk/static/samples/mini-std/cpp2/mini-std.cc (revision 951)
@@ -363,6 +363,13 @@
struct switch_is_sorted;
template <typename Exact>
+ struct case_<switch_is_sorted, Exact, 1> :
+ public mlc::where_ < mlc::eq_< stc_find_type(Exact, is_sorted), stc::true_ > >
+ {
+ typedef SortedContainer<Exact> ret;
+ };
+
+ template <typename Exact>
struct default_case_<switch_is_sorted, Exact>
{
typedef Container<Exact> ret;
@@ -373,6 +380,13 @@
struct switch_is_unique;
template <typename Exact>
+ struct case_<switch_is_unique, Exact, 1> :
+ public mlc::where_ < mlc::eq_< stc_find_type(Exact, is_unique), stc::true_ > >
+ {
+ typedef UniqueContainer<Exact> ret;
+ };
+
+ template <typename Exact>
struct default_case_<switch_is_unique, Exact>
{
typedef Container<Exact> ret;
@@ -504,6 +518,34 @@
// Container base. //
// ---------------- //
+ // Sub-types used to avoid "duplicate base type" problems.
+ template <typename Exact>
+ struct container_base_is_sorted : public virtual switch_<switch_is_sorted, Exact>::ret
+ {};
+
+ template <typename Exact>
+ struct container_base_is_unique : public virtual switch_<switch_is_unique, Exact>::ret
+ {};
+
+ template <typename Exact>
+ struct container_base_is_mutable: public virtual switch_<switch_is_mutable, Exact>::ret
+ {};
+
+ template <typename Exact>
+ struct container_base_is_frontinsertion
+ : public virtual switch_<switch_is_frontinsertion, Exact>::ret
+ {};
+
+ template <typename Exact>
+ struct container_base_is_backinsertion
+ : public virtual switch_<switch_is_backinsertion, Exact>::ret
+ {};
+
+ template <typename Exact>
+ struct container_base_iterator_kind
+ : public virtual switch_<switch_iterator_kind, Exact>::ret
+ {};
+
// Forward declaration.
template <typename Exact> struct container_base;
@@ -537,10 +579,12 @@
};
template <typename Exact>
- - struct container_base : public virtual switch_<switch_is_sorted, Exact>::ret,
- - public virtual switch_<switch_is_frontinsertion, Exact>::ret,
- - public virtual switch_<switch_is_backinsertion, Exact>::ret,
- - public virtual switch_<switch_iterator_kind, Exact>::ret
+ struct container_base : public virtual container_base_is_sorted<Exact>,
+ public virtual container_base_is_unique<Exact>,
+ public virtual container_base_is_mutable<Exact>,
+ public virtual container_base_is_frontinsertion<Exact>,
+ public virtual container_base_is_backinsertion<Exact>,
+ public virtual container_base_iterator_kind<Exact>
{
typedef top<Exact> super;
@@ -680,14 +724,14 @@
current& operator--()
{
- - //iter_--;
+ iter_--;
return *this;
}
current operator--(int)
{
current ret = *this;
- - //--iter_;
+ --iter_;
return ret;
}
@@ -897,6 +941,76 @@
// Morphers. //
// ---------- //
+ // Iterators
+
+ // iterator_morpher_
+ template <typename Exact>
+ struct iterator_morpher_;
+
+ template <typename Exact>
+ struct super_trait_< iterator_morpher_<Exact> >
+ {
+ typedef Iterator<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct vtypes<iterator_morpher_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct iterator_morpher_ : public Iterator<Exact>
+ {
+ stc_typename(delegatee);
+
+ protected:
+ iterator_morpher_();
+ };
+
+
+ template <typename Iterator>
+ struct transform_morpher_iterator;
+
+ template <typename Iterator>
+ struct super_trait_<transform_morpher_iterator<Iterator> >
+ {
+ typedef iterator_morpher_<transform_morpher_iterator<Iterator> > ret;
+ };
+
+ template <typename Iterator>
+ struct vtypes<transform_morpher_iterator<Iterator> >
+ {
+ typedef Iterator delegatee;
+ };
+
+ template <typename Iterator>
+ struct transform_morpher_iterator : public iterator_morpher_<transform_morpher_iterator<Iterator> >
+ {
+ typedef iterator_morpher_<transform_morpher_iterator<Iterator> > super;
+ stc_using(delegatee);
+ stc_using(value_t);
+
+ typedef std::unary_function<value_t&,value_t> transform_t;
+
+ transform_morpher_iterator(delegatee& deleg, transform_t& trans) :
+ deleg_ (deleg),
+ trans_ (trans)
+ {
+ }
+
+ value_t& impl_op_star()
+ {
+ return (*trans_)(*(deleg_.iter_));
+ }
+
+ private:
+ delegatee& deleg_;
+ transform_t& trans_;
+ };
+
+
+ // Containers
+
// container_morpher_
template <typename Exact>
struct container_morpher_;
@@ -908,6 +1022,11 @@
};
template <typename Exact>
+ struct vtypes<container_morpher_<Exact> >
+ {
+ };
+
+ template <typename Exact>
struct container_morpher_ : public container_base<Exact>
{
stc_typename(delegatee);
@@ -918,22 +1037,43 @@
// transform_morpher
- - template <typename Exact>
+ template <typename Container>
struct transform_morpher;
- - template <typename Exact>
- - struct super_trait_< transform_morpher<Exact> >
+ template <typename Container>
+ struct super_trait_<transform_morpher<Container> >
{
- - typedef container_morpher_<Exact> ret;
+ typedef container_morpher_<Container> ret;
};
- - template <typename Exact>
- - struct transform_morpher : public container_morpher_<Exact>
+ template <typename Container>
+ struct vtypes<transform_morpher<Container> >
+ {
+ typedef Container delegatee;
+ typedef transform_morpher_iterator<typename Container::iter_t> iter_t;
+ };
+
+ template <typename Container>
+ struct transform_morpher : public container_morpher_<transform_morpher<Container> >
{
- - typedef container_morpher_<Exact> super;
+ typedef transform_morpher<Container> current;
+ typedef container_morpher_<Container> super;
+
stc_using(delegatee);
+ stc_using(value_t);
+
+ typedef std::unary_function<value_t&,value_t> transform_t;
+
+ transform_morpher(delegatee& d, transform_t& trans) :
+ container_morpher_<current>(),
+ deleg_ (d),
+ trans_ (trans)
+ {
+ }
- - // FIXME : le type d'it doit changer. (transform_it??)
+ protected:
+ delegatee& deleg_;
+ transform_t& trans_;
};
} // End of namespace mstd.
@@ -965,6 +1105,14 @@
{
}
+class transform : public std::unary_function<int&, int>
+{
+ int operator() (int& i)
+ {
+ return i + 1;
+ }
+};
+
int main()
{
// List
@@ -1035,10 +1183,10 @@
// Dummy<int> a;
// test(a);
- -}
- -
- -
- -
- -
+ // Morphers
+ transform t;
+ mstd::transform_morpher<mstd::list<int> > tm(l, t);
+ // mstd::transform_morpher_iterator< mstd::list<int>::iter_t > im(l, t);
+}
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGJPXe8QvmnUS5oeMRAg5bAJ9UoOf+kcCgPDjXYuTan3c5W8cCGgCgrA7v
jBlTy1bXWFO58pw/JFRSzk0=
=0zK1
-----END PGP SIGNATURE-----
1
0
950: Add a new class encoded_image_ in order to factorize code for rle_image and sparse_image. rle_image and sparse_image are know based on std::vector.
by Nicolas Ballas 17 Apr '07
by Nicolas Ballas 17 Apr '07
17 Apr '07
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add a new class encoded_image_ in order to factorize code for rle_image and sparse_image. rle_image and sparse_image are know based on std::vector.
* tests/core/sparse_image.cc,
* tests/core/rle_image.cc: Add new tests.
* oln/core/rle/rle_image.hh, oln/core/rle/rle_psite.hh,
* oln/core/rle/rle_pset.hh, oln/core/gen/sparse_encode.hh,
* oln/core/gen/rle_pset.hh, oln/core/gen/rle_psite.hh,
* oln/core/encode/sparse_encode.hh,
* oln/core/sparse/sparse_image.hh: Remove.
* oln/core/gen/rle_image.hh: rle_image is an encoded_image_.
* oln/core/gen/rle_encode.hh: Header inclusion modifcation.
* oln/core/gen/sparse_image.hh: sparse_image is an encoded_image,
and it is based on a std::vector.
* oln/core/internal/encoded_image.hh: New.
* oln/core/internal/encoded_image_psite.hh: New.
* oln/core/internal/encoded_image_pset.hh: New..
oln/core/gen/rle_encode.hh | 6
oln/core/gen/rle_image.hh | 45 --
oln/core/gen/sparse_encode.hh | 95 ++++++
oln/core/gen/sparse_image.hh | 138 ++++++++
oln/core/internal/encoded_image.hh | 108 ++++++
oln/core/internal/encoded_image_pset.hh | 488 +++++++++++++++++++++++++++++++
oln/core/internal/encoded_image_psite.hh | 83 +++++
tests/core/rle_image.cc | 27 +
tests/core/sparse_image.cc | 51 ++-
9 files changed, 983 insertions(+), 58 deletions(-)
Index: tests/core/sparse_image.cc
--- tests/core/sparse_image.cc (revision 949)
+++ tests/core/sparse_image.cc (working copy)
@@ -1,20 +1,41 @@
-#include <iostream>
-#include <oln/core/rle/rle_psite.hh>
#include <oln/core/2d/image2d.hh>
+#include <oln/core/gen/sparse_image.hh>
+#include <oln/core/gen/sparse_encode.hh>
#include <oln/debug/print.hh>
-#include <oln/core/rle/rle_pset.hh>
-#include <oln/core/sparse/sparse_image.hh>
-#include <oln/core/encode/sparse_encode.hh>
+
+
+
+#include <iostream>
+
+
+template <typename Pset>
+void test(const Pset& my_set)
+{
+ typename Pset::piter run (my_set);
+ for (run.start(); run.is_valid(); run.next())
+ ;
+ // std::cout << run << std::endl;
+
+ // std::cout << "Reverse" << std::endl;
+ typename Pset::bkd_piter run2 (my_set);
+
+ for (run2.start(); run2.is_valid(); run2.next())
+ ;
+ // std::cout << run2 << std::endl;
+}
int main()
{
oln::point2d p(0,1), q(2,2), r(3, 0);
- oln::image2d<int> ima2d (1, 5);
+ oln::internal::enc_image_pset_<oln::point2d> my_set;
oln::sparse_image<oln::point2d, int> sparse;
oln::sparse_image<oln::point2d, int> sparse2;
- ima2d(oln::point2d(0, 4)) = 5;
+
+ my_set.insert(p, 5);
+ my_set.insert(q, 8);
+ test(my_set);
std::vector<int> values;
int a =5;
@@ -23,10 +44,24 @@
values.push_back(a);
a = 42;
values.push_back(a);
-
sparse.insert(q, 3, values);
+// oln::debug::print(sparse);
+// std::cout << std::endl;
+
+ oln::image2d<int> ima2d (1, 5);
+
+
+
+ ima2d(oln::point2d(0, 4)) = 5;
+ ima2d(oln::point2d(0, 3)) = 2;
+
+// oln::debug::print(ima2d);
+
sparse2 = sparse_encode(ima2d);
+// oln::debug::print(sparse2);
+// std::cout << std::endl;
+
return 0;
}
Index: tests/core/rle_image.cc
--- tests/core/rle_image.cc (revision 949)
+++ tests/core/rle_image.cc (working copy)
@@ -1,28 +1,29 @@
#include <iostream>
#include <oln/core/2d/image2d.hh>
-#include <oln/core/gen/rle_psite.hh>
+
#include <oln/core/gen/rle_image.hh>
#include <oln/debug/print.hh>
-#include <oln/core/gen/rle_pset.hh>
#include <oln/core/gen/rle_encode.hh>
-template <typename P>
-void test(const oln::rle_pset<P>& my_set)
+template <typename Pset>
+void test(const Pset& my_set)
{
- typename oln::rle_pset<P>::piter run (my_set);
+ typename Pset::piter run (my_set);
for (run.start(); run.is_valid(); run.next())
- ;
+ /*std::cout << run << std::endl*/;
+
+ // std::cout << "Reverse" << std::endl;
- typename oln::rle_pset<P>::bkd_piter run2 (my_set);
+ typename Pset::bkd_piter run2 (my_set);
for (run2.start(); run2.is_valid(); run2.next())
- ;
+ /*std::cout << run2 << std::endl*/;
}
int main()
{
oln::point2d p(0,1), q(2,2), r(3, 0);
- oln::rle_pset<oln::point2d> my_set;
+ oln::internal::enc_image_pset_<oln::point2d> my_set;
oln::rle_image<oln::point2d, int> rle;
oln::rle_image<oln::point2d, int> rle2;
@@ -33,10 +34,18 @@
rle.insert(p, 5, 4);
rle.insert(q, 8, 9);
+// oln::debug::print(rle);
+// std::cout << std::endl;
+
oln::image2d<int> ima2d (1, 5);
ima2d(oln::point2d(0, 4)) = 5;
+// oln::debug::print(ima2d);
+
rle2 = rle_encode(ima2d);
+// oln::debug::print(rle2);
+// std::cout << std::endl;
+
return 0;
}
Index: oln/core/gen/sparse_encode.hh
--- oln/core/gen/sparse_encode.hh (revision 0)
+++ oln/core/gen/sparse_encode.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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 OLN_CORE_GEN_SPARSE_ENCODE_HH
+# define OLN_CORE_GEN_SPARSE_ENCODE_HH
+
+# include <oln/core/concept/image.hh>
+
+# include <oln/core/gen/sparse_image.hh>
+
+# include <vector>
+
+namespace oln
+{
+
+ /*!
+ ** encode a generic image to a sparse image format
+ **
+ ** @param input an Image
+ **
+ ** @return a sparse image
+ */
+ template <typename I>
+ sparse_image<typename I::point, typename I::value>
+ sparse_encode(const Image<I>& input)
+ {
+ sparse_image<typename I::point, typename I::value> output;
+ typename I::piter p(input.points());
+ unsigned len = 1;
+ /// old point first dim coordinate
+ typename I::coord old = 1;
+ /// range pointstart
+ typename I::point rstart;
+ /// range value
+ std::vector<typename I::value> values;
+
+ p.start();
+ if (!p.is_valid())
+ return output;
+
+ rstart = p;
+
+ // FIXME: is it generall ?
+ old = (p.to_point())[0];
+ values.push_back(input(p));
+ p.next();
+ while (p.is_valid())
+ {
+ if ((p.to_point())[0] - 1 == old)
+ {
+ ++len;
+ values.push_back(input(p));
+ }
+ else
+ {
+ output.insert(rstart, len, values);
+ rstart = p;
+ len = 1;
+ values.clear();
+ values.push_back(input(p));
+ }
+ old = (p.to_point())[0];
+ p.next();
+ }
+ output.insert(rstart, len, values);
+ return output;
+ }
+}
+
+#endif // !OLN_CORE_ENCODE_SPARSE_ENCODE_HH
Index: oln/core/gen/rle_image.hh
--- oln/core/gen/rle_image.hh (revision 949)
+++ oln/core/gen/rle_image.hh (working copy)
@@ -30,9 +30,7 @@
# include <vector>
-# include <oln/core/internal/image_base.hh>
-# include <oln/core/gen/rle_psite.hh>
-# include <oln/core/gen/rle_pset.hh>
+# include <oln/core/internal/encoded_image.hh>
@@ -47,7 +45,7 @@
struct super_trait_< rle_image<P, T> >
{
typedef rle_image<P, T> current;
- typedef internal::primitive_image_<current> ret;
+ typedef internal::encoded_image_<current> ret;
};
// Virtual types
@@ -61,29 +59,20 @@
typedef P point;
typedef typename P::coord coord;
- typedef rle_psite<P> psite;
+ typedef typename vtypes< internal::encoded_image_< rle_image<P, T> > >::pset pset__;
- typedef rle_pset<point> pset;
-
- typedef mlc::none plain;
-
- typedef std::pair< pset, std::vector< value > > data;
+ typedef std::pair< pset__, std::vector< value > > data;
};
- /*
- ** \class rle_image
- ** \brief rle image (use a pair of point range and value as representation)
- **
- */
+ // rle_image
template < typename P, typename T>
- class rle_image : public internal::primitive_image_< rle_image<P, T> >
+ class rle_image : public internal::encoded_image_< rle_image<P, T> >
{
typedef rle_image<P, T> current;
- typedef internal::primitive_image_< rle_image<P, T> > super;
+ typedef internal::encoded_image_<current> super;
public:
stc_using(pset);
- stc_using(box);
stc_using(point);
stc_using(value);
stc_using(rvalue);
@@ -93,10 +82,6 @@
rle_image();
-
- const pset& impl_points() const;
-
- bool impl_owns_(const psite& p) const;
void insert(const point& p, unsigned len, value val);
rvalue impl_read(const psite& p) const;
lvalue impl_read_write(const psite& p);
@@ -112,22 +97,6 @@
}
template <typename P, typename T>
- const typename rle_image<P, T>::pset&
- rle_image<P, T>::impl_points() const
- {
- assert(this->has_data());
- return this->data_->first;
- }
-
- template <typename P, typename T>
- bool
- rle_image<P, T>::impl_owns_(const typename rle_image<P, T>::psite& p) const
- {
- assert(this->has_data());
- return this->data_->first.has(p.start_);
- }
-
- template <typename P, typename T>
void
rle_image<P, T>::insert(const typename rle_image<P, T>::point& p,
unsigned len, rle_image<P, T>::value val)
Index: oln/core/gen/rle_encode.hh
--- oln/core/gen/rle_encode.hh (revision 949)
+++ oln/core/gen/rle_encode.hh (working copy)
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ENCODE_RLE_ENCODE_HH
-# define OLN_CORE_ENCODE_RLE_ENCODE_HH
+#ifndef OLN_CORE_GEN_RLE_ENCODE_HH
+# define OLN_CORE_GEN_RLE_ENCODE_HH
# include <oln/core/concept/image.hh>
@@ -81,4 +81,4 @@
}
} // end of namespace oln
-#endif /* !OLN_CORE_ENCODE_RLE_ENCODE_HH */
+#endif /* !OLN_CORE_GEN_RLE_ENCODE_HH */
Index: oln/core/gen/sparse_image.hh
--- oln/core/gen/sparse_image.hh (revision 0)
+++ oln/core/gen/sparse_image.hh (revision 0)
@@ -0,0 +1,138 @@
+// 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 OLN_CORE_GEN_SPARSE_IMAGE_HH
+# define OLN_CORE_GEN_SPARSE_IMAGE_HH
+
+
+# include <vector>
+
+# include <oln/core/internal/encoded_image.hh>
+
+
+
+namespace oln
+{
+ // Fwd decl.
+ template <typename P, typename T>
+ struct sparse_image;
+
+ // Super type.
+ template <typename P, typename T>
+ struct super_trait_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::encoded_image_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P, typename T>
+ struct vtypes< sparse_image<P, T> >
+ {
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef P point;
+ typedef typename P::coord coord;
+
+ typedef typename vtypes< internal::encoded_image_< sparse_image<P, T> > >::pset pset__;
+
+ typedef std::pair< pset__, std::vector <std::vector<value> > > data;
+ };
+
+ // sparse_image class
+ template < typename P, typename T>
+ class sparse_image : public internal::encoded_image_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::encoded_image_< current > super;
+
+ public:
+ stc_using(pset);
+ stc_using(point);
+ stc_using(value);
+ stc_using(rvalue);
+ stc_using(lvalue);
+ stc_using(psite);
+ stc_using(data);
+
+ sparse_image();
+
+ void insert(const point& p, unsigned len, const std::vector<value>& val);
+ rvalue impl_read(const psite& p) const;
+ lvalue impl_read_write(const psite& p);
+
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ sparse_image<P, T>::sparse_image()
+ {
+ this->data_ = new data;
+ }
+
+ template <typename P, typename T>
+ void
+ sparse_image<P, T>::insert(const point& p, unsigned len,
+ const std::vector<typename sparse_image<P, T>::value>& val)
+ {
+ assert(this->has_data());
+ this->data_->first.insert(p, len);
+ this->data_->second.push_back(val);
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::rvalue
+ sparse_image<P, T>::impl_read(const sparse_image<P, T>::psite& ps) const
+ {
+ assert(this->has_data() && ps.pset_pos_ < this->data_->second.size() &&
+ ps.index_ < this->data_->second[ps.pset_pos_].size());
+
+ return this->data_->second[ps.pset_pos_][ps.index_];
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::lvalue
+ sparse_image<P, T>::impl_read_write(const sparse_image<P, T>::psite& ps)
+ {
+ assert(this->has_data() && ps.pset_pos_ < this->data_->second.size() &&
+ ps.index_ < this->data_->second[ps.pset_pos_].size());
+
+ return this->data_->second[ps.pset_pos_][ps.index_];
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_GEN_SPARSE_IMAGE_HH
+
Index: oln/core/internal/encoded_image.hh
--- oln/core/internal/encoded_image.hh (revision 0)
+++ oln/core/internal/encoded_image.hh (revision 0)
@@ -0,0 +1,108 @@
+// 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 OLN_CORE_INTERNAL_ENCODED_IMAGE_HH
+# define OLN_CORE_INTERNAL_ENCODED_IMAGE_HH
+
+# include <vector>
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/encoded_image_psite.hh>
+# include <oln/core/internal/encoded_image_pset.hh>
+
+namespace oln
+{
+ // Fwd decl.
+ namespace internal { template <typename Exact> struct encoded_image_; }
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::encoded_image_<Exact> >
+ {
+ typedef internal::primitive_image_<Exact> ret;
+ };
+
+ // Virtual types
+ template <typename Exact>
+ struct vtypes< internal::encoded_image_<Exact> >
+ {
+ typedef stc_deferred(point) point__;
+ typedef internal::enc_image_psite_<point__> psite;
+ typedef internal::enc_image_pset_<point__> pset;
+ typedef mlc::none plain;
+ };
+
+
+ namespace internal
+ {
+ // encoded_image_
+ template <typename Exact>
+ class encoded_image_ : public primitive_image_< Exact >
+ {
+ typedef encoded_image_<Exact> current;
+ typedef primitive_image_< Exact > super;
+ public:
+ stc_using(pset);
+ stc_using(psite);
+ stc_using(data);
+
+ const pset& impl_points() const;
+ bool impl_owns_(const psite& p) const;
+ protected:
+ encoded_image_();
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ encoded_image_<Exact>::encoded_image_()
+ {
+ }
+
+ template <typename Exact>
+ const typename encoded_image_<Exact>::pset&
+ encoded_image_<Exact>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename Exact>
+ bool
+ encoded_image_<Exact>::impl_owns_(const typename encoded_image_<Exact>::psite& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first.has(p.start_);
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_ENCODED_IMAGE__HH
Index: oln/core/internal/encoded_image_psite.hh
--- oln/core/internal/encoded_image_psite.hh (revision 0)
+++ oln/core/internal/encoded_image_psite.hh (revision 0)
@@ -0,0 +1,83 @@
+// 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 OLN_CORE_INTERNAL_ENCODED_IMAGE_PSITE_HH
+# define OLN_CORE_INTERNAL_ENCODED_IMAGE_PSITE_HH
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ // psite for encoded images
+
+ template <typename P>
+ struct enc_image_psite_
+ {
+ enc_image_psite_();
+
+ P to_point() const;
+ operator P () const;
+
+ P start_;
+ unsigned index_;
+ unsigned pset_pos_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ enc_image_psite_<P>::enc_image_psite_()
+ {
+ }
+
+ template <typename P>
+ P
+ enc_image_psite_<P>::to_point() const
+ {
+ P p = this->start_;
+
+ p[0] += this->index_;
+ return p;
+ }
+
+ template <typename P>
+ enc_image_psite_<P>::operator P() const
+ {
+ return this->to_point();
+ }
+
+# endif /* !OLN_INCLUDE_ONLY */
+
+ } // end of namespace internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_ENCODED_IMAGE_PSITE_HH
Index: oln/core/internal/encoded_image_pset.hh
--- oln/core/internal/encoded_image_pset.hh (revision 0)
+++ oln/core/internal/encoded_image_pset.hh (revision 0)
@@ -0,0 +1,488 @@
+// 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 OLN_CORE_INTERNAL_ENCODED_IMAGE_PSET_HH
+# define OLN_CORE_INTERNAL_ENCODED_IMAGE_PSET_HH
+
+# include <vector>
+# include <utility>
+
+# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
+# include <oln/core/gen/fbbox.hh>
+# include <oln/core/internal/encoded_image_psite.hh>
+
+namespace oln
+{
+
+ // Forwards declaration
+ namespace internal
+ {
+ template <typename P> struct enc_image_pset_;
+ template <typename Exact> struct enc_image_pset_piter_;
+ template <typename P> struct enc_image_pset_fwd_piter_;
+ template <typename P> struct enc_image_pset_bkd_piter_;
+ }
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< internal::enc_image_pset_<P> >
+ {
+ typedef internal::enc_image_pset_<P> current;
+ typedef internal::point_set_base_<current> ret;
+ };
+
+ // Vtypes
+ template <typename P>
+ struct vtypes< internal::enc_image_pset_<P> >
+ {
+ typedef P point;
+
+ typedef typename oln::internal::f_point_to_box_< P >::ret box;
+ typedef internal::enc_image_pset_fwd_piter_<P> fwd_piter;
+ typedef internal::enc_image_pset_bkd_piter_<P> bkd_piter;
+ };
+
+ namespace internal
+ {
+
+ // pset for encoded image
+ template <typename P>
+ class enc_image_pset_ : public point_set_base_<enc_image_pset_ <P> >
+ {
+ typedef enc_image_pset_<P> current;
+ typedef point_set_base_< current > super;
+
+ public:
+ stc_using(point);
+ stc_using(box);
+
+ typedef std::vector<std::pair<point, unsigned> > std_container;
+
+ enc_image_pset_();
+
+ unsigned impl_npoints() const;
+ const box& impl_bbox() const;
+ void insert(const P& p, unsigned len);
+ bool impl_has(const P& p) const;
+ const std_container& con() const;
+
+ unsigned range_len_(const P& range_len_) const;
+
+ protected:
+ unsigned npts;
+
+ std_container con_; // FIXME: Add a &.
+ fbbox_<point> fb_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ enc_image_pset_<P>::enc_image_pset_() : npts(0)
+ {
+ }
+
+
+ template <typename P>
+ unsigned
+ enc_image_pset_<P>::impl_npoints() const
+ {
+ return npts;
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_<P>::insert(const P& p, unsigned len)
+ {
+ point pend;
+ typename std_container::value_type elt (p, len);
+
+ this->con_.push_back(elt);
+
+ //update bbox
+ fb_.take(p);
+ pend = p;
+ pend[0] += len - 1;
+ fb_.take(pend);
+ // update size
+ npts += len;
+ }
+
+ template <typename P>
+ const typename enc_image_pset_<P>::box&
+ enc_image_pset_<P>::impl_bbox() const
+ {
+ return fb_.box();
+ }
+
+ template <typename P>
+ bool
+ enc_image_pset_<P>::impl_has(const P& p) const
+ {
+ typename std_container::const_iterator irun;
+
+ for (irun = this->con_.begin(); irun != this->con_.end(); ++irun)
+ {
+ if (irun->first == p)
+ return true;
+ }
+ return false;
+ }
+
+ template <typename P>
+ const typename enc_image_pset_<P>::std_container&
+ enc_image_pset_<P>::con() const
+ {
+ return this->con_;
+ }
+
+ template <typename P>
+ unsigned
+ enc_image_pset_<P>::range_len_(const P& range_start) const
+ {
+ typename std_container::const_iterator irun;
+
+ for (irun = this->con_.begin(); irun != this->con_.end(); ++irun)
+ {
+ if (irun->first == range_start)
+ return irun->second;
+ }
+ assert(irun != this->con_.end());
+ return (irun->second);
+ }
+
+# endif // !OLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+ // end of enc_image_pset_ class
+
+
+
+
+
+ // iterators for class internal::enc_image_pset_<P>
+ // base class for factorizing code
+
+ // Super type
+ template <typename Exact>
+ struct super_trait_< internal::enc_image_pset_piter_<Exact> >
+ {
+ typedef internal::enc_image_pset_piter_<Exact> current;
+ typedef internal::iterator_on_points_base_<Exact> ret;
+ };
+
+
+ // Virtual types
+ template <typename Exact>
+ struct vtypes< internal::enc_image_pset_piter_<Exact> >
+ {
+ };
+
+ namespace internal
+ {
+ // class enc_image_pset__iterator_
+ template <typename Exact>
+ class enc_image_pset_piter_ : public iterator_on_points_base_< Exact >
+ {
+ typedef iterator_on_points_base_< Exact > super;
+ typedef enc_image_pset_piter_<Exact> current;
+ public:
+ stc_using(point);
+ typedef enc_image_psite_<point> psite;
+
+ const enc_image_psite_<point>& impl_to_psite() const;
+ point impl_to_point() const;
+ const enc_image_psite_<point>* impl_psite_adr() const;
+ operator psite () const;
+ const point* impl_point_adr() const; //FIXME
+
+ protected:
+ enc_image_pset_piter_(const enc_image_pset_<point>& con);
+
+ const typename enc_image_pset_<point>::std_container& con_;
+
+ point p_;
+ enc_image_psite_<point> ps_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ enc_image_pset_piter_<Exact>::enc_image_pset_piter_(const enc_image_pset_<typename enc_image_pset_piter_<Exact>::point>& cont) :
+ con_(cont.con())
+ {
+ }
+
+ template <typename Exact>
+ const enc_image_psite_<typename enc_image_pset_piter_<Exact>::point>&
+ enc_image_pset_piter_<Exact>::impl_to_psite() const
+ {
+ return ps_;
+ }
+
+ template <typename Exact>
+ typename enc_image_pset_piter_<Exact>::point
+ enc_image_pset_piter_<Exact>::impl_to_point() const
+ {
+ return ps_;
+ }
+
+ template <typename Exact>
+ enc_image_pset_piter_<Exact>::operator typename enc_image_pset_piter_<Exact>::psite () const
+ {
+ return this->impl_to_psite();
+ }
+
+ template <typename Exact>
+ const enc_image_psite_<typename enc_image_pset_piter_<Exact>::point>*
+ enc_image_pset_piter_<Exact>::impl_psite_adr() const
+ {
+ return &ps_;
+ }
+
+ template <typename Exact>
+ const typename enc_image_pset_piter_<Exact>::point*
+ enc_image_pset_piter_<Exact>::impl_point_adr() const
+ {
+ return &p_;
+ }
+ // end of class enc_image_pset__iterator_
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+
+
+
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< internal::enc_image_pset_fwd_piter_<P> >
+ {
+ typedef internal::enc_image_pset_fwd_piter_<P> current;
+ typedef internal::enc_image_pset_piter_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P>
+ struct vtypes< internal::enc_image_pset_fwd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ namespace internal
+ {
+ // class enc_image_pset__fwd_iterator_
+ template <typename P>
+ class enc_image_pset_fwd_piter_ : public enc_image_pset_piter_<enc_image_pset_fwd_piter_<P> >
+ {
+ typedef enc_image_pset_piter_< enc_image_pset_fwd_piter_<P> > super;
+ typedef enc_image_pset_fwd_piter_<P> current;
+ public:
+ stc_using(point);
+
+ enc_image_pset_fwd_piter_(const enc_image_pset_<P>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+
+ protected:
+ typename enc_image_pset_<point>::std_container::const_iterator it_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ enc_image_pset_fwd_piter_<P>::enc_image_pset_fwd_piter_(const enc_image_pset_<P>& cont) :
+ super(cont)
+ {
+ this->it_ = this->con_.end();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_fwd_piter_<P>::impl_start()
+ {
+ this->it_ = this->con_.begin(); // FIXME: Test if (this->it_ != this->con_.end())...
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = 0;
+ this->ps_.pset_pos_ = 0;
+ this->p_ = this->ps_.start_;
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_fwd_piter_<P>::impl_next()
+ {
+ precondition(this->is_valid());
+
+ ++this->ps_.index_;
+
+ if (this->ps_.index_ >= this->it_->second)
+ {
+ ++this->it_;
+ ++this->ps_.pset_pos_;
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = 0;
+ }
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_fwd_piter_<P>::impl_invalidate()
+ {
+ this->it_ = this->con_.end();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ bool
+ enc_image_pset_fwd_piter_<P>::impl_is_valid() const
+ {
+ return this->it_ != this->con_.end();
+ }
+# endif // ! OLN_INCLUDE_ONLY
+
+ // end of class enc_image_pset__fwd_iterator_
+
+ } // end of namespace internal
+
+
+
+
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< internal::enc_image_pset_bkd_piter_<P> >
+ {
+ typedef internal::enc_image_pset_bkd_piter_<P> current;
+ typedef internal::enc_image_pset_piter_<current> ret;
+ };
+
+ // Virtual type
+ template <typename P>
+ struct vtypes< internal::enc_image_pset_bkd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ namespace internal
+ {
+ // enc_image_pset_bkd_piter_
+ template <typename P>
+ class enc_image_pset_bkd_piter_ : public enc_image_pset_piter_<enc_image_pset_bkd_piter_<P> >
+ {
+ typedef enc_image_pset_piter_< enc_image_pset_bkd_piter_<P> > super;
+ typedef enc_image_pset_bkd_piter_<P> current;
+ public:
+ stc_using(point);
+
+ enc_image_pset_bkd_piter_(const enc_image_pset_<P>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+
+ protected:
+ typename enc_image_pset_<point>::std_container::const_reverse_iterator it_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ enc_image_pset_bkd_piter_<P>::enc_image_pset_bkd_piter_(const enc_image_pset_<P>& cont) :
+ super(cont)
+ {
+ this->it_ = this->con_.rend();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_bkd_piter_<P>::impl_start()
+ {
+ this->it_ = this->con_.rbegin(); // FIXME: Test if (this->it_ != this->con_.rend())...
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = this->it_->second - 1;
+ this->ps_.pset_pos_ = this->con_.size() - 1;
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_bkd_piter_<P>::impl_next()
+ {
+ precondition(this->is_valid());
+
+ --(this->ps_.index_);
+
+ if (this->ps_.index_ + 1 == 0)
+ {
+ ++this->it_;
+ --this->ps_.pset_pos_;
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = this->it_->second - 1;
+ }
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ enc_image_pset_bkd_piter_<P>::impl_invalidate()
+ {
+ this->it_ = this->con_.rend();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ bool
+ enc_image_pset_bkd_piter_<P>::impl_is_valid() const
+ {
+ return this->it_ != this->con_.rend();
+ }
+# endif // ! OLN_INCLUDE_ONLY
+
+ // end of class enc_image_pset_bkd_piter_
+
+ } // end of namespace internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_ENCODED_IMAGE_PSET_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make 'inplace' mandatory and start a tour.
* doc: New directory.
* doc/tour: New sub-directory.
* doc/tour/tour1_extra.cc: New.
* doc/tour/tour1.cc: New.
* tests/core/image1d.cc: Remove unused decl and update.
* tests/core/image2d.cc: Use namespace.
* tests/core/image3d.cc: Update.
* tests/algorithms/basic_morpho.cc: Remove hack.
Update includes.
* oln/debug/print.hh (print_1D): New.
* tests/core/stack.cc,
* tests/algorithms/fill.cc,
* oln/debug/iota.hh,
* oln/draw/bresenham.hh,
* oln/level/fill.hh,
* oln/level/clone.hh,
* oln/level/apply_inplace.hh: Update.
* oln/core/1d/image1d.hh (prepare): New.
* oln/core/1d/image1d_b.hh (prepare): New.
* oln/core/internal/symmetrical_window.hh: New.
* oln/core/internal/window.hh (impl_take): New.
(take): Call impl_take.
* oln/core/2d/vline2d.hh,
* oln/core/2d/hline2d.hh,
* oln/core/2d/rectangle2d.hh: Update.
* oln/core/2d/neighb2d.hh: Add FIXMEs.
* oln/core/gen/inplace.hh (inplace): New overload.
* oln/core/concept/image.hh (is_empty): New in Image.
(min_ind, max_ind, ninds): New in Image_1D.
* oln/core/concept/function.hh: Remove obsolete commented code.
* oln/core/concept/image_identity.hh: Cosmetic change.
* oln/core/internal/image_selectors.hh (Image_dimension): Handle
1D and 3D cases.
* oln/core/internal/image_base.hh (impl_is_empty): New.
* oln/core/internal/op_image_extended_by_nbh.hh (init_): New
overload.
(init_): Unconst nbh in the Neighborhood version.
* oln/core/internal/special_op.hh: Cosmetic change.
* oln/morpho/cc_tarjan.hh: Fix.
doc/tour/tour1.cc | 322 ++++++++++++++++++++++++++
doc/tour/tour1_extra.cc | 212 +++++++++++++++++
oln/core/1d/image1d.hh | 26 ++
oln/core/1d/image1d_b.hh | 17 +
oln/core/2d/hline2d.hh | 14 -
oln/core/2d/neighb2d.hh | 2
oln/core/2d/rectangle2d.hh | 15 -
oln/core/2d/vline2d.hh | 14 -
oln/core/concept/function.hh | 48 ---
oln/core/concept/image.hh | 43 +++
oln/core/gen/inplace.hh | 14 +
oln/core/internal/image_base.hh | 9
oln/core/internal/image_selectors.hh | 24 +
oln/core/internal/op_image_extended_by_nbh.hh | 17 +
oln/core/internal/special_op.hh | 4
oln/core/internal/symmetrical_window.hh | 111 ++++++++
oln/core/internal/window.hh | 17 +
oln/debug/iota.hh | 19 +
oln/debug/print.hh | 39 +++
oln/draw/bresenham.hh | 27 +-
oln/level/apply_inplace.hh | 23 -
oln/level/clone.hh | 4
oln/level/fill.hh | 68 +----
oln/morpho/cc_tarjan.hh | 8
tests/algorithms/basic_morpho.cc | 14 -
tests/algorithms/fill.cc | 2
tests/core/image1d.cc | 5
tests/core/image2d.cc | 20 -
tests/core/image3d.cc | 24 -
tests/core/stack.cc | 3
30 files changed, 977 insertions(+), 188 deletions(-)
Index: tests/core/stack.cc
--- tests/core/stack.cc (revision 948)
+++ tests/core/stack.cc (working copy)
@@ -45,7 +45,8 @@
typedef image2d<int> I;
I ima_0(3, 3), ima_1(3, 3);
- level::fill(stack(ima_0, ima_1).inplace(), coords);
+ image_stack<2,I> ima = stack(ima_0, ima_1);
+ level::fill(inplace(ima), coords);
{
I::piter p(ima_0.points());
for_all(p)
Index: tests/core/image1d.cc
--- tests/core/image1d.cc (revision 948)
+++ tests/core/image1d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -38,7 +38,6 @@
// Fill a 1D image using its iterator.
image1d<char> ima1(3);
- image1d<char>::box box1 = ima1.points();
image1d<char>::piter p1 (ima1.points());
for_all(p1)
ima1(p1) = 1;
@@ -50,7 +49,7 @@
// Fill a 1D image using the routine level::fill.
image1d<long> ima3(ima1.points());
- level::fill(ima3, 3);
+ level::fill(inplace(ima3), 3);
// Add the three images.
Index: tests/core/image2d.cc
--- tests/core/image2d.cc (revision 948)
+++ tests/core/image2d.cc (working copy)
@@ -28,34 +28,34 @@
/// Test oln::image2d.
#include <cassert>
-// FIXME: We should not include oln/basics2d.hh, but
-// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?).
#include <oln/core/2d/image2d.hh>
#include <oln/level/fill.hh>
int
main()
{
+ using namespace oln;
+
// Fill a 2D image using its iterator.
- oln::image2d<char> ima1(3, 3);
- oln::image2d<char>::piter p1(ima1.points());
+ image2d<char> ima1(3, 3);
+ image2d<char>::piter p1(ima1.points());
for_all(p1)
ima1(p1) = 1;
// Fill a 2D image using a classic loop.
- oln::image2d<int> ima2(ima1.points());
+ image2d<int> ima2(ima1.points());
for (unsigned i = 0; i < 3; ++i)
for (unsigned j = 0; j < 3; ++j)
ima2.at(i, j) = 2;
- // Fill a 2D image using the routine oln::level::fill.
- oln::image2d<long> ima3(ima1.points());
- oln::level::fill(ima3, 3);
+ // Fill a 2D image using the routine level::fill.
+ image2d<long> ima3(ima1.points());
+ level::fill(inplace(ima3), 3);
// Add the three images.
- oln::image2d<long> sum(ima1.points());
- oln::image2d<long>::piter p(sum.points());
+ image2d<long> sum(ima1.points());
+ image2d<long>::piter p(sum.points());
for_all(p)
sum(p) = ima1(p) + ima2(p) + ima3(p);
// And check the sum.
Index: tests/core/image3d.cc
--- tests/core/image3d.cc (revision 948)
+++ tests/core/image3d.cc (working copy)
@@ -28,35 +28,35 @@
/// Test oln::image3d.
#include <cassert>
-// FIXME: We should not include oln/basics3d.hh, but
-// oln/core/3d/image3d.hh (and oln/core/3d/neigh3d.hh ?).
-#include <oln/basics3d.hh>
+#include <oln/core/3d/image3d.hh>
#include <oln/level/fill.hh>
int
main()
{
+ using namespace oln;
+
// Fill a 3D image using its iterator.
- oln::image3d<char> ima1(3, 3, 3);
- oln_vtype_(oln::image3d<char>, piter) p1(ima1.topo());
+ image3d<char> ima1(3, 3, 3);
+ image3d<char>::piter p1(ima1.points());
for_all(p1)
ima1(p1) = 1;
// Fill a 3D image using a classic loop.
- oln::image3d<int> ima2(ima1.topo());
+ image3d<int> ima2(ima1.points());
for (unsigned i = 0; i < 3; ++i)
for (unsigned j = 0; j < 3; ++j)
for (unsigned k = 0; k < 3; ++k)
- ima2(oln::point3d(i, j, k)) = 2;
+ ima2.at(i, j, k) = 2;
- // Fill a 3D image using the routine oln::level::fill.
- oln::image3d<long> ima3(ima1.topo());
- oln::level::fill(ima3, 3);
+ // Fill a 3D image using the routine level::fill.
+ image3d<long> ima3(ima1.points());
+ level::fill(inplace(ima3), 3);
// Add the three images.
- oln::image3d<long> sum(ima1.topo());
- oln_vtype_(oln::image3d<long>, piter) p(sum.topo());
+ image3d<long> sum(ima1.points());
+ image3d<long>::piter p(sum.points());
for_all(p)
sum(p) = ima1(p) + ima2(p) + ima3(p);
// And check the sum.
Index: tests/algorithms/basic_morpho.cc
--- tests/algorithms/basic_morpho.cc (revision 948)
+++ tests/algorithms/basic_morpho.cc (working copy)
@@ -1,8 +1,12 @@
#include <oln/core/2d/image2d.hh>
-#include <oln/core/2d/window2d.hh>
#include <oln/core/2d/neighb2d.hh>
+#include <oln/core/2d/window2d.hh>
+#include <oln/core/2d/rectangle2d.hh>
+#include <oln/core/2d/hline2d.hh>
+#include <oln/core/2d/vline2d.hh>
+
#include <oln/morpho/elementary_dilation.hh>
#include <oln/morpho/elementary_erosion.hh>
@@ -40,13 +44,13 @@
for_all(p1)
ima(p1) = i++ % 2;
- my_test( (morpho::elementary_erosion(ima + c4)).image(), 0);
+ my_test( morpho::elementary_erosion(ima + c4), 0);
- my_test( (morpho::elementary_dilation(ima + c4)).image(), 1 );
+ my_test( morpho::elementary_dilation(ima + c4), 1 );
- my_test( (morpho::elementary_opening(ima + c4)).image(), 0);
+ my_test( morpho::elementary_opening(ima + c4), 0);
- my_test( (morpho::elementary_closing(ima + c4)).image(), 1);
+ my_test( morpho::elementary_closing(ima + c4), 1);
my_test( morpho::erosion(ima, win3x3), 0);
Index: tests/algorithms/fill.cc
--- tests/algorithms/fill.cc (revision 948)
+++ tests/algorithms/fill.cc (working copy)
@@ -38,7 +38,7 @@
using namespace oln;
typedef image2d<int> image_t;
image_t ima(3, 3);
- level::fill(ima, 51);
+ level::fill(inplace(ima), 51);
image_t::piter p(ima.points());
for_all(p)
assert(ima(p) = 51);
Index: doc/tour/tour1_extra.cc
--- doc/tour/tour1_extra.cc (revision 0)
+++ doc/tour/tour1_extra.cc (revision 0)
@@ -0,0 +1,212 @@
+// 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: tour1_extra.cc.
+
+#include <oln/core/1d/image1d.hh>
+#include <oln/arith/plus.hh>
+
+
+int main()
+{
+ using namespace oln;
+
+
+ // Let us take a few examples to illustrate how images and data are
+ // managed. In these examples, we will use the notion of "block of
+ // instructions" from the C/C+ languages: "{" ... "}".
+
+
+
+
+ // Example 1:
+
+ { // A new block starts here.
+
+ image1d<float> local_ima(1000);
+ // A non-empty image is created; a memory buffer automatically is
+ // allocated to store image data. Some code using 'local_ima' can
+ // be inserted here...
+
+ } // The block ends and 'local_ima' is not more accessible.
+
+ // At the end of the block, since the user cannot use 'local_ima'
+ // anymore, the memory is automatically deallocated.
+
+
+
+
+ // Example 2:
+
+ image1d<float> ima; // An empty image---a variable.
+
+ { // A new block.
+
+ image1d<float> local_ima(1000); // A non-empty image.
+ // Some work is performed with 'local_ima' here.
+ // ...
+ ima = local_ima; // Last, we state that ima IS local_ima.
+
+ } // End of the block: 'local_ima' is no more accessible.
+
+ assert(not ima.is_empty()); // We test that 'ima' is no more empty.
+
+ // Since we state that "ima IS local_ima" and since 'ima' is still
+ // accessible by the user, the contents of 'local_ima' is preserved.
+
+ // Conversely to the example 1, the memory allocated for 'local_ima'
+ // is thus NOT deallocated: the data of 'local_ima' is "transfered"
+ // to 'ima'. There is NO data "copy" involved during this transfer
+ // so it is fast and it saves memory.
+
+
+
+
+ // Example 3:
+
+ {
+ image1d<int> orig(5); // An original image.
+ for (int i = 0; i < 5; ++i)
+ orig(i) = i;
+ debug::println(orig);
+ // 0 1 2 3 4
+
+ image1d<int> ima = orig; // 'ima' is 'orig'.
+ ima = ima + ima; // Point-wise sum of ima and itself.
+ debug::println(ima);
+ // 0 2 4 6 8
+
+ debug::println(orig);
+ // 0 1 2 3 4
+ }
+
+ // To explain this result, let us detail the point-wise sum line.
+ // The assignment "ima = ima + ima" is a two-step process: first
+ // "ima + ima" is computed, then the assignment is performed. This
+ // line can be rewritten as:
+
+ // image1d<int> anon = ima + ima; // line (a)
+ // ima = anon; // line (b)
+
+ // where 'anon' is the "anonymous" result of the sum. We can see
+ // that 'ima' is used in line (a) to compute a new image, namely
+ // 'anon'. At that precise line, 'ima' still designates 'orig'. At
+ // line (b) the definition of 'ima' changes: 'ima' was designating
+ // 'orig', now it designates 'anon', that is, the sum result.
+ // Eventually the data of 'orig' have never changed since it has
+ // been initialized.
+
+ // In this example, two images with effective data have been
+ // created: the sum result, which is accessible through 'ima', and
+ // 'orig'.
+
+ // The same explanation in pictures. When the sum "ima + ima" is
+ // computed, the images and their data look like:
+ //
+ // +-----------+
+ // orig --> | 0 1 2 3 4 |
+ // +-----------+
+ // ^
+ // ima ______|
+ //
+ // +-----------+
+ // anon --> | 0 2 4 6 8 |
+ // +-----------+
+ //
+ // Then the assignment modifies this scheme into:
+ //
+ // +-----------+
+ // orig --> | 0 1 2 3 4 |
+ // +-----------+
+ // ima ______
+ // |
+ // v
+ // +-----------+
+ // anon --> | 0 2 4 6 8 |
+ // +-----------+
+ //
+ // and the temporary 'anon' disapears.
+
+
+
+
+
+ // Example 4:
+
+ {
+ image1d<int> ima(5);
+ for (int i = 0; i < 5; ++i)
+ ima(i) = i;
+ debug::println(ima);
+ // 0 1 2 3 4
+
+ ima = ima + ima;
+ debug::println(ima);
+ // 0 2 4 6 8
+ }
+
+ // Let us re-write the assignment line:
+
+ // image1d<int> anon = ima + ima; // line (a)
+ // ima = anon; // line (b)
+
+ // A new image, 'anon', is created to store the sum result; this
+ // image is just like a temporary object since it is anonymous. In
+ // line (a) the definition of 'ima' changes: it was the original
+ // image with its data being "0 1 2 3 4" and it now designates the
+ // sum result. The original data becomes inaccessible by the user
+ // so it is automatically deallocated.
+
+ // The same explanation In pictures. After the sum is computed, we
+ // have:
+ // +-----------+
+ // ima ---> | 0 1 2 3 4 |
+ // +-----------+
+ //
+ // +-----------+
+ // anon --> | 0 2 4 6 8 |
+ // +-----------+
+ //
+ // and the assignment of 'ima' leads to:
+ //
+ // +-----------+
+ // ima | 0 1 2 3 4 |
+ // | +-----------+
+ // |_________
+ // |
+ // v
+ // +-----------+
+ // anon --> | 0 2 4 6 8 |
+ // +-----------+
+ //
+ // so the original data, which is unreachable, are deallocated and
+ // the temporary 'anon' disappears; we end up with:
+ //
+ // +-----------+
+ // ima ---> | 0 2 4 6 8 |
+ // +-----------+
+}
Index: doc/tour/tour1.cc
--- doc/tour/tour1.cc (revision 0)
+++ doc/tour/tour1.cc (revision 0)
@@ -0,0 +1,322 @@
+w// Copyright (C) 2001, 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: tour1.cc.
+
+#include <oln/core/1d/image1d.hh>
+
+#include <oln/arith/plus.hh> // arith
+
+#include <oln/level/fill.hh> // level
+#include <oln/level/paste.hh>
+
+#include <oln/debug/println.hh> // debug
+
+
+int main()
+{
+ // Olena is organized in a namespace hierarchy. Everything is
+ // declared by Olena within the 'oln::' namespace, and possibly a
+ // sub-namespace such as 'oln::arith::' (arithmetic operations on
+ // images), 'oln::morpho::' (morphological operations), etc. For
+ // the sake of simplicity, we will neglect the 'oln::' prefix in
+ // this file.
+
+ using namespace oln;
+
+ // There are three kinds of image dimensions supported for the
+ // moment: 1D, 2D, and 3D. The respective basic image types are
+ // respectively image1d, image2d, and image3d. All are template'd,
+ // parametrized by the kind of value associated to each point.
+ //
+ // We will start to use the 1D images, because there are less values
+ // to assign (!) and because they are easy to display. Although we
+ // will be in 1D, we will talk about "points" and "pixels", just
+ // like in the classical 2D world.
+
+ // Here are the two most basic ways to build an image:
+
+ image1d<int> img1a; // which builds an empty image;
+ image1d<int> img1b(20); // which builds an image with 20 pixels.
+
+ // The type of values enclosed in those images is 'int' for
+ // integers.
+
+ // The empty image has no data and its definition domain is still
+ // unset. We do not know yet the number of pixels it contains.
+ // However, it is really useful to have such an "empty image"
+ // because it is a placeholder for the result of some processing, or
+ // another image.
+
+ // Trying to access the pixel value from an empty image leads to an
+ // error at run-time.
+
+ // Assigning an image to another one is NOT a costly operation.
+ // Actually img1a behaves like some mathematical variable. Put
+ // differently it is just a name to designate an image. After the
+ // following instruction
+
+ img1a = img1b;
+
+ // Both variables img1a and img1b can be used equivalently to access
+ // the same data. Just like in maths we can state that "img1a IS
+ // img2b" and we only have ONE actual image in memory. The image
+ // definition---its domain and its pixel values--is shared by img1a
+ // AND img1b.
+
+
+ // Since an image is a function that maps values to points, to read
+ // or modify a pixel value, we just the same notation than the one
+ // of functions:
+
+ img1a(0) = 7; // Assign value 7 to the 1st pixel of img1a.
+ img1a(10) = 51; // Assign value 51 to the 11th pixel of img1a.
+
+ std::cout << "img1b(10) = " << img1b(10)
+ << std::endl; // Print 51 since img1b is img1a.
+
+ // As you can see, Olena provides a unique easy syntax to access an
+ // image value, whatever we want to read this value or to modify it:
+ // "ima(p)", where p is a variable that represents a point of the 1D
+ // domain. In "val = ima(p)" we read the pixel value, whereas in
+ // "ima(p) = new_val" we write in an image. For 1D images, a 1D
+ // point behaves just like an index so the user can write "ima(i)"
+ // with i being an integer.
+
+
+ // A single image variable can be used to designate one image and
+ // then another one.
+
+ image1d<int> img2a(20); // An image (not empty).
+ image1d<int> img2b(20); // Another one (not empty).
+ image1d<int> img; // A variable.
+
+ img = img2a; // img is img2a
+ img(5) = 19; // so img2a(5) is set to 19.
+
+ img = img2b; // img is NOW img2b
+ img(5) = 69; // so img2b(5) is set to 69.
+
+ std::cout << (100 * img2a(5) + img2b(5)) // Gives 1969.
+ << std::endl;
+
+
+
+ // In the Olena library, all image types behave like image1d:
+ //
+ // +-----------------------------------------------------------+
+ // | |
+ // | - an "empty" image actually is a mathematical variable |
+ // | |
+ // | => just think in a mathemetical way when dealing |
+ // | with images; |
+ // | |
+ // | |
+ // | - no dynamic memory allocation/deallocation is required |
+ // | |
+ // | the user never has to use "new / delete" (the C++ |
+ // | equivalent for the C "malloc / free") so she does |
+ // | not have to manipulate pointers or to directly |
+ // | access memory |
+ // | |
+ // | => Olena prevents the user from making mistakes; |
+ // | |
+ // | |
+ // | - image data/values can be shared between several |
+ // | variables and the memory used for image data is |
+ // | handled by the library |
+ // | |
+ // | => memory management is automatic. |
+ // | |
+ // | |
+ // +-----------------------------------------------------------+
+
+
+
+
+ image1d<char> img3a(0, 19); // These 1D image data go from the
+ // index 0 to the index 19; it thus has
+ // 20 points.
+
+ // Memory has been allocated so data can be stored but pixel values
+ // have not been initialized yet. So we fill img3a, that is, all
+ // pixels of img3a, with the value 'a':
+ level::fill(inplace(img3a), 'a');
+
+ // The "fill" algorithm is located in the sub-namespace "level"
+ // since this algorithm deals with the "level" of pixel values.
+
+ // Note that the term "level" refers to the fact that an
+ // image can be considered as a landscape where the
+ // elevation at a particular location/point is given by the
+ // corresponding pixel value.
+
+ // The full name of this routine is "oln::level::fill". To access
+ // to a particular algorithm, the proper file shall be included.
+ // The file names of algorithms strictly map their C++ name; so
+ // oln::level::fill is defined in the file "oln/level/fill.hh".
+
+ // Most algorithms in Olena are constructed following the classical
+ // scheme: "output algo(input)", where the input image is only read.
+ // However some few algorithms take an input image in order to
+ // modify it. To enforce this particular feature, the user shall
+ // explicitly state that the image is provided so that its data is
+ // modified "inplace".
+
+ // The algorithm call shall be "level::fill(inplace(ima), val)".
+ // When forgetting the "inplace(..)" statement it does not compile.
+
+
+ // We then define below a second image to play with. As you can see
+ // this image has data for the indices 5 to 14 (so it has 10
+ // points). The definition domain of a 1D image can start from
+ // any index, even a negative one.
+ image1d<char> img3b(5, 14);
+
+ // We initialize the image values.
+ level::fill(inplace(img3b), 'b');
+
+ // Last we now paste the contents of img3b in img3a...
+ level::paste(img3b, inplace(img3a));
+
+ // ...and print the result.
+ debug::println(img3a);
+
+ // Before pasting, the couple of images looked like:
+ //
+ // index = 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
+ //
+ // img3a = a a a a a a a a a a a a a a a a a a a a
+ // img3b = b b b b b b b b b b
+ //
+ // so after pasting we get:
+ // img3a = a a a a a b b b b b b b b b b a a a a a
+ //
+ // Just remember that a point is an absolute location on the
+ // discrete domain. For the 1D case, an index is thus NOT an
+ // offset. When we write "imgb(5)", we designate the first pixel of
+ // imgb since this image starts at index 5.
+
+
+ // With this simple example we can see that images defined on
+ // different domains (or set of points) can interoperate. The set
+ // of points an image is defined on can be accessed and printed.
+ // The following code:
+
+ std::cout << "img3a.points() = " << img3a.points() << std::endl
+ << "img3b.points() = " << img3b.points() << std::endl;
+
+ // gives:
+ // img3a.points() = { (0) .. (19) }
+ // img3b.points() = { (5) .. (14) }
+
+ // The notion of point sets plays an inportant role in Olena. Many
+ // tests are performed at run-time to ensure that the program is
+ // correct.
+
+ // For instance, the algorithm level::paste tests that the set of
+ // points of img3b (whose values are to be pasted) is a subset of
+ // the destination image. We can reproduce this same test:
+
+ std::cout << (img3b.points() <= img3a.points() ?
+ "true" :
+ "false") << std::endl; // which gives 'true'.
+
+ // Accessing the value of an image at a given point also performs a
+ // test to make sure that this point belongs to the image domain
+ // (and consequently that data access in memory is valid). For
+ // instance, calling "img3a(9)" actually runs a code equivalent to
+ // this test:
+
+ point1d p = 9;
+ std::cout << (img3a.points().has(p) ?
+ "true" :
+ "false") << std::endl; // which gives 'true'.
+
+ // The type of 1D image points is "point1d". The 1D image type
+ // features the method "operator()(point1d p)"; when we write
+ // "img3a(9)" it is just a shortcut for "img3a( point1d(9) )".
+
+ // When having a point we can access its index following:
+ std::cout << p.ind() << std::endl; // which gives 9.
+
+ // To know if a point belongs to an image domain or not, we can run
+ // this shorter test:
+ std::cout << (img3a.has(p) ?
+ "true" :
+ "false") << std::endl; // which gives 'true'.
+
+
+ // Since the notion of point is independent from the image it
+ // applies on, we can form expressions where p is used on several
+ // images:
+
+ img3a(p) = 'M', img3b(p) = 'W'; // At index 9, both values change.
+ debug::println(img3a);
+ debug::println(img3b);
+ // we obtain:
+ // a a a a a b b b b M b b b b b a a a a a
+ // b b b b W b b b b b
+
+
+ // To modify all the values of an image we can iterate over its
+ // domain with an index i:
+
+ for (int i = 5; i <= 14; ++i)
+ img3b(i) = 'a' + i - 5;
+ debug::println(img3b);
+ // a b c d e f g h i j
+
+ // There is a safer way to iterate that avoids to provide a wrong
+ // value for the minimum or maximum index value:
+ for (int i = img3b.min_ind(); i <= img3b.max_ind(); ++i)
+ img3b(i) = 'b' + i - img3b.min_ind();
+ debug::println(img3b);
+ // b c d e f g h i j k
+
+
+ // The Olena library was built with the following rationale:
+ //
+ // +-----------------------------------------------------------+
+ // | |
+ // | If you do not want to be "generic", if you are used to |
+ // | the classical way of browsing pixel values, you can! |
+ // | |
+ // +-----------------------------------------------------------+
+
+
+ // Indeed, the loops above depict the "classical" way to iterate
+ // over the contents of a 1D image. The next tour file explains
+ // the solution provided by Olena to write better loops...
+
+
+ // Jump to tour1_extra.cc if you want some more information about
+ // image data management.
+
+ // Jump to tour2.cc to continue the tour.
+}
Index: oln/debug/print.hh
--- oln/debug/print.hh (revision 948)
+++ oln/debug/print.hh (working copy)
@@ -83,6 +83,44 @@
+# ifdef OLN_ENV_1D
+
+ /// Default version.
+
+ template <typename I>
+ void print_1D(const Image<I>&, const I& input, std::ostream& ostr)
+ {
+ print_Gen(input, ostr);
+ }
+
+ /// Version for classical 1D images.
+
+ template <typename I>
+ void print_1D(const Point_Wise_Accessible_Image<I>&, const I& input,
+ std::ostream& ostr)
+ {
+ const oln_coord(I)
+ imin = input.min_ind(),
+ imax = input.max_ind();
+ for (oln_coord(I) i = imin; i <= imax; ++i)
+ {
+ if (input.has(i))
+ ostr << format(input(i));
+ else
+ ostr << '-';
+ ostr << ' ';
+ }
+ }
+
+ template <typename I>
+ void print(const Image_1D<I>& input, std::ostream& ostr)
+ {
+ impl::print_1D(exact(input), exact(input), ostr);
+ }
+
+# endif // OLN_ENV_1D
+
+
# ifdef OLN_ENV_2D
/// Default version.
@@ -128,7 +166,6 @@
# endif // OLN_ENV_2D
-
} // end of namespace oln::debug::impl
Index: oln/debug/iota.hh
--- oln/debug/iota.hh (revision 948)
+++ oln/debug/iota.hh (working copy)
@@ -39,16 +39,16 @@
{
template <typename I>
- void iota(Mutable_Image<I>& in_out);
-
- template <typename I>
void iota(inplace_<I> in_out);
# ifndef OLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename I>
- void iota(Mutable_Image<I>& in_out)
+ void iota_(Mutable_Image<I>& in_out)
{
oln_value(I) v = 0;
oln_fwd_piter(I) p(in_out.points());
@@ -56,10 +56,19 @@
in_out(p) = v++;
}
+ } // end of namespace oln::debug::impl
+
template <typename I>
void iota(inplace_<I> in_out)
{
- iota(in_out.unwrap());
+ impl::iota_(in_out.unwrap());
+ }
+
+ // guard
+ template <typename I>
+ void iota(const Image<I>&)
+ {
+ mlc::abort_<I>::check(); // FIXME: Add err msg.
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 948)
+++ oln/core/1d/image1d.hh (working copy)
@@ -85,6 +85,7 @@
image1d();
image1d(const box1d& b);
+ image1d(const point1d& pmin, const point1d& pmax);
image1d(unsigned n);
bool impl_owns_(const point1d& p) const;
@@ -102,6 +103,9 @@
const box1d& impl_points() const;
};
+ template <typename T, typename D>
+ bool prepare(image1d<T>& target, with_t, const D& dat);
+
# ifndef OLN_INCLUDE_ONLY
@@ -119,6 +123,15 @@
}
template <typename T>
+ image1d<T>::image1d(const point1d& pmin, const point1d& pmax)
+ {
+ precondition(pmax >= pmin);
+ box1d b(pmin, pmax);
+ this->data_ = new data(new array_t(pmin.ind(), pmax.ind()),
+ b);
+ }
+
+ template <typename T>
image1d<T>::image1d(unsigned n)
{
precondition(n != 0);
@@ -185,6 +198,19 @@
return this->data_->second;
}
+ template <typename T, typename D>
+ bool prepare(image1d<T>& target, with_t, const D& dat)
+ {
+ precondition(not target.has_data());
+ box1d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ array1d_<T,int>* ptr = new array1d_<T,int>(b.pmin().ind(),
+ b.pmax().ind());
+ target.data__() = new typename image1d<T>::data(ptr, b);
+ return box_ok;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 948)
+++ oln/core/1d/image1d_b.hh (working copy)
@@ -107,6 +107,9 @@
unsigned impl_border() const;
};
+ template <typename T, typename D>
+ bool prepare(image1d_b<T>& target, with_t, const D& dat);
+
# ifndef OLN_INCLUDE_ONLY
@@ -193,6 +196,20 @@
return this->data_->second;
}
+ template <typename T, typename D>
+ bool prepare(image1d_b<T>& target, with_t, const D& dat)
+ {
+ precondition(not target.has_data());
+ box1d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ unsigned border = 2; // FIXME: Use init!
+ array1d_<T,int>* ptr = new array1d_<T,int>(b.pmin().ind() - border,
+ b.pmax().ind() + border);
+ target.data__() = new typename image1d_b<T>::data(ptr, border, b);
+ return box_ok;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 948)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -52,6 +52,7 @@
namespace internal
{
+ // FIXME: constify.
neighb2d mk_c4();
neighb2d mk_c8();
neighb2d mk_c2_row();
@@ -101,6 +102,7 @@
} // end of namespace oln::internal
+ // FIXME: constify.
extern neighb2d c4;
extern neighb2d c8;
extern neighb2d c2_row;
Index: oln/core/2d/vline2d.hh
--- oln/core/2d/vline2d.hh (revision 948)
+++ oln/core/2d/vline2d.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_2D_VLINE2D_HH
# define OLN_CORE_2D_VLINE2D_HH
-# include <oln/core/internal/window.hh>
+# include <oln/core/internal/symmetrical_window.hh>
# include <oln/core/2d/dpoint2d.hh>
@@ -39,11 +39,13 @@
class vline2d;
+# define super internal::symmetrical_window_<vline2d>
+
// Super type.
template <>
struct super_trait_< vline2d >
{
- typedef internal::window_<vline2d> ret;
+ typedef super ret;
};
@@ -57,7 +59,7 @@
/// 2D vertical line window.
- class vline2d : public internal::window_< vline2d >
+ class vline2d : public super
{
public:
@@ -66,7 +68,7 @@
private:
void init_(int drow_min, int drow_max);
- void take(); // safety; w/o impl, it provides from calling super::take(dp).
+ void impl_take(); // safety; w/o impl, it provides from calling take(dp).
}; // end of class oln::vline2d
@@ -90,11 +92,13 @@
vline2d::init_(int drow_min, int drow_max)
{
for (int drow = drow_min; drow <= drow_max; ++drow)
- this->internal::window_<vline2d>::take(dpoint2d(drow, 0));
+ this->super::impl_take(dpoint2d(drow, 0));
}
# endif // ! OLN_INCLUDE_ONLY
+#undef super
+
} // end of namespace oln
Index: oln/core/2d/hline2d.hh
--- oln/core/2d/hline2d.hh (revision 948)
+++ oln/core/2d/hline2d.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_2D_HLINE2D_HH
# define OLN_CORE_2D_HLINE2D_HH
-# include <oln/core/internal/window.hh>
+# include <oln/core/internal/symmetrical_window.hh>
# include <oln/core/2d/dpoint2d.hh>
@@ -39,11 +39,13 @@
class hline2d;
+# define super internal::symmetrical_window_<hline2d>
+
// Super type.
template <>
struct super_trait_< hline2d >
{
- typedef internal::window_<hline2d> ret;
+ typedef super ret;
};
@@ -57,7 +59,7 @@
/// 2D horizontal line window.
- class hline2d : public internal::window_< hline2d >
+ class hline2d : public super
{
public:
@@ -65,7 +67,7 @@
private:
void init_(int dcol_min, int dcol_max);
- void take(); // safety; w/o impl, it provides from calling super::take(dp).
+ void impl_take(); // safety; w/o impl, it prevents from calling take(dp).
}; // end of class oln::hline2d
@@ -83,11 +85,13 @@
hline2d::init_(int dcol_min, int dcol_max)
{
for (int dcol = dcol_min; dcol <= dcol_max; ++dcol)
- this->internal::window_<hline2d>::take(dpoint2d(0, dcol));
+ this->super::impl_take(dpoint2d(0, dcol));
}
# endif // ! OLN_INCLUDE_ONLY
+# undef super
+
} // end of namespace oln
Index: oln/core/2d/rectangle2d.hh
--- oln/core/2d/rectangle2d.hh (revision 948)
+++ oln/core/2d/rectangle2d.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_2D_RECTANGLE2D_HH
# define OLN_CORE_2D_RECTANGLE2D_HH
-# include <oln/core/internal/window.hh>
+# include <oln/core/internal/symmetrical_window.hh>
# include <oln/core/2d/dpoint2d.hh>
@@ -39,11 +39,13 @@
class rectangle2d;
+# define super internal::symmetrical_window_<rectangle2d>
+
// Super type.
template <>
struct super_trait_< rectangle2d >
{
- typedef internal::window_<rectangle2d> ret;
+ typedef super ret;
};
@@ -57,7 +59,7 @@
/// 2D rectangular window.
- class rectangle2d : public internal::window_< rectangle2d >
+ class rectangle2d : public super
{
public:
@@ -70,10 +72,11 @@
private:
void init_(int drow_min, int dcol_min,
int drow_max, int dcol_max);
- void take(); // safety; w/o impl, it provides from calling super::take(dp).
unsigned half_height_, half_width_;
+ void impl_take(); // safety; w/o impl, it prevents from calling take(dp).
+
}; // end of class oln::rectangle2d
@@ -105,11 +108,13 @@
{
for (int drow = drow_min; drow <= drow_max; ++drow)
for (int dcol = dcol_min; dcol <= dcol_max; ++dcol)
- this->internal::window_<rectangle2d>::take(dpoint2d(drow, dcol));
+ this->super::impl_take(dpoint2d(drow, dcol));
}
# endif // ! OLN_INCLUDE_ONLY
+# undef super
+
} // end of namespace oln
Index: oln/core/gen/inplace.hh
--- oln/core/gen/inplace.hh (revision 948)
+++ oln/core/gen/inplace.hh (working copy)
@@ -57,6 +57,11 @@
inplace(Mutable_Image<I>& ima);
+ template <typename I>
+ inplace_<I>
+ inplace(inplace_<I> ima);
+
+
# ifndef OLN_INCLUDE_ONLY
@@ -80,6 +85,8 @@
return this->unwrap();
}
+ // inplace
+
template <typename I>
inplace_<I>
inplace(Mutable_Image<I>& ima)
@@ -88,6 +95,13 @@
return tmp;
}
+ template <typename I>
+ inplace_<I>
+ inplace(inplace_<I> ima)
+ {
+ return ima;
+ }
+
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 948)
+++ oln/core/concept/image.hh (working copy)
@@ -131,7 +131,9 @@
// stc_typename(output); // FIXME: Uncomment!
stc_typename(plain);
+ bool is_empty() const; // Not subject to delegation.
bool owns_(const psite& p) const;
+
rvalue operator()(const psite& p) const;
rvalue read_(const psite& p) const;
@@ -209,11 +211,16 @@
stc_using_from(Mutable_Image, lvalue);
stc_typename(index);
+ // FIXME: Confusing! We already have indices for 1D images...
+ // FIXME: Use "offset" instead!
rvalue operator[](index i) const;
lvalue operator[](index i);
std::size_t npoints() const;
- // FIXME: ...
+
+ // FIXME: Add:
+ // point point_at_offset(o) const
+ // std::size_t offset_from_point(point p) const
protected:
Fast_Image();
@@ -275,6 +282,11 @@
{
stc_typename(coord);
+ // final
+ coord min_ind() const;
+ coord max_ind() const;
+ unsigned ninds() const;
+
protected:
Image_1D();
};
@@ -443,8 +455,16 @@
template <typename Exact>
bool
+ Image<Exact>::is_empty() const
+ {
+ return exact(this)->impl_is_empty();
+ }
+
+ template <typename Exact>
+ bool
Image<Exact>::owns_(const typename Image<Exact>::psite& p) const
{
+ precondition(not this->is_empty());
return exact(this)->impl_owns_(p);
}
@@ -626,6 +646,27 @@
{
}
+ template <typename Exact>
+ typename Image_1D<Exact>::coord
+ Image_1D<Exact>::min_ind() const
+ {
+ return this->bbox().pmin().ind();
+ }
+
+ template <typename Exact>
+ typename Image_1D<Exact>::coord
+ Image_1D<Exact>::max_ind() const
+ {
+ return this->bbox().pmax().ind();
+ }
+
+ template <typename Exact>
+ unsigned
+ Image_1D<Exact>::ninds() const
+ {
+ return this->bbox().pmax().ind() - this->bbox().pmin().ind() + 1;
+ }
+
// ----------------------------------- Image_2D<Exact>
template <typename Exact>
Index: oln/core/concept/function.hh
--- oln/core/concept/function.hh (revision 948)
+++ oln/core/concept/function.hh (working copy)
@@ -37,18 +37,6 @@
{
- /*
-
- // Fwd decl.
- namespace morpher {
- template <typename I, typename F> class two_way;
- template <typename I, typename F> class two_way_rw;
- }
- namespace value { template <typename I, typename F> class two_way; }
-
- */
-
-
template <typename Exact>
struct Function : public Any<Exact>
{
@@ -90,42 +78,17 @@
};
- /*
-
// Value1 -> Value2 *and* Value2 -> Value1.
template <typename Exact>
struct Function_v2w2v : public Function<Exact>
{
- public:
-
- template <typename I>
- oln::morpher::two_way<I, Exact>
- operator()(oln::abstract::mutable_image<I>& input) const;
-
+ typedef Function_v2w2v<void> category;
protected:
Function_v2w2v();
};
- // (Image, Point) -> Value2 *and* (Image, Point, Value2) -> Value1.
-
- template <typename Exact>
- struct Function_rw : public Function<Exact>
- {
- public:
-
- template <typename I>
- oln::morpher::two_way_rw<I, Exact>
- operator()(oln::abstract::mutable_image<I>& input) const;
-
- protected:
- Function_rw();
- };
-
- */
-
-
// Point -> Point.
template <typename Exact>
@@ -159,21 +122,12 @@
{
}
- /*
-
template <typename Exact>
Function_v2w2v<Exact>::Function_v2w2v()
{
}
template <typename Exact>
- Function_rw<Exact>::Function_rw()
- {
- }
-
- */
-
- template <typename Exact>
Function_p2p<Exact>::Function_p2p()
{
}
Index: oln/core/concept/image_identity.hh
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 948)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -28,9 +28,15 @@
#ifndef OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+# include <oln/core/concept/grid.hh>
# include <oln/core/concept/image.hh>
+
+// FIXME: Bad! Move Grid_*D into concept/grid.hh...
+# include <oln/core/1d/grid1d.hh>
# include <oln/core/2d/grid2d.hh>
-# include <oln/value/tags.hh>
+# include <oln/core/3d/grid3d.hh>
+
+# include <oln/value/tags.hh> // FIXME: Bad!
namespace oln
@@ -69,11 +75,27 @@
template <typename Exact>
struct case_< Image_dimension, Exact, 1 >
:
+ where_< stc_is_a(grid, Grid_1D) >
+ {
+ typedef Image_1D<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_dimension, Exact, 2 >
+ :
where_< stc_is_a(grid, Grid_2D) >
{
typedef Image_2D<Exact> ret;
};
+ template <typename Exact>
+ struct case_< Image_dimension, Exact, 3 >
+ :
+ where_< stc_is_a(grid, Grid_3D) >
+ {
+ typedef Image_3D<Exact> ret;
+ };
+
// FIXME: ...
Index: oln/core/internal/window.hh
--- oln/core/internal/window.hh (revision 948)
+++ oln/core/internal/window.hh (working copy)
@@ -72,12 +72,16 @@
public:
stc_using(point);
- typedef typename point::dpoint dpoint;
+ typedef oln_dpoint(point) dpoint;
- window_();
Exact& take(const dpoint& dp);
+ Exact& impl_take(const dpoint& dp);
+
Exact impl_op_unary_minus_() const;
+ protected:
+ window_();
+
}; // end of class oln::internal::window_<Exact>
@@ -92,7 +96,14 @@
Exact&
window_<Exact>::take(const typename window_<Exact>::dpoint& dp)
{
- this->take_( dp);
+ return exact(this)->impl_take(dp);
+ }
+
+ template <typename Exact>
+ Exact&
+ window_<Exact>::impl_take(const typename window_<Exact>::dpoint& dp)
+ {
+ this->take_(dp); // from dpoints_impl_.
return exact(*this);
}
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 948)
+++ oln/core/internal/image_base.hh (working copy)
@@ -238,6 +238,7 @@
stc_typename(data);
+ bool impl_is_empty() const;
bool has_data() const;
// pseudo-private:
@@ -360,9 +361,15 @@
/// image_base_<Exact>
template <typename Exact>
+ bool image_base_<Exact>::impl_is_empty() const
+ {
+ return this->data_ = 0; // FIXME: This is not sufficient...
+ }
+
+ template <typename Exact>
bool image_base_<Exact>::has_data() const
{
- return this->data_ != 0;
+ return this->data_ != 0; // FIXME: redundant with is_empty? (no)
}
template <typename Exact>
Index: oln/core/internal/op_image_extended_by_nbh.hh
--- oln/core/internal/op_image_extended_by_nbh.hh (revision 948)
+++ oln/core/internal/op_image_extended_by_nbh.hh (working copy)
@@ -28,6 +28,7 @@
#ifndef OLN_CORE_INTERNAL_OP_IMAGE_EXTENDED_BY_NBH_HH
# define OLN_CORE_INTERNAL_OP_IMAGE_EXTENDED_BY_NBH_HH
+# include <mlc/unconst.hh>
# include <oln/core/concept/neighborhood.hh>
# include <oln/core/internal/image_base.hh>
# include <oln/core/gen/op.hh>
@@ -123,10 +124,14 @@
template <typename N, typename I>
bool init_(Neighborhood<N>* this_,
+ const internal::single_image_morpher_<I>& dat);
+
+ template <typename N, typename I>
+ bool init_(Neighborhood<N>* this_,
const internal::current& dat);
template <typename I, typename N>
- bool init_(Image<I>* this_,
+ bool init_(Image<I>* this_, // FIXME: Pb with I being "const J"...
const internal::current& dat);
@@ -186,6 +191,14 @@
template <typename N, typename I>
bool init_(Neighborhood<N>* this_,
+ const internal::single_image_morpher_<I>& data)
+ {
+ exact(*this_) = data.nbhood();
+ return true;
+ }
+
+ template <typename N, typename I>
+ bool init_(Neighborhood<N>* this_,
const internal::current& data)
{
exact(*this_) = data.nbhood();
@@ -220,7 +233,7 @@
precondition(not target.has_data());
target.data__() = new typename op_<I, extended_by, N>::data;
bool ima_ok = prepare(target.data__()->first, with, dat);
- bool nbh_ok = init(target.data__()->second, with, dat);
+ bool nbh_ok = init(mlc::unconst_cast(target.data__()->second), with, dat);
postcondition(ima_ok);
postcondition(nbh_ok);
return ima_ok and nbh_ok;
Index: oln/core/internal/special_op.hh
--- oln/core/internal/special_op.hh (revision 948)
+++ oln/core/internal/special_op.hh (working copy)
@@ -41,14 +41,14 @@
template <typename L, typename OpName, typename R> class op_;
- /// Virtual types.
+ // Virtual types.
template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
struct vtypes< internal::special_op_<Lcat, L, OpName, Rcat, R> >
/* undefined; to be specialized... */
;
- /// Super type.
+ // Super type.
template <typename Lcat, typename L, typename OpName, typename Rcat, typename R>
struct super_trait_< internal::special_op_<Lcat, L, OpName, Rcat, R> >
/* undefined; to be specialized... */
Index: oln/core/internal/symmetrical_window.hh
--- oln/core/internal/symmetrical_window.hh (revision 0)
+++ oln/core/internal/symmetrical_window.hh (revision 0)
@@ -0,0 +1,111 @@
+// 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 OLN_CORE_INTERNAL_SYMMETRICAL_WINDOW_HH
+# define OLN_CORE_INTERNAL_SYMMETRICAL_WINDOW_HH
+
+# include <oln/core/internal/window.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class symmetrical_window_; }
+
+#define current symmetrical_window_<Exact>
+#define super internal::window_<Exact>
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::current >
+ {
+ typedef super ret;
+ };
+
+
+ // Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::current >
+ {
+ };
+
+ namespace internal
+ {
+
+ /// Base implementation class for symmetrical window classes.
+
+ template <typename Exact>
+ class symmetrical_window_ : public super
+ {
+ public:
+ stc_using(dpoint);
+
+ const Exact& impl_op_unary_minus_() const;
+ Exact& impl_take(const dpoint& dp);
+
+ protected:
+ symmetrical_window_();
+
+ }; // end of class oln::internal::symmetrical_window_<Exact>
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ current::symmetrical_window_()
+ {
+ }
+
+ template <typename Exact>
+ const Exact&
+ current::impl_op_unary_minus_() const
+ {
+ return exact(*this);
+ }
+
+ template <typename Exact>
+ Exact&
+ current::impl_take(const typename current::dpoint& dp)
+ {
+ this->super::impl_take(dp);
+ this->super::impl_take(-dp);
+ return exact(*this);
+ }
+
+ } // end of namespace oln::internal
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef super
+# undef current
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_SYMMETRICAL_WINDOW_HH
Index: oln/draw/bresenham.hh
--- oln/draw/bresenham.hh (revision 948)
+++ oln/draw/bresenham.hh (working copy)
@@ -46,11 +46,6 @@
// Fwd decl.
template <typename I>
- void bresenham(Mutable_Image<I>& in_out,
- const oln_point(I)& begin, const oln_point(I)& end,
- const oln_value(I)& value);
-
- template <typename I>
void bresenham(inplace_<I> in_out,
const oln_point(I)& begin, const oln_point(I)& end,
const oln_value(I)& value);
@@ -66,28 +61,32 @@
const oln_point(I)& begin, const oln_point(I)& end,
const oln_value(I)& value)
{
- level::paste(literal(value) / line2d(begin, end), in_out);
+ level::paste(literal(value) / line2d(begin, end),
+ inplace(in_out));
}
} // end of namespace oln::draw::impl
- // Facades.
+ // Facade.
template <typename I>
- void bresenham(Mutable_Image<I>& in_out,
+ void bresenham(inplace_<I> in_out,
const oln_point(I)& begin, const oln_point(I)& end,
const oln_value(I)& value)
{
- impl::bresenham_(exact(in_out), begin, end, value);
+ impl::bresenham_(in_out.unwrap(), begin, end, value);
}
- template <typename I>
- void bresenham(inplace_<I> in_out,
- const oln_point(I)& begin, const oln_point(I)& end,
- const oln_value(I)& value)
+
+ // Guard.
+
+ template <typename I, typename P, typename V>
+ void bresenham(const Image<I>&,
+ const P&, const P&,
+ const V&)
{
- bresenham(in_out.unwrap(), begin, end, value);
+ mlc::abort_<I>::check(); // FIXME: Add err msg.
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/morpho/cc_tarjan.hh
--- oln/morpho/cc_tarjan.hh (revision 948)
+++ oln/morpho/cc_tarjan.hh (working copy)
@@ -29,6 +29,8 @@
# define OLN_MORPHO_CC_TARJAN_HH
# include <oln/core/concept/image.hh>
+# include <oln/core/internal/f_ch_value.hh>
+# include <oln/level/fill.hh>
namespace oln
{
@@ -116,10 +118,10 @@
oln_plain_value(I, oln_point(I)) parent;
prepare(parent, with, input);
- oln_plain(I) is_processed;
+ // init.
+ oln_plain_value(I, bool) is_processed;
prepare(is_processed, with, input);
- oln_piter(I) p1(is_processed.points());
- is_processed(p1) = false; // FIXME : built with ?.
+ level::fill(inplace(is_processed), false);
first_pass(input, parent, is_processed);
second_pass(input, parent, output);
Index: oln/level/fill.hh
--- oln/level/fill.hh (revision 948)
+++ oln/level/fill.hh (working copy)
@@ -53,36 +53,22 @@
// Fwd decls.
template <typename I>
- void fill(Mutable_Image<I>& target, /* with */ const oln_value(I)& value);
+ void fill(inplace_<I> target, /* with */ const oln_value(I)& value);
template <typename I, typename J>
- void fill(Mutable_Image<I>& target, /* with */ const Image<J>& data);
+ void fill(inplace_<I> target, /* with */ const Image<J>& data);
template <typename I, typename F>
- void fill(Mutable_Image<I>& target, /* with */ const Function_p2v<F>& fun);
+ void fill(inplace_<I> target, /* with */ const Function_p2v<F>& fun);
template <typename I, typename V, typename P>
- void fill(Mutable_Image<I>& target, /* with */ V (*fun)(P));
+ void fill(inplace_<I> target, /* with */ V (*f)(P));
// FIXME: Inactivated.
// template <typename I>
// void fill(Value_Wise_Mutable_Image<I>& target, const oln_value(I)& value);
- // versions for temporary images
-
- template <typename I>
- void fill(inplace_<I> target, /* with */ const oln_value(I)& value);
-
- template <typename I, typename J>
- void fill(inplace_<I> target, /* with */ const Image<J>& data);
-
- template <typename I, typename F>
- void fill(inplace_<I> target, /* with */ const Function_p2v<F>& fun);
-
- template <typename I, typename V, typename P>
- void fill(inplace_<I> target, /* with */ V (*fun)(P));
-
# ifndef OLN_INCLUDE_ONLY
@@ -130,56 +116,44 @@
/// Facades.
template <typename I>
- void fill(Mutable_Image<I>& target, const oln_value(I)& value)
+ void fill(inplace_<I> target, const oln_value(I)& value)
{
- impl::fill_from_value_(exact(target), value);
+ impl::fill_from_value_(target.unwrap(), value);
}
template <typename I, typename J>
- void fill(Mutable_Image<I>& target, const Image<J>& data)
+ void fill(inplace_<I> target, const Image<J>& data)
{
assert_same_grid_<I, J>::check();
- precondition(target.points() <= data.points());
- impl::fill_from_image_(exact(target), exact(data));
+ precondition(target.unwrap().points() <= data.points());
+ impl::fill_from_image_(target.unwrap(), exact(data));
}
template <typename I, typename F>
- void fill(Mutable_Image<I>& target, const Function_p2v<F>& fun)
+ void fill(inplace_<I> target, const Function_p2v<F>& fun)
{
- impl::fill_from_function_(exact(target), exact(fun));
+ typedef mlc_basic(oln_argument(F)) P;
+ mlc::assert_< mlc_is_a(P, Point) >::check(); // FIXME: Add err msg.
+ // FIXME: Check also the value type.
+ impl::fill_from_function_(target.unwrap(), exact(fun));
}
template <typename I, typename V, typename P>
- void fill(Mutable_Image<I>& target, V (*f)(P))
+ void fill(inplace_<I> target, V (*f)(P))
{
mlc::assert_< mlc_is_a(P, Point) >::check(); // FIXME: Add err msg.
- impl::fill_from_function_(exact(target), functorize_p2v(f));
+ // FIXME: Check also the value type.
+ impl::fill_from_function_(target.unwrap(), functorize_p2v(f));
}
- // with inplace_<I>
-
- template <typename I>
- void fill(inplace_<I> target, const oln_value(I)& value)
- {
- fill(target.unwrap(), value);
- }
- template <typename I, typename J>
- void fill(inplace_<I> target, const Image<J>& data)
- {
- fill(target.unwrap(), data);
- }
- template <typename I, typename F>
- void fill(inplace_<I> target, const Function_p2v<F>& fun)
- {
- fill(target.unwrap(), fun);
- }
+ /// Guard.
- template <typename I, typename V, typename P>
- void fill(inplace_<I> target, V (*fun)(P))
+ template <typename I, typename T>
+ void fill(const Image<I>&, const T&)
{
- fill(target.unwrap(), fun);
+ mlc::abort_<I>::check(); // FIXME: Add err msg.
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/level/clone.hh
--- oln/level/clone.hh (revision 948)
+++ oln/level/clone.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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
Index: oln/level/apply_inplace.hh
--- oln/level/apply_inplace.hh (revision 948)
+++ oln/level/apply_inplace.hh (working copy)
@@ -80,27 +80,26 @@
/// Facades.
template <typename F, typename I>
- void apply_inplace(const Function_v2v<F>& f, Mutable_Image<I>& in_out)
+ void apply_inplace(const Function_v2v<F>& f, inplace_<I> in_out)
{
- impl::apply_inplace_(exact(f), exact(in_out));
+ // FIXME: Add check.
+ impl::apply_inplace_(exact(f), in_out.unwrap());
}
template <typename R, typename A, typename I>
- void apply_inplace(R (*f)(A), Mutable_Image<I>& in_out)
+ void apply_inplace(R (*f)(A), inplace_<I> in_out)
{
- impl::apply_inplace_(functorize_v2v(f), exact(in_out));
+ // FIXME: Add check.
+ impl::apply_inplace_(functorize_v2v(f), in_out.unwrap());
}
- template <typename F, typename I>
- void apply_inplace(const Function_v2v<F>& f, inplace_<I> in_out)
- {
- apply_inplace(f, in_out.unwrap());
- }
- template <typename R, typename A, typename I>
- void apply_inplace(R (*f)(A), inplace_<I> in_out)
+ /// Guard.
+
+ template <typename T, typename I>
+ void apply_inplace(const T&, const Image<I>&)
{
- apply_inplace(f, in_out.unwrap());
+ mlc::abort_<I>::check(); // FIXME: Add err msg.
}
# endif // ! OLN_INCLUDE_ONLY
1
0
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
1
0
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
rle_class based on std::vector.
* tests/core/rle_image.cc: add tests.
* oln/core/rle/rle_image.hh, oln/core/rle/rle_psite.hh, oln/core/rle/rle_pset.hh,
* oln/core/sparse/sparse_image.hh: Clean code.
* oln/core/gen/rle_pset.hh, oln/core/gen/rle_image.hh,
* oln/core/gen/rle_psite : New, add rle_image class which is based on a std::vector
* oln/core/encode/rle_encode.hh: Rename.
* oln/core/gen/rle_encode.hh: ... this.
oln/core/gen/rle_encode.hh | 2
oln/core/gen/rle_image.hh | 160 ++++++++++++
oln/core/gen/rle_pset.hh | 496 ++++++++++++++++++++++++++++++++++++++++
oln/core/gen/rle_psite.hh | 88 +++++++
oln/core/rle/rle_image.hh | 7
oln/core/rle/rle_pset.hh | 19 -
oln/core/rle/rle_psite.hh | 9
oln/core/sparse/sparse_image.hh | 3
tests/core/rle_image.cc | 21 +
9 files changed, 769 insertions(+), 36 deletions(-)
Index: tests/core/rle_image.cc
--- tests/core/rle_image.cc (revision 946)
+++ tests/core/rle_image.cc (working copy)
@@ -1,10 +1,22 @@
#include <iostream>
#include <oln/core/2d/image2d.hh>
-#include <oln/core/rle/rle_psite.hh>
-#include <oln/core/rle/rle_image.hh>
+#include <oln/core/gen/rle_psite.hh>
+#include <oln/core/gen/rle_image.hh>
#include <oln/debug/print.hh>
-#include <oln/core/rle/rle_pset.hh>
-#include <oln/core/encode/rle_encode.hh>
+#include <oln/core/gen/rle_pset.hh>
+#include <oln/core/gen/rle_encode.hh>
+
+template <typename P>
+void test(const oln::rle_pset<P>& my_set)
+{
+ typename oln::rle_pset<P>::piter run (my_set);
+ for (run.start(); run.is_valid(); run.next())
+ ;
+
+ typename oln::rle_pset<P>::bkd_piter run2 (my_set);
+ for (run2.start(); run2.is_valid(); run2.next())
+ ;
+}
int main()
@@ -16,6 +28,7 @@
my_set.insert(p, 5);
my_set.insert(q, 8);
+ test(my_set);
rle.insert(p, 5, 4);
rle.insert(q, 8, 9);
Index: oln/core/rle/rle_image.hh
--- oln/core/rle/rle_image.hh (revision 946)
+++ oln/core/rle/rle_image.hh (working copy)
@@ -93,15 +93,12 @@
rle_image();
- /// pset impl_points() const : return image pset
+
const pset& impl_points() const;
- /// bool impl_owns_(const psite& p) const : same has impl_has
+
bool impl_owns_(const psite& p) const;
- /// void insert(const point& p, unsigned len, value val) : insert a new range on the image
void insert(const point& p, unsigned len, value val);
- /// rvalue impl_read(const psite& p) const : return value associated to psite (for reading)
rvalue impl_read(const psite& p) const;
- /// lvalue impl_read_write(const psite& p) : lvalue impl_read_write(const psite& p) (for writing)
lvalue impl_read_write(const psite& p);
};
Index: oln/core/rle/rle_psite.hh
--- oln/core/rle/rle_psite.hh (revision 946)
+++ oln/core/rle/rle_psite.hh (working copy)
@@ -40,25 +40,20 @@
template <typename P, typename T> struct rle_image;
/*
- ** \class rle_piste
+ ** \class rle_psite
** \brief psite for rle image
**
** Note: P must be a point type
*/
template <typename P>
- class rle_psite
+ struct rle_psite
{
- public:
rle_psite();
- // to_point: convert the psite to corresponding point
P to_point() const;
- // operator P(): convert psite to the corresponding point
operator P () const;
- /// start of the range which contains the psite
P start_;
- /// index of the point in the range
unsigned index_;
};
Index: oln/core/rle/rle_pset.hh
--- oln/core/rle/rle_pset.hh (revision 946)
+++ oln/core/rle/rle_pset.hh (working copy)
@@ -84,24 +84,18 @@
rle_pset();
- /// unsigned impl_npoints() const : return number of point in the point set
unsigned impl_npoints() const;
- /// const box& impl_bbox() const : return a box which includes all poin into the set
const box& impl_bbox() const;
- /// void insert(const P& p, unsigned len): insert a new range on the point set
void insert(const P& p, unsigned len);
- /// bool impl_has(const P& p) const : if p include in the set
bool impl_has(const P& p) const;
- /// const std_container& con() const : return the container of the point
const std_container& con() const;
unsigned range_len_(const P& range_len_) const;
protected:
/// number of point in the set
unsigned npts;
- /// container of the set
+
std_container con_; // FIXME: Add a &.
- /// pset box
fbbox_<point> fb_;
};
@@ -215,16 +209,11 @@
rle_pset_fwd_piter_(const rle_pset<P>& con);
- /// void impl_start(): set the iterator to the start of pset
void impl_start();
- /// void impl_next(): go to next point
void impl_next();
- /// void impl_invalidate(): invalidate iterator
void impl_invalidate();
- /// void impl_valid(): is the iterator valid?
bool impl_is_valid() const;
- /// conversion method
const rle_psite<P>& impl_to_psite() const;
point impl_to_point() const;
const point* impl_psite_adr() const;
@@ -234,7 +223,6 @@
protected:
const typename rle_pset<P>::std_container& con_;
typename rle_pset<P>::std_container::const_iterator it_;
- /// current point
rle_psite<P> ps_;
};
@@ -352,16 +340,11 @@
rle_pset_bkd_piter_(const rle_pset<P>& con);
- /// void impl_start(): set the iterator to the start of pset
void impl_start();
- /// void impl_next(): go to next point
void impl_next();
- /// void impl_invalidate(): invalidate iterator
void impl_invalidate();
- /// void impl_valid(): is the iterator valid?
bool impl_is_valid() const;
- /// conversion methods
const rle_psite<P>& impl_to_psite() const;
point impl_to_point() const;
const point* impl_psite_adr() const;
Index: oln/core/gen/rle_pset.hh
--- oln/core/gen/rle_pset.hh (revision 0)
+++ oln/core/gen/rle_pset.hh (revision 0)
@@ -0,0 +1,496 @@
+// 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 OLN_CORE_RLE_RLE_PSET_HH
+# define OLN_CORE_RLE_RLE_PSET_HH
+
+# include <vector>
+# include <utility>
+
+# include <oln/core/rle/rle_psite.hh>
+# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
+# include <oln/core/gen/fbbox.hh>
+
+
+namespace oln
+{
+
+ // Forwards declaration
+ template <typename P> struct rle_pset;
+ template <typename P> struct rle_pset_fwd_piter_;
+ template <typename P> struct rle_pset_bkd_piter_;
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< rle_pset<P> >
+ {
+ typedef rle_pset<P> current;
+ typedef internal::point_set_base_<current> ret;
+ };
+
+ // Vtypes associated to rle_pset class
+ template <typename P>
+ struct vtypes< rle_pset<P> >
+ {
+ typedef P point;
+
+ typedef typename oln::internal::f_point_to_box_< P >::ret box;
+ typedef rle_pset_fwd_piter_<P> fwd_piter;
+ typedef rle_pset_bkd_piter_<P> bkd_piter;
+ };
+
+ // rle_pset class
+ /*
+ ** \class rle_pset
+ ** \brief pset correspoding to the rle_image class
+ **
+ ** Note: P must be a point type
+ */
+ template <typename P>
+ class rle_pset : public internal::point_set_base_<rle_pset <P> >
+ {
+ typedef rle_pset<P> current;
+ typedef internal::point_set_base_<rle_pset<P> > super;
+
+ public:
+ stc_using(point);
+ stc_using(box);
+
+ typedef std::vector<std::pair<point, unsigned> > std_container;
+
+ rle_pset();
+
+ unsigned impl_npoints() const;
+ const box& impl_bbox() const;
+ void insert(const P& p, unsigned len);
+ bool impl_has(const P& p) const;
+ const std_container& con() const;
+
+ unsigned range_len_(const P& range_len_) const;
+ protected:
+ /// number of point in the set
+ unsigned npts;
+
+ std_container con_; // FIXME: Add a &.
+ fbbox_<point> fb_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ rle_pset<P>::rle_pset() : npts(0)
+ {
+ }
+
+
+ template <typename P>
+ unsigned
+ rle_pset<P>::impl_npoints() const
+ {
+ return npts;
+ }
+
+ template <typename P>
+ void
+ rle_pset<P>::insert(const P& p, unsigned len)
+ {
+ point pend;
+ typename std_container::value_type elt (p, len);
+
+ this->con_.push_back(elt);
+
+ //update bbox
+ fb_.take(p);
+ pend = p;
+ pend[0] += len - 1;
+ fb_.take(pend);
+ // update size
+ npts += len;
+ }
+
+ template <typename P>
+ const typename rle_pset<P>::box&
+ rle_pset<P>::impl_bbox() const
+ {
+ return fb_.box();
+ }
+
+ template <typename P>
+ bool
+ rle_pset<P>::impl_has(const P& p) const
+ {
+ typename std_container::const_iterator irun;
+
+ for (irun = this->con_.begin(); irun != this->con_.end(); ++irun)
+ {
+ if (irun->first == p)
+ return true;
+ }
+ return false;
+ }
+
+ template <typename P>
+ const typename rle_pset<P>::std_container&
+ rle_pset<P>::con() const
+ {
+ return this->con_;
+ }
+
+ template <typename P>
+ unsigned
+ rle_pset<P>::range_len_(const P& range_start) const
+ {
+ typename std_container::const_iterator irun;
+
+ for (irun = this->con_.begin(); irun != this->con_.end(); ++irun)
+ {
+ if (irun->first == range_start)
+ return irun->second;
+ }
+ assert(irun != this->con_.end());
+ return (irun->second);
+ }
+
+# endif // !OLN_INCLUDE_ONLY
+
+ // end of rle_pset class
+
+ // -------------------- iterators on classes deriving from internal::rle_pset<P>
+
+
+ // ------------------- base class for factorizing code
+
+ // Forward declaration
+ template <typename Exact>
+ class rle_pset_piter_;
+
+ template <typename Exact>
+ struct super_trait_< rle_pset_piter_<Exact> >
+ {
+ typedef rle_pset_piter_<Exact> current;
+ typedef internal::iterator_on_points_base_<Exact> ret;
+ };
+
+
+ // Virtual types
+ template <typename Exact>
+ struct vtypes< rle_pset_piter_<Exact> >
+ {
+ };
+
+ // class rle_pset_iterator_
+ /*
+ ** \class rle_pset_piter_
+ ** \brief base iterator class for factorizing code
+ **
+ */
+ template <typename Exact>
+ class rle_pset_piter_ : public internal::iterator_on_points_base_< Exact >
+ {
+ typedef internal::iterator_on_points_base_< Exact > super;
+ typedef rle_pset_piter_<Exact> current;
+ public:
+ stc_using(point);
+ typedef rle_psite<point> psite;
+
+ const rle_psite<point>& impl_to_psite() const;
+ point impl_to_point() const;
+ const rle_psite<point>* impl_psite_adr() const;
+ operator psite () const;
+ const point* impl_point_adr() const; //FIXME
+
+ protected:
+ rle_pset_piter_(const rle_pset<point>& con);
+
+ const typename rle_pset<point>::std_container& con_;
+
+ point p_;
+ rle_psite<point> ps_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ rle_pset_piter_<Exact>::rle_pset_piter_(const rle_pset<typename rle_pset_piter_<Exact>::point>& cont) :
+ con_(cont.con())
+ {
+ }
+
+ template <typename Exact>
+ const rle_psite<typename rle_pset_piter_<Exact>::point>&
+ rle_pset_piter_<Exact>::impl_to_psite() const
+ {
+ return ps_;
+ }
+
+ template <typename Exact>
+ typename rle_pset_piter_<Exact>::point
+ rle_pset_piter_<Exact>::impl_to_point() const
+ {
+ return ps_;
+ }
+
+ template <typename Exact>
+ rle_pset_piter_<Exact>::operator typename rle_pset_piter_<Exact>::psite () const
+ {
+ return this->impl_to_psite();
+ }
+
+ template <typename Exact>
+ const rle_psite<typename rle_pset_piter_<Exact>::point>*
+ rle_pset_piter_<Exact>::impl_psite_adr() const
+ {
+ return &ps_;
+ }
+
+ template <typename Exact>
+ const typename rle_pset_piter_<Exact>::point*
+ rle_pset_piter_<Exact>::impl_point_adr() const
+ {
+ return &p_;
+ }
+ //end of class rle_pset_iterator_
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+
+ // Forward declaration
+ template <typename P>
+ class rle_pset_fwd_piter_;
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< rle_pset_fwd_piter_<P> >
+ {
+ typedef rle_pset_fwd_piter_<P> current;
+ typedef rle_pset_piter_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P>
+ struct vtypes< rle_pset_fwd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ // class rle_pset_fwd_iterator_
+ /*
+ ** \class rle_pset_fwd_piter_
+ ** \brief foward iterator for rle_pset
+ **
+ ** P must be a point type
+ */
+ template <typename P>
+ class rle_pset_fwd_piter_ : public rle_pset_piter_<rle_pset_fwd_piter_<P> >
+ {
+ typedef rle_pset_piter_< rle_pset_fwd_piter_<P> > super;
+ typedef rle_pset_fwd_piter_<P> current;
+ public:
+ stc_using(point);
+
+ rle_pset_fwd_piter_(const rle_pset<P>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+
+ protected:
+ typename rle_pset<point>::std_container::const_iterator it_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ rle_pset_fwd_piter_<P>::rle_pset_fwd_piter_(const rle_pset<P>& cont) :
+ super(cont)
+ {
+ this->it_ = this->con_.end();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ void
+ rle_pset_fwd_piter_<P>::impl_start()
+ {
+ this->it_ = this->con_.begin(); // FIXME: Test if (this->it_ != this->con_.end())...
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = 0;
+ this->ps_.pset_pos_ = 0;
+ this->p_ = this->ps_.start_;
+ }
+
+ template <typename P>
+ void
+ rle_pset_fwd_piter_<P>::impl_next()
+ {
+ precondition(this->is_valid());
+
+ ++this->ps_.index_;
+
+ if (this->ps_.index_ >= this->it_->second)
+ {
+ ++this->it_;
+ ++this->ps_.pset_pos_;
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = 0;
+ }
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ rle_pset_fwd_piter_<P>::impl_invalidate()
+ {
+ this->it_ = this->con_.end();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ bool
+ rle_pset_fwd_piter_<P>::impl_is_valid() const
+ {
+ return this->it_ != this->con_.end();
+ }
+# endif // ! OLN_INCLUDE_ONLY
+
+ //end of class rle_pset_fwd_iterator_
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Forward declaration
+ template <typename P>
+ class rle_pset_bkd_piter_;
+
+ // Super type.
+ template <typename P>
+ struct super_trait_< rle_pset_bkd_piter_<P> >
+ {
+ typedef rle_pset_bkd_piter_<P> current;
+ typedef rle_pset_piter_<current> ret;
+ };
+
+ // Virtual type
+ template <typename P>
+ struct vtypes< rle_pset_bkd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ /*
+ ** \class rle_pset_bkd_piter_
+ ** \brief backward iterator for rle_pset
+ **
+ ** P must be a point type
+ */
+ template <typename P>
+ class rle_pset_bkd_piter_ : public rle_pset_piter_<rle_pset_bkd_piter_<P> >
+ {
+ typedef rle_pset_piter_< rle_pset_bkd_piter_<P> > super;
+ typedef rle_pset_bkd_piter_<P> current;
+ public:
+ stc_using(point);
+
+ rle_pset_bkd_piter_(const rle_pset<P>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+
+ protected:
+ typename rle_pset<point>::std_container::const_reverse_iterator it_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ rle_pset_bkd_piter_<P>::rle_pset_bkd_piter_(const rle_pset<P>& cont) :
+ super(cont)
+ {
+ this->it_ = this->con_.rend();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ void
+ rle_pset_bkd_piter_<P>::impl_start()
+ {
+ this->it_ = this->con_.rbegin(); // FIXME: Test if (this->it_ != this->con_.rend())...
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = this->it_->second - 1;
+ this->ps_.pset_pos_ = this->con_.size() - 1;
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ rle_pset_bkd_piter_<P>::impl_next()
+ {
+ precondition(this->is_valid());
+
+ --(this->ps_.index_);
+
+ if (this->ps_.index_ + 1 == 0)
+ {
+ ++this->it_;
+ --this->ps_.pset_pos_;
+ this->ps_.start_ = this->it_->first;
+ this->ps_.index_ = this->it_->second - 1;
+ }
+ this->p_ = this->ps_.start_;
+ this->p_[0] += this->ps_.index_;
+ }
+
+ template <typename P>
+ void
+ rle_pset_bkd_piter_<P>::impl_invalidate()
+ {
+ this->it_ = this->con_.rend();
+ this->ps_.pset_pos_ = this->con_.size();
+ }
+
+ template <typename P>
+ bool
+ rle_pset_bkd_piter_<P>::impl_is_valid() const
+ {
+ return this->it_ != this->con_.rend();
+ }
+# endif // ! OLN_INCLUDE_ONLY
+
+ // end of class rle_pset_bkd_piter_
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_RLE_RLE_PSET_HH
Index: oln/core/gen/rle_image.hh
--- oln/core/gen/rle_image.hh (revision 0)
+++ oln/core/gen/rle_image.hh (revision 0)
@@ -0,0 +1,160 @@
+// 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 OLN_CORE_GEN_RLE_IMAGE_HH
+# define OLN_CORE_GEN_RLE_IMAGE_HH
+
+# include <vector>
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/gen/rle_psite.hh>
+# include <oln/core/gen/rle_pset.hh>
+
+
+
+namespace oln
+{
+ // Fwd decl.
+ template <typename P, typename T>
+ struct rle_image;
+
+ // Super type.
+ template <typename P, typename T>
+ struct super_trait_< rle_image<P, T> >
+ {
+ typedef rle_image<P, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P, typename T>
+ struct vtypes< rle_image<P, T> >
+ {
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef P point;
+ typedef typename P::coord coord;
+
+ typedef rle_psite<P> psite;
+
+ typedef rle_pset<point> pset;
+
+ typedef mlc::none plain;
+
+ typedef std::pair< pset, std::vector< value > > data;
+ };
+
+
+ /*
+ ** \class rle_image
+ ** \brief rle image (use a pair of point range and value as representation)
+ **
+ */
+ template < typename P, typename T>
+ class rle_image : public internal::primitive_image_< rle_image<P, T> >
+ {
+ typedef rle_image<P, T> current;
+ typedef internal::primitive_image_< rle_image<P, T> > super;
+ public:
+ stc_using(pset);
+ stc_using(box);
+ stc_using(point);
+ stc_using(value);
+ stc_using(rvalue);
+ stc_using(lvalue);
+ stc_using(psite);
+ stc_using(data);
+
+ rle_image();
+
+
+ const pset& impl_points() const;
+
+ bool impl_owns_(const psite& p) const;
+ void insert(const point& p, unsigned len, value val);
+ rvalue impl_read(const psite& p) const;
+ lvalue impl_read_write(const psite& p);
+
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ rle_image<P, T>::rle_image()
+ {
+ this->data_ = new data;
+ }
+
+ template <typename P, typename T>
+ const typename rle_image<P, T>::pset&
+ rle_image<P, T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename P, typename T>
+ bool
+ rle_image<P, T>::impl_owns_(const typename rle_image<P, T>::psite& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first.has(p.start_);
+ }
+
+ template <typename P, typename T>
+ void
+ rle_image<P, T>::insert(const typename rle_image<P, T>::point& p,
+ unsigned len, rle_image<P, T>::value val)
+ {
+ assert(this->has_data());
+ this->data_->first.insert(p, len);
+ this->data_->second.push_back(val);
+ }
+
+ template <typename P, typename T>
+ typename rle_image<P, T>::rvalue
+ rle_image<P, T>::impl_read(const rle_image<P, T>::psite& ps) const
+ {
+ assert(this->has_data() && ps.pset_pos_ < this->data_->second.size());
+ return this->data_->second[ps.pset_pos_];
+ }
+
+ template <typename P, typename T>
+ typename rle_image<P, T>::lvalue
+ rle_image<P, T>::impl_read_write(const rle_image<P, T>::psite& ps)
+ {
+ assert(this->has_data() && ps.pset_pos_ < this->data_->second.size());
+ return this->data_->second[ps.pset_pos_];
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_GEN_RLE_IMAGE_HH
Index: oln/core/gen/rle_psite.hh
--- oln/core/gen/rle_psite.hh (revision 0)
+++ oln/core/gen/rle_psite.hh (revision 0)
@@ -0,0 +1,88 @@
+// 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 OLN_CORE_RLE_RLE_PSITE_HH
+# define OLN_CORE_RLE_RLE_PSITE_HH
+
+
+# include <map>
+# include <utility>
+
+namespace oln
+{
+
+
+ // Forward declaration
+ template <typename P, typename T> struct rle_image;
+
+ /*
+ ** \class rle_psite
+ ** \brief psite for rle image
+ **
+ ** Note: P must be a point type
+ */
+ template <typename P>
+ struct rle_psite
+ {
+ rle_psite();
+
+ P to_point() const;
+ operator P () const;
+
+ P start_;
+ unsigned index_;
+ unsigned pset_pos_;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ rle_psite<P>::rle_psite()
+ {
+ }
+
+ template <typename P>
+ P
+ rle_psite<P>::to_point() const
+ {
+ P p = this->start_;
+
+ p[0] += this->index_;
+ return p;
+ }
+
+ template <typename P>
+ rle_psite<P>::operator P() const
+ {
+ return this->to_point();
+ }
+
+# endif /* !OLN_INCLUDE_ONLY */
+
+ //end of class rle_psite
+}
+#endif // !OLN_CORE_RLE_RLE_PSITE_HH
Index: oln/core/gen/rle_encode.hh
--- oln/core/gen/rle_encode.hh (revision 946)
+++ oln/core/gen/rle_encode.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/core/concept/image.hh>
-# include <oln/core/rle/rle_image.hh>
+# include <oln/core/gen/rle_image.hh>
namespace oln
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 946)
+++ oln/core/sparse/sparse_image.hh (working copy)
@@ -129,7 +129,8 @@
template <typename P, typename T>
void
- sparse_image<P, T>::insert(const point& p, unsigned len, const std::vector<typename sparse_image<P, T>::value>& val)
+ sparse_image<P, T>::insert(const point& p, unsigned len,
+ const std::vector<typename sparse_image<P, T>::value>& val)
{
assert(this->has_data());
this->data_->first.insert(p, len);
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the type of value-casted images.
* oln/core/gen/casted_image.hh: New.
* oln/core/gen/value_cast.hh (include): Add casted_image.hh.
* oln/morpher/stack_rw.hxx,
* oln/morpher/value_cast.hh,
* oln/morpher/identity.hh,
* oln/morpher/thru_fun.hh,
* oln/morpher/tags.hh,
* oln/morpher/value_cast.hxx,
* oln/morpher/count_rw.hh,
* oln/morpher/identity.hxx,
* oln/morpher/stack.hh,
* oln/morpher/count_rw.hxx,
* oln/morpher/stack_rw.hh,
* oln/morpher/stack.hxx,
* oln/morpher/internal/image_value_morpher.hh,
* oln/morpher/internal/image_extension.hh: Remove; obsolete.
casted_image.hh | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
value_cast.hh | 3 +
2 files changed, 149 insertions(+)
Index: oln/core/gen/casted_image.hh
--- oln/core/gen/casted_image.hh (revision 0)
+++ oln/core/gen/casted_image.hh (revision 0)
@@ -0,0 +1,146 @@
+// 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 OLN_CORE_GEN_CASTED_IMAGE_HH
+# define OLN_CORE_GEN_CASTED_IMAGE_HH
+
+# include <oln/core/gen/through.hh>
+# include <oln/core/gen/pw_value.hh>
+# include <oln/core/internal/f_ch_value.hh>
+
+
+namespace oln
+{
+
+
+# define current casted_image<I, V>
+# define super internal::value_morpher_< current >
+
+
+ // Fwd decl.
+ template <typename I, typename V> class casted_image;
+
+
+ // Super type.
+ template <typename I, typename V>
+ struct super_trait_< current >
+ {
+ typedef super ret;
+ };
+
+
+ // Virtual types.
+ template <typename I, typename V>
+ struct vtypes< current >
+ {
+ typedef I delegatee;
+ typedef internal::singleton<const I> data;
+
+ typedef V value;
+ typedef V rvalue;
+
+ typedef oln_plain_value(I, V) plain;
+ typedef casted_image<pl::rec<I>, V> skeleton;
+ };
+
+
+ /// casted_image<I, V>
+
+ template <typename I, typename V>
+ class casted_image : public super
+ {
+ public:
+ stc_using(data);
+ stc_using(psite);
+
+ casted_image();
+ casted_image(const Image<I>& ima);
+
+ const I& impl_image() const;
+
+ V impl_read(const psite& p) const;
+ };
+
+
+ // value_cast
+
+ template <typename V, typename I>
+ casted_image<I, V> value_cast(const Image<I>& ima);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I, typename V>
+ current::casted_image()
+ {
+ }
+
+ template <typename I, typename V>
+ current::casted_image(const Image<I>& ima)
+ {
+ precondition(exact(ima).has_data());
+ this->data_ = new data(exact(ima));
+ }
+
+ template <typename I, typename V>
+ const I&
+ current::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->value;
+ }
+
+ template <typename I, typename V>
+ V
+ current::impl_read(const typename current::psite& p) const
+ {
+ assert(this->has_data());
+ assert(this->image().has_data());
+ return this->data_->value(p);
+ }
+
+ // value_cast
+
+ template <typename V, typename I>
+ current value_cast(const Image<I>& ima)
+ {
+ current tmp(ima);
+ return tmp;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef super
+# undef current
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/value_cast.hh>
+
+
+#endif // ! OLN_CORE_GEN_CASTED_IMAGE_HH
Index: oln/core/gen/value_cast.hh
--- oln/core/gen/value_cast.hh (revision 945)
+++ oln/core/gen/value_cast.hh (working copy)
@@ -88,4 +88,7 @@
} // end of namespace oln
+# include <oln/core/gen/casted_image.hh>
+
+
#endif // ! OLN_CORE_GEN_VALUE_CAST_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing ChangeLog text of previous commit.
Refactor point and dpoint interface.
* oln/core/traits_id.hh,
* oln/core/traits.hh,
* oln/core/case.hh,
* oln/basics3d.hh: Remove; obsolete.
* oln/core/internal/point1d.hh,
* oln/core/internal/dpoint1d.hh,
* oln/core/internal/point1d.hh,
* oln/core/internal/point2d.hh: Remove.
Their contents is now in...
* oln/core/internal/point_impl.hh: ...this new file.
* oln/core/1d/dpoint1d.hh,
* oln/core/1d/point1d.hh,
* oln/core/2d/dpoint2d.hh,
* oln/core/2d/point2d.hh: Update inheritance.
* oln/core/concept/generalized_point.hh: Remove.
(Generalized_Point): Move into...
* oln/core/concept/point.hh: ...this file.
Handle 3D.
* oln/core/3d/neighb3d.hh (mk_c4_slice, mk_c8_slice): Rename as...
(mk_c4_sli, mk_c8_sli): ...these.
(mk_c4_row, mk_c4_col, mk_c8_row, mk_c8_col): Remove.
Update.
* oln/core/3d/dpoint3d.hh,
* oln/core/3d/array3d.hh,
* oln/core/3d/image3d.hh,
* oln/core/3d/window3d.hh,
* oln/core/3d/point3d.hh: Update.
* oln/core/3d/image3d_b.hh,
* oln/core/3d/grid3d.hh,
* oln/core/3d/box3d.hh: New.
* oln/core/internal/f_grid_to_plain_image.hh: Add 3D case.
* oln/core/internal/f_grid_to_box.hh: Add 3D case.
* oln/core/concept/image.hh (Image_3D): Add interface.
Split operators into different files.
* oln/core/internal/image_ops.hh: Remove.
Split contents into...
* oln/core/gen/extended_by.hh,
* oln/core/gen/restricted_to.hh,
* oln/core/gen/applied_on.hh,
* oln/core/gen/through.hh,
* oln/core/gen/such_as.hh,
* oln/core/gen/over.hh,
* oln/core/internal/macro_extended_by.hh: ...these new files.
And split decls and defs.
* oln/core/gen/op.hh: Update.
* oln/core/gen/point.hh: New.
* oln/core/gen/dpoint.hh: New.
Various bug fixes and cleanups.
* oln/core/rle/rle_pset.hh: Update; use oln_f_point_to_box.
* oln/core/concept/iterator_on_points.hh (Iterator_on_Points):
Remove virtual inheritance.
* oln/core/concept/image.hh (nrows, ncols): New in Image_2D.
* oln/core/concept/function.hh (category): New in function
concepts.
* oln/core/concept/point_set.hh (box): Rename as...
(i_box): ...this.
* oln/core/concept/neighborhood.hh (category): Remove.
* oln/core/concept/value.hh (vtypes<bool>): New.
* oln/core/concept/operators.hh (operator-): Fix missing decl.
* oln/core/1d/array1d.hh (array1d_): Fix ctor.
* oln/core/1d/image1d.hh,
* oln/core/1d/image1d_b.hh,
* oln/core/2d/image2d.hh,
* oln/core/2d/image2d_b.hh (include): Top box inclusion.
* oln/core/1d/box1d.hh (point): Remove (useless).
(include): Remove gen/box.hh (useless).
(box1d): Use stc_using_.
* oln/core/2d/box2d.hh: Likewise.
(box): Update to...
(i_box): ...this.
* oln/core/2d/neighb2d.hh (c2r, c2c): Rename as...
(c2_row, c2_col): ...these.
* oln/core/2d/array2d.hh (row_pad): Rename as...
(i_pad): ...this.
* oln/core/gen/dpoints_piter.hh (include): Update.
* oln/core/gen/box.hh (gen_box): Rename as...
(box): ...this.
(P): Remove parameter.
(G, C): New parameters.
* oln/core/gen/fun.hh (set_category_of_): Remove (obsolete).
Separate decls and defs.
* oln/core/gen/fbbox.hh: Update.
* oln/core/gen/niter_has.hh (include): Update.
* oln/core/gen/value_cast.hh (set_category_of_): Remove.
(casted_fp2v_): Rename as...
(casted_fun_): ...this more general class.
* oln/core/gen/neighb.hh (include): Update.
* oln/core/gen/literal.hh: Split decls and defs.
* oln/core/gen/image_stack.hh: Fix missing include.
* oln/core/gen/fun_ops.hh (set_category_of_): Remove.
* oln/core/internal/op_image_through_fv2v.hh: Fix comment.
* oln/core/internal/box.hh: Update.
* oln/core/internal/point_set_base.hh (operator|): Move to...
* oln/core/gen/such_as.hh: ...this file.
* oln/core/internal/point_set_base.hh (f_box_from_point_): Move
to...
* oln/core/internal/f_point_to_box.hh: ...this new file.
* oln/core/internal/op_image_such_as_fp2b.hh (include): Update.
* oln/core/internal/point_set_std_based.hh: Update.
* oln/core/internal/image_base.hh (include): Remove
internal/image_ops.
* oln/core/internal/op_fv2v_applied_on_image.hh (value, rvalue):
Fix.
* oln/core/internal/point_base.hh: Remove FIXMEs.
* oln/core/internal/category_of.hh (set_category_of_): Remove.
(get_category_of_),
(get_category_base_type_): New.
* oln/core/internal/iterator_on_points_impl.hh
(iterator_on_points_impl): Rename as...
(iterator_on_points_impl_): ...this.
Remove parameter P.
Remove inheritance; update include.
Rewrite code using static_cast.
* oln/core/internal/f_pset_to_plain_image.hh: Update.
* oln/core/internal/iterator_on_points_base.hh (inheritance):
Update.
* oln/stc/scoop.hh (stc_using_): New.
* oln/draw/bresenham.hh (include): Update.
Update tests.
* tests/core/iter_point1d.cc,
* tests/core/iter_point2d.cc,
* tests/core/iter_point3d.cc,
* tests/core/subset.cc,
* tests/core/rle_image.cc: Update.
* TODO: Update.
TODO | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
Index: TODO
--- TODO (revision 944)
+++ TODO (working copy)
@@ -16,14 +16,11 @@
basics important routines: fill, assign, clone, unmorph (undress?),
convert, ... + add 'with' to disambiguate
-torus and mask types, and the proper niter type deductions (with or
-without virtual border)
+mask types, and the proper niter type deductions (with or without
+virtual border)
virtual border adaptation and initialization policies
-safe type when image is mutable; question: can we have Mutable_Image&
-as argument when an image, a morpher, is created on the fly?
-
io pnm
draw routines
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add 3D, remove some fixmes, and make various cleanups.
oln/core/1d/array1d.hh | 3
oln/core/1d/box1d.hh | 7
oln/core/1d/dpoint1d.hh | 21 -
oln/core/1d/image1d.hh | 2
oln/core/1d/image1d_b.hh | 7
oln/core/1d/point1d.hh | 22 +
oln/core/2d/array2d.hh | 33 +-
oln/core/2d/box2d.hh | 18 -
oln/core/2d/dpoint2d.hh | 22 +
oln/core/2d/image2d.hh | 4
oln/core/2d/image2d_b.hh | 9
oln/core/2d/neighb2d.hh | 13 -
oln/core/2d/point2d.hh | 21 +
oln/core/3d/array3d.hh | 295 +++++++++++++++++++-------
oln/core/3d/box3d.hh | 154 +++++++++++++
oln/core/3d/dpoint3d.hh | 115 ++--------
oln/core/3d/grid3d.hh | 95 ++++++++
oln/core/3d/image3d.hh | 223 +++++++++++--------
oln/core/3d/image3d_b.hh | 290 +++++++++++++++++++++++++
oln/core/3d/neighb3d.hh | 276 ++++++++++--------------
oln/core/3d/point3d.hh | 133 +++--------
oln/core/3d/window3d.hh | 16 -
oln/core/concept/function.hh | 4
oln/core/concept/image.hh | 90 +++++++
oln/core/concept/iterator_on_points.hh | 3
oln/core/concept/neighborhood.hh | 3
oln/core/concept/operators.hh | 18 -
oln/core/concept/point.hh | 24 +-
oln/core/concept/point_set.hh | 2
oln/core/concept/value.hh | 6
oln/core/gen/applied_on.hh | 134 +++++++++++
oln/core/gen/box.hh | 67 ++---
oln/core/gen/dpoint.hh | 92 ++++++++
oln/core/gen/dpoints_piter.hh | 2
oln/core/gen/extended_by.hh | 60 +++++
oln/core/gen/fbbox.hh | 5
oln/core/gen/fun.hh | 193 ++++++++++-------
oln/core/gen/fun_ops.hh | 58 -----
oln/core/gen/image_stack.hh | 1
oln/core/gen/literal.hh | 157 +++++++------
oln/core/gen/neighb.hh | 15 -
oln/core/gen/niter_has.hh | 2
oln/core/gen/op.hh | 92 --------
oln/core/gen/over.hh | 108 +++++++++
oln/core/gen/point.hh | 93 ++++++++
oln/core/gen/restricted_to.hh | 95 ++++++++
oln/core/gen/such_as.hh | 220 +++++++++++++++++++
oln/core/gen/through.hh | 134 +++++++++++
oln/core/gen/value_cast.hh | 61 ++---
oln/core/internal/box.hh | 8
oln/core/internal/category_of.hh | 59 ++---
oln/core/internal/f_grid_to_box.hh | 16 -
oln/core/internal/f_grid_to_plain_image.hh | 13 -
oln/core/internal/f_point_to_box.hh | 112 +++++++++
oln/core/internal/f_pset_to_plain_image.hh | 17 +
oln/core/internal/image_base.hh | 7
oln/core/internal/iterator_on_points_base.hh | 11
oln/core/internal/iterator_on_points_impl.hh | 127 +++++------
oln/core/internal/macro_extended_by.hh | 128 +++++++++++
oln/core/internal/op_fv2v_applied_on_image.hh | 4
oln/core/internal/op_image_such_as_fp2b.hh | 7
oln/core/internal/op_image_through_fv2v.hh | 2
oln/core/internal/point_base.hh | 4
oln/core/internal/point_impl.hh | 199 +++++++++++++++++
oln/core/internal/point_set_base.hh | 63 -----
oln/core/internal/point_set_std_based.hh | 2
oln/core/rle/rle_pset.hh | 2
oln/draw/bresenham.hh | 4
oln/stc/scoop.hh | 1
tests/core/iter_point1d.cc | 17 -
tests/core/iter_point2d.cc | 19 -
tests/core/iter_point3d.cc | 22 -
tests/core/rle_image.cc | 2
tests/core/subset.cc | 1
74 files changed, 3154 insertions(+), 1211 deletions(-)
Index: tests/core/iter_point1d.cc
--- tests/core/iter_point1d.cc (revision 943)
+++ tests/core/iter_point1d.cc (working copy)
@@ -26,23 +26,20 @@
// Public License.
#include <cassert>
-
#include <oln/core/1d/image1d.hh>
-#include <oln/core/internal/iterator_on_points_base.hh>
-
int
main()
{
+ using namespace oln;
- oln::image1d<int> ima1(40);
- oln::image1d<int>::piter p (ima1.points());
- oln::point1d p1;
+ image1d<int> ima(10);
+ point1d p_;
- for (p.start(); p.is_valid(); p.next())
- p1.ind() = p.ind();
+ image1d<int>::piter p(ima.points());
+ for_all(p)
+ p_.ind() = p.ind();
- assert(p1.ind() = 39);
- return 0;
+ assert(p_.ind() = 9);
}
Index: tests/core/iter_point2d.cc
--- tests/core/iter_point2d.cc (revision 943)
+++ tests/core/iter_point2d.cc (working copy)
@@ -26,25 +26,22 @@
// Public License.
#include <cassert>
-
#include <oln/core/2d/image2d.hh>
int
main()
{
+ using namespace oln;
- oln::image2d<int> ima1(40, 30);
- oln::image2d<int>::piter p (ima1.points());
- oln::point2d p1;
+ image2d<int> ima(20, 10);
+ point2d p_;
+ image2d<int>::piter p(ima.points());
- for (p.start(); p.is_valid(); p.next())
+ for_all(p)
{
- p1.row() = p.row();
- p1.col() = p.col();
+ p_.row() = p.row();
+ p_.col() = p.col();
}
- assert(p1.row() = 39);
- assert(p1.col() = 29);
-
- return 0;
+ assert(p_.row() = 19 and p_.col() = 9);
}
Index: tests/core/iter_point3d.cc
--- tests/core/iter_point3d.cc (revision 943)
+++ tests/core/iter_point3d.cc (working copy)
@@ -26,27 +26,23 @@
// Public License.
#include <cassert>
-
#include <oln/core/3d/image3d.hh>
int
main()
{
+ using namespace oln;
- oln::image3d<int> ima1(40, 30, 20);
- oln::image3d<int>::piter p (ima1.points());
- oln::point3d p1;
+ image3d<int> ima(30, 20, 10);
+ point3d p_;
+ image3d<int>::piter p(ima.points());
- for (p.start(); p.is_valid(); p.next())
+ for_all(p)
{
- p1.row() = p.row();
- p1.col() = p.col();
- p1.slice() = p.slice();
+ p_.sli() = p.sli();
+ p_.row() = p.row();
+ p_.col() = p.col();
}
- assert(p1.row() = 39);
- assert(p1.col() = 29);
- assert(p1.slice() = 19);
-
- return 0;
+ assert(p_.sli() = 29 and p_.row() = 19 and p_.col() = 9);
}
Index: tests/core/subset.cc
--- tests/core/subset.cc (revision 943)
+++ tests/core/subset.cc (working copy)
@@ -28,6 +28,7 @@
#include <cassert>
#include <oln/core/2d/image2d.hh>
#include <oln/core/2d/neighb2d.hh>
+#include <oln/core/gen/restricted_to.hh>
int main()
Index: tests/core/rle_image.cc
--- tests/core/rle_image.cc (revision 943)
+++ tests/core/rle_image.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
+#include <oln/core/2d/image2d.hh>
#include <oln/core/rle/rle_psite.hh>
#include <oln/core/rle/rle_image.hh>
-#include <oln/core/2d/image2d.hh>
#include <oln/debug/print.hh>
#include <oln/core/rle/rle_pset.hh>
#include <oln/core/encode/rle_encode.hh>
Index: oln/core/rle/rle_pset.hh
--- oln/core/rle/rle_pset.hh (revision 943)
+++ oln/core/rle/rle_pset.hh (working copy)
@@ -59,7 +59,7 @@
{
typedef P point;
- typedef typename f_box_from_point_<P>::ret box;
+ typedef oln_f_point_to_box(P) box;
typedef rle_pset_fwd_piter_<P> fwd_piter;
typedef rle_pset_bkd_piter_<P> bkd_piter;
};
Index: oln/core/concept/iterator_on_points.hh
--- oln/core/concept/iterator_on_points.hh (revision 943)
+++ oln/core/concept/iterator_on_points.hh (working copy)
@@ -31,7 +31,6 @@
# include <ostream>
-# include <oln/core/concept/generalized_point.hh>
# include <oln/core/concept/iterator.hh>
# include <oln/core/concept/point.hh>
@@ -43,7 +42,7 @@
template <typename Exact>
struct Iterator_on_Points : public Iterator<Exact>,
- virtual public Generalized_Point<Exact>
+ public Generalized_Point<Exact>
{
stc_typename(point);
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 943)
+++ oln/core/concept/image.hh (working copy)
@@ -291,8 +291,10 @@
// final
coord min_row() const;
coord max_row() const;
+ unsigned nrows() const;
coord min_col() const;
coord max_col() const;
+ unsigned ncols() const;
protected:
Image_2D();
@@ -307,6 +309,17 @@
{
stc_typename(coord);
+ // final
+ coord min_row() const;
+ coord max_row() const;
+ unsigned nrows() const;
+ coord min_col() const;
+ coord max_col() const;
+ unsigned ncols() const;
+ coord min_sli() const;
+ coord max_sli() const;
+ unsigned nslis() const;
+
protected:
Image_3D();
};
@@ -635,6 +648,13 @@
}
template <typename Exact>
+ unsigned
+ Image_2D<Exact>::nrows() const
+ {
+ return this->bbox().pmax().row() - this->bbox().pmin().row() + 1;
+ }
+
+ template <typename Exact>
typename Image_2D<Exact>::coord
Image_2D<Exact>::min_col() const
{
@@ -648,6 +668,13 @@
return this->bbox().pmax().col();
}
+ template <typename Exact>
+ unsigned
+ Image_2D<Exact>::ncols() const
+ {
+ return this->bbox().pmax().col() - this->bbox().pmin().col() + 1;
+ }
+
// ----------------------------------- Image_3D<Exact>
template <typename Exact>
@@ -655,6 +682,69 @@
{
}
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::min_row() const
+ {
+ return this->bbox().pmin().row();
+ }
+
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::max_row() const
+ {
+ return this->bbox().pmax().row();
+ }
+
+ template <typename Exact>
+ unsigned
+ Image_3D<Exact>::nrows() const
+ {
+ return this->bbox().pmax().row() - this->bbox().pmin().row() + 1;
+ }
+
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::min_col() const
+ {
+ return this->bbox().pmin().col();
+ }
+
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::max_col() const
+ {
+ return this->bbox().pmax().col();
+ }
+
+ template <typename Exact>
+ unsigned
+ Image_3D<Exact>::ncols() const
+ {
+ return this->bbox().pmax().col() - this->bbox().pmin().col() + 1;
+ }
+
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::min_sli() const
+ {
+ return this->bbox().pmin().sli();
+ }
+
+ template <typename Exact>
+ typename Image_3D<Exact>::coord
+ Image_3D<Exact>::max_sli() const
+ {
+ return this->bbox().pmax().sli();
+ }
+
+ template <typename Exact>
+ unsigned
+ Image_3D<Exact>::nslis() const
+ {
+ return this->bbox().pmax().sli() - this->bbox().pmin().sli() + 1;
+ }
+
// ----------------------------------- Point_Wise_Accessible_Image_2D<Exact>
template <typename Exact>
Index: oln/core/concept/function.hh
--- oln/core/concept/function.hh (revision 943)
+++ oln/core/concept/function.hh (working copy)
@@ -62,6 +62,7 @@
template <typename Exact>
struct Function_p2v : public Function<Exact>
{
+ typedef Function_p2v<void> category;
protected:
Function_p2v();
};
@@ -72,6 +73,7 @@
template <typename Exact>
struct Function_p2b : public Function<Exact>
{
+ typedef Function_p2b<void> category;
protected:
Function_p2b();
};
@@ -82,6 +84,7 @@
template <typename Exact>
struct Function_v2v : public Function<Exact>
{
+ typedef Function_v2v<void> category;
protected:
Function_v2v();
};
@@ -128,6 +131,7 @@
template <typename Exact>
struct Function_p2p : public Function<Exact>
{
+ typedef Function_p2p<void> category;
protected:
Function_p2p();
};
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 943)
+++ oln/core/concept/point.hh (working copy)
@@ -31,7 +31,6 @@
# include <mlc/value.hh>
-# include <oln/core/concept/generalized_point.hh>
# include <oln/core/concept/grid.hh>
# include <oln/core/concept/operators.hh>
@@ -40,8 +39,22 @@
namespace oln
{
- /// Instant value.
- oln_decl_instant_value(point);
+
+ /// Concept-class "Generalized_Point".
+
+ template <typename Exact>
+ struct Generalized_Point : virtual public Any<Exact>
+ {
+ stc_typename(grid);
+ stc_typename(dim);
+ stc_typename(coord);
+ stc_typename(dpoint);
+
+ enum { n = mlc_value(dim) };
+
+ protected:
+ Generalized_Point();
+ };
/// Concept-class "Point".
@@ -127,6 +140,10 @@
# ifndef OLN_INCLUDE_ONLY
+ template <typename Exact>
+ Generalized_Point<Exact>::Generalized_Point()
+ {
+ }
template <typename Exact>
bool Point<Exact>::op_equal_(const Exact& rhs) const
@@ -193,7 +210,6 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 943)
+++ oln/core/concept/point_set.hh (working copy)
@@ -36,7 +36,7 @@
{
/// Instant value.
- oln_decl_instant_value(box);
+ oln_decl_instant_value(i_box);
/// Concept-class "Point_Set".
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 943)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -42,7 +42,6 @@
{
stc_typename(grid);
stc_typename(point);
- stc_typename(category);
protected:
Neighborhood();
@@ -58,7 +57,7 @@
{
}
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/concept/value.hh
--- oln/core/concept/value.hh (revision 943)
+++ oln/core/concept/value.hh (working copy)
@@ -53,6 +53,12 @@
Boolean();
};
+ template <>
+ struct vtypes< bool > // FIXME: single_vtype? or move elsewhere?
+ {
+ typedef stc::is<Boolean> category;
+ };
+
# ifndef OLN_INCLUDE_ONLY
Index: oln/core/concept/operators.hh
--- oln/core/concept/operators.hh (revision 943)
+++ oln/core/concept/operators.hh (working copy)
@@ -81,6 +81,10 @@
/// Operator - (default version).
template <typename T>
+ T operator- (const Any<T>& lhs, const Any<T>& rhs);
+
+ /// Operator - (default version).
+ template <typename T>
T operator- (const Any<T>& rhs);
@@ -136,6 +140,13 @@
return tmp += exact(rhs);
}
+ template <typename T>
+ T operator- (const Any<T>& lhs, const Any<T>& rhs)
+ {
+ T tmp = exact(lhs);
+ return tmp -= exact(rhs);
+ }
+
template <typename L, typename R>
L& operator%=(Any<L>& lhs, const Any<R>& rhs)
{
@@ -171,13 +182,6 @@
return exact(lhs).op_plus_(exact(rhs));
}
- template <typename T>
- T operator- (const Any<T>& lhs, const Any<T>& rhs)
- {
- T tmp = exact(lhs);
- return tmp -= rhs;
- }
-
template <typename L, typename R>
xtd_op_minus_trait(L, R) operator- (const Any<L>& lhs, const Any<R>& rhs)
{
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 943)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -30,26 +30,27 @@
# define OLN_CORE_1D_DPOINT1D_HH
# include <oln/core/1d/grid1d.hh>
-# include <oln/core/internal/dpoint1d.hh>
+# include <oln/core/internal/dpoint_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
-
+ // Fwd decls.
struct point1d;
struct dpoint1d;
- /// Super type.
+ // Super type.
template<>
struct super_trait_< dpoint1d >
{
- typedef internal::dpoint1d_< dpoint1d > ret;
+ typedef internal::dpoint_base_< dpoint1d > ret;
};
- /// Virtual types.
+ // Virtual types.
template <>
struct vtypes< dpoint1d >
{
@@ -60,10 +61,12 @@
/// Usual 1D dpoint class.
- class dpoint1d : public internal::dpoint1d_< dpoint1d >
+ class dpoint1d : public internal::dpoint_base_< dpoint1d >,
+ public internal::point_impl_< 1, dpoint1d >
{
+ typedef internal::dpoint_base_< dpoint1d > super;
public:
- /// Ctors.
+ stc_using_(coord);
dpoint1d();
dpoint1d(int ind);
};
@@ -81,13 +84,11 @@
this->ind() = ind;
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
-// dpoint1d goes with point1d so:
# include <oln/core/1d/point1d.hh>
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 943)
+++ oln/core/1d/array1d.hh (working copy)
@@ -105,7 +105,7 @@
len_(len)
{
precondition(len > 0);
- imax_ = imin_ + len_;
+ imax_ = imin_ + len_ - 1;
allocate_();
}
@@ -192,7 +192,6 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 943)
+++ oln/core/1d/image1d.hh (working copy)
@@ -29,10 +29,10 @@
#ifndef OLN_CORE_1D_IMAGE1D_HH
# define OLN_CORE_1D_IMAGE1D_HH
+# include <oln/core/1d/box1d.hh>
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/box1d.hh>
namespace oln
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 943)
+++ oln/core/1d/image1d_b.hh (working copy)
@@ -28,20 +28,15 @@
#ifndef OLN_CORE_1D_IMAGE1D_B_HH
# define OLN_CORE_1D_IMAGE1D_B_HH
+# include <oln/core/1d/box1d.hh>
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/box1d.hh>
namespace oln
{
-
- // FIXME: Conversely to image2d_b, we use here the triplet class
- // instead of the array_b_ class.
-
-
// Fwd decl.
template <typename T> class image1d_b;
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 943)
+++ oln/core/1d/box1d.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_CORE_1D_BOX1D_HH
# define OLN_CORE_1D_BOX1D_HH
-# include <oln/core/gen/box.hh>
# include <oln/core/1d/point1d.hh>
+# include <oln/core/internal/box.hh>
namespace oln
@@ -58,11 +58,10 @@
{
typedef internal::box_< box1d > super;
public:
- // Note: we can't use stc_using because box1d isn't a templated class
- typedef super::point point;
+ stc_using_(from_to_t);
box1d();
- box1d(const box1d::from_to_t& dat);
+ box1d(const from_to_t& dat);
box1d(const point1d& pmin, const point1d& pmax);
template <typename D>
box1d(const internal::initializer_<D>& data);
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 943)
+++ oln/core/1d/point1d.hh (working copy)
@@ -30,26 +30,27 @@
# define OLN_CORE_1D_POINT1D_HH
# include <oln/core/1d/grid1d.hh>
-# include <oln/core/internal/point1d.hh>
+# include <oln/core/internal/point_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
-
+ // Fwd decls.
class point1d;
class dpoint1d;
- /// Super type.
+ // Super type.
template<>
struct super_trait_< point1d >
{
- typedef internal::point1d_< point1d > ret;
+ typedef internal::point_base_< point1d > ret;
};
- /// Virtual types.
+ // Virtual types.
template <>
struct vtypes< point1d >
{
@@ -60,10 +61,13 @@
/// Usual 1D point class.
- class point1d : public internal::point1d_< point1d >
+ class point1d : public internal::point_base_< point1d >,
+ public internal::point_impl_< 1, point1d >
{
+ typedef internal::point_base_< point1d > super;
public:
- /// Ctors.
+ stc_using_(coord);
+
point1d();
point1d(int ind);
};
@@ -81,13 +85,11 @@
this->ind() = ind;
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
-// point1d goes with dpoint1d so:
# include <oln/core/1d/dpoint1d.hh>
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 943)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -96,15 +96,15 @@
return tmp;
}
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::internal
extern neighb2d c4;
extern neighb2d c8;
- extern neighb2d c2r;
- extern neighb2d c2c;
+ extern neighb2d c2_row;
+ extern neighb2d c2_col;
# ifndef OLN_INCLUDE_ONLY
@@ -123,14 +123,13 @@
neighb2d c4 = internal::mk_c4();
neighb2d c8 = internal::mk_c8();
- neighb2d c2r = internal::mk_c2_row();
- neighb2d c2c = internal::mk_c2_col();
-# endif // OLN_INCLUDE_ONLY
+ neighb2d c2_row = internal::mk_c2_row();
+ neighb2d c2_col = internal::mk_c2_col();
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
-
#endif // ! OLN_CORE_2D_NEIGHB2D_HH
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 943)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -30,26 +30,27 @@
# define OLN_CORE_2D_DPOINT2D_HH
# include <oln/core/2d/grid2d.hh>
-# include <oln/core/internal/dpoint2d.hh>
+# include <oln/core/internal/dpoint_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
-
+ // Fwd decls.
struct point2d;
struct dpoint2d;
- /// Super type.
+ // Super type.
template<>
struct super_trait_< dpoint2d >
{
- typedef internal::dpoint2d_< dpoint2d > ret;
+ typedef internal::dpoint_base_< dpoint2d > ret;
};
- /// Virtual types.
+ // Virtual types.
template <>
struct vtypes< dpoint2d >
{
@@ -60,9 +61,14 @@
/// Usual 2D dpoint class.
- class dpoint2d : public internal::dpoint2d_< dpoint2d >
+ class dpoint2d : public internal::dpoint_base_< dpoint2d >,
+ public internal::point_impl_< 2, dpoint2d >
{
+ typedef internal::dpoint_base_< dpoint2d > super;
public:
+
+ stc_using_(coord);
+
/// Ctors.
dpoint2d();
dpoint2d(int row, int col);
@@ -82,13 +88,11 @@
this->col() = col;
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
-// dpoint2d goes with point2d so:
# include <oln/core/2d/point2d.hh>
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 943)
+++ oln/core/2d/array2d.hh (working copy)
@@ -79,11 +79,7 @@
const T* buffer() const;
T* buffer();
- std::size_t row_pad() const
- {
- precondition(buffer_ != 0 and array_ != 0);
- return &(array_[imin_+1][jmin_]) - &(array_[imin_][jmin_]);
- }
+ std::size_t i_pad() const;
protected:
@@ -105,10 +101,8 @@
template <typename T, typename C>
array2d_<T, C>::array2d_(C imin, C jmin, C imax, C jmax) :
- imin_(imin),
- jmin_(jmin),
- imax_(imax),
- jmax_(jmax)
+ imin_(imin), jmin_(jmin),
+ imax_(imax), jmax_(jmax)
{
precondition(imax >= imin and jmax >= jmin);
ilen_ = imax - imin + 1;
@@ -119,15 +113,13 @@
template <typename T, typename C>
array2d_<T, C>::array2d_(C ilen, C jlen) :
- imin_(0),
- jmin_(0),
- ilen_(ilen),
- jlen_(jlen)
+ imin_(0), jmin_(0),
+ ilen_(ilen), jlen_(jlen)
{
precondition(ilen > 0 and jlen > 0);
// FIXME: Test that ilen_ and jlen_ are not huge!
- imax_ = imin_ + ilen_;
- jmax_ = jmin_ + ilen_;
+ imax_ = imin_ + ilen_ - 1;
+ jmax_ = jmin_ + ilen_ - 1;
allocate_();
}
@@ -175,7 +167,6 @@
j >= jmin_ and j <= jmax_;
}
-
template <typename T, typename C>
C array2d_<T, C>::imin() const
{
@@ -213,6 +204,13 @@
}
template <typename T, typename C>
+ std::size_t array2d_<T, C>::i_pad() const
+ {
+ precondition(buffer_ != 0 and array_ != 0);
+ return jlen_;
+ }
+
+ template <typename T, typename C>
std::size_t array2d_<T, C>::ncells() const
{
return blen_;
@@ -255,8 +253,7 @@
array_ = 0; // safety
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 943)
+++ oln/core/2d/image2d.hh (working copy)
@@ -29,10 +29,10 @@
#ifndef OLN_CORE_2D_IMAGE2D_HH
# define OLN_CORE_2D_IMAGE2D_HH
+# include <oln/core/2d/box2d.hh>
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/box2d.hh>
namespace oln
@@ -42,7 +42,7 @@
template <typename T> class image2d;
- /// Virtual types.
+ // Virtual types.
template <typename T>
struct vtypes< image2d<T> >
{
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 943)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -29,10 +29,10 @@
#ifndef OLN_CORE_2D_IMAGE2D_B_HH
# define OLN_CORE_2D_IMAGE2D_B_HH
+# include <oln/core/2d/box2d.hh>
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/box2d.hh>
namespace oln
@@ -43,7 +43,7 @@
template <typename T> class image2d_b;
- /// Virtual types.
+ // Virtual types.
template <typename T>
struct vtypes< image2d_b<T> >
{
@@ -68,7 +68,7 @@
};
- /// Super type.
+ // Super type.
template <typename T>
struct super_trait_< image2d_b<T> >
{
@@ -236,7 +236,7 @@
std::size_t image2d_b<T>::pad(const dpoint2d& dp) const
{
assert(this->has_data());
- return this->data_->first.row_pad() * dp.row() + dp.col();
+ return this->data_->first.i_pad() * dp.row() + dp.col();
}
// template <typename T, typename D>
@@ -269,7 +269,6 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 943)
+++ oln/core/2d/box2d.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_CORE_2D_BOX2D_HH
# define OLN_CORE_2D_BOX2D_HH
-# include <oln/core/concept/point_set.hh> // for internal::tag::box_t
# include <oln/core/2d/point2d.hh>
+# include <oln/core/concept/point_set.hh> // for internal::tag::i_box_t
# include <oln/core/internal/box.hh>
@@ -59,12 +59,10 @@
{
typedef internal::box_< box2d > super;
public:
- // Note: we can't use stc_using because box2d isn't a templated class
- typedef super::point point;
- typedef super::from_to_t from_to_t;
+ stc_using_(from_to_t);
box2d();
- box2d(const box2d::from_to_t& dat);
+ box2d(const from_to_t& dat);
box2d(const point2d& pmin, const point2d& pmax);
template <typename D>
box2d(const internal::initializer_<D>& data);
@@ -74,11 +72,11 @@
{
template <typename U>
- bool init__(tag::box_t, box2d& b,
+ bool init__(tag::i_box_t, box2d& b,
const pair< nrows_t<U>, ncols_t<U> >& data);
template <typename U>
- bool init__(tag::box_t, box2d& b,
+ bool init__(tag::i_box_t, box2d& b,
const triplet< from_t<point2d>, nrows_t<U>, ncols_t<U> >& data);
} // end of namespace oln::internal
@@ -103,7 +101,7 @@
template <typename D>
box2d::box2d(const internal::initializer_<D>& data)
{
- bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
+ bool box_ok = internal::init__(internal::tag::i_box_t(), *this, data.value());
postcondition(box_ok);
}
@@ -112,7 +110,7 @@
{
template <typename U>
- bool init__(tag::box_t, box2d& b,
+ bool init__(tag::i_box_t, box2d& b,
const pair< nrows_t<U>, ncols_t<U> >& data)
{
unsigned nrows = data.first.value;
@@ -126,7 +124,7 @@
}
template <typename U>
- bool init__(tag::box_t, box2d& b,
+ bool init__(tag::i_box_t, box2d& b,
const triplet< from_t<point2d>, nrows_t<U>, ncols_t<U> >& data)
{
unsigned nrows = data.second.value;
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 943)
+++ oln/core/2d/point2d.hh (working copy)
@@ -30,26 +30,27 @@
# define OLN_CORE_2D_POINT2D_HH
# include <oln/core/2d/grid2d.hh>
-# include <oln/core/internal/point2d.hh>
+# include <oln/core/internal/point_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
-
+ // Fwd decls.
class point2d;
class dpoint2d;
- /// Super type.
+ // Super type.
template<>
struct super_trait_< point2d >
{
- typedef internal::point2d_< point2d > ret;
+ typedef internal::point_base_< point2d > ret;
};
- /// Virtual types.
+ // Virtual types.
template <>
struct vtypes< point2d >
{
@@ -60,14 +61,18 @@
/// Usual 2D point class.
- class point2d : public internal::point2d_< point2d >
+ class point2d : public internal::point_base_< point2d >,
+ public internal::point_impl_< 2, point2d >
{
typedef internal::initializer_<
internal::pair< internal::row_t<int>, internal::col_t<int> >
> row_col_t;
+
+ typedef internal::point_base_< point2d > super;
public:
- /// Ctors.
+ stc_using_(coord);
+
point2d();
point2d(int row, int col); // FIXME: Remove!
point2d(const row_col_t& dat);
@@ -95,11 +100,9 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
-// point2d goes with dpoint2d so:
# include <oln/core/2d/dpoint2d.hh>
Index: oln/core/3d/neighb3d.hh
--- oln/core/3d/neighb3d.hh (revision 943)
+++ oln/core/3d/neighb3d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -36,215 +36,169 @@
namespace oln
{
+ // FIXME: neighb3d should be an actual type, not an alias...
typedef neighb_<dpoint3d> neighb3d;
+# ifdef OLN_ENABLE_DEFAULT
+
+ // Default is c6.
+ template <typename D>
+ bool init_(neighb3d* this_, const D&);
+
+# endif // OLN_ENABLE_DEFAULT
+
+
namespace internal
{
neighb3d mk_c6();
neighb3d mk_c18();
neighb3d mk_c26();
- neighb3d mk_c4_slice();
- neighb3d mk_c8_slice();
- neighb3d mk_c4_row();
- neighb3d mk_c8_row();
- neighb3d mk_c4_col();
- neighb3d mk_c8_col();
+
+ neighb3d mk_c4_sli();
+ neighb3d mk_c8_sli();
+
+ neighb3d mk_c2_sli();
+ neighb3d mk_c2_row();
+ neighb3d mk_c2_col();
# ifndef OLN_INCLUDE_ONLY
neighb3d mk_c6()
{
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(1, 0, 0));
- flower = false;
- }
- return the_;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1))
+ .take(dpoint3d(0, 1, 0))
+ .take(dpoint3d(1, 0, 0));
+ return tmp;
}
-
neighb3d mk_c18()
{
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(0, 1, -1))
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(0, 1, 1))
- .add(dpoint3d(1, -1, 0))
- .add(dpoint3d(1, 0, -1))
- .add(dpoint3d(1, 0, 0))
- .add(dpoint3d(1, 0, 1))
- .add(dpoint3d(1, 1, 0));
- flower = false;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1))
+ .take(dpoint3d(0, 1, -1))
+ .take(dpoint3d(0, 1, 0))
+ .take(dpoint3d(0, 1, 1))
+ .take(dpoint3d(1, -1, 0))
+ .take(dpoint3d(1, 0, -1))
+ .take(dpoint3d(1, 0, 0))
+ .take(dpoint3d(1, 0, 1))
+ .take(dpoint3d(1, 1, 0));
+ return tmp;
}
- return the_;
- }
-
neighb3d mk_c26()
{
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(0, 1, -1))
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(0, 1, 1))
- .add(dpoint3d(1, -1, -1))
- .add(dpoint3d(1, -1, 0))
- .add(dpoint3d(1, -1, 1))
- .add(dpoint3d(1, 0, -1))
- .add(dpoint3d(1, 0, 0))
- .add(dpoint3d(1, 0, 1))
- .add(dpoint3d(1, 1, -1))
- .add(dpoint3d(1, 1, 0))
- .add(dpoint3d(1, 1, 1));
- flower = false;
- }
- return the_;
- }
-
-
- neighb3d mk_c4_slice()
- {
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(0, 1, 0));
- flower = false;
- }
- return the_;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1))
+ .take(dpoint3d(0, 1, -1))
+ .take(dpoint3d(0, 1, 0))
+ .take(dpoint3d(0, 1, 1))
+ .take(dpoint3d(1, -1, -1))
+ .take(dpoint3d(1, -1, 0))
+ .take(dpoint3d(1, -1, 1))
+ .take(dpoint3d(1, 0, -1))
+ .take(dpoint3d(1, 0, 0))
+ .take(dpoint3d(1, 0, 1))
+ .take(dpoint3d(1, 1, -1))
+ .take(dpoint3d(1, 1, 0))
+ .take(dpoint3d(1, 1, 1));
+ return tmp;
}
-
- neighb3d mk_c8_slice()
- {
- static bool flower = true;
- static neighb3d the_;
- if (flower)
+ neighb3d mk_c4_sli()
{
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(0, 1, -1))
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(0, 1, 1));
- flower = false;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1))
+ .take(dpoint3d(0, 1, 0));
+ return tmp;
}
- return the_;
- }
-
- neighb3d mk_c4_row()
- {
- static bool flower = true;
- static neighb3d the_;
- if (flower)
+ neighb3d mk_c8_sli()
{
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(1, 0, 0));
- flower = false;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1))
+ .take(dpoint3d(0, 1, -1))
+ .take(dpoint3d(0, 1, 0))
+ .take(dpoint3d(0, 1, 1));
+ return tmp;
}
- return the_;
- }
-
- neighb3d mk_c8_row()
+ neighb3d mk_c2_sli()
{
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 0, 1))
- .add(dpoint3d(1, 0, -1))
- .add(dpoint3d(1, 0, 0))
- .add(dpoint3d(1, 0, 1));
- flower = false;
- }
- return the_;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(1, 0, 0));
+ return tmp;
}
-
- neighb3d mk_c4_col()
+ neighb3d mk_c2_row3d()
{
- static bool flower = true;
- static neighb3d the_;
- if (flower)
- {
- the_
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(1, 0, 0));
- flower = false;
- }
- return the_;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 1, 0));
+ return tmp;
}
-
- neighb3d mk_c8_col()
- {
- static bool flower = true;
- static neighb3d the_;
- if (flower)
+ neighb3d mk_c2_col3d()
{
- the_
- .add(dpoint3d(0, 1, 0))
- .add(dpoint3d(1, -1, 0))
- .add(dpoint3d(1, 0, 0))
- .add(dpoint3d(1, 1, 0));
- flower = false;
- }
- return the_;
+ neighb3d tmp;
+ tmp
+ .take(dpoint3d(0, 0, 1));
+ return tmp;
}
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::internal
- extern const neighb3d c6;
- extern const neighb3d c18;
- extern const neighb3d c26;
-
- extern const neighb3d c4_slice;
- extern const neighb3d c8_slice;
- extern const neighb3d c4_row;
- extern const neighb3d c8_row;
- extern const neighb3d c4_col;
- extern const neighb3d c8_col;
+ extern neighb3d c6;
+ extern neighb3d c18;
+ extern neighb3d c26;
+
+ extern neighb3d c4_sli;
+ extern neighb3d c8_sli;
+
+ extern neighb3d c2_sli;
+ extern neighb3d c2_row3d;
+ extern neighb3d c2_col3d;
# ifndef OLN_INCLUDE_ONLY
- const neighb3d c6 = internal::mk_c6();
- const neighb3d c18 = internal::mk_c18();
- const neighb3d c26 = internal::mk_c26();
-
- const neighb3d c4_slice = internal::mk_c4_slice();
- const neighb3d c8_slice = internal::mk_c8_slice();
- const neighb3d c4_row = internal::mk_c4_row();
- const neighb3d c8_row = internal::mk_c8_row();
- const neighb3d c4_col = internal::mk_c4_col();
- const neighb3d c8_col = internal::mk_c8_col();
+# ifdef OLN_ENABLE_DEFAULT
+
+ /// Default is c6.
+ template <typename D>
+ bool init_(neighb3d* this_, const D&)
+ {
+ *this_ = c6;
+ return true;
+ }
+
+# endif // OLN_ENABLE_DEFAULT
+
+ neighb3d c6 = internal::mk_c6();
+ neighb3d c18 = internal::mk_c18();
+ neighb3d c26 = internal::mk_c26();
+
+ neighb3d c4_sli = internal::mk_c4_sli();
+ neighb3d c8_sli = internal::mk_c8_sli();
+
+ neighb3d c2_sli = internal::mk_c2_sli();
+ neighb3d c2_row3d = internal::mk_c2_row3d();
+ neighb3d c2_col3d = internal::mk_c2_col3d();
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/3d/dpoint3d.hh
--- oln/core/3d/dpoint3d.hh (revision 943)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,118 +29,69 @@
#ifndef OLN_CORE_3D_DPOINT3D_HH
# define OLN_CORE_3D_DPOINT3D_HH
-# include <mlc/int.hh>
-# include <oln/core/3d/point3d.hh>
-# include <oln/core/internal/dpoint_nd.hh>
+# include <oln/core/3d/grid3d.hh>
+# include <oln/core/internal/dpoint_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
- typedef dpoint3d_<int> dpoint3d;
+ // Fwd decls.
+ struct point3d;
+ struct dpoint3d;
- /// Super type.
- template<typename C>
- struct set_super_type< dpoint3d_<C> >
+ // Super type.
+ template<>
+ struct super_trait_< dpoint3d >
{
- typedef internal::dpoint_nd< dpoint3d_<C> > ret;
+ typedef internal::dpoint_base_< dpoint3d > ret;
};
- /// Fwd decls.
- template <unsigned D> struct grid_;
- typedef grid_<3> grid3d;
- template <typename C> struct point3d_;
- typedef point3d_<int> point3d;
-
-
- /// Virtual types associated to oln::dpoint3d_<C>.
- template <typename C>
- struct vtypes< dpoint3d_<C> >
- {
- typedef grid3d grid_type;
- typedef point3d point_type;
- typedef C coord_type;
- typedef mlc::uint_<3> dim_type;
-
- typedef mlc::uint_<0> slice_comp_type;
- typedef mlc::uint_<1> row_comp_type;
- typedef mlc::uint_<2> col_comp_type;
+ // Virtual types.
+ template <>
+ struct vtypes< dpoint3d >
+ {
+ typedef grid3d grid;
+ typedef int coord;
+ typedef point3d point;
};
- /// General 3D dpoint class.
- template <typename C>
- class dpoint3d_
- : public internal::dpoint_nd< dpoint3d_<C> >
+ /// Usual 3D dpoint class.
+ class dpoint3d : public internal::dpoint_base_< dpoint3d >,
+ public internal::point_impl_< 3, dpoint3d >
{
- typedef dpoint3d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t;
-
- using super_t::v_;
-
+ typedef internal::dpoint_base_< dpoint3d > super;
public:
-
- /// Ctor.
- dpoint3d_();
-
- /// Ctor.
- dpoint3d_(const xtd::vec<3,C>& v);
-
- /// Ctor.
- dpoint3d_(C slice, C row, C col);
-
- C slice() const;
- C& slice();
-
- C row() const;
- C& row();
-
- C col() const;
- C& col();
+ stc_using_(coord);
+ dpoint3d();
+ dpoint3d(int sli, int row, int col);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- dpoint3d_<C>::dpoint3d_()
- {
- }
-
- template <typename C>
- dpoint3d_<C>::dpoint3d_(const xtd::vec<3,C>& v)
- : super_t(v)
+ dpoint3d::dpoint3d()
{
}
- template <typename C>
- dpoint3d_<C>::dpoint3d_(C slice, C row, C col)
- : super_t(xtd::mk_vec(slice, row, col))
+ dpoint3d::dpoint3d(int sli, int row, int col)
{
+ this->sli() = sli;
+ this->row() = row;
+ this->col() = col;
}
- template <typename C>
- C dpoint3d_<C>::slice() const { return v_[0]; }
- template <typename C>
- C& dpoint3d_<C>::slice() { return v_[0]; }
-
- template <typename C>
- C dpoint3d_<C>::row() const { return v_[1]; }
- template <typename C>
- C& dpoint3d_<C>::row() { return v_[1]; }
-
- template <typename C>
- C dpoint3d_<C>::col() const { return v_[2]; }
- template <typename C>
- C& dpoint3d_<C>::col() { return v_[2]; }
+# endif // ! OLN_INCLUDE_ONLY
-# endif
+} // end of namespace oln
-} // end of namespace oln
+# include <oln/core/3d/point3d.hh>
#endif // ! OLN_CORE_3D_DPOINT3D_HH
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 943)
+++ oln/core/3d/array3d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 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
@@ -29,43 +29,75 @@
#ifndef OLN_CORE_3D_ARRAY3D_HH
# define OLN_CORE_3D_ARRAY3D_HH
-# include <cstdlib>
+# include <cstddef>
+# include <iostream>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 3D array class.
- template <typename value_t, typename coord_t = int>
- class array3d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array3d_
{
public:
+ // Not impled.
+ array3d_();
+ array3d_(const array3d_<T,C>& rhs);
+ void operator=(const array3d_<T,C>&);
+ // end of Not impled.
+
+
/// Ctor.
- array3d(coord_t imin, coord_t jmin, coord_t kmin,
- coord_t imax, coord_t jmax, coord_t kmax);
+ array3d_(C imin, C jmin, C kmin,
+ C imax, C jmax, C kmax);
+
/// Ctor.
- array3d(coord_t ilen, coord_t jlen, coord_t klen);
+ array3d_(C ilen, C jlen, C klen);
/// Dtor.
- ~array3d();
+ ~array3d_();
+
+ const T& operator()(C i, C j, C k) const;
+ T& operator()(C i, C j, C k);
+
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
+
+ bool has(C i, C j, C k) const;
+
+ std::size_t memsize() const;
+ std::size_t ncells() const;
- value_t operator()(coord_t i, coord_t j, coord_t k) const;
- value_t& operator()(coord_t i, coord_t j, coord_t k);
+ C imin() const;
+ C jmin() const;
+ C kmin() const;
- bool has(coord_t i, coord_t j, coord_t k) const;
+ C imax() const;
+ C jmax() const;
+ C kmax() const;
- size_t memsize() const;
+ C ilen() const;
+ C jlen() const;
+ C klen() const;
+
+ const T* buffer() const;
+ T* buffer();
+
+ std::size_t i_pad() const;
+ std::size_t j_pad() const;
protected:
- coord_t imin_, jmin_, kmin_, imax_, jmax_, kmax_;
- coord_t ilen_, jlen_, klen_;
- value_t* buffer_;
- value_t** array_2nd_dim_;
- value_t*** array_1st_dim_;
+ C imin_, jmin_, kmin_, imax_, jmax_, kmax_;
+ C ilen_, jlen_, klen_;
+ std::size_t blen_;
+ T* buffer_;
+ T** array_tmp_;
+ T*** array_;
private:
@@ -74,58 +106,77 @@
};
+ template <typename T, typename C>
+ std::ostream& operator<<(std::ostream& ostr, const array3d_<T,C>& arr);
+
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array3d<value_t, coord_t>::array3d(coord_t imin, coord_t jmin, coord_t kmin,
- coord_t imax, coord_t jmax, coord_t kmax)
- : imin_(imin), jmin_(jmin), kmin_(kmin),
+ template <typename T, typename C>
+ array3d_<T, C>::array3d_(C imin, C jmin, C kmin,
+ C imax, C jmax, C kmax) :
+ imin_(imin), jmin_(jmin), kmin_(kmin),
imax_(imax), jmax_(jmax), kmax_(kmax)
{
precondition(imax >= imin and jmax >= jmin and kmax >= kmin);
ilen_ = imax - imin + 1;
jlen_ = jmax - jmin + 1;
klen_ = kmax - kmin + 1;
+ // FIXME: Test that ilen_ and jlen_ are not huge!
allocate_();
}
- template <typename value_t, typename coord_t>
- array3d<value_t, coord_t>::array3d(coord_t ilen, coord_t jlen, coord_t klen)
- : imin_(0), jmin_(0), kmin_(0),
+ template <typename T, typename C>
+ array3d_<T, C>::array3d_(C ilen, C jlen, C klen) :
+ imin_(0), jmin_(0), kmin_(0),
ilen_(ilen), jlen_(jlen), klen_(klen)
{
precondition(ilen > 0 and jlen > 0 and klen > 0);
- imax_ = imin_ + ilen_;
- jmax_ = jmin_ + ilen_;
- kmax_ = kmin_ + klen_;
+ // FIXME: Test that *len_ are not huge!
+ imax_ = imin_ + ilen_ - 1;
+ jmax_ = jmin_ + ilen_ - 1;
+ kmax_ = kmin_ + klen_ - 1;
allocate_();
}
- template <typename value_t, typename coord_t>
- array3d<value_t, coord_t>::~array3d()
+ template <typename T, typename C>
+ array3d_<T, C>::~array3d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t
- array3d<value_t, coord_t>::operator()(coord_t i, coord_t j, coord_t k) const
+ template <typename T, typename C>
+ const T& array3d_<T, C>::operator()(C i, C j, C k) const
{
precondition(has(i, j, k));
- return array_1st_dim_[i][j][k];
+ return array_[i][j][k];
}
- template <typename value_t, typename coord_t>
- value_t&
- array3d<value_t, coord_t>::operator()(coord_t i, coord_t j, coord_t k)
+ template <typename T, typename C>
+ T& array3d_<T, C>::operator()(C i, C j, C k)
{
precondition(has(i, j, k));
- return array_1st_dim_[i][j][k];
+ return array_[i][j][k];
+ }
+
+ template <typename T, typename C>
+ const T& array3d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array3d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < blen_);
+ return buffer_[ind];
}
- template <typename value_t, typename coord_t>
- bool array3d<value_t, coord_t>::has(coord_t i, coord_t j, coord_t k) const
+ template <typename T, typename C>
+ bool array3d_<T, C>::has(C i, C j, C k) const
{
return
i >= imin_ and i <= imax_ and
@@ -133,57 +184,157 @@
k >= kmin_ and k <= kmax_;
}
- template <typename value_t, typename coord_t>
- size_t array3d<value_t, coord_t>::memsize() const
+ template <typename T, typename C>
+ C array3d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::jmin() const
+ {
+ return jmin_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::kmin() const
+ {
+ return kmin_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::jmax() const
+ {
+ return jmax_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::kmax() const
+ {
+ return kmax_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::ilen() const
+ {
+ return ilen_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::jlen() const
+ {
+ return jlen_;
+ }
+
+ template <typename T, typename C>
+ C array3d_<T, C>::klen() const
+ {
+ return klen_;
+ }
+
+ template <typename T, typename C>
+ const T* array3d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array3d_<T, C>::buffer()
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ std::size_t array3d_<T, C>::i_pad() const
+ {
+ precondition(buffer_ != 0 and array_ != 0);
+ return std::size_t(klen_) * std::size_t(jlen_);
+ }
+
+ template <typename T, typename C>
+ std::size_t array3d_<T, C>::j_pad() const
+ {
+ precondition(buffer_ != 0 and array_ != 0);
+ return klen_;
+ }
+
+ template <typename T, typename C>
+ std::size_t array3d_<T, C>::ncells() const
+ {
+ return blen_;
+ }
+
+ template <typename T, typename C>
+ std::size_t array3d_<T, C>::memsize() const
{
return
// buffer_
- size_t(ilen_) * size_t(jlen_) * size_t(klen_) * sizeof(value_t)
+ blen_ * sizeof(T)
+
- // array_2nd_dim_
- size_t(ilen_) * size_t(jlen_) * sizeof(value_t*)
+ // array_tmp_
+ std::size_t(ilen_) * std::size_t(jlen_) * sizeof(T*)
+
- // array_1st_dim_
- size_t(ilen_) * sizeof(value_t*);
+ // array_
+ std::size_t(ilen_) * sizeof(T**);
}
- template <typename value_t, typename coord_t>
- void array3d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array3d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(ilen_) * size_t(jlen_) * size_t(klen_)];
- array_2nd_dim_ = new value_t*[size_t(ilen_) * size_t(jlen_)];
- array_1st_dim_ = new value_t**[size_t(ilen_)];
- value_t* buf = buffer_ - kmin_;
- for (coord_t i = 0; i < ilen_; ++i)
+ blen_ = std::size_t(ilen_) * std::size_t(jlen_) * std::size_t(klen_);
+ buffer_ = new T [blen_];
+ array_tmp_ = new T* [std::size_t(ilen_) * size_t(jlen_)];
+ array_ = new T**[std::size_t(ilen_)];
+ T* buf = buffer_ - kmin_;
+ for (C i = 0; i < ilen_; ++i)
{
- value_t** nth_array_2nd_dim = array_2nd_dim_ + i * jlen_;
- array_1st_dim_[i] = nth_array_2nd_dim - jmin_;
- for (coord_t j = 0; j < jlen_; ++j)
+ T** arr_i_ = array_tmp_ + i * jlen_;
+ array_[i] = arr_i_ - jmin_;
+ for (C j = 0; j < jlen_; ++j)
{
- nth_array_2nd_dim[j] = buf;
+ arr_i_[j] = buf;
buf += klen_;
}
}
- array_1st_dim_ -= imin_;
+ array_ -= imin_;
}
- template <typename value_t, typename coord_t>
- void array3d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array3d_<T, C>::deallocate_()
{
- precondition(buffer_ != 0 and
- array_2nd_dim_ != 0 and
- array_1st_dim_ != 0);
+ precondition(buffer_ != 0 and array_ != 0 and array_tmp_ != 0);
delete[] buffer_;
buffer_ = 0; // safety
- delete[] array_2nd_dim_;
- array_2nd_dim_ = 0; // safety
- array_1st_dim_ += imin_;
- delete[] array_1st_dim_;
- array_1st_dim_ = 0; // safety
+ delete[] array_tmp_;
+ array_tmp_ = 0; // safety
+ array_ += imin_;
+ delete[] array_;
+ array_ = 0; // safety
+ }
+
+ template <typename T, typename C>
+ std::ostream& operator<<(std::ostream& ostr, const array3d_<T,C>& arr)
+ {
+ return ostr << "{"
+ << " imin=" << arr.imin()
+ << " jmin=" << arr.jmin()
+ << " kmin=" << arr.kmin()
+ << " imax=" << arr.imax()
+ << " jmax=" << arr.jmax()
+ << " kmax=" << arr.kmax()
+ << " ilen=" << arr.ilen()
+ << " jlen=" << arr.jlen()
+ << " klen=" << arr.klen()
+ << " blen=" << arr.ncells() << " }";
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 943)
+++ oln/core/3d/image3d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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
@@ -29,171 +29,218 @@
#ifndef OLN_CORE_3D_IMAGE3D_HH
# define OLN_CORE_3D_IMAGE3D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/3d/box3d.hh>
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
# include <oln/core/3d/array3d.hh>
-# include <oln/core/3d/point3d.hh>
-# include <oln/core/3d/topo3d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image3d;
- /// Virtual types associated to oln::image3d<T>.
+ // Virtual types.
template <typename T>
struct vtypes< image3d<T> >
{
- typedef topo3d topo_type;
+ typedef point3d point;
- typedef point3d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box3d pset;
+ typedef internal::pair< array3d_<value, coord>*, box3d > data;
+
+ typedef image3d<T> plain;
+ typedef image3d<pl::value> skeleton;
};
- /// Super type declaration.
+ // Super type.
template <typename T>
- struct set_super_type< image3d<T> >
+ struct super_trait_< image3d<T> >
{
- typedef image3d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image3d<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 3D image class.
+
template <typename T>
- class image3d : public image_entry< image3d<T> >
+ class image3d : public internal::plain_primitive_image_< image3d<T> >
{
- typedef image3d<T> self_t;
- typedef array3d<T> array_t;
-
+ typedef image3d<T> current;
+ typedef internal::plain_primitive_image_<current> super;
+ typedef array3d_<T, int> array_t;
public:
+ stc_using(data);
- /// Ctor using sizes.
- image3d(unsigned nslices, unsigned nrows, unsigned ncols,
- unsigned border = 2);
+ image3d();
+ image3d(const box3d& b);
+ image3d(unsigned nslis, unsigned nrows, unsigned ncols);
- /// Ctor using an existing topology.
- image3d(const topo3d& topo);
+ bool impl_owns_(const point3d& p) const;
- const topo3d& impl_topo() const;
+ bool impl_has_at(int sli, int row, int col) const;
- T impl_op_read(const point3d& p) const;
- T impl_at(int slice, int row, int col) const;
+ const T& impl_read(const point3d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int sli, int row, int col) const;
- T& impl_op_readwrite(const point3d& p);
- T& impl_at(int slice, int row, int col);
+ T& impl_read_write(const point3d& p);
+ T& impl_index_read_write(unsigned i);
+ T& impl_at(int sli, int row, int col);
- T* adr_at(int slice, int row, int col);
- const T* adr_at(int slice, int row, int col) const;
+ void impl_write(const point3d& p, const T& v);
- private:
+ std::size_t impl_npoints() const;
- topo3d topo_;
- internal::tracked_ptr<array_t> data_;
+ const box3d& impl_points() const;
};
+ template <typename T, typename D>
+ bool prepare(image3d<T>& target, with_t, const D& dat);
+
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image3d<T>::image3d(unsigned nslices, unsigned nrows, unsigned ncols,
- unsigned border)
- : topo_(bbox3d(point3d(0, 0, 0 ),
- point3d(nslices - 1, nrows - 1, ncols - 1)),
- border),
- data_(new array_t(0 - border,
- 0 - border,
- 0 - border,
- nslices - 1 + border,
- nrows - 1 + border,
- ncols - 1 + border))
+ image3d<T>::image3d()
+ {
+ }
+
+ template <typename T>
+ image3d<T>::image3d(const box3d& b)
+ {
+ this->data_ = new data(new array_t(b.pmin().sli(),
+ b.pmin().row(),
+ b.pmin().col(),
+ b.pmax().sli(),
+ b.pmax().row(),
+ b.pmax().col()),
+ b);
+ }
+
+ template <typename T>
+ image3d<T>::image3d(unsigned nslis, unsigned nrows, unsigned ncols)
{
+ precondition(nslis != 0 and nrows != 0 and ncols != 0);
+ this->data_ = new data(new array_t(0, 0, 0,
+ nslis - 1,
+ nrows - 1,
+ ncols - 1),
+ box3d(point3d(0, 0, 0),
+ point3d(nslis - 1,
+ nrows - 1,
+ ncols - 1)));
}
template <typename T>
- image3d<T>::image3d(const topo3d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().slice(),
- topo.bbox().pmin().row(),
- topo.bbox().pmin().col(),
- topo.bbox().pmax().slice(),
- topo.bbox().pmax().row(),
- topo.bbox().pmax().col()))
+ bool image3d<T>::impl_owns_(const point3d& p) const
{
+ assert(this->has_data());
+ return this->data_->first.has(p.sli(), p.row(), p.col());
}
template <typename T>
- const topo3d&
- image3d<T>::impl_topo() const
+ bool image3d<T>::impl_has_at(int sli, int row, int col) const
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->first.has(sli, row, col);
}
+ template <typename T>
+ const T& image3d<T>::impl_read(const point3d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first(p.sli(), p.row(), p.col());
+ }
template <typename T>
- T
- image3d<T>::impl_op_read(const point3d& p) const
+ const T& image3d<T>::impl_index_read(unsigned i) const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.slice(), p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->first[i];
}
template <typename T>
- T
- image3d<T>::impl_at(int slice, int row, int col) const
+ const T& image3d<T>::impl_at(int sli, int row, int col) const
{
- precondition(data_->has(slice, row, col));
- return data_->operator()(slice, row, col);
+ assert(this->has_data());
+ return this->data_->first(sli, row, col);
}
+ template <typename T>
+ T& image3d<T>::impl_read_write(const point3d& p)
+ {
+ assert(this->has_data());
+ return this->data_->first(p.sli(), p.row(), p.col());
+ }
template <typename T>
- T&
- image3d<T>::impl_op_readwrite(const point3d& p)
+ T& image3d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.slice(), p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->first[i];
}
template <typename T>
- T&
- image3d<T>::impl_at(int slice, int row, int col)
+ T& image3d<T>::impl_at(int sli, int row, int col)
{
- precondition(data_->has(slice, row, col));
- return data_->operator()(slice, row, col);
+ assert(this->has_data());
+ return this->data_->first(sli, row, col);
}
+ template <typename T>
+ void image3d<T>::impl_write(const point3d& p, const T& v)
+ {
+ assert(this->has_data());
+ this->data_->first(p.sli(), p.row(), p.col()) = v;
+ }
template <typename T>
- T* image3d<T>::adr_at(int slice, int row, int col)
+ std::size_t image3d<T>::impl_npoints() const
{
- precondition(data_ != 0);
- precondition(data_->has(slice, row, col));
- return &(data_->operator()(slice, row, col));
+ // faster than the default code given by primitive_image_
+ assert(this->has_data());
+ return this->data_->first.ncells();
}
template <typename T>
- const T* image3d<T>::adr_at(int slice, int row, int col) const
+ const box3d& image3d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(slice, row, col));
- return &(data_->operator()(slice, row, col));
+ assert(this->has_data());
+ return this->data_->second;
}
-# endif
+ template <typename T, typename D>
+ bool prepare(image3d<T>& target, with_t, const D& dat)
+ {
+ precondition(not target.has_data());
+ box3d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ array3d_<T,int>* ptr = new array3d_<T,int>(b.pmin().sli(),
+ b.pmin().row(),
+ b.pmin().col(),
+ b.pmax().sli(),
+ b.pmax().row(),
+ b.pmax().col());
+ target.data__() = new typename image3d<T>::data(ptr, b);
+ return box_ok;
+ }
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/3d/image3d_b.hh
--- oln/core/3d/image3d_b.hh (revision 0)
+++ oln/core/3d/image3d_b.hh (revision 0)
@@ -0,0 +1,290 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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 OLN_CORE_3D_IMAGE3D_B_HH
+# define OLN_CORE_3D_IMAGE3D_B_HH
+
+# include <oln/core/3d/box3d.hh>
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/3d/array3d.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ template <typename T> class image3d_b;
+
+
+ // Virtual types.
+ template <typename T>
+ struct vtypes< image3d_b<T> >
+ {
+ typedef point3d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box3d pset;
+ typedef internal::triplet< array3d_<T, int>*,
+ unsigned,
+ box3d > data;
+
+ typedef mlc::true_ vborder;
+
+ typedef image3d_b<T> plain;
+ typedef image3d_b<pl::value> skeleton;
+ };
+
+
+ // Super type.
+ template <typename T>
+ struct super_trait_< image3d_b<T> >
+ {
+ typedef image3d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
+ };
+
+
+ /// General 3D image class.
+
+ template <typename T>
+ class image3d_b : public internal::plain_primitive_image_< image3d_b<T> >
+ {
+ typedef image3d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
+ typedef array3d_<T, int> array_t;
+ public:
+ stc_using(data);
+
+ image3d_b();
+ image3d_b(const box3d& b,
+ unsigned border = 2);
+ image3d_b(unsigned nslis, unsigned nrows, unsigned ncols,
+ unsigned border = 2);
+
+ bool impl_owns_(const point3d& p) const;
+
+ bool impl_has_at(int sli, int row, int col) const;
+
+ const T& impl_read(const point3d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int sli, int row, int col) const;
+
+ T& impl_read_write(const point3d& p);
+ T& impl_index_read_write(unsigned i);
+ T& impl_at(int sli, int row, int col);
+
+ void impl_write(const point3d& p, const T& v);
+
+ std::size_t impl_npoints() const;
+
+ const box3d& impl_points() const;
+
+ unsigned impl_border() const;
+ std::size_t pad(const dpoint3d& dp) const;
+ };
+
+// template <typename T, typename D>
+// bool init_(image3d_b<T>* this_, const D& dat);
+
+ template <typename T, typename D>
+ bool prepare(image3d_b<T>& target, with_t, const D& dat);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image3d_b<T>::image3d_b()
+ {
+ }
+
+ template <typename T>
+ image3d_b<T>::image3d_b(const box3d& b,
+ unsigned border)
+ {
+ this->data_ = new data(new array_t(b.pmin().sli() - border,
+ b.pmin().row() - border,
+ b.pmin().col() - border,
+ b.pmax().sli() + border,
+ b.pmax().row() + border,
+ b.pmax().col() + border),
+ border,
+ b);
+ }
+
+ template <typename T>
+ image3d_b<T>::image3d_b(unsigned nslis, unsigned nrows, unsigned ncols,
+ unsigned border)
+ {
+ precondition(nslis != 0 and nrows != 0 and ncols != 0);
+ this->data_ = new data(new array_t(- border,
+ - border,
+ - border,
+ nslis - 1 + border,
+ nrows - 1 + border,
+ ncols - 1 + border),
+ border,
+ box3d(point3d(0, 0, 0),
+ point3d(nslis - 1,
+ nrows - 1,
+ ncols - 1)));
+ }
+
+ template <typename T>
+ bool image3d_b<T>::impl_owns_(const point3d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first.has(p.sli(), p.row(), p.col());
+ }
+
+ template <typename T>
+ bool image3d_b<T>::impl_has_at(int sli, int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->first.has(sli, row, col);
+ }
+
+ template <typename T>
+ const T& image3d_b<T>::impl_read(const point3d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first(p.sli(), p.row(), p.col());
+ }
+
+ template <typename T>
+ const T& image3d_b<T>::impl_index_read(unsigned i) const
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->first[i];
+ }
+
+ template <typename T>
+ const T& image3d_b<T>::impl_at(int sli, int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->first(sli, row, col);
+ }
+
+ template <typename T>
+ T& image3d_b<T>::impl_read_write(const point3d& p)
+ {
+ assert(this->has_data());
+ return this->data_->first(p.sli(), p.row(), p.col());
+ }
+
+ template <typename T>
+ T& image3d_b<T>::impl_index_read_write(unsigned i)
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->first[i];
+ }
+
+ template <typename T>
+ T& image3d_b<T>::impl_at(int sli, int row, int col)
+ {
+ assert(this->has_data());
+ return this->data_->first(sli, row, col);
+ }
+
+ template <typename T>
+ void image3d_b<T>::impl_write(const point3d& p, const T& v)
+ {
+ assert(this->has_data());
+ this->data_->first(p.sli(), p.row(), p.col()) = v;
+ }
+
+ template <typename T>
+ const box3d& image3d_b<T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->third;
+ }
+
+ template <typename T>
+ unsigned image3d_b<T>::impl_border() const
+ {
+ assert(this->has_data());
+ return this->data_->second;
+ }
+
+ template <typename T>
+ std::size_t image3d_b<T>::pad(const dpoint3d& dp) const
+ {
+ assert(this->has_data());
+ return
+ this->data_->first.i_pad() * dp.sli() +
+ this->data_->first.j_pad() * dp.row() +
+ dp.col();
+ }
+
+// template <typename T, typename D>
+// bool init_(image3d_b<T>* this_, const D& dat)
+// {
+// precondition(not this_->has_data());
+// box3d b;
+// bool box_ok = init(b, with, dat);
+// postcondition(box_ok);
+// unsigned border = 2; // FIXME: Use init!
+// this_->data__() = new typename image3d_b<T>::data(b.pmin(), b.pmax(), border);
+// return box_ok;
+// }
+
+ template <typename T, typename D>
+ bool prepare(image3d_b<T>& target, with_t, const D& dat)
+ {
+ precondition(not target.has_data());
+ box3d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ unsigned border = 2; // FIXME: Use init!
+ array3d_<T,int>* ptr = new array3d_<T,int>(b.pmin().sli() - border,
+ b.pmin().row() - border,
+ b.pmin().col() - border,
+ b.pmax().sli() + border,
+ b.pmax().row() + border,
+ b.pmax().col() + border);
+ target.data__() = new typename image3d_b<T>::data(ptr, border, b);
+ return box_ok;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_IMAGE3D_B_HH
Index: oln/core/3d/grid3d.hh
--- oln/core/3d/grid3d.hh (revision 0)
+++ oln/core/3d/grid3d.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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 OLN_CORE_3D_GRID3D_HH
+# define OLN_CORE_3D_GRID3D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/2d/grid2d.hh> // So import 2d instant values.
+
+
+
+# define OLN_ENV_3D
+
+
+
+namespace oln
+{
+
+ /// Instant values.
+ oln_decl_instant_value(sli);
+ oln_decl_instant_value(dsli);
+ oln_decl_instant_value(nslis);
+
+
+ /// \{
+ /// Fwd decls.
+
+ template <typename Exact> struct Grid_3D;
+ struct grid3d;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_3D.
+
+ template <typename Exact>
+ struct vtypes< Grid_3D<Exact> >
+ {
+ typedef mlc::uint_<3> dim;
+ };
+
+ template <typename Exact>
+ struct Grid_3D : public Grid<Exact>
+ {
+ protected:
+ Grid_3D() {}
+ };
+
+ /// \}
+
+
+ // Super type.
+
+ template<>
+ struct super_trait_< grid3d >
+ {
+ typedef Grid_3D< grid3d > ret;
+ };
+
+
+ /// Cubic grid struct.
+
+ struct grid3d : public Grid_3D< grid3d >
+ {
+ };
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_GRID3D_HH
Index: oln/core/3d/window3d.hh
--- oln/core/3d/window3d.hh (revision 943)
+++ oln/core/3d/window3d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -28,10 +28,16 @@
#ifndef OLN_CORE_3D_WINDOW3D_HH
# define OLN_CORE_3D_WINDOW3D_HH
-// Headers required for the complete definition of oln::window3d
-// (i.e., oln::window_<dpoint3d>).
-# include <oln/core/3d/aliases.hh>
-# include <oln/core/3d/dpoint3d.hh>
# include <oln/core/gen/window.hh>
+
+namespace oln
+{
+
+ // FIXME: window3d should be an actual type, not an alias...
+ typedef gen_window<dpoint3d> window3d;
+
+} // end of namespace oln
+
+
#endif // ! OLN_CORE_3D_WINDOW3D_HH
Index: oln/core/3d/box3d.hh
--- oln/core/3d/box3d.hh (revision 0)
+++ oln/core/3d/box3d.hh (revision 0)
@@ -0,0 +1,154 @@
+// 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 OLN_CORE_3D_BOX3D_HH
+# define OLN_CORE_3D_BOX3D_HH
+
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/concept/point_set.hh> // for internal::tag::i_box_t
+# include <oln/core/internal/box.hh>
+
+
+namespace oln
+{
+
+ // Fwd decl.
+ class box3d;
+
+ // Super type
+ template <>
+ struct super_trait_< box3d >
+ {
+ typedef internal::box_<box3d> ret;
+ };
+
+ // Virtual types
+ template <>
+ struct vtypes<box3d>
+ {
+ typedef point3d point;
+ typedef box3d box;
+ };
+
+ // Class box3d
+ class box3d : public internal::box_< box3d >
+ {
+ typedef internal::box_< box3d > super;
+ public:
+ stc_using_(from_to_t);
+
+ box3d();
+ box3d(const from_to_t& dat);
+ box3d(const point3d& pmin, const point3d& pmax);
+ template <typename D>
+ box3d(const internal::initializer_<D>& data);
+ };
+
+ namespace internal
+ {
+
+ template <typename U>
+ bool init__(tag::i_box_t, box3d& b,
+ const triplet< nrows_t<U>, ncols_t<U>, nslis_t<U> >& data);
+
+ template <typename U>
+ bool init__(tag::i_box_t, box3d& b,
+ const quartet< from_t<point3d>,
+ nrows_t<U>, ncols_t<U>, nslis_t<U> >& data);
+
+ } // end of namespace oln::internal
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ box3d::box3d()
+ {
+ }
+
+ box3d::box3d(const box3d::from_to_t& dat) :
+ super(dat)
+ {
+ }
+
+ box3d::box3d(const point3d& pmin, const point3d& pmax) :
+ super(pmin, pmax)
+ {
+ }
+
+ template <typename D>
+ box3d::box3d(const internal::initializer_<D>& data)
+ {
+ bool box_ok = internal::init__(internal::tag::i_box_t(), *this, data.value());
+ postcondition(box_ok);
+ }
+
+
+ namespace internal
+ {
+
+ template <typename U>
+ bool init__(tag::i_box_t, box3d& b,
+ const triplet< nrows_t<U>, ncols_t<U>, nslis_t<U> >& data)
+ {
+ unsigned nrows = data.first.value;
+ unsigned ncols = data.second.value;
+ unsigned nslis = data.third.value;
+ precondition(nrows != 0 and ncols != 0 and nslis != 0);
+ b.pmin().row() = 0;
+ b.pmin().col() = 0;
+ b.pmin().sli() = 0;
+ b.pmax().row() = nrows - 1;
+ b.pmax().col() = ncols - 1;
+ b.pmax().sli() = nslis - 1;
+ return true;
+ }
+
+ template <typename U>
+ bool init__(tag::i_box_t, box3d& b,
+ const quartet< from_t<point3d>,
+ nrows_t<U>, ncols_t<U>, nslis_t<U> >& data)
+ {
+ unsigned nrows = data.second.value;
+ unsigned ncols = data.third.value;
+ unsigned nslis = data.fourth.value;
+ precondition(nrows != 0 and ncols != 0 and nslis != 0);
+ b.pmin() = data.first.value;
+ b.pmax().row() = b.pmin().row() + nrows - 1;
+ b.pmax().col() = b.pmin().col() + ncols - 1;
+ b.pmax().sli() = b.pmin().sli() + nslis - 1;
+ return true;
+ }
+
+ } // end of namespace oln::internal
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_BOX3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 943)
+++ oln/core/3d/point3d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,128 +29,81 @@
#ifndef OLN_CORE_3D_POINT3D_HH
# define OLN_CORE_3D_POINT3D_HH
-# include <mlc/int.hh>
-# include <oln/core/internal/point_nd.hh>
+# include <oln/core/3d/grid3d.hh>
+# include <oln/core/internal/point_base.hh>
+# include <oln/core/internal/point_impl.hh>
namespace oln
{
- /// Fwd decls.
- template <unsigned D> struct grid_;
- template <typename C> struct dpoint3d_;
- template <typename C> struct point3d_;
+ // Fwd decls.
+ class point3d;
+ class dpoint3d;
- typedef grid_<3> grid3d;
- typedef dpoint3d_<int> dpoint3d;
- typedef point3d_<int> point3d;
-
-
- /* FIXME: Is this the right place for these functions (on types)?
- In particular, the function on dpoint3d should be near the
- definition of dpoint3d, not point3d's. */
- /// Specializations of functions point and dpoint :
- /// \f$(n, coord) \rightarrow type\f$ for \f$n = 3\f$.
- /// \{
- template <typename C> struct point_ <3, C> { typedef point3d_<C> ret; };
- template <typename C> struct dpoint_ <3, C> { typedef dpoint3d_<C> ret; };
- /// \}
-
-
-
- /// Super type.
- template<typename C>
- struct set_super_type< point3d_<C> >
+ // Super type.
+ template<>
+ struct super_trait_< point3d >
{
- typedef internal::point_nd< point3d_<C> > ret;
+ typedef internal::point_base_< point3d > ret;
};
- /// Virtual types associated to oln::point3d_<C>.
- template <typename C>
- struct vtypes< point3d_<C> >
- {
- typedef grid3d grid_type;
- typedef dpoint3d dpoint_type;
- typedef C coord_type;
- typedef mlc::uint_<3> dim_type;
-
- typedef mlc::uint_<0> slice_comp_type;
- typedef mlc::uint_<1> row_comp_type;
- typedef mlc::uint_<2> col_comp_type;
+ // Virtual types.
+ template <>
+ struct vtypes< point3d >
+ {
+ typedef grid3d grid;
+ typedef int coord;
+ typedef dpoint3d dpoint;
};
- /// General 3D point class.
- template <typename C>
- class point3d_ : public internal::point_nd< point3d_<C> >
- {
- typedef point3d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
-
- using super_t::v_;
-
+ /// Usual 3D point class.
+ class point3d : public internal::point_base_< point3d >,
+ public internal::point_impl_< 3, point3d >
+ {
+ typedef internal::initializer_<
+ internal::triplet< internal::sli_t<int>, internal::row_t<int>, internal::col_t<int> >
+ > sli_row_col_t;
+ typedef internal::point_base_< point3d > super;
public:
+ stc_using_(coord);
- /// Ctor.
- point3d_();
-
- /// Ctor.
- point3d_(C slice, C row, C col);
-
- /// Ctor.
- point3d_(const xtd::vec<3,C>& v);
-
- C slice() const;
- C& slice();
-
- C row() const;
- C& row();
-
- C col() const;
- C& col();
+ point3d();
+ point3d(int sli, int row, int col); // FIXME: Remove!
+ point3d(const sli_row_col_t& dat);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- point3d_<C>::point3d_()
+ point3d::point3d()
{
}
- template <typename C>
- point3d_<C>::point3d_(C slice, C row, C col)
- : super_t (xtd::mk_vec(slice, row, col))
+ point3d::point3d(int sli, int row, int col) // FIXME: Remove!
{
+ this->sli() = sli;
+ this->row() = row;
+ this->col() = col;
}
- template <typename C>
- point3d_<C>::point3d_(const xtd::vec<3,C>& v)
- : super_t(v)
+ point3d::point3d(const point3d::sli_row_col_t& dat)
{
+ this->sli() = dat->first.value;
+ this->row() = dat->second.value;
+ this->col() = dat->third.value;
}
- template <typename C>
- C point3d_<C>::slice() const { return v_[0]; }
- template <typename C>
- C& point3d_<C>::slice() { return v_[0]; }
-
- template <typename C>
- C point3d_<C>::row() const { return v_[1]; }
- template <typename C>
- C& point3d_<C>::row() { return v_[1]; }
-
- template <typename C>
- C point3d_<C>::col() const { return v_[2]; }
- template <typename C>
- C& point3d_<C>::col() { return v_[2]; }
-
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
+# include <oln/core/3d/dpoint3d.hh>
+
+
#endif // ! OLN_CORE_3D_POINT3D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 943)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_GEN_DPOINTS_PITER_HH
# define OLN_CORE_GEN_DPOINTS_PITER_HH
-# include <oln/core/concept/generalized_point.hh>
+# include <oln/core/concept/point.hh>
# include <oln/core/concept/window.hh>
# include <oln/core/concept/neighborhood.hh>
# include <oln/core/concept/image.hh>
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 943)
+++ oln/core/gen/box.hh (working copy)
@@ -29,91 +29,90 @@
#ifndef OLN_CORE_GEN_BOX_HH
# define OLN_CORE_GEN_BOX_HH
-# include <oln/core/concept/point.hh>
-# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/box.hh>
+# include <oln/core/gen/point.hh>
namespace oln
{
+# define current box<G,C>
+
// Fwd decl.
- template <typename P> class gen_box;
+ template <typename G, typename C> class box;
// Super type.
- template <typename P>
- struct super_trait_< gen_box<P> >
+ template <typename G, typename C>
+ struct super_trait_< current >
{
- typedef gen_box<P> current__;
- typedef internal::box_<current__> ret;
+ typedef internal::box_< current > ret;
};
- /// Virtual types.
- template <typename P>
- struct vtypes< gen_box<P> >
+ // Virtual types.
+ template <typename G, typename C>
+ struct vtypes< current >
{
- typedef P point;
- typedef gen_box<P> box;
+ typedef point<G, C> point;
+ typedef current box;
};
/// Generic box class based on a point class.
- template <typename P>
- class gen_box : public internal::box_< gen_box<P> >,
- private mlc::assert_< mlc_is_a(P, Point) >
+ template <typename G, typename C>
+ class box : public internal::box_< current >
{
- typedef gen_box<P> current;
typedef internal::box_<current> super;
public:
- stc_using(point);
- stc_using(box);
-
+ stc_using(from_to_t);
- public:
+ box();
- gen_box();
- gen_box(const P& pmin, const P& pmax);
- gen_box(const typename gen_box<P>::from_to_t& data);
+ box(const oln::point<G,C>& pmin, const oln::point<G,C>& pmax);
+ box(const from_to_t& data);
template <typename D>
- gen_box(const internal::initializer_<D>& data);
+ box(const internal::initializer_<D>& data);
- }; // end of class oln::gen_box<P>
+ }; // end of class oln::box<G,C>
# ifndef OLN_INCLUDE_ONLY
- template <typename P>
- gen_box<P>::gen_box()
+ template <typename G, typename C>
+ current::box()
{
+ mlc::assert_< mlc_is_a(G, Grid) >::check();
}
- template <typename P>
- gen_box<P>::gen_box(const P& pmin, const P& pmax) :
- super(pmin, pmax)
+ template <typename G, typename C>
+ current::box(const oln::point<G,C>& pmin,
+ const oln::point<G,C>& pmax)
+ : super(pmin, pmax)
{
}
- template <typename P>
- gen_box<P>::gen_box(const typename gen_box<P>::from_to_t& data) :
+ template <typename G, typename C>
+ current::box(const typename current::from_to_t& data) :
super(data)
{
}
- template <typename P>
+ template <typename G, typename C>
template <typename D>
- gen_box<P>::gen_box(const internal::initializer_<D>& data) :
+ current::box(const internal::initializer_<D>& data) :
super(data)
{
}
# endif // ! OLN_INCLUDE_ONLY
+# undef current
+
} // end of namespace oln
Index: oln/core/gen/fun.hh
--- oln/core/gen/fun.hh (revision 943)
+++ oln/core/gen/fun.hh (working copy)
@@ -42,14 +42,9 @@
-// FIXME: Separate defs and decls.
-
-
-
namespace oln
{
-
namespace internal
{
@@ -87,145 +82,184 @@
- // ----------------------------- fun_p2b_<F>
+ // fun_p2b_<F>
+ // -------------
- // Fwd decl.
- template <typename F> struct fun_p2b_;
-
- // Category.
- namespace internal
- {
- template <typename F>
- struct set_category_of_< fun_p2b_<F> >
- {
- typedef stc::is< Function_p2b > ret;
- };
- }
-
- // Class.
template <typename F>
struct fun_p2b_ : public Function_p2b< fun_p2b_<F> >
{
typedef oln_arg_of_(F) argument;
typedef oln_res_of_(F) result;
- fun_p2b_(const F& f) : f_(f) {}
-
- result operator()(argument arg) const
- {
- return this->f_(arg);
- }
+ fun_p2b_(const F& f);
+ result operator()(argument arg) const;
private:
F f_;
};
+ template <typename B, typename P>
+ fun_p2b_<B (*)(P)>
+ functorize_p2b(B (*f)(P));
+
+
// Specialization.
+
template <typename I>
- struct fun_p2b_< Binary_Image<I> > : public Function_p2b< fun_p2b_< Binary_Image<I> > >
+ struct fun_p2b_< Binary_Image<I> >
+ :
+ public Function_p2b< fun_p2b_< Binary_Image<I> > >
{
typedef const oln_point(I)& argument;
typedef oln_rvalue(I) result;
- fun_p2b_(const Binary_Image<I>& ima)
- : ima_(exact(ima))
- {}
-
- result operator()(argument arg) const
- {
- return this->ima_(arg);
- }
+ fun_p2b_(const I& ima);
+ oln_rvalue(I) operator()(const oln_point(I)& arg) const;
private:
I ima_;
};
+ template <typename I>
+ fun_p2b_< Binary_Image<I> >
+ functorize_p2b(const Binary_Image<I>& ima);
- // ----------------------------- fun_p2v_<F>
+ // fun_p2v_<F>
+ // -------------
- // Fwd decl.
- template <typename F> struct fun_p2v_;
- // Category.
- namespace internal
- {
template <typename F>
- struct set_category_of_< fun_p2v_<F> >
+ struct fun_p2v_ : public Function_p2v< fun_p2v_<F> >
{
- typedef stc::is< Function_p2v > ret;
+ typedef oln_arg_of_(F) argument;
+ typedef oln_res_of_(F) result;
+
+ fun_p2v_(const F& f);
+ result operator()(argument arg) const;
+
+ private:
+ F f_;
};
- }
- // Class.
+ template <typename V, typename P>
+ fun_p2v_<V (*)(P)>
+ functorize_p2v(V (*f)(P));
+
+
+ // fun_v2v_<F>
+ // -------------
+
+
template <typename F>
- struct fun_p2v_ : public Function_p2v< fun_p2v_<F> >
+ struct fun_v2v_ : public Function_v2v< fun_v2v_<F> >
{
typedef oln_arg_of_(F) argument;
typedef oln_res_of_(F) result;
- fun_p2v_(const F& f) : f_(f) {}
-
- result operator()(argument arg) const
- {
- return this->f_(arg);
- }
+ fun_v2v_(const F& f);
+ result operator()(argument arg) const;
private:
F f_;
};
+ template <typename Vr, typename Va>
+ fun_v2v_<Vr (*)(Va)>
+ functorize_v2v(Vr (*f)(Va));
- // functorize_p2v
- template <typename V, typename P>
- fun_p2v_<V (*)(P)>
- functorize_p2v(V (*f)(P))
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // fun_p2b_<F>
+
+ template <typename F>
+ fun_p2b_<F>::fun_p2b_(const F& f)
+ : f_(f)
{
- mlc::assert_< mlc_is_a(P, Point) >::check(); // FIXME: Add err msg.
- fun_p2v_<V (*)(P)> tmp(f);
- return tmp;
}
+ template <typename F>
+ typename fun_p2b_<F>::result
+ fun_p2b_<F>::operator()(typename fun_p2b_<F>::argument arg) const
+ {
+ return this->f_(arg);
+ }
- // ----------------------------- fun_v2v_<F>
+ template <typename B, typename P>
+ fun_p2b_<B (*)(P)>
+ functorize_p2b(B (*f)(P))
+ {
+ typedef mlc_basic(P) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check();
+ // FIXME: Add static check about B being Boolean.
+ fun_p2b_<B (*)(P)> tmp(f);
+ return tmp;
+ }
+ template <typename I>
+ fun_p2b_< Binary_Image<I> >::fun_p2b_(const I& ima)
+ : ima_(ima)
+ {
+ }
- // Fwd decl.
- template <typename F> struct fun_v2v_;
+ template <typename I>
+ oln_rvalue(I)
+ fun_p2b_< Binary_Image<I> >::operator()(const oln_point(I)& arg) const
+ {
+ return this->ima_(arg);
+ }
- // Category.
- namespace internal
+ template <typename I>
+ fun_p2b_< Binary_Image<I> >
+ functorize_p2b(const Binary_Image<I>& ima)
{
+ fun_p2b_< Binary_Image<I> > tmp(exact(ima));
+ return tmp;
+ }
+
+ // fun_p2v_<F>
+
template <typename F>
- struct set_category_of_< fun_v2v_<F> >
+ fun_p2v_<F>::fun_p2v_(const F& f)
+ : f_(f)
{
- typedef stc::is< Function_v2v > ret;
- };
}
- // Class.
template <typename F>
- struct fun_v2v_ : public Function_v2v< fun_v2v_<F> >
+ typename fun_p2v_<F>::result
+ fun_p2v_<F>::operator()(typename fun_p2v_<F>::argument arg) const
{
- typedef oln_arg_of_(F) argument;
- typedef oln_res_of_(F) result;
-
- fun_v2v_(const F& f) : f_(f) {}
+ return this->f_(arg);
+ }
- result operator()(argument arg) const
+ template <typename V, typename P>
+ fun_p2v_<V (*)(P)>
+ functorize_p2v(V (*f)(P))
{
- return this->f_(arg);
+ typedef mlc_basic(P) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ fun_p2v_<V (*)(P)> tmp(f);
+ return tmp;
}
- private:
- F f_;
- };
+ // fun_v2v_<F>
+ template <typename F>
+ fun_v2v_<F>::fun_v2v_(const F& f)
+ : f_(f)
+ {
+ }
- // functorize_v2v
+ template <typename F>
+ typename fun_v2v_<F>::result
+ fun_v2v_<F>::operator()(typename fun_v2v_<F>::argument arg) const
+ {
+ return this->f_(arg);
+ }
template <typename Vr, typename Va>
fun_v2v_<Vr (*)(Va)>
@@ -235,6 +269,7 @@
return tmp;
}
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/point.hh
--- oln/core/gen/point.hh (revision 0)
+++ oln/core/gen/point.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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 OLN_CORE_GEN_POINT_HH
+# define OLN_CORE_GEN_POINT_HH
+
+# include <oln/core/internal/point_base.hh>
+# include <oln/core/internal/point_impl.hh>
+
+
+namespace oln
+{
+
+# define current point<G, C>
+
+
+ // Fwd decls.
+ template <typename G, typename C> struct point;
+ template <typename G, typename C> struct dpoint;
+
+
+ // Super type.
+ template<typename G, typename C>
+ struct super_trait_< current >
+ {
+ typedef internal::point_base_< current > ret;
+ };
+
+
+ // Virtual types.
+ template <typename G, typename C>
+ struct vtypes< current >
+ {
+ typedef G grid;
+ typedef C coord;
+ typedef dpoint<G,C> dpoint;
+ };
+
+
+ template <typename G, typename C>
+ class point : public internal::point_base_< current >,
+ public internal::point_impl_< mlc_value(oln_dim(G)), current >
+ {
+ public:
+ point();
+ // nothing else here
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename G, typename C>
+ current::point()
+ {
+ mlc::assert_< mlc_is_a(G, Grid) >::check();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef current
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/dpoint.hh>
+
+
+#endif // ! OLN_CORE_GEN_POINT_HH
Index: oln/core/gen/extended_by.hh
--- oln/core/gen/extended_by.hh (revision 0)
+++ oln/core/gen/extended_by.hh (revision 0)
@@ -0,0 +1,60 @@
+// 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 OLN_CORE_GEN_EXTENDED_BY_HH
+# define OLN_CORE_GEN_EXTENDED_BY_HH
+
+
+// "ima + extension"
+
+
+namespace oln
+{
+ struct extended_by;
+}
+
+
+# include <oln/core/internal/op_image_extended_by_nbh.hh>
+# include <oln/core/internal/macro_extended_by.hh>
+
+
+namespace oln
+{
+
+ oln_decl_op_image_extended_by_const(Neighborhood);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ oln_def_op_image_extended_by_const(Neighborhood);
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_EXTENDED_BY_HH
Index: oln/core/gen/fbbox.hh
--- oln/core/gen/fbbox.hh (revision 943)
+++ oln/core/gen/fbbox.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/core/gen/box.hh>
# include <oln/core/concept/point.hh>
-# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/internal/f_point_to_box.hh>
namespace oln
@@ -49,7 +49,7 @@
public:
- typedef typename f_box_from_point_<P>::ret box_t;
+ typedef oln_f_point_to_box(P) box_t;
fbbox_();
operator box_t() const;
@@ -125,7 +125,6 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
Index: oln/core/gen/restricted_to.hh
--- oln/core/gen/restricted_to.hh (revision 0)
+++ oln/core/gen/restricted_to.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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 OLN_CORE_GEN_RESTRICTED_TO_HH
+# define OLN_CORE_GEN_RESTRICTED_TO_HH
+
+
+namespace oln
+{
+ struct restricted_to;
+}
+
+
+# include <oln/core/internal/op_image_restricted_to_pset.hh>
+# include <oln/core/gen/inplace.hh>
+
+
+namespace oln
+{
+
+ // Image | Point_Set
+
+ template <typename I, typename S>
+ op_<const I, restricted_to, const S>
+ operator | (const Image<I>& ima, const Point_Set<S>& pset);
+
+ template <typename I, typename S>
+ op_<I, restricted_to, const S>
+ operator | (Mutable_Image<I>& ima, const Point_Set<S>& pset);
+
+ template <typename I, typename S>
+ inplace_< op_<I, restricted_to, const S> >
+ operator | (inplace_<I> ima, const Point_Set<S>& pset);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I, typename S>
+ op_<const I, restricted_to, const S>
+ operator | (const Image<I>& ima, const Point_Set<S>& pset)
+ {
+ mlc::assert_equal_< oln_point(S), oln_point(I) >::check();
+ precondition(pset < ima.points());
+ op_<const I, restricted_to, const S> tmp(exact(ima), exact(pset));
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ op_<I, restricted_to, const S>
+ operator | (Mutable_Image<I>& ima, const Point_Set<S>& pset)
+ {
+ mlc::assert_equal_< oln_point(S), oln_point(I) >::check();
+ precondition(pset < ima.points());
+ op_<I, restricted_to, const S> tmp(exact(ima), exact(pset));
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ inplace_< op_<I, restricted_to, const S> >
+ operator | (inplace_<I> ima, const Point_Set<S>& pset)
+ {
+ return (ima.unwrap() | pset).inplace();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_RESTRICTED_TO_HH
Index: oln/core/gen/applied_on.hh
--- oln/core/gen/applied_on.hh (revision 0)
+++ oln/core/gen/applied_on.hh (revision 0)
@@ -0,0 +1,134 @@
+// 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 OLN_CORE_GEN_APPLIED_ON_HH
+# define OLN_CORE_GEN_APPLIED_ON_HH
+
+
+// "f << ima" is "for all p, (f << ima)(p) = f(ima(p))"
+
+
+namespace oln
+{
+ struct applied_on;
+}
+
+
+# include <oln/core/internal/op_fv2v_applied_on_image.hh>
+# include <oln/core/gen/fun.hh>
+# include <oln/core/gen/inplace.hh>
+
+
+namespace oln
+{
+
+ // Function_v2v << Image
+
+ template <typename F, typename I>
+ op_<const F, applied_on, const I>
+ operator << (const Function_v2v<F>& f, const Image<I>& ima);
+
+ template <typename F, typename I>
+ op_<const F, applied_on, I>
+ operator << (const Function_v2v<F>& f, Mutable_Image<I>& ima);
+
+ template <typename F, typename I>
+ inplace_< op_<const F, applied_on, I> >
+ operator << (const Function_v2v<F>& f, inplace_<I> ima);
+
+ // V -> V << Image
+
+ template <typename W, typename V, typename I>
+ op_<const fun_v2v_<W (*)(V)>, applied_on, const I>
+ operator << (W (*f)(V), const Image<I>& ima);
+
+ template <typename W, typename V, typename I>
+ op_<const fun_v2v_<W (*)(V)>, applied_on, I>
+ operator << (W (*f)(V), Mutable_Image<I>& ima);
+
+ template <typename W, typename V, typename I>
+ inplace_< op_<const fun_v2v_<W (*)(V)>, applied_on, I> >
+ operator << (W (*f)(V), inplace_<I> ima);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Function_v2v << Image
+
+ template <typename F, typename I>
+ op_<const F, applied_on, const I>
+ operator << (const Function_v2v<F>& f, const Image<I>& ima)
+ {
+ op_<const F, applied_on, const I> tmp(exact(f), exact(ima));
+ return tmp;
+ }
+
+ template <typename F, typename I>
+ op_<const F, applied_on, I>
+ operator << (const Function_v2v<F>& f, Mutable_Image<I>& ima)
+ {
+ op_<const F, applied_on, I> tmp(exact(f), exact(ima));
+ return tmp;
+ }
+
+ template <typename F, typename I>
+ inplace_< op_<const F, applied_on, I> >
+ operator << (const Function_v2v<F>& f, inplace_<I> ima)
+ {
+ return (f << ima.unwrap()).inplace();
+ }
+
+ // V -> V << Image
+
+ template <typename W, typename V, typename I>
+ op_<const fun_v2v_<W (*)(V)>, applied_on, const I>
+ operator << (W (*f)(V), const Image<I>& ima)
+ {
+ return functorize_v2v(f) << ima;
+ }
+
+ template <typename W, typename V, typename I>
+ op_<const fun_v2v_<W (*)(V)>, applied_on, I>
+ operator << (W (*f)(V), Mutable_Image<I>& ima)
+ {
+ return functorize_v2v(f) << ima;
+ }
+
+ template <typename W, typename V, typename I>
+ inplace_< op_<const fun_v2v_<W (*)(V)>, applied_on, I> >
+ operator << (W (*f)(V), inplace_<I> ima)
+ {
+ return (f << ima.unwrap()).inplace();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_APPLIED_ON_HH
Index: oln/core/gen/niter_has.hh
--- oln/core/gen/niter_has.hh (revision 943)
+++ oln/core/gen/niter_has.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_GEN_NITER_HAS_HH
# define OLN_CORE_GEN_NITER_HAS_HH
-# include <oln/core/concept/generalized_point.hh>
+# include <oln/core/concept/point.hh>
# include <oln/core/internal/piter_adaptor.hh>
# include <oln/core/gen/dpoints_piter.hh>
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 943)
+++ oln/core/gen/op.hh (working copy)
@@ -30,111 +30,23 @@
# include <oln/core/internal/special_op.hh>
# include <oln/core/internal/category_of.hh>
-# include <oln/core/concept/function.hh>
-# include <oln/core/concept/value.hh>
-# include <oln/core/gen/inplace.hh>
-
-
-
-// Macro.
-
-# define oln_decl_op_(OpName, Lconcept, OpSym, Rconcept) \
- \
- template <typename L, typename R> \
- op_<L, OpName, R> \
- operator OpSym (Lconcept<L>& lhs, Rconcept<R>& rhs) \
- { \
- op_<L, OpName, R> tmp(exact(lhs), exact(rhs)); \
- return tmp; \
- } \
- \
- template <typename L, typename R> \
- op_<L, OpName, const R> \
- operator OpSym (Lconcept<L>& lhs, const Rconcept<R>& rhs) \
- { \
- op_<L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
- return tmp; \
- } \
- \
- template <typename L, typename R> \
- op_<const L, OpName, R> \
- operator OpSym (const Lconcept<L>& lhs, Rconcept<R>& rhs) \
- { \
- op_<const L, OpName, R> tmp(exact(lhs), exact(rhs)); \
- return tmp; \
- } \
- \
- template <typename L, typename R> \
- op_<const L, OpName, const R> \
- operator OpSym (const Lconcept<L>& lhs, const Rconcept<R>& rhs) \
- { \
- op_<const L, OpName, const R> tmp(exact(lhs), exact(rhs)); \
- return tmp; \
- } \
- \
- struct e_n_d___w_i_t_h___a___s_e_m_i___c_o_l_u_m_n
-
-
-
-# define oln_decl_inplace_image_op(OpName, OpSym, Rconcept) \
- \
- template <typename L, typename R> \
- inplace_< op_<L, OpName, R> > \
- operator OpSym (inplace_<L> lhs, Rconcept<R>& rhs) \
- { \
- mlc::assert_< mlc_is_a(L, Mutable_Image) >::check(); \
- op_<L, OpName, R> tmp(lhs.unwrap(), exact(rhs)); \
- return inplace(tmp); \
- } \
- \
- struct e_n_d___w_i_t_h___a___s_e_m_i___c_o_l_u_m_n
-
-
-
-// FIXME: Split into different files so that the client can explicitly include
-// what is really needed...
-
-# define oln_decl_op_extended_by(Lconcept, Rconcept) oln_decl_op_( extended_by, Lconcept, +, Rconcept)
-# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_( such_as, Lconcept, |, Rconcept)
-# define oln_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to, Lconcept, |, Rconcept)
-# define oln_decl_op_over(Lconcept, Rconcept) oln_decl_op_( over, Lconcept, /, Rconcept)
-# define oln_decl_op_applied_on(Lconcept, Rconcept) oln_decl_op_( applied_on, Lconcept, <<, Rconcept)
-# define oln_decl_op_through(Lconcept, Rconcept) oln_decl_op_( through, Lconcept, >>, Rconcept)
-// ...
-
namespace oln
{
-
- /// \{
- /// Operator Names.
-
- struct extended_by;
- struct such_as;
- struct restricted_to;
- struct over;
- struct applied_on;
- struct through;
-
- /// \}
-
-
-
-
// Fwd decl.
template <typename L, typename OpName, typename R> class op_;
- /// Virtual types.
+ // Virtual types.
template <typename L, typename OpName, typename R>
struct vtypes< op_<L, OpName, R> >
{
};
- /// Super type.
+ // Super type.
# define super \
internal::special_op_< oln_category_of_(L), L, OpName, oln_category_of_(R), R >
Index: oln/core/gen/through.hh
--- oln/core/gen/through.hh (revision 0)
+++ oln/core/gen/through.hh (revision 0)
@@ -0,0 +1,134 @@
+// 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 OLN_CORE_GEN_THROUGH_HH
+# define OLN_CORE_GEN_THROUGH_HH
+
+
+// "ima >> ima" is "for all p, (ima >> f)(p) = f(ima(p))"
+
+
+namespace oln
+{
+ struct through;
+}
+
+
+# include <oln/core/internal/op_image_through_fv2v.hh>
+# include <oln/core/gen/fun.hh>
+# include <oln/core/gen/inplace.hh>
+
+
+namespace oln
+{
+
+ // Image >> Function_v2v
+
+ template <typename I, typename F>
+ op_<const I, through, const F>
+ operator >> (const Image<I>& ima, const Function_v2v<F>& f);
+
+ template <typename I, typename F>
+ op_<I, through, const F>
+ operator >> (Mutable_Image<I>& ima, const Function_v2v<F>& f);
+
+ template <typename I, typename F>
+ inplace_< op_<I, through, const F> >
+ operator >> (inplace_<I> ima, const Function_v2v<F>& f);
+
+ // Image >> V -> V
+
+ template <typename I, typename W, typename V>
+ op_<const I, through, const fun_v2v_<W (*)(V)> >
+ operator >> (const Image<I>& ima, W (*f)(V));
+
+ template <typename I, typename W, typename V>
+ op_<I, through, const fun_v2v_<W (*)(V)> >
+ operator >> (Mutable_Image<I>& ima, W (*f)(V));
+
+ template <typename I, typename W, typename V>
+ inplace_< op_<I, through, const fun_v2v_<W (*)(V)> > >
+ operator >> (inplace_<I> ima, W (*f)(V));
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Image >> Function_v2v
+
+ template <typename I, typename F>
+ op_<const I, through, const F>
+ operator >> (const Image<I>& ima, const Function_v2v<F>& f)
+ {
+ op_<const I, through, const F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ op_<I, through, const F>
+ operator >> (Mutable_Image<I>& ima, const Function_v2v<F>& f)
+ {
+ op_<I, through, const F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ inplace_< op_<I, through, const F> >
+ operator >> (inplace_<I> ima, const Function_v2v<F>& f)
+ {
+ return (ima.unwrap() >> f).inplace();
+ }
+
+ // Image >> V -> V
+
+ template <typename I, typename W, typename V>
+ op_<const I, through, const fun_v2v_<W (*)(V)> >
+ operator >> (const Image<I>& ima, W (*f)(V))
+ {
+ return ima >> functorize_v2v(f);
+ }
+
+ template <typename I, typename W, typename V>
+ op_<I, through, const fun_v2v_<W (*)(V)> >
+ operator >> (Mutable_Image<I>& ima, W (*f)(V))
+ {
+ return ima >> functorize_v2v(f);
+ }
+
+ template <typename W, typename V, typename I>
+ inplace_< op_<I, through, const fun_v2v_<W (*)(V)> > >
+ operator >> (inplace_<I> ima, W (*f)(V))
+ {
+ return (ima.unwrap() >> f).inplace();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_THROUGH_HH
Index: oln/core/gen/such_as.hh
--- oln/core/gen/such_as.hh (revision 0)
+++ oln/core/gen/such_as.hh (revision 0)
@@ -0,0 +1,220 @@
+// 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 OLN_CORE_GEN_SUCH_AS_HH
+# define OLN_CORE_GEN_SUCH_AS_HH
+
+
+namespace oln
+{
+ struct such_as;
+}
+
+
+# include <oln/core/internal/op_pset_such_as_fp2b.hh>
+# include <oln/core/internal/op_image_such_as_fp2b.hh>
+# include <oln/core/gen/fun.hh>
+# include <oln/core/gen/inplace.hh>
+
+
+namespace oln
+{
+
+ // Point_Set | Function_p2b
+
+ template <typename S, typename F>
+ op_<const S, such_as, const F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f);
+
+
+ // Point_Set | P -> B
+
+ template <typename S, typename B, typename P>
+ op_<const S, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (const Point_Set<S>& lhs, B (*f)(P));
+
+
+ // Image | Function_p2b
+
+ template <typename I, typename F>
+ op_<const I, such_as, const F>
+ operator | (const Image<I>& ima, const Function_p2b<F>& f);
+
+ template <typename I, typename F>
+ op_<I, such_as, const F>
+ operator | (Mutable_Image<I>& ima, const Function_p2b<F>& f);
+
+ template <typename I, typename F>
+ inplace_< op_<I, such_as, const F> >
+ operator | (inplace_<I> ima, const Function_p2b<F>& f);
+
+
+ // Image | P -> B
+
+ template <typename I, typename B, typename P>
+ op_<const I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (const Image<I>& ima, B (*f)(P));
+
+ template <typename I, typename B, typename P>
+ op_<I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (Mutable_Image<I>& ima, B (*f)(P));
+
+ template <typename I, typename B, typename P>
+ inplace_< op_<I, such_as, const fun_p2b_<B (*)(P)> > >
+ operator | (inplace_<I> ima, B (*f)(P));
+
+
+ // Image | Binary_Image
+
+ template <typename I, typename J>
+ op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (const Image<I>& ima, const Binary_Image<J>& f_ima_b);
+
+ template <typename I, typename J>
+ op_<I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (Mutable_Image<I>& ima, const Binary_Image<J>& f_ima_b);
+
+ template <typename I, typename J>
+ inplace_< op_<I, such_as, const fun_p2b_< Binary_Image<J> > > >
+ operator | (inplace_<I> ima, const Binary_Image<J>& f_ima_b);
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Point_Set | Function_p2b
+
+ template <typename S, typename F>
+ op_<const S, such_as, const F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f)
+ {
+ typedef mlc_basic(oln_argument(F)) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(S) >::check();
+ op_<const S, such_as, const F> tmp(exact(pset), exact(f));
+ return tmp;
+ }
+
+ // Point_Set | P -> B
+
+ template <typename S, typename B, typename P>
+ op_<const S, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (const Point_Set<S>& pset, B (*f)(P))
+ {
+ return pset | functorize_p2b(f);
+ }
+
+ // Image | Function_p2b
+
+ template <typename I, typename F>
+ op_<const I, such_as, const F>
+ operator | (const Image<I>& ima, const Function_p2b<F>& f)
+ {
+ typedef mlc_basic(oln_argument(F)) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(I) >::check();
+ op_<const I, such_as, const F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ op_<I, such_as, const F>
+ operator | (Mutable_Image<I>& ima, const Function_p2b<F>& f)
+ {
+ typedef mlc_basic(oln_argument(F)) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(I) >::check();
+ op_<I, such_as, const F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ inplace_< op_<I, such_as, const F> >
+ operator | (inplace_<I> ima, const Function_p2b<F>& f)
+ {
+ return (ima.unwrap() | f).inplace();
+ }
+
+ // Image | P -> B
+
+ template <typename I, typename B, typename P>
+ op_<const I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (const Image<I>& ima, B (*f)(P))
+ {
+ return ima | functorize_p2b(f);
+ }
+
+ template <typename I, typename B, typename P>
+ op_<I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (Mutable_Image<I>& ima, B (*f)(P))
+ {
+ return ima | functorize_p2b(f);
+ }
+
+ template <typename I, typename B, typename P>
+ inplace_< op_<I, such_as, const fun_p2b_<B (*)(P)> > >
+ operator | (inplace_<I> ima, B (*f)(P))
+ {
+ return (ima.unwrap() | f).inplace();
+ }
+
+ // Image | Binary_Image
+
+ template <typename I, typename J>
+ op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (const Image<I>& ima, const Binary_Image<J>& f)
+ {
+ precondition(f.points() >= ima.points());
+ mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
+ op_<const I, such_as, const fun_p2b_< Binary_Image<J> > > tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename J>
+ op_<I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (Mutable_Image<I>& ima, const Binary_Image<J>& f)
+ {
+ precondition(f.points() >= ima.points());
+ mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
+ op_<I, such_as, const fun_p2b_< Binary_Image<J> > > tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename J>
+ inplace_< op_<I, such_as, const fun_p2b_< Binary_Image<J> > > >
+ operator | (inplace_<I> ima, const Binary_Image<J>& f)
+ {
+ return (ima.unwrap() | f).inplace();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_SUCH_AS_HH
Index: oln/core/gen/value_cast.hh
--- oln/core/gen/value_cast.hh (revision 943)
+++ oln/core/gen/value_cast.hh (working copy)
@@ -31,45 +31,23 @@
# include <oln/core/gen/fun.hh>
-// FIXME: Separate defs and decls.
-
-
-
namespace oln
{
+ // casted_fun_<F, V>
- // ----------------------------- casted_fp2v_<F, V>
-
-
- // Fwd decl.
- template <typename F, typename V> struct casted_fp2v_;
-
- // Category.
- namespace internal
- {
- template <typename F, typename V>
- struct set_category_of_< casted_fp2v_<F, V> >
- {
- typedef stc::is< Function_p2v > ret;
- };
- }
-
-
- // Class.
template <typename F, typename V>
- struct casted_fp2v_ : public Function_p2v< casted_fp2v_<F, V> >
+ struct casted_fun_
+ :
+ public oln::internal::category_base_type_from_< F, casted_fun_<F, V> >::ret
{
typedef oln_arg_of_(F) argument;
typedef oln_res_of_(F) f_result;
typedef V result;
- casted_fp2v_(const F& f) : f_(f) {}
+ casted_fun_(const Function<F>& f);
- result operator()(argument arg) const
- {
- return static_cast<V>(this->f_(arg));
- }
+ result operator()(argument arg) const;
private:
F f_;
@@ -79,16 +57,33 @@
// value_cast
template <typename V, typename F>
- casted_fp2v_<F, V> value_cast(const Function_p2v<F>& f)
+ casted_fun_<F, V> value_cast(const Function<F>& f);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename F, typename V>
+ casted_fun_<F, V>::casted_fun_(const Function<F>& f)
+ : f_(exact(f))
{
- // FIXME: Check that the cast "F::result -> V" is OK.
- casted_fp2v_<F, V> tmp(exact(f));
- return tmp;
}
+ template <typename F, typename V>
+ typename casted_fun_<F, V>::result
+ casted_fun_<F, V>::operator()(typename casted_fun_<F, V>::argument arg) const
+ {
+ return static_cast<V>(this->f_(arg));
+ }
- // FIXME: Add casted_fv2v_<F,V>?
+ template <typename V, typename F>
+ casted_fun_<F, V> value_cast(const Function<F>& f)
+ {
+ // FIXME: Check that the cast "F::result -> V" is OK.
+ casted_fun_<F, V> tmp(f);
+ return tmp;
+ }
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 943)
+++ oln/core/gen/neighb.hh (working copy)
@@ -31,19 +31,11 @@
# include <oln/core/internal/dpoints_impl.hh>
# include <oln/core/internal/neighborhood_base.hh>
-# include <oln/core/internal/op_image_extended_by_nbh.hh>
namespace oln
{
-
- // Op.
- oln_decl_op_extended_by(Image, Neighborhood);
- oln_decl_inplace_image_op(extended_by, +, Neighborhood);
-
-
-
// Fwd decl.
template <typename Dp> class neighb_;
@@ -96,10 +88,13 @@
return *this;
}
-# endif
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
+// FIXME: Bad!
+# include <oln/core/gen/extended_by.hh>
+
+
#endif // ! OLN_CORE_GEN_NEIGHB_HH
Index: oln/core/gen/literal.hh
--- oln/core/gen/literal.hh (revision 943)
+++ oln/core/gen/literal.hh (working copy)
@@ -33,13 +33,9 @@
# include <oln/core/concept/value.hh>
-
-
namespace oln
{
-
-
// ----------------------------- literal_<T>
@@ -48,120 +44,143 @@
{
typedef const T& result;
- literal_(const T& val) : val_(val) {}
+ literal_(const T& val);
- result operator()() const
- {
- return this->val_;
- }
+ const T& operator()() const;
- operator T() const
- {
- return this->val_;
- }
+ operator T() const;
template <typename U>
- operator literal_<U>() const
- {
- literal_<U> tmp(this->val_);
- return tmp;
- }
+ operator literal_<U>() const;
- result value() const
- {
- return this->val_;
- }
+ const T& value() const;
private:
T val_;
};
- // literal
template <typename T>
- literal_<T>
- literal(const T& val)
- {
- literal_<T> tmp(val);
- return tmp;
- }
+ literal_<T> literal(const T& val);
// ----------------------------- lit_p2v_<P,T>
- // Fwd decl.
- template <typename P, typename T> struct lit_p2v_;
-
- // Category.
- namespace internal
+ template <typename P, typename V>
+ struct lit_p2v_ : public Function_p2v< lit_p2v_<P,V> >
{
- template <typename P, typename T>
- struct set_category_of_< lit_p2v_<P,T> >
- {
- typedef stc::is< Function_p2v > ret;
+ typedef P argument;
+ typedef const V& result;
+
+ lit_p2v_(const V& val);
+
+ const V& operator()(const P&) const;
+
+ private:
+ V val_;
};
- }
- // Class.
- template <typename P, typename T>
- struct lit_p2v_ : public Function_p2v< lit_p2v_<P,T> >
+
+ // ----------------------------- lit_p2b_<P,B>
+
+
+ template <typename P, typename B>
+ struct lit_p2b_ : public Function_p2b< lit_p2b_<P,B> >
{
typedef P argument;
- typedef T result;
+ typedef const B& result;
+
+ lit_p2b_(const B& val);
+
+ const B& operator()(const P&) const;
+
+ private:
+ B val_;
+ };
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
- lit_p2v_(const T& val)
+ // literal_<T>
+
+ template <typename T>
+ literal_<T>::literal_(const T& val)
: val_(val)
{
}
- result operator()(argument) const
+ template <typename T>
+ const T&
+ literal_<T>::operator()() const
{
return this->val_;
}
- private:
- T val_;
- };
+ template <typename T>
+ literal_<T>::operator T() const
+ {
+ return this->val_;
+ }
+ template <typename T>
+ template <typename U>
+ literal_<T>::operator literal_<U>() const
+ {
+ literal_<U> tmp(this->val_);
+ return tmp;
+ }
- // ----------------------------- lit_p2b_<P,B>
+ template <typename T>
+ const T&
+ literal_<T>::value() const
+ {
+ return this->val_;
+ }
+
+ template <typename T>
+ literal_<T>
+ literal(const T& val)
+ {
+ literal_<T> tmp(val);
+ return tmp;
+ }
- // Fwd decl.
- template <typename P, typename B> struct lit_p2b_;
+ // lit_p2v_<P,V>
- // Category.
- namespace internal
- {
- template <typename P, typename B>
- struct set_category_of_< lit_p2b_<P,B> >
+ template <typename P, typename V>
+ lit_p2v_<P,V>::lit_p2v_(const V& val)
+ : val_(val)
{
- typedef stc::is< Function_p2b > ret;
- };
}
- // Class.
- template <typename P, typename B>
- struct lit_p2b_ : public Function_p2b< lit_p2b_<P,B> >
+ template <typename P, typename V>
+ const V&
+ lit_p2v_<P,V>::operator()(const P&) const
{
- typedef P argument;
- typedef B result;
+ return this->val_;
+ }
- lit_p2b_(const B& val)
+
+ //lit_p2b_<P,B>
+
+ template <typename P, typename B>
+ lit_p2b_<P,B>::lit_p2b_(const B& val)
: val_(val)
{
}
- result operator()(argument) const
+ template <typename P, typename B>
+ const B&
+ lit_p2b_<P,B>::operator()(const P&) const
{
return this->val_;
}
- private:
- B val_;
- };
-
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/dpoint.hh
--- oln/core/gen/dpoint.hh (revision 0)
+++ oln/core/gen/dpoint.hh (revision 0)
@@ -0,0 +1,92 @@
+// 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 OLN_CORE_GEN_DPOINT_HH
+# define OLN_CORE_GEN_DPOINT_HH
+
+# include <oln/core/internal/dpoint_base.hh>
+# include <oln/core/internal/point_impl.hh>
+
+
+namespace oln
+{
+
+# define current dpoint<G, C>
+
+ // Fwd decls.
+ template <typename G, typename C> struct dpoint;
+ template <typename G, typename C> struct point;
+
+
+ // Super type.
+ template<typename G, typename C>
+ struct super_trait_< current >
+ {
+ typedef internal::dpoint_base_< current > ret;
+ };
+
+
+ // Virtual types.
+ template <typename G, typename C>
+ struct vtypes< current >
+ {
+ typedef G grid;
+ typedef C coord;
+ typedef point<G,C> point;
+ };
+
+
+ template <typename G, typename C>
+ class dpoint : public internal::dpoint_base_< current >,
+ public internal::point_impl_< mlc_value(oln_dim(G)), current >
+ {
+ public:
+ dpoint();
+ // nothing else here
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename G, typename C>
+ current::dpoint()
+ {
+ mlc::assert_< mlc_is_a(G, Grid) >::check();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef current
+
+} // end of namespace oln
+
+
+# include <oln/core/gen/point.hh>
+
+
+#endif // ! OLN_CORE_GEN_DPOINT_HH
Index: oln/core/gen/image_stack.hh
--- oln/core/gen/image_stack.hh (revision 943)
+++ oln/core/gen/image_stack.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/value_proxy.hh>
+# include <oln/core/internal/f_ch_value.hh>
# include <mlc/int.hh>
# include <xtd/vec.hh>
Index: oln/core/gen/fun_ops.hh
--- oln/core/gen/fun_ops.hh (revision 943)
+++ oln/core/gen/fun_ops.hh (working copy)
@@ -28,25 +28,13 @@
#ifndef OLN_CORE_GEN_FUN_OPS_HH
# define OLN_CORE_GEN_FUN_OPS_HH
-# include <oln/core/concept/function.hh>
-# include <oln/core/concept/point.hh>
+# include <oln/core/gen/fun.hh>
# include <oln/core/gen/literal.hh>
# define oln_decl_p2v_cmp_(Name, Sym) \
\
- template <typename L, typename R> struct p2v_##Name##_; \
- \
- namespace internal \
- { \
- template <typename L, typename R> \
- struct set_category_of_< p2v_##Name##_<L,R> > \
- { \
- typedef stc::is< Function_p2b > ret; \
- }; \
- } \
- \
template <typename L, typename R> \
struct p2v_##Name##_ : public Function_p2b< p2v_##Name##_<L,R> > \
{ \
@@ -94,17 +82,6 @@
# define oln_decl_p2v_arith_(Name, Sym) \
\
- template <typename L, typename R> struct p2v_##Name##_; \
- \
- namespace internal \
- { \
- template <typename L, typename R> \
- struct set_category_of_< p2v_##Name##_<L,R> > \
- { \
- typedef stc::is< Function_p2v > ret; \
- }; \
- } \
- \
template <typename L, typename R> \
struct p2v_##Name##_ : public Function_p2v< p2v_##Name##_<L,R> > \
{ \
@@ -151,17 +128,6 @@
# define oln_decl_p2v_un_(Name, Sym) \
\
- template <typename T> struct p2v_##Name##_; \
- \
- namespace internal \
- { \
- template <typename T> \
- struct set_category_of_< p2v_##Name##_<T> > \
- { \
- typedef stc::is< Function_p2v > ret; \
- }; \
- } \
- \
template <typename T> \
struct p2v_##Name##_ : public Function_p2v< p2v_##Name##_<T> > \
{ \
@@ -194,17 +160,6 @@
# define oln_decl_p2b_bin_(Name, Sym) \
\
- template <typename L, typename R> struct p2b_##Name##_; \
- \
- namespace internal \
- { \
- template <typename L, typename R> \
- struct set_category_of_< p2b_##Name##_<L,R> > \
- { \
- typedef stc::is< Function_p2b > ret; \
- }; \
- } \
- \
template <typename L, typename R> \
struct p2b_##Name##_ : public Function_p2b< p2b_##Name##_<L,R> > \
{ \
@@ -252,17 +207,6 @@
# define oln_decl_p2b_un_(Name, Sym) \
\
- template <typename T> struct p2b_##Name##_; \
- \
- namespace internal \
- { \
- template <typename T> \
- struct set_category_of_< p2b_##Name##_<T> > \
- { \
- typedef stc::is< Function_p2b > ret; \
- }; \
- } \
- \
template <typename T> \
struct p2b_##Name##_ : public Function_p2b< p2b_##Name##_<T> > \
{ \
Index: oln/core/gen/over.hh
--- oln/core/gen/over.hh (revision 0)
+++ oln/core/gen/over.hh (revision 0)
@@ -0,0 +1,108 @@
+// 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 OLN_CORE_GEN_OVER_HH
+# define OLN_CORE_GEN_OVER_HH
+
+
+namespace oln
+{
+ struct over;
+}
+
+
+# include <oln/core/internal/op_fp2v_over_pset.hh>
+# include <oln/core/gen/fun.hh>
+# include <oln/core/gen/literal.hh>
+
+
+namespace oln
+{
+
+ // Function_p2v / Point_Set
+
+ template <typename F, typename S>
+ op_<const F, over, const S>
+ operator / (const Function_p2v<F>& f, const Point_Set<S>& pset);
+
+
+ // (P -> V) / Point_Set
+
+ template <typename V, typename P, typename S>
+ op_<const fun_p2v_<V (*)(P)>, over, const S>
+ operator / (V (*f)(P), const Point_Set<S>& pset);
+
+
+ // V / Point_Set
+
+ template <typename V, typename S>
+ op_<const lit_p2v_<oln_point(S), V>, over, const S>
+ operator / (const literal_<V>& value, const Point_Set<S>& pset);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Function_p2v / Point_Set
+
+ template <typename F, typename S>
+ op_<const F, over, const S>
+ operator / (const Function_p2v<F>& f, const Point_Set<S>& pset)
+ {
+ typedef mlc_basic(oln_argument(F)) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(S) >::check();
+ op_<const F, over, const S> tmp(exact(f), exact(pset));
+ return tmp;
+ }
+
+ // P -> V / Point_Set
+
+ template <typename V, typename P, typename S>
+ op_<const fun_p2v_<V (*)(P)>, over, const S>
+ operator / (V (*f)(P), const Point_Set<S>& pset)
+ {
+ return functorize_p2v(f) / pset;
+ }
+
+ // V / Point_Set
+
+ template <typename V, typename S>
+ op_<const lit_p2v_<oln_point(S), V>, over, const S>
+ operator / (const literal_<V>& value, const Point_Set<S>& pset)
+ {
+ lit_p2v_<oln_point(S), V> lit(value);
+ op_<const lit_p2v_<oln_point(S), V>, over, const S> tmp(lit, exact(pset));
+ return tmp;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_OVER_HH
Index: oln/core/internal/f_grid_to_plain_image.hh
--- oln/core/internal/f_grid_to_plain_image.hh (revision 943)
+++ oln/core/internal/f_grid_to_plain_image.hh (working copy)
@@ -48,12 +48,15 @@
struct grid2d_hex;
struct grid2d_tri;
- // FIXME: 3D...
+ struct grid3d;
+
+ // FIXME: ...
// Image types.
template <typename T> class image1d;
template <typename T> class image2d;
+ template <typename T> class image3d;
/// \}
@@ -85,7 +88,13 @@
typedef image2d<T> ret; // FIXME: or image2d_b<T>?
};
- // FIXME: 2D hex/tri, 3D...
+ template <typename T>
+ struct grid_to_plain_image__< grid3d, T >
+ {
+ typedef image3d<T> ret; // FIXME: or image3d_b<T>?
+ };
+
+ // FIXME: 2D hex/tri...
/// \}
Index: oln/core/internal/op_image_through_fv2v.hh
--- oln/core/internal/op_image_through_fv2v.hh (revision 943)
+++ oln/core/internal/op_image_through_fv2v.hh (working copy)
@@ -84,7 +84,7 @@
namespace internal
{
- /// Implementation class for the result of "Function_v2v F << Image I".
+ /// Implementation class for the result of "Image I >> Function_v2v F".
template <typename I, typename F>
class current : public super
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 943)
+++ oln/core/internal/box.hh (working copy)
@@ -49,7 +49,7 @@
};
- /// Virtual types associated to oln::box_<P>.
+ // Virtual types associated to oln::box_<P>.
template <typename Exact>
struct vtypes< internal::box_<Exact> >
{
@@ -111,7 +111,7 @@
- /// Super types.
+ // Super types.
template <typename B>
struct super_trait_< box_fwd_piter_<B> >
@@ -128,7 +128,7 @@
};
- /// Virtual types.
+ // Virtual types.
template <typename B>
struct vtypes< box_fwd_piter_<B> >
@@ -233,7 +233,7 @@
template <typename D>
box_<Exact>::box_(const internal::initializer_<D>& data)
{
- bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
+ bool box_ok = internal::init__(internal::tag::i_box_t(), *this, data.value());
postcondition(box_ok);
}
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 943)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -34,29 +34,6 @@
namespace oln
{
- // function : point -> box
-
- template <typename P> class gen_box;
-
- template <typename P>
- struct f_box_from_point_ { typedef gen_box<P> ret; };
-
- class point1d;
- class box1d;
-
- template <>
- struct f_box_from_point_< point1d > { typedef box1d ret; };
-
- class point2d;
- class box2d;
-
- template <>
- struct f_box_from_point_< point2d > { typedef box2d ret; };
-
- // FIXME: Move the code above elsewhere.
-
-
-
namespace internal
{
@@ -75,9 +52,8 @@
// point_set_base_ class
- // Fwd decls.
+ // Fwd decl.
namespace internal { template <typename Exact> struct point_set_base_; }
- template <typename P> class gen_box;
// Super type.
@@ -102,6 +78,7 @@
typedef stc::final< stc::is<Point_Set> > category;
typedef stc::final< oln_grid(point__) > grid;
+ // typedef stc::final< oln_coord(point__) > coord;
typedef stc::final< fwd_piter__ > piter;
};
@@ -126,45 +103,11 @@
{
}
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::internal
} // end of namespace oln
-
-/// \{
-/// FIXME: Bad!
-
-# include <oln/core/gen/fun.hh>
-# include <oln/core/internal/op_pset_such_as_fp2b.hh>
-
-namespace oln
-{
-
- // Point_Set | Function.
-
- oln_decl_op_such_as(Point_Set, Function_p2b);
-
-
- // Specialization.
-
- template <typename S, typename B, typename P>
- op_<const S, such_as, const fun_p2b_<B (*)(P)> >
- operator | (const Point_Set<S>& lhs, B (*f)(P))
- {
- typedef mlc_basic(P) P_;
- mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
- mlc::assert_equal_< P_, oln_point(S) >::check();
- op_<const S, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(lhs), f);
- return tmp;
- }
-
-
-} // end of namespace oln
-
-/// \}
-
-
#endif // ! OLN_CORE_INTERNAL_POINT_SET_BASE_HH
Index: oln/core/internal/op_image_such_as_fp2b.hh
--- oln/core/internal/op_image_such_as_fp2b.hh (revision 943)
+++ oln/core/internal/op_image_such_as_fp2b.hh (working copy)
@@ -28,10 +28,15 @@
#ifndef OLN_CORE_INTERNAL_OP_IMAGE_SUCH_AS_FP2B_HH
# define OLN_CORE_INTERNAL_OP_IMAGE_SUCH_AS_FP2B_HH
-# include <oln/core/internal/op_image_restricted_to_pset.hh>
+# include <oln/core/gen/restricted_to.hh>
# include <oln/core/internal/op_pset_such_as_fp2b.hh>
+// "ima such_as f : p -> b" is "ima restricted_to (ima.points such_as f)"
+
+// FIXME: That's cool but too much code is involved...
+// FIXME: ...So write a specialized version!
+
namespace oln
{
Index: oln/core/internal/f_grid_to_box.hh
--- oln/core/internal/f_grid_to_box.hh (revision 943)
+++ oln/core/internal/f_grid_to_box.hh (working copy)
@@ -43,18 +43,18 @@
// Grid types.
struct grid1d;
-
struct grid2d;
struct grid2d_hex;
struct grid2d_tri;
-
- // FIXME: 3D...
+ struct grid3d;
+ // ...
// Box types.
struct box1d;
struct box2d;
- template <typename P> class gen_box;
+ struct box3d;
+ // ...
/// \}
@@ -86,7 +86,13 @@
typedef box2d ret;
};
- // FIXME: 2D hex/tri, 3D...
+ // FIXME: 2D hex/tri...
+
+ template <>
+ struct grid_to_box__< grid3d >
+ {
+ typedef box3d ret;
+ };
/// \}
Index: oln/core/internal/f_point_to_box.hh
--- oln/core/internal/f_point_to_box.hh (revision 0)
+++ oln/core/internal/f_point_to_box.hh (revision 0)
@@ -0,0 +1,112 @@
+// 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 OLN_CORE_INTERNAL_F_POINT_TO_BOX_HH
+# define OLN_CORE_INTERNAL_F_POINT_TO_BOX_HH
+
+# include <oln/core/concept/point.hh>
+
+
+# define oln_f_point_to_box(P) \
+typename oln::internal::f_point_to_box_< P >::ret
+
+
+namespace oln
+{
+
+ /// \{
+ /// Forward declarations.
+
+ // Point types.
+
+ struct point1d;
+ struct point2d;
+ struct point3d;
+ template <typename G, typename C> class point;
+
+ // Box types.
+
+ struct box1d;
+ struct box2d;
+ struct box3d;
+ template <typename G, typename C> class box;
+
+ /// \}
+
+
+
+ namespace internal
+ {
+
+ template <typename P>
+ struct point_to_box__;
+
+
+ /// \{
+ /// Definitions.
+
+ template <typename G, typename C>
+ struct point_to_box__< point<G, C> >
+ {
+ typedef box<G, C> ret;
+ };
+
+ template <>
+ struct point_to_box__< point1d >
+ {
+ typedef box1d ret;
+ };
+
+ template <>
+ struct point_to_box__< point2d >
+ {
+ typedef box2d ret;
+ };
+
+ // FIXME: 2D hex/tri...
+
+ template <>
+ struct point_to_box__< point3d >
+ {
+ typedef box3d ret;
+ };
+
+ /// \}
+
+
+ template <typename P>
+ struct f_point_to_box_ : private mlc::assert_< mlc_is_a(P, Point) >,
+ public point_to_box__< P >
+ {
+ };
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_POINT_TO_BOX_HH
Index: oln/core/internal/point_impl.hh
--- oln/core/internal/point_impl.hh (revision 0)
+++ oln/core/internal/point_impl.hh (revision 0)
@@ -0,0 +1,199 @@
+// 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 OLN_CORE_INTERNAL_POINT_IMPL_HH
+# define OLN_CORE_INTERNAL_POINT_IMPL_HH
+
+# include <oln/core/equipment.hh>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ // default
+
+ template <unsigned dim, typename Exact>
+ struct point_impl_
+ {
+ // nothing
+ };
+
+
+ // dim = 1
+
+ template <typename Exact>
+ struct point_impl_< 1, Exact >
+ {
+ private:
+ stc_typename(coord);
+ public:
+
+ coord ind() const;
+ coord& ind();
+ };
+
+
+ // dim = 2
+
+ template <typename Exact>
+ struct point_impl_< 2, Exact >
+ {
+ private:
+ stc_typename(coord);
+ public:
+
+ coord row() const;
+ coord& row();
+
+ coord col() const;
+ coord& col();
+ };
+
+
+ // dim = 3
+
+ template <typename Exact>
+ struct point_impl_< 3, Exact >
+ {
+ private:
+ stc_typename(coord);
+ public:
+
+ coord sli() const;
+ coord& sli();
+
+ coord row() const;
+ coord& row();
+
+ coord col() const;
+ coord& col();
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // dim = 1
+
+ template <typename Exact>
+ typename point_impl_<1, Exact>::coord
+ point_impl_<1, Exact>::ind() const
+ {
+ return static_cast<const Exact&>(*this)[0];
+ }
+
+ template <typename Exact>
+ typename point_impl_<1, Exact>::coord &
+ point_impl_<1, Exact>::ind()
+ {
+ return static_cast<Exact&>(*this)[0];
+ }
+
+ // dim = 2
+
+ template <typename Exact>
+ typename point_impl_<2, Exact>::coord
+ point_impl_<2, Exact>::row() const
+ {
+ return static_cast<const Exact&>(*this)[0];
+ }
+
+ template <typename Exact>
+ typename point_impl_<2, Exact>::coord &
+ point_impl_<2, Exact>::row()
+ {
+ return static_cast<Exact&>(*this)[0];
+ }
+
+ template <typename Exact>
+ typename point_impl_<2, Exact>::coord
+ point_impl_<2, Exact>::col() const
+ {
+ return static_cast<const Exact&>(*this)[1];
+ }
+
+ template <typename Exact>
+ typename point_impl_<2, Exact>::coord &
+ point_impl_<2, Exact>::col()
+ {
+ return static_cast<Exact&>(*this)[1];
+ }
+
+ // dim = 3
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord
+ point_impl_<3, Exact>::sli() const
+ {
+ return static_cast<const Exact&>(*this)[0];
+ }
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord &
+ point_impl_<3, Exact>::sli()
+ {
+ return static_cast<Exact&>(*this)[0];
+ }
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord
+ point_impl_<3, Exact>::row() const
+ {
+ return static_cast<const Exact&>(*this)[1];
+ }
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord &
+ point_impl_<3, Exact>::row()
+ {
+ return static_cast<Exact&>(*this)[1];
+ }
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord
+ point_impl_<3, Exact>::col() const
+ {
+ return static_cast<const Exact&>(*this)[2];
+ }
+
+ template <typename Exact>
+ typename point_impl_<3, Exact>::coord &
+ point_impl_<3, Exact>::col()
+ {
+ return static_cast<Exact&>(*this)[2];
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_POINT_IMPL_HH
Index: oln/core/internal/macro_extended_by.hh
--- oln/core/internal/macro_extended_by.hh (revision 0)
+++ oln/core/internal/macro_extended_by.hh (revision 0)
@@ -0,0 +1,128 @@
+// 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 OLN_CORE_INTERNAL_MACRO_EXTENDED_BY_HH
+# define OLN_CORE_INTERNAL_MACRO_EXTENDED_BY_HH
+
+
+# include <oln/core/gen/inplace.hh>
+
+
+# define oln_decl_op_image_extended_by_const(Concept) \
+ \
+ template <typename I, typename E> \
+ op_<const I, extended_by, const E> \
+ operator + (const Image<I>& ima, const Concept<E>& ext); \
+ \
+ template <typename I, typename E> \
+ op_<I, extended_by, const E> \
+ operator + (Mutable_Image<I>& ima, const Concept<E>& ext); \
+ \
+ template <typename I, typename E> \
+ inplace_< op_<I, extended_by, const E> > \
+ operator + (inplace_<I> ima, const Concept<E>& ext); \
+ \
+ struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+
+# define oln_decl_op_image_extended_by_mutable(Concept) \
+ \
+ template <typename I, typename E> \
+ op_<const I, extended_by, E> \
+ operator + (const Image<I>& ima, Concept<E>& ext); \
+ \
+ template <typename I, typename E> \
+ op_<I, extended_by, E> \
+ operator + (Mutable_Image<I>& ima, Concept<E>& ext); \
+ \
+ template <typename I, typename E> \
+ inplace_< op_<I, extended_by, E> > \
+ operator + (inplace_<I> ima, Concept<E>& ext); \
+ \
+ struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+
+# define oln_def_op_image_extended_by_const(Concept) \
+ \
+ template <typename I, typename E> \
+ op_<const I, extended_by, const E> \
+ operator + (const Image<I>& ima, const Concept<E>& ext) \
+ { \
+ op_<const I, extended_by, const E> tmp(exact(ima), exact(ext)); \
+ return tmp; \
+ } \
+ \
+ template <typename I, typename E> \
+ op_<I, extended_by, const E> \
+ operator + (Mutable_Image<I>& ima, const Concept<E>& ext) \
+ { \
+ op_<I, extended_by, const E> tmp(exact(ima), exact(ext)); \
+ return tmp; \
+ } \
+ \
+ template <typename I, typename E> \
+ inplace_< op_<I, extended_by, const E> > \
+ operator + (inplace_<I> ima, const Concept<E>& ext) \
+ { \
+ return (ima.unwrap() + ext).inplace(); \
+ } \
+ \
+ struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+
+# define oln_def_op_image_extended_by_mutable(Concept) \
+ \
+ template <typename I, typename E> \
+ op_<const I, extended_by, E> \
+ operator + (const Image<I>& ima, Concept<E>& ext) \
+ { \
+ op_<const I, extended_by, E> tmp(exact(ima), exact(ext)); \
+ return tmp; \
+ } \
+ \
+ template <typename I, typename E> \
+ op_<I, extended_by, E> \
+ operator + (Mutable_Image<I>& ima, Concept<E>& ext) \
+ { \
+ op_<I, extended_by, E> tmp(exact(ima), exact(ext)); \
+ return tmp; \
+ } \
+ \
+ template <typename I, typename E> \
+ inplace_< op_<I, extended_by, E> > \
+ operator + (inplace_<I> ima, Concept<E>& ext) \
+ { \
+ return (ima.unwrap() + ext).inplace(); \
+ } \
+ \
+ struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+#endif // ! OLN_CORE_INTERNAL_MACRO_EXTENDED_BY_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 943)
+++ oln/core/internal/image_base.hh (working copy)
@@ -514,14 +514,7 @@
# endif // ! OLN_INCLUDE_ONLY
-
} // end of namespace oln
-
-// FIXME: Bad!
-# include <oln/core/internal/image_ops.hh>
-
-
-
#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 943)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -66,7 +66,7 @@
typedef stc::final< point__ > point;
typedef stc::final< pset_std_based_fwd_piter_<std_container__> > fwd_piter;
typedef stc::final< pset_std_based_bkd_piter_<std_container__> > bkd_piter;
- typedef stc::final< typename f_box_from_point_<point__>::ret > box;
+ typedef stc::final< oln_f_point_to_box(point__) > box;
};
Index: oln/core/internal/op_fv2v_applied_on_image.hh
--- oln/core/internal/op_fv2v_applied_on_image.hh (revision 943)
+++ oln/core/internal/op_fv2v_applied_on_image.hh (working copy)
@@ -64,8 +64,8 @@
typedef I delegatee;
typedef internal::pair<I,F> data;
- typedef oln_result(F) rvalue;
- typedef mlc_basic(rvalue) value;
+ typedef mlc_basic(oln_result(F)) value;
+ typedef value rvalue;
typedef typename mlc::if_< mlc::and_list_< mlc_is_not_const(I),
stc_is_found_type(I, lvalue),
Index: oln/core/internal/point_base.hh
--- oln/core/internal/point_base.hh (revision 943)
+++ oln/core/internal/point_base.hh (working copy)
@@ -50,8 +50,8 @@
template <typename Exact>
struct vtypes< internal::point_base_<Exact> >
{
- typedef stc::abstract grid; // FIXME: Could be defined and final?
- typedef stc::abstract coord; // FIXME: Likewise?
+ typedef stc::abstract grid;
+ typedef stc::abstract coord;
typedef stc::abstract dpoint;
typedef stc_deferred(grid) grid__;
Index: oln/core/internal/category_of.hh
--- oln/core/internal/category_of.hh (revision 943)
+++ oln/core/internal/category_of.hh (working copy)
@@ -29,62 +29,69 @@
# define OLN_CORE_INTERNAL_CATEGORY_OF_HH
# include <mlc/basic.hh>
+# include <oln/core/internal/utils.hh>
-# define oln_category_of_(Type) typename oln::internal::category_of_< Type >::ret
+# define oln_category_of_(Type) \
+ typename oln::internal::category_of_< Type >::ret
+
namespace oln
{
- // Fwd decls.
- template <typename Exact> struct Boolean;
-
-
-
namespace internal
{
- // Category_of_
-
+ template <typename T1, typename T2>
+ struct get_category_of_
+ : private mlc::abort_< pair<T1,T2> > // FIXME: Add error msg.
+ {
+ };
- template <typename T>
- struct set_category_of_
+ template <template <class> class C>
+ struct get_category_of_< C<void>, mlc::not_found >
{
- typedef stc_type(T, category) ret;
+ typedef stc::is<C> ret;
};
- template <>
- struct set_category_of_< bool > // FIXME: Move into oln/core/value/*.
+ template <template <class> class C>
+ struct get_category_of_< mlc::not_found, stc::is<C> >
{
- typedef stc::is< Boolean > ret;
+ typedef stc::is<C> ret;
};
+ // category_of_
+
template <typename T>
struct category_of_
{
- typedef typename set_category_of_< mlc_basic(T) >::ret ret;
+ typedef mlc_basic(T) T__;
+ typedef mlc_typedef(T__, category) ret_1;
+ typedef stc_find_type(T__, category) ret_2;
+ typedef typename get_category_of_<ret_1, ret_2>::ret ret;
};
- // ...
-
+ template <class C, typename Exact>
+ struct get_category_base_type_;
- // only_if_
-
- template < typename Ret,
- typename Check_1,
- typename Check_2 = void,
- typename Check_3 = void,
- typename Check_4 = void >
- struct only_if_
+ template <template <class> class C, typename Exact>
+ struct get_category_base_type_< stc::is<C>, Exact >
{
- typedef Ret ret;
+ typedef C<Exact> ret;
};
+ // category_base_type_from_
+ template <typename From, typename Exact>
+ struct category_base_type_from_
+ {
+ typedef oln_category_of_(From) C;
+ typedef typename get_category_base_type_<C, Exact>::ret ret;
+ };
} // end of namespace oln::internal
Index: oln/core/internal/iterator_on_points_impl.hh
--- oln/core/internal/iterator_on_points_impl.hh (revision 943)
+++ oln/core/internal/iterator_on_points_impl.hh (working copy)
@@ -25,116 +25,109 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-
#ifndef OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
+# include <oln/core/equipment.hh>
-namespace oln
-{
- // Forward declarations
- namespace impl
+namespace oln
{
- template <unsigned n, typename Exact, typename P>
- struct iterator_on_points_impl;
- }
-
- template <unsigned n, typename Exact, typename P>
- struct super_trait_< impl::iterator_on_points_impl<n, Exact, P> >
+ namespace internal
{
- typedef Any<P> ret;
- };
- template <unsigned n, typename Exact, typename P>
- struct vtypes< impl::iterator_on_points_impl<n, Exact, P> >
+ template <unsigned n, typename Exact>
+ struct iterator_on_points_impl_
{
};
-
- namespace impl
- {
- template <unsigned n, typename Exact, typename P>
- struct iterator_on_points_impl : public virtual Any<Exact>
+ // 1d impl
+ template <typename Exact>
+ struct iterator_on_points_impl_< 1, Exact >
{
+ private:
+ stc_typename(coord);
+ public:
+ coord ind() const;
};
- /// point1d interface
- template <typename Exact, typename P>
- struct iterator_on_points_impl<1, Exact, P> : public virtual Any< Exact >
+ // 2d impl
+ template <typename Exact>
+ struct iterator_on_points_impl_< 2, Exact >
{
- typename P::coord ind() const;
+ private:
+ stc_typename(coord);
+ public:
+ coord row() const;
+ coord col() const;
};
- /// point2d interface
- template <typename Exact, typename P>
- struct iterator_on_points_impl<2, Exact, P>: public virtual Any< Exact >
+ // 3d impl
+ template <typename Exact>
+ struct iterator_on_points_impl_< 3, Exact >
{
- typename P::coord row() const;
- typename P::coord col() const;
- };
-
- /// point3d interface
- template <typename Exact, typename P>
- struct iterator_on_points_impl<3, Exact, P>: public virtual Any< Exact >
- {
- typename P::coord row() const;
- typename P::coord col() const;
- typename P::coord slice() const;
+ private:
+ stc_typename(coord);
+ public:
+ coord sli() const;
+ coord row() const;
+ coord col() const;
};
# ifndef OLN_INCLUDE_ONLY
- // point1d
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<1, Exact, P>::ind() const
+ // 1d impl
+
+ template <typename Exact>
+ typename iterator_on_points_impl_<1, Exact>::coord
+ iterator_on_points_impl_<1, Exact>::ind() const
{
- return exact(this)->to_point().ind();
+ return static_cast<const Exact&>(*this).to_point().ind();
}
- // point2d
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<2, Exact, P>::row() const
+ // 2d impl
+
+ template <typename Exact>
+ typename iterator_on_points_impl_<2, Exact>::coord
+ iterator_on_points_impl_<2, Exact>::row() const
{
- return exact(this)->to_point().row();
+ return static_cast<const Exact&>(*this).to_point().row();
}
-
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<2, Exact, P>::col() const
+ template <typename Exact>
+ typename iterator_on_points_impl_<2, Exact>::coord
+ iterator_on_points_impl_<2, Exact>::col() const
{
- return exact(this)->to_point().col();
+ return static_cast<const Exact&>(*this).to_point().col();
}
- // point3d
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<3, Exact, P>::row() const
+ // 3d impl
+
+ template <typename Exact>
+ typename iterator_on_points_impl_<3, Exact>::coord
+ iterator_on_points_impl_<3, Exact>::sli() const
{
- return exact(this)->to_point().row();
+ return static_cast<const Exact&>(*this).to_point().sli();
}
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<3, Exact, P>::col() const
+ template <typename Exact>
+ typename iterator_on_points_impl_<3, Exact>::coord
+ iterator_on_points_impl_<3, Exact>::row() const
{
- return exact(this)->to_point().col();
+ return static_cast<const Exact&>(*this).to_point().row();
}
- template <typename Exact, typename P>
- typename P::coord
- iterator_on_points_impl<3, Exact, P>::slice() const
+ template <typename Exact>
+ typename iterator_on_points_impl_<3, Exact>::coord
+ iterator_on_points_impl_<3, Exact>::col() const
{
- return exact(this)->to_point().slice();
+ return static_cast<const Exact&>(*this).to_point().col();
}
# endif // ! OLN_INCLUDE_ONLY
- } // end of namespace oln
+ } // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/f_pset_to_plain_image.hh
--- oln/core/internal/f_pset_to_plain_image.hh (revision 943)
+++ oln/core/internal/f_pset_to_plain_image.hh (working copy)
@@ -32,7 +32,8 @@
# include <oln/core/internal/f_grid_to_plain_image.hh>
-#define oln_f_pset_to_plain_image(Ps, T) typename oln::internal::f_pset_to_plain_image_< Ps, T >::ret
+# define oln_f_pset_to_plain_image(Ps, T) \
+ typename oln::internal::f_pset_to_plain_image_< Ps, T >::ret
namespace oln
@@ -42,7 +43,7 @@
/// Forward declarations.
// point set types
- template <typename P> class gen_box;
+ template <typename G, typename C> class box;
class box1d;
class box2d;
// FIXME: ...
@@ -95,10 +96,16 @@
// ...
- template <typename P, typename T>
- struct pset_to_plain_image__< gen_box<P>, T >
+ template <typename G, typename T>
+ struct pset_to_plain_image__< box<G, int>, T >
{
- typedef oln_f_grid_to_plain_image(oln_grid(P), T) ret;
+ typedef oln_f_grid_to_plain_image(G, T) ret;
+ };
+
+ template <typename G, typename C, typename T>
+ struct pset_to_plain_image__< box<G, C>, T >
+ {
+ // FIXME: Not impled yet (every C should be handled; not only int).
};
template <typename S, typename F_p2b, typename T>
Index: oln/core/internal/iterator_on_points_base.hh
--- oln/core/internal/iterator_on_points_base.hh (revision 943)
+++ oln/core/internal/iterator_on_points_base.hh (working copy)
@@ -58,9 +58,6 @@
typedef stc::final< oln_coord(point__) > coord;
typedef stc::final< oln_dim(point__) > dim;
typedef stc::final< oln_dpoint(point__) > dpoint;
-
- // for getting point implementation
- typedef stc_deferred(dim) dim__;
};
@@ -68,10 +65,9 @@
{
template <typename Exact>
- class iterator_on_points_base_ : public Iterator_on_Points<Exact>,
- public impl::iterator_on_points_impl
- <mlc_value(typename vtypes< internal::iterator_on_points_base_<Exact> >::dim__),
- Exact, typename vtypes< internal::iterator_on_points_base_<Exact> >::point__>
+ class iterator_on_points_base_
+ : public Iterator_on_Points<Exact>,
+ public internal::iterator_on_points_impl_<mlc_value(stc_deferred(dim)), Exact>
{
protected:
iterator_on_points_base_();
@@ -91,4 +87,5 @@
} // end of namespace oln
+
#endif // ! OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 943)
+++ oln/stc/scoop.hh (working copy)
@@ -136,6 +136,7 @@
// For concepts.
# define stc_typename(Type) typedef stc_type(Exact, Type) Type
# define stc_using(Type) typedef typename super::Type Type
+# define stc_using_(Type) typedef super::Type Type
# define stc_using_from(Abstraction, Type) typedef typename Abstraction<Exact>::Type Type
# define stc_deduce_typename(Src, Type) typedef stc_type(Src, Type) Type
Index: oln/draw/bresenham.hh
--- oln/draw/bresenham.hh (revision 943)
+++ oln/draw/bresenham.hh (working copy)
@@ -30,9 +30,11 @@
# include <oln/core/concept/image.hh>
# include <oln/core/gen/inplace.hh>
-# include <oln/core/2d/line2d.hh>
+# include <oln/core/gen/over.hh>
# include <oln/level/paste.hh>
+# include <oln/core/2d/line2d.hh> // FIXME: 2D!
+
namespace oln
1
0