URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-14 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add 3d handling
* mln/convert/to_image.hh: Update.
* mln/core/box3d.hh: New.
* mln/core/dpoint3d.hh: New.
* mln/core/image3d_b.hh: New.
* mln/core/internal/box_impl.hh: Update.
* mln/core/neighb3d.hh: New.
* mln/core/pixter3d_b.hh: New.
* mln/core/point3d.hh: New.
* mln/core/w_window3d_float.hh: New.
* mln/core/w_window3d_int.hh: New.
* mln/core/win/cube3d.hh: New.
* mln/core/window3d.hh: New.
* mln/debug/println.hh: Update.
* mln/geom/max_sli.hh: New.
* mln/geom/min_sli.hh: New.
* mln/geom/nslis.hh: New.
* mln/geom/size3d.hh: New.
* mln/make/box3d.hh: New.
* mln/make/dpoint3d.hh: New.
* mln/make/point3d.hh: New.
* mln/make/w_window1d.hh: Precondition of oddness fixed.
* mln/make/w_window3d.hh: New.
* mln/make/w_window3d_int.hh: New.
* mln/make/window3d.hh: New.
* tests/box3d.cc: New.
* tests/dpoint3d.cc: New.
* tests/image3d_b.cc: New.
* tests/pixter3d_b.cc: New.
* tests/point3d.cc: New.
* tests/w_window3d_int.cc: New.
* tests/window3d.cc: New.
---
mln/convert/to_image.hh | 7
mln/core/box3d.hh | 58 ++++
mln/core/dpoint3d.hh | 71 +++++
mln/core/image3d_b.hh | 555 ++++++++++++++++++++++++++++++++++++++++++
mln/core/internal/box_impl.hh | 88 ++++++
mln/core/neighb3d.hh | 174 +++++++++++++
mln/core/pixter3d_b.hh | 130 +++++++++
mln/core/point3d.hh | 56 ++++
mln/core/w_window3d_float.hh | 56 ++++
mln/core/w_window3d_int.hh | 56 ++++
mln/core/win/cube3d.hh | 193 ++++++++++++++
mln/core/window3d.hh | 56 ++++
mln/debug/println.hh | 33 ++
mln/geom/max_sli.hh | 66 ++++
mln/geom/min_sli.hh | 66 ++++
mln/geom/nslis.hh | 67 +++++
mln/geom/size3d.hh | 41 +++
mln/make/box3d.hh | 108 ++++++++
mln/make/dpoint3d.hh | 74 +++++
mln/make/point3d.hh | 74 +++++
mln/make/w_window1d.hh | 2
mln/make/w_window3d.hh | 90 ++++++
mln/make/w_window3d_int.hh | 76 +++++
mln/make/window3d.hh | 84 ++++++
tests/box3d.cc | 43 +++
tests/dpoint3d.cc | 53 ++++
tests/image3d_b.cc | 52 +++
tests/pixter3d_b.cc | 96 +++++++
tests/point3d.cc | 62 ++++
tests/w_window3d_int.cc | 83 ++++++
tests/window3d.cc | 57 ++++
31 files changed, 2725 insertions(+), 2 deletions(-)
Index: trunk/milena/tests/window3d.cc
===================================================================
--- trunk/milena/tests/window3d.cc (revision 0)
+++ trunk/milena/tests/window3d.cc (revision 1110)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/window3d.cc
+ *
+ * \brief Tests on mln::window3d.
+ */
+
+#include <mln/core/window3d.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ window3d w;
+
+ mln_assertion(w.is_centered() == false);
+ mln_assertion(w.is_symmetric() == true);
+
+ w.insert(make::dpoint3d(-1, -1, -1));
+ w.insert(make::dpoint3d( 1, 1, 1));
+ w.insert(make::dpoint3d( 0, 0, 2));
+
+ image3d_b<bool> ima = convert::to_image(w);
+ debug::println(ima);
+
+ mln_assertion(w.delta() == 2);
+}
Index: trunk/milena/tests/w_window3d_int.cc
===================================================================
--- trunk/milena/tests/w_window3d_int.cc (revision 0)
+++ trunk/milena/tests/w_window3d_int.cc (revision 1110)
@@ -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.
+
+/*! \file tests/w_window3d_int.cc
+ *
+ * \brief Tests on mln::w_window3d_int.
+ */
+
+#include <mln/core/w_window3d_int.hh>
+#include <mln/core/win/cube3d.hh>
+
+#include <mln/convert/to_image.hh>
+#include <mln/convert/to_w_window.hh>
+
+#include <mln/convert/to_fun.hh>
+#include <mln/estim/sum.hh>
+
+#include <mln/debug/println.hh>
+
+
+int f(mln::point3d p)
+{
+ return p.sli() + p.row() + p.col();
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ int ws[3][9] = {{-3, -2, -3,
+ -2, 1, -2,
+ -3, -2, -3},
+ { 2, 0, -2,
+ 0, 0, 0,
+ 2, 0, -2},
+ { 3, 2, 3,
+ 2, -1, 2,
+ 3, 2, 3}};
+ w_window3d_int w_win = make::w_window3d(ws);
+
+ image3d_b<int> ima = convert::to_image(w_win);
+ w_window3d_int w_win_2 = convert::to_w_window(ima);
+ mln_assertion(w_win_2 == w_win);
+ }
+
+ {
+ w_window3d_int w_win = make::w_window(win::cube3d(3),
+ convert::to_fun(f));
+ // -3 -2 -1 0 +1
+ // -2 -1 0 +1 +2
+ // -1 0 +1 +2 +3
+ image3d_b<int> ima = convert::to_image(w_win);
+ debug::println(ima);
+ mln_assertion(estim::sum(ima) == 0);
+ }
+
+}
Index: trunk/milena/tests/box3d.cc
===================================================================
--- trunk/milena/tests/box3d.cc (revision 0)
+++ trunk/milena/tests/box3d.cc (revision 1110)
@@ -0,0 +1,43 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/box3d.cc
+ *
+ * \brief Tests on mln::box3d.
+ */
+
+#include <mln/core/box3d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ box3d b = make::box3d(2, 6, 3);
+ mln_assertion(b.nslis() == 2 && b.nrows() == 6 && b.ncols() == 3);
+}
Index: trunk/milena/tests/image3d_b.cc
===================================================================
--- trunk/milena/tests/image3d_b.cc (revision 0)
+++ trunk/milena/tests/image3d_b.cc (revision 1110)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/image3d_b.cc
+ *
+ * \brief Tests on mln::image3d_b.
+ */
+
+#include <mln/core/image3d_b.hh>
+#include <mln/geom/size3d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned nslis = 3;
+ const unsigned nrows = 4;
+ const unsigned ncols = 5;
+ const unsigned border = 4;
+
+ image3d_b<int> f(nslis, nrows, ncols, border);
+
+ mln_assertion(f.npoints() == geom::nslis(f) * geom::nrows(f) * geom::ncols(f));
+ mln_assertion(f.ncells() == ((nrows + 2 * border)
+ * (ncols + 2 * border)
+ * (nslis + 2 * border)));
+}
Index: trunk/milena/tests/dpoint3d.cc
===================================================================
--- trunk/milena/tests/dpoint3d.cc (revision 0)
+++ trunk/milena/tests/dpoint3d.cc (revision 1110)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/dpoint3d.cc
+ *
+ * \brief Tests on mln::dpoint3d.
+ */
+
+#include <mln/core/dpoint3d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ point3d p, q;
+ dpoint3d dp;
+
+ p = make::point3d(2, 1, 4);
+ q = make::point3d(4, 7, 1);
+ dp = make::dpoint3d(2, 6, -3);
+
+ mln_assertion(dp == q - p);
+ mln_assertion(q == p + dp);
+
+ const int (&vec)[3] = dp.to_vec();
+ mln_assertion(vec[1] == 6);
+}
Index: trunk/milena/tests/pixter3d_b.cc
===================================================================
--- trunk/milena/tests/pixter3d_b.cc (revision 0)
+++ trunk/milena/tests/pixter3d_b.cc (revision 1110)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/pixter3d_b.cc
+ *
+ * \brief Tests on mln::fwd_pixter3d_b.
+ */
+
+#include <mln/core/image3d_b.hh>
+
+
+const unsigned size = 5;
+const unsigned len = 125;
+const int v = 51;
+
+
+template <typename I>
+void test_fill(I& ima)
+{
+ mln_pixter(I) pxl(ima);
+ unsigned i = 0;
+ for_all(pxl)
+ {
+ ++i;
+ pxl.val() = v;
+ }
+ std::cout << i << std::endl;
+ mln_assertion(i == len);
+ mln_assertion(! pxl.is_valid());
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ mln_assertion(ima(p) == v);
+}
+
+
+template <typename I>
+void test_const(const I& imac, I& ima)
+{
+ {
+ mln_pixter(const I) pxl(imac); // const is mandatory
+ pxl.start();
+ mln_assertion(pxl.val() == v);
+ // pxl.val() = v; // error is OK since pixter on 'const I'
+ }
+ {
+ // mln_pixter(I) pxl_(imac); // error is OK since mutable I but const imac
+ mln_pixter(I) pxl(ima);
+ pxl.start();
+ pxl.val() = 2 * pxl.val();
+ mln_assertion(pxl.val() == 2 * v);
+ }
+ {
+ mln_pixter(const I) pxl(ima); // const promotion is OK
+ pxl.start();
+ mln_assertion(pxl.val() == 2 * v);
+ // pxl.val() = v; // error is OK since pixter on 'const I'
+ }
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image3d_b<int> I;
+ I ima(size, size, size);
+
+ test_fill(ima);
+ test_const(ima, ima);
+}
Index: trunk/milena/tests/point3d.cc
===================================================================
--- trunk/milena/tests/point3d.cc (revision 0)
+++ trunk/milena/tests/point3d.cc (revision 1110)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/point3d.cc
+ *
+ * \brief Tests on mln::point3d.
+ */
+
+#include <mln/core/point3d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ point3d p, q;
+
+ // assignment
+
+ p[0] = 4;
+ p.sli() += 1;
+ mln_assertion(p.sli() == 5 && p[0] == 5);
+ p[1] = 2;
+ p.row() += 7;
+ mln_assertion(p.row() == 9 && p[1] == 9);
+ p[2] = 6;
+ p.col() += -3;
+ mln_assertion(p.col() == 3 && p[2] == 3);
+
+ // construction
+ q = make::point3d(5, 9, 3);
+ mln_assertion(p == q);
+
+ q.set_all(0);
+ for (unsigned i = 0; i < p.dim; ++i)
+ mln_assertion(q[i] == 0);
+}
Index: trunk/milena/mln/convert/to_image.hh
===================================================================
--- trunk/milena/mln/convert/to_image.hh (revision 1109)
+++ trunk/milena/mln/convert/to_image.hh (revision 1110)
@@ -35,6 +35,7 @@
# include <mln/core/image1d_b.hh>
# include <mln/core/image2d_b.hh>
+# include <mln/core/image3d_b.hh>
# include <mln/core/concept/point_set.hh>
# include <mln/core/concept/window.hh>
@@ -68,6 +69,12 @@
template <unsigned dim, typename V> struct helper_image_from_;
template <typename V>
+ struct helper_image_from_< 3, V >
+ {
+ typedef image3d_b<V> ret;
+ };
+
+ template <typename V>
struct helper_image_from_< 2, V >
{
typedef image2d_b<V> ret;
Index: trunk/milena/mln/debug/println.hh
===================================================================
--- trunk/milena/mln/debug/println.hh (revision 1109)
+++ trunk/milena/mln/debug/println.hh (revision 1110)
@@ -74,7 +74,9 @@
point2d p;
int& row = p.row();
int& col = p.col();
- const int max_row = b.max_row(), max_col = b.max_col();
+ const int
+ max_row = b.max_row(),
+ max_col = b.max_col();
for (row = b.min_row(); row <= max_row; ++row)
{
@@ -88,6 +90,35 @@
std::cout << std::endl;
}
+ template <typename I>
+ void println(const box3d& b, const I& input)
+ {
+ point3d p;
+ int& sli = p.sli();
+ int& row = p.row();
+ int& col = p.col();
+ const int
+ min_sli = b.min_sli(),
+ max_row = b.max_row(),
+ max_col = b.max_col();
+
+ for (row = b.min_row(); row <= max_row; ++row)
+ {
+ for (sli = b.max_sli(); sli >= min_sli; --sli)
+ {
+ for (int i = min_sli; i <= sli; ++i)
+ std::cout << ' ';
+ for (col = b.min_col(); col <= max_col; ++col)
+ if (input.has(p))
+ std::cout << format( input(p) ) << ' ';
+ else
+ std::cout << " ";
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+ }
+ }
+
} // end of namespace mln::debug::impl
Index: trunk/milena/mln/geom/nslis.hh
===================================================================
--- trunk/milena/mln/geom/nslis.hh (revision 0)
+++ trunk/milena/mln/geom/nslis.hh (revision 1110)
@@ -0,0 +1,67 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_NSLIS_HH
+# define MLN_GEOM_NSLIS_HH
+
+/*! \file mln/geom/nslis.hh
+ *
+ * \brief Give the number of slices of an image.
+ */
+
+# include <mln/geom/min_sli.hh>
+# include <mln/geom/max_sli.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the number of slices of an image.
+ template <typename I>
+ unsigned nslis(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ unsigned nslis(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return geom::max_sli(ima) - geom::min_sli(ima) + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_NSLIS_HH
Index: trunk/milena/mln/geom/min_sli.hh
===================================================================
--- trunk/milena/mln/geom/min_sli.hh (revision 0)
+++ trunk/milena/mln/geom/min_sli.hh (revision 1110)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MIN_SLI_HH
+# define MLN_GEOM_MIN_SLI_HH
+
+/*! \file mln/geom/min_sli.hh
+ *
+ * \brief Give the minimum sli of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the minimum sli of an image.
+ template <typename I>
+ mln_coord(I) min_sli(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) min_sli(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmin().sli();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MIN_SLI_HH
Index: trunk/milena/mln/geom/max_sli.hh
===================================================================
--- trunk/milena/mln/geom/max_sli.hh (revision 0)
+++ trunk/milena/mln/geom/max_sli.hh (revision 1110)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_MAX_SLI_HH
+# define MLN_GEOM_MAX_SLI_HH
+
+/*! \file mln/geom/max_sli.hh
+ *
+ * \brief Give the maximum sli of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the maximum sli of an image.
+ template <typename I>
+ mln_coord(I) max_sli(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) max_sli(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmax().sli();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MAX_SLI_HH
Index: trunk/milena/mln/geom/size3d.hh
===================================================================
--- trunk/milena/mln/geom/size3d.hh (revision 0)
+++ trunk/milena/mln/geom/size3d.hh (revision 1110)
@@ -0,0 +1,41 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_SIZE3D_HH
+# define MLN_GEOM_SIZE3D_HH
+
+/*! \file mln/geom/size3d.hh
+ *
+ * \brief Facade to include 3D size access routines.
+ */
+
+# include <mln/geom/nslis.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
+
+#endif // ! MLN_GEOM_SIZE3D_HH
Index: trunk/milena/mln/core/neighb3d.hh
===================================================================
--- trunk/milena/mln/core/neighb3d.hh (revision 0)
+++ trunk/milena/mln/core/neighb3d.hh (revision 1110)
@@ -0,0 +1,174 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_NEIGHB3D_HH
+# define MLN_CORE_NEIGHB3D_HH
+
+/*! \file mln/core/neighb3d.hh
+ *
+ * \brief Definition of the mln::neighb3d alias and of some classical
+ * 3D neighborhoods.
+ */
+
+# include <cmath>
+# include <mln/core/neighb.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a neighborhood defined on the 3D square
+ * grid with integer coordinates.
+ */
+ typedef neighb_<dpoint3d> neighb3d;
+
+
+ /*! \brief 6-connectivity neighborhood on the 3D grid.
+ *
+ * . . .
+ * . o .
+ * . . .
+ *
+ * . o .
+ * o x o
+ * . o .
+ *
+ * . . .
+ * . o .
+ * . . .
+ *
+ * \return A neighb3d.
+ */
+ const neighb3d& c6();
+
+ /*! \brief 18-connectivity neighborhood on the 3D grid.
+ *
+ * . o .
+ * o o o
+ * . o .
+ *
+ * o o o
+ * o x o
+ * o o o
+ *
+ * . o .
+ * o o o
+ * . o .
+ *
+ * \return A neighb3d.
+ */
+ const neighb3d& c18();
+
+ /*! \brief 26-connectivity neighborhood on the 3D grid.
+ *
+ * o o o
+ * o o o
+ * o o o
+ *
+ * o o o
+ * o x o
+ * o o o
+ *
+ * o o o
+ * o o o
+ * o o o
+ *
+ * \return A neighb3d.
+ */
+ const neighb3d& c26();
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const neighb3d& c6()
+ {
+ static bool flower = true;
+ static neighb3d it;
+ if (flower)
+ {
+ it.insert(make::dpoint3d(+1, 0, 0));
+ it.insert(make::dpoint3d(0, +1, 0));
+ it.insert(make::dpoint3d(0, 0, +1));
+ flower = false;
+ }
+ return it;
+ }
+
+ const neighb3d& c18()
+ {
+ static bool flower = true;
+ static neighb3d it;
+ if (flower)
+ {
+ it.insert(make::dpoint3d(+1, 0, 0));
+ it.insert(make::dpoint3d(0, +1, 0));
+ it.insert(make::dpoint3d(0, 0, +1));
+
+ it.insert(make::dpoint3d(+1, 0, +1));
+ it.insert(make::dpoint3d(+1, 0, -1));
+ it.insert(make::dpoint3d(0, +1, +1));
+ it.insert(make::dpoint3d(0, +1, -1));
+ it.insert(make::dpoint3d(+1, +1, 0));
+ it.insert(make::dpoint3d(+1, -1, 0));
+
+ flower = false;
+ }
+ return it;
+ }
+
+ const neighb3d& c26()
+ {
+ static bool flower = true;
+ static neighb3d it;
+ if (flower)
+ {
+ it.insert(make::dpoint3d(+1, 0, 0));
+ it.insert(make::dpoint3d(0, +1, 0));
+ it.insert(make::dpoint3d(0, 0, +1));
+
+ it.insert(make::dpoint3d(+1, 0, +1));
+ it.insert(make::dpoint3d(+1, 0, -1));
+ it.insert(make::dpoint3d(0, +1, +1));
+ it.insert(make::dpoint3d(0, +1, -1));
+ it.insert(make::dpoint3d(+1, +1, 0));
+ it.insert(make::dpoint3d(+1, -1, 0));
+
+ it.insert(make::dpoint3d(+1, +1, +1));
+ it.insert(make::dpoint3d(+1, +1, -1));
+ it.insert(make::dpoint3d(+1, -1, +1));
+ it.insert(make::dpoint3d(+1, -1, -1));
+ flower = false;
+ }
+ return it;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_NEIGHB3D_HH
Index: trunk/milena/mln/core/dpoint3d.hh
===================================================================
--- trunk/milena/mln/core/dpoint3d.hh (revision 0)
+++ trunk/milena/mln/core/dpoint3d.hh (revision 1110)
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_DPOINT3D_HH
+# define MLN_CORE_DPOINT3D_HH
+
+/*! \file mln/core/dpoint3d.hh
+ *
+ * \brief Definition of the mln::dpoint3d alias and of its
+ * construction routine.
+ */
+
+# include <mln/core/dpoint.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a delta-point defined on the 3D square
+ * grid with integer coordinates.
+ */
+ typedef dpoint_<3,int> dpoint3d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/dpoint3d.hh>
+# include <mln/core/point3d.hh>
+
+
+namespace mln
+{
+
+ // FIXME: Doc!
+ const dpoint3d segolene = make::dpoint3d( 0, 0, -1);
+ const dpoint3d sarkosy = make::dpoint3d( 0, 0, +1);
+ // FIXME: More serious directions :)
+ const dpoint3d top = make::dpoint3d( 0, -1, 0);
+ const dpoint3d bottom = make::dpoint3d( 0, +1, 0);
+ const dpoint3d back = make::dpoint3d(-1, 0, 0);
+ const dpoint3d front = make::dpoint3d(+1, 0, 0);
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_DPOINT3D_HH
Index: trunk/milena/mln/core/pixter3d_b.hh
===================================================================
--- trunk/milena/mln/core/pixter3d_b.hh (revision 0)
+++ trunk/milena/mln/core/pixter3d_b.hh (revision 1110)
@@ -0,0 +1,130 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_PIXTER3D_B_HH
+# define MLN_CORE_PIXTER3D_B_HH
+
+/*! \file mln/core/pixter3d_b.hh
+ *
+ * \brief Pixel iterator class on a image 3d with border.
+ */
+
+# include <mln/core/internal/pixel_iterator_base.hh>
+# include <mln/core/point3d.hh>
+# include <mln/geom/size3d.hh>
+
+
+
+namespace mln
+{
+
+ template <typename I>
+ class fwd_pixter3d_b : public internal::pixel_iterator_base_< I,
fwd_pixter3d_b<I> >
+ {
+ typedef internal::pixel_iterator_base_< I, fwd_pixter3d_b<I> > super_;
+
+ public:
+
+ /// Image type.
+ typedef I image;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] image Image to iterate over its pixels.
+ */
+ fwd_pixter3d_b(I& image);
+
+ /// Go to the next pixel.
+ void next_();
+
+ private:
+
+ /// Twice the size of the image border.
+ unsigned border_x2_;
+
+ /// Row offset.
+ unsigned row_offset_;
+
+ /// End of the current row.
+ mln_qlf_value(I)* eor_;
+
+ ///Next Slide offset for row.
+ unsigned next_srow_offset_;
+
+ /// Next Slide offset.
+ unsigned next_sli_offset_;
+
+ /// Slide offset.
+ unsigned sli_offset_;
+
+ /// End of the current slide.
+ mln_qlf_value(I)* eos_;
+ };
+
+
+ // FIXME: bkd_pixter3d_b
+
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ fwd_pixter3d_b<I>::fwd_pixter3d_b(I& image) :
+ super_(image)
+ {
+ mln_precondition(image.has_data());
+ border_x2_ = 2 * image.border();
+ row_offset_ = geom::max_col(image) - geom::min_col(image) + 1 + border_x2_;
+ eor_ = & image.at(geom::min_sli(image), geom::min_row(image),
geom::max_col(image)) + 1;
+ next_sli_offset_ = 4 * image.border() * image.bbox().ncols() + 2 * image.border();
+ sli_offset_ = (image.bbox().ncols() + border_x2_) * (image.bbox().nrows() +
border_x2_);
+ eos_ = & image.at(geom::min_sli(image), geom::max_row(image) + 1,
geom::min_col(image));
+ next_srow_offset_ = (image.bbox().ncols() + border_x2_) * border_x2_;
+ }
+
+ template <typename I>
+ void
+ fwd_pixter3d_b<I>::next_()
+ {
+ ++this->value_ptr_;
+ if (this->value_ptr_ == eor_ && this->value_ptr_ != this->eoi_)
+ {
+ this->value_ptr_ += border_x2_;
+ eor_ += row_offset_;
+ }
+ if (this->value_ptr_ == eos_ && this->value_ptr_ != this->eoi_)
+ {
+ this->value_ptr_ += next_sli_offset_;
+ eos_ += sli_offset_;
+ eor_ += next_srow_offset_;
+ }
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_PIXTER3D_B_HH
Index: trunk/milena/mln/core/internal/box_impl.hh
===================================================================
--- trunk/milena/mln/core/internal/box_impl.hh (revision 1109)
+++ trunk/milena/mln/core/internal/box_impl.hh (revision 1110)
@@ -56,6 +56,37 @@
struct box_impl_;
template <typename C, typename E> // FIXME: Add an extra param to replace
'unsigned'.
+ struct box_impl_<3, C, E>
+ {
+ /// Give the number of slis.
+ unsigned nslis() const;
+
+ /// Give the minimum sli.
+ C min_sli() const;
+
+ /// Give the minimum sli.
+ C max_sli() const;
+
+ /// Give the number of rows.
+ unsigned nrows() const;
+
+ /// Give the minimum row.
+ C min_row() const;
+
+ /// Give the minimum row.
+ C max_row() const;
+
+ /// Give the number of cols.
+ unsigned ncols() const;
+
+ /// Give the minimum col.
+ C min_col() const;
+
+ /// Give the minimum col.
+ C max_col() const;
+ };
+
+ template <typename C, typename E> // FIXME: Add an extra param to replace
'unsigned'.
struct box_impl_<2, C, E>
{
/// Give the number of rows.
@@ -95,6 +126,63 @@
// box_impl
+ // 3
+
+ template <typename C, typename E>
+ unsigned box_impl_<3, C, E>::nslis() const
+ {
+ return internal::force_exact<E>(*this).bbox().len(0);
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::min_sli() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmin()[0];
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::max_sli() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmax()[0];
+ }
+
+ template <typename C, typename E>
+ unsigned box_impl_<3, C, E>::nrows() const
+ {
+ return internal::force_exact<E>(*this).bbox().len(1);
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::min_row() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmin()[1];
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::max_row() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmax()[1];
+ }
+
+ template <typename C, typename E>
+ unsigned box_impl_<3, C, E>::ncols() const
+ {
+ return internal::force_exact<E>(*this).bbox().len(2);
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::min_col() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmin()[2];
+ }
+
+ template <typename C, typename E>
+ C box_impl_<3, C, E>::max_col() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmax()[2];
+ }
+
+
// 2
template <typename C, typename E>
Index: trunk/milena/mln/core/point3d.hh
===================================================================
--- trunk/milena/mln/core/point3d.hh (revision 0)
+++ trunk/milena/mln/core/point3d.hh (revision 1110)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_POINT3D_HH
+# define MLN_CORE_POINT3D_HH
+
+/*! \file mln/core/point3d.hh
+ *
+ * \brief Definition of the mln::point3d alias and of its construction
+ * routine.
+ */
+
+# include <mln/core/point.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a point defined on the 3D square grid with
+ * integer coordinates.
+ */
+ typedef point_<3,int> point3d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/point3d.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+#endif // ! MLN_CORE_POINT3D_HH
Index: trunk/milena/mln/core/window3d.hh
===================================================================
--- trunk/milena/mln/core/window3d.hh (revision 0)
+++ trunk/milena/mln/core/window3d.hh (revision 1110)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WINDOW3D_HH
+# define MLN_CORE_WINDOW3D_HH
+
+/*! \file mln/core/window3d.hh
+ *
+ * \brief Definition of the mln::window3d alias and of a construction
+ * routine.
+ */
+
+# include <mln/core/window.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a window with arbitrary shape, defined on
+ * the 3D square grid with integer coordinates.
+ */
+ typedef window<dpoint3d> window3d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/window3d.hh>
+
+
+#endif // ! MLN_CORE_WINDOW3D_HH
Index: trunk/milena/mln/core/w_window3d_int.hh
===================================================================
--- trunk/milena/mln/core/w_window3d_int.hh (revision 0)
+++ trunk/milena/mln/core/w_window3d_int.hh (revision 1110)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_W_WINDOW3D_INT_HH
+# define MLN_CORE_W_WINDOW3D_INT_HH
+
+/*! \file mln/core/w_window3d_int.hh
+ *
+ * \brief Definition of the mln::w_window3d_int alias.
+ */
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a w_window with arbitrary shape, defined
+ * on the 3D grid (with integer coordinates) and whose
+ * weights are integers.
+ */
+ typedef w_window<dpoint3d, int> w_window3d_int;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/w_window3d.hh>
+
+
+#endif // ! MLN_CORE_W_WINDOW3D_INT_HH
Index: trunk/milena/mln/core/win/cube3d.hh
===================================================================
--- trunk/milena/mln/core/win/cube3d.hh (revision 0)
+++ trunk/milena/mln/core/win/cube3d.hh (revision 1110)
@@ -0,0 +1,193 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_CUBE3D_HH
+# define MLN_CORE_WIN_CUBE3D_HH
+
+/*! \file mln/core/win/cube3d.hh
+ *
+ * \brief Definition of the mln::win::cube3d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint3d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Cube window defined on the 3D grid.
+ *
+ * An cube3d is centered and symmetrical; so
+ * its height (length) is odd.
+ *
+ * For instance: \n
+ * o o o \n
+ * o o o \n
+ * o o o \n
+
+ * o o o \n
+ * o x o \n
+ * o o o \n
+
+ * o o o \n
+ * o o o \n
+ * o o o \n
+ * is defined with length = 3.
+ */
+ struct cube3d : public Window< cube3d >,
+ public internal::dpoints_base_< dpoint3d, cube3d >
+ {
+ /// Point associated type.
+ typedef point3d point;
+
+ /// Dpoint associated type.
+ typedef dpoint3d dpoint;
+
+ /*! \brief Point_Iterator type to browse a cube such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint3d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a cube such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint3d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus height, of the cube3d.
+ *
+ * \pre \p length is odd.
+ */
+ cube3d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the cube length, that is, its height.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ cube3d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print a cube3d window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A cube3d window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::cube3d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const cube3d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ cube3d::cube3d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dind = length / 2;
+ for (int sli = - dind; sli <= dind; ++sli)
+ for (int row = - dind; row <= dind; ++row)
+ for (int col = - dind; col <= dind; ++col)
+ insert(make::dpoint3d(sli, row, col));
+ }
+
+ bool cube3d::is_centered() const
+ {
+ return true;
+ }
+
+ bool cube3d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned cube3d::length() const
+ {
+ return length_;
+ }
+
+ unsigned cube3d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ cube3d& cube3d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const cube3d& win)
+ {
+ ostr << "[cube3d: length=" << win.length() <<
']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_CUBE3D_HH
Index: trunk/milena/mln/core/box3d.hh
===================================================================
--- trunk/milena/mln/core/box3d.hh (revision 0)
+++ trunk/milena/mln/core/box3d.hh (revision 1110)
@@ -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 received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_BOX3D_HH
+# define MLN_CORE_BOX3D_HH
+
+/*! \file mln/core/box3d.hh
+ *
+ * \brief Definition of the mln::box3d alias and of construction
+ * routines.
+ */
+
+# include <mln/core/box.hh>
+# include <mln/core/point3d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a box defined on the 3D square grid with
+ * integer coordinates.
+ *
+ * \see mln::win::rectangle3d.
+ */
+ typedef box_<point3d> box3d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/box3d.hh>
+
+
+#endif // ! MLN_CORE_BOX3D_HH
Index: trunk/milena/mln/core/w_window3d_float.hh
===================================================================
--- trunk/milena/mln/core/w_window3d_float.hh (revision 0)
+++ trunk/milena/mln/core/w_window3d_float.hh (revision 1110)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_W_WINDOW3D_FLOAT_HH
+# define MLN_CORE_W_WINDOW3D_FLOAT_HH
+
+/*! \file mln/core/w_window3d_float.hh
+ *
+ * \brief Definition of the mln::w_window3d_float alias.
+ */
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a w_window with arbitrary shape, defined
+ * on the 3D grid (with integer coordinates) and whose
+ * weights are floating values.
+ */
+ typedef w_window<dpoint3d, float> w_window3d_float;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/w_window3d.hh>
+
+
+#endif // ! MLN_CORE_W_WINDOW3D_FLOAT_HH
Index: trunk/milena/mln/core/image3d_b.hh
===================================================================
--- trunk/milena/mln/core/image3d_b.hh (revision 0)
+++ trunk/milena/mln/core/image3d_b.hh (revision 1110)
@@ -0,0 +1,555 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE3D_B_HH
+# define MLN_CORE_IMAGE3D_B_HH
+
+/*! \file mln/core/image3d_b.hh
+ *
+ * \brief Definition of the basic mln::image3d_b class.
+ */
+
+# include <mln/core/internal/image_base.hh>
+# include <mln/core/box3d.hh>
+
+# include <mln/border/thickness.hh>
+# include <mln/value/set.hh>
+# include <mln/fun/i2v/all.hh>
+
+# include <mln/core/line_piter.hh>
+
+// FIXME:
+
+// # include <mln/core/pixter3d_b.hh>
+// # include <mln/core/dpoints_pixter.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename T> struct image3d_b;
+
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct is_fast< image3d_b<T> >
+ {
+ typedef metal::true_ ret;
+ };
+
+ } // end of mln::trait
+
+
+
+ /*! \brief Basic 3D image class.
+ *
+ * The parameter \c T is the type of pixel values. This image class
+ * stores data in memory and has a virtual border with constant
+ * thickness around data.
+ */
+ template <typename T>
+ struct image3d_b : public internal::image_base_< box3d, image3d_b<T> >
+ {
+ // Warning: just to make effective types appear in Doxygen:
+ typedef box3d pset;
+ typedef point3d psite;
+ typedef point3d point;
+ typedef dpoint3d dpoint;
+ typedef mln_fwd_piter(box3d) fwd_piter;
+ typedef mln_bkd_piter(box3d) bkd_piter;
+ typedef line_piter_<point> line_piter;
+ // End of warning.
+
+
+ /// Value associated type.
+ typedef T value;
+
+ /// Return type of read-only access.
+ typedef const T& rvalue;
+
+ /// Return type of read-write access.
+ typedef T& lvalue;
+
+ /// Change value type.
+ template <typename U>
+ struct change_value
+ {
+ typedef image3d_b<U> ret;
+ };
+
+ /// Value_Set associated type.
+ typedef mln::value::set<T> vset;
+
+
+ /// Constructor without argument.
+ image3d_b();
+
+ /// Constructor with the numbers of indexes and the
+ /// border thickness.
+ image3d_b(int nslis, int nrows, int ncols, unsigned bdr = border::thickness);
+
+ /// Constructor with a box and the border thickness (default is
+ /// 3).
+ image3d_b(const box3d& b, unsigned bdr = border::thickness);
+
+ /// Copy constructor.
+ image3d_b(const image3d_b<T>& rhs);
+
+ /// Assignment operator.
+ image3d_b& operator=(const image3d_b<T>& rhs);
+
+ /// Destructor.
+ ~image3d_b();
+
+
+ /// Initialize an empty image.
+ void init_with(int nslis, int nrows, int ncols, unsigned bdr = border::thickness);
+
+ /// Initialize an empty image.
+ void init_with(const box3d& b, unsigned bdr = border::thickness);
+
+
+ /// Test if \p p is valid.
+ bool owns_(const point3d& p) const;
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Give the definition domain.
+ const box3d& domain() const;
+
+ /// Give the border thickness.
+ unsigned border() const;
+
+ /// Give the number of cells (points including border ones).
+ std::size_t ncells() const;
+
+ /// Read-only access to the image value located at point \p p.
+ const T& operator()(const point3d& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ T& operator()(const point3d& p);
+
+ /// Read-only access to the image value located at offset \p o.
+ const T& operator[](unsigned o) const;
+
+ /// Read-write access to the image value located at offset \p o.
+ T& operator[](unsigned o);
+
+ /// Read-only access to the image value located at (\p ind).
+ const T& at(int sli, int row, int col) const;
+
+ /// Read-write access to the image value located at (\p ind).
+ T& at(int sli, int row, int col);
+
+
+ /// Fast Image method
+
+ /// Give the offset corresponding to the delta-point \p dp.
+ int offset(const dpoint3d& dp) const;
+
+ /// Give the point corresponding to the offset \p o.
+ point3d point_at_offset(unsigned o) const;
+
+ /// Give a hook to the value buffer.
+ const T* buffer() const;
+
+ /// Give a hook to the value buffer.
+ T* buffer();
+
+
+ private:
+
+ T* buffer_;
+ T*** array_;
+
+ box3d b_; // theoretical box
+ unsigned bdr_;
+ box3d vb_; // virtual box, i.e., box including the virtual border
+
+ void update_vb_();
+ void allocate_();
+ void deallocate_();
+
+ typedef internal::image_base_< box3d, image3d_b<T> > super;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // ctors
+
+ template <typename T>
+ image3d_b<T>::image3d_b()
+ : buffer_(0),
+ array_ (0)
+ {
+ bdr_ = border::thickness; // default value in ctors.
+ }
+
+ template <typename T>
+ image3d_b<T>::image3d_b(int nslis, int nrows, int ncols, unsigned bdr)
+ : buffer_(0),
+ array_ (0)
+ {
+ init_with(nslis, nrows, ncols, bdr);
+ }
+
+ template <typename T>
+ void
+ image3d_b<T>::init_with(int nslis, int nrows, int ncols, unsigned bdr)
+ {
+ mln_precondition(! this->has_data());
+ b_ = make::box3d(nslis, nrows, ncols);
+ bdr_ = bdr;
+ allocate_();
+ }
+
+ template <typename T>
+ image3d_b<T>::image3d_b(const box3d& b, unsigned bdr)
+ : buffer_(0),
+ array_ (0)
+ {
+ init_with(b, bdr);
+ }
+
+ template <typename T>
+ void
+ image3d_b<T>::init_with(const box3d& b, unsigned bdr)
+ {
+ mln_precondition(! this->has_data());
+ b_ = b;
+ bdr_ = bdr;
+ allocate_();
+ }
+
+ template <typename T>
+ image3d_b<T>::image3d_b(const image3d_b<T>& rhs)
+ : super(rhs),
+ b_(rhs.domain()),
+ bdr_(rhs.border())
+ {
+ allocate_();
+ std::memcpy(this->buffer_,
+ rhs.buffer_,
+ ncells() * sizeof(T));
+ }
+
+ // assignment
+
+ template <typename T>
+ image3d_b<T>&
+ image3d_b<T>::operator=(const image3d_b<T>& rhs)
+ {
+ mln_precondition(rhs.has_data());
+ if (& rhs == this)
+ return *this;
+ if (this->has_data())
+ this->deallocate_();
+ this->b_ = rhs.domain();
+ this->bdr_ = rhs.border();
+ allocate_();
+ std::memcpy(this->buffer_,
+ rhs.buffer_,
+ ncells() * sizeof(T));
+ return *this;
+ }
+
+ // methods
+
+ template <typename T>
+ bool
+ image3d_b<T>::has_data() const
+ {
+ return buffer_ != 0 && array_ != 0;;
+ }
+
+ template <typename T>
+ const typename image3d_b<T>::vset&
+ image3d_b<T>::values() const
+ {
+ return vset::the();
+ }
+
+ template <typename T>
+ const box3d&
+ image3d_b<T>::domain() const
+ {
+ mln_precondition(this->has_data());
+ return b_;
+ }
+
+ template <typename T>
+ unsigned
+ image3d_b<T>::border() const
+ {
+ mln_precondition(this->has_data());
+ return bdr_;
+ }
+
+ template <typename T>
+ std::size_t
+ image3d_b<T>::ncells() const
+ {
+ mln_precondition(this->has_data());
+ return vb_.npoints();
+ }
+
+ template <typename T>
+ bool
+ image3d_b<T>::owns_(const point3d& p) const
+ {
+ mln_precondition(this->has_data());
+ return vb_.has(p);
+ }
+
+ template <typename T>
+ const T&
+ image3d_b<T>::operator()(const point3d& p) const
+ {
+ mln_precondition(this->owns_(p));
+ return array_[p.sli()][p.row()][p.col()];
+ }
+
+ template <typename T>
+ T&
+ image3d_b<T>::operator()(const point3d& p)
+ {
+ mln_precondition(this->owns_(p));
+ return array_[p.sli()][p.row()][p.col()];
+ }
+
+ template <typename T>
+ const T&
+ image3d_b<T>::operator[](unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ T&
+ image3d_b<T>::operator[](unsigned o)
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ const T&
+ image3d_b<T>::at(int sli, int row, int col) const
+ {
+ mln_precondition(this->owns_(make::point3d(sli, row, col)));
+ return array_[sli][row][col];
+ }
+
+ template <typename T>
+ T&
+ image3d_b<T>::at(int sli, int row, int col)
+ {
+ mln_precondition(this->owns_(make::point3d(sli, row, col)));
+ return array_[sli][row][col];
+ }
+
+ template <typename T>
+ image3d_b<T>::~image3d_b()
+ {
+ deallocate_();
+ }
+
+ template <typename T>
+ const T*
+ image3d_b<T>::buffer() const
+ {
+ mln_precondition(this->has_data());
+ return buffer_;
+ }
+
+ template <typename T>
+ T*
+ image3d_b<T>::buffer()
+ {
+ mln_precondition(this->has_data());
+ return buffer_;
+ }
+
+ template <typename T>
+ int
+ image3d_b<T>::offset(const dpoint3d& dp) const
+ {
+ mln_precondition(this->has_data());
+ int o = dp[0];
+ return o;
+ }
+
+ template <typename T>
+ point3d
+ image3d_b<T>::point_at_offset(unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ point3d p = make::point3d(o / (vb_.len(1) * vb_.len(2)) + vb_.min_sli(),
+ (o % (vb_.len(1) * vb_.len(2))) / vb_.len(2) + vb_.min_row(),
+ o % vb_.len(2) + vb_.min_col());
+ mln_postcondition(& this->operator()(p) == this->buffer_ + o);
+ return p;
+ }
+
+
+ // private
+
+ template <typename T>
+ void
+ image3d_b<T>::update_vb_()
+ {
+ vb_.pmin() = b_.pmin() - dpoint3d(all(bdr_));
+ vb_.pmax() = b_.pmax() + dpoint3d(all(bdr_));
+ }
+
+ template <typename T>
+ void
+ image3d_b<T>::allocate_()
+ {
+ update_vb_();
+ unsigned
+ ns = vb_.len(0),
+ nr = vb_.len(1),
+ nc = vb_.len(2);
+ buffer_ = new T[nr * nc * ns];
+ array_ = new T**[ns];
+ T* buf = buffer_ - vb_.pmin().col();
+ for (unsigned i = 0; i < ns; ++i)
+ {
+ T** tmp = new T*[nr];
+ array_[i] = tmp;
+ for (unsigned j = 0; j < nr; ++j)
+ {
+ array_[i][j] = buf;
+ buf += nc;
+ }
+ array_[i] -= vb_.pmin().row();
+ }
+ array_ -= vb_.pmin().sli();
+ mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_);
+ }
+
+ template <typename T>
+ void
+ image3d_b<T>::deallocate_()
+ {
+ if (buffer_)
+ {
+ delete[] buffer_;
+ buffer_ = 0;
+ }
+ for (typename point::coord i = vb_.pmin().sli(); i <= vb_.pmax().sli(); ++i)
+ {
+ if (array_[i])
+ {
+ array_[i] += vb_.pmin().row();
+ delete[] array_[i];
+ array_[i] = 0;
+ }
+ }
+ if (array_)
+ {
+ array_ += vb_.pmin().sli();
+ delete[] array_;
+ array_ = 0;
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/trait/pixter.hh>
+# include <mln/core/dpoints_pixter.hh>
+# include <mln/core/pixter3d_b.hh>
+# include <mln/core/w_window.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ // pixter
+
+ template <typename T>
+ struct fwd_pixter< image3d_b<T> >
+ {
+ typedef fwd_pixter3d_b< image3d_b<T> > ret;
+ };
+
+ template <typename T>
+ struct fwd_pixter< const image3d_b<T> >
+ {
+ typedef fwd_pixter3d_b< const image3d_b<T> > ret;
+ };
+
+ template <typename T>
+ struct bkd_pixter< image3d_b<T> >
+ {
+ typedef internal::fixme ret;
+ };
+
+ // qixter
+
+ template <typename T, typename W>
+ struct fwd_qixter< image3d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< image3d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct fwd_qixter< const image3d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image3d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< image3d_b<T>, W >
+ {
+ typedef internal::fixme ret;
+ };
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE3D_B_HH
Index: trunk/milena/mln/make/w_window1d.hh
===================================================================
--- trunk/milena/mln/make/w_window1d.hh (revision 1109)
+++ trunk/milena/mln/make/w_window1d.hh (revision 1110)
@@ -64,7 +64,7 @@
w_window1d(W (&weights)[M])
{
int h = M / 2;
- mln_precondition(1 == (M % 1));
+ mln_precondition(1 == (M % 2));
mln::w_window<mln::dpoint1d, W> tmp;
unsigned i = 0;
for (int ind = - h; ind <= h; ++ind)
Index: trunk/milena/mln/make/w_window3d.hh
===================================================================
--- trunk/milena/mln/make/w_window3d.hh (revision 0)
+++ trunk/milena/mln/make/w_window3d.hh (revision 1110)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_W_WINDOW3D_HH
+# define MLN_MAKE_W_WINDOW3D_HH
+
+/*! \file mln/make/w_window3d.hh
+ *
+ * \brief Routine to create an mln::w_window in the 3D case.
+ */
+
+# include <cmath>
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create a 3D mln::w_window from an array of weights.
+ *
+ * \param[in] weights Array.
+ *
+ * \pre The array size, \c M, has to be an odd integer.
+ * \pre The array size, \c N, has to be the square of \c M.
+ *
+ * \return A 3D weighted window.
+ */
+ template <typename W, unsigned M, unsigned N>
+ mln::w_window<mln::dpoint3d, W> w_window3d(W (&weights)[M][N]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W, unsigned M, unsigned N>
+ mln::w_window<mln::dpoint3d, W>
+ w_window3d(W (&weights)[M][N])
+ {
+ int h = M / 2;
+ mln_precondition(1 == (M % 2) && M * M == N);
+ mln::w_window<mln::dpoint3d, W> tmp;
+ unsigned i = 0;
+ for (int sli = - h; sli <= h; ++sli)
+ for (int row = - h; row <= h; ++row)
+ for (int col = - h; col <= h; ++col)
+ {
+ const W& cur = weights[i / N][i % N];
+ if (cur != 0)
+ tmp.insert(cur, make::dpoint3d(sli, row, col));
+ i++;
+ }
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_W_WINDOW3D_HH
Index: trunk/milena/mln/make/dpoint3d.hh
===================================================================
--- trunk/milena/mln/make/dpoint3d.hh (revision 0)
+++ trunk/milena/mln/make/dpoint3d.hh (revision 1110)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_DPOINT3D_HH
+# define MLN_MAKE_DPOINT3D_HH
+
+/*! \file mln/make/dpoint3d.hh
+ *
+ * \brief Routine to construct an mln::dpoint3d.
+ */
+
+# include <mln/core/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::dpoint3d.
+ *
+ * \param[in] sli Sli coordinate.
+ * \param[in] row Row coordinate.
+ * \param[in] col Col coordinate.
+ *
+ * \return A 3D dpoint.
+ */
+ mln::dpoint3d dpoint3d(int sli, int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::dpoint3d dpoint3d(int sli, int row, int col)
+ {
+ mln::dpoint3d tmp;
+ tmp[0] = sli;
+ tmp[1] = row;
+ tmp[2] = col;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_DPOINT3D_HH
Index: trunk/milena/mln/make/w_window3d_int.hh
===================================================================
--- trunk/milena/mln/make/w_window3d_int.hh (revision 0)
+++ trunk/milena/mln/make/w_window3d_int.hh (revision 1110)
@@ -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 MLN_MAKE_W_WINDOW3D_INT_HH
+# define MLN_MAKE_W_WINDOW3D_INT_HH
+
+/*! \file mln/make/w_window3d_int.hh
+ *
+ * \brief Routine to create a mln::w_window3d_int.
+ */
+
+# include <mln/core/w_window3d_int.hh>
+# include <mln/make/w_window3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create a mln::w_window3d_int.
+ *
+ * \param[in] weights Array of integers.
+ *
+ * \pre The array size, \c M, has to be an odd integer.
+ * \pre The array size, \c N, has to be the square of \c M.
+ *
+ * \return A 3D int-weighted window.
+ */
+ template <unsigned M, unsigned N>
+ mln::w_window3d_int w_window3d_int(int (&weights)[M][N]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned M, unsigned N>
+ mln::w_window3d_int
+ w_window3d_int(int (&weights)[M][N])
+ {
+ mln_precondition(1 == (M % 2) && M * M == N);
+ return make::w_window3d(weights);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_W_WINDOW3D_INT_HH
Index: trunk/milena/mln/make/window3d.hh
===================================================================
--- trunk/milena/mln/make/window3d.hh (revision 0)
+++ trunk/milena/mln/make/window3d.hh (revision 1110)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_WINDOW3D_HH
+# define MLN_MAKE_WINDOW3D_HH
+
+/*! \file mln/make/window3d.hh
+ *
+ * \brief Routine to create an mln::window3d.
+ */
+
+# include <cmath>
+# include <mln/core/window3d.hh>
+# include <mln/make/dpoint3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::window3d.
+ *
+ * \param[in] values Array of Booleans.
+ *
+ * \pre The array size, \c M, has to be an odd integer.
+ * \pre The array size, \c N, has to be the square of \c N.
+ *
+ * \return A 3D window.
+ */
+ template <unsigned M, unsigned N>
+ mln::window3d window3d(bool (&values)[M][N]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned M, unsigned N>
+ mln::window3d window3d(bool (&values)[M][N])
+ {
+ int h = M / 2;
+ mln_precondition((M % 2) == 1 && M * M == N);
+ mln::window3d tmp;
+ unsigned i = 0;
+ for (int sli = - h; sli <= h; ++sli)
+ for (int row = - h; row <= h; ++row)
+ for (int col = - h; col <= h; ++col)
+ if (values[i / N][i++ % N])
+ tmp.insert(make::dpoint3d(sli, row, col));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_WINDOW3D_HH
Index: trunk/milena/mln/make/box3d.hh
===================================================================
--- trunk/milena/mln/make/box3d.hh (revision 0)
+++ trunk/milena/mln/make/box3d.hh (revision 1110)
@@ -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 MLN_MAKE_BOX3D_HH
+# define MLN_MAKE_BOX3D_HH
+
+/*! \file mln/make/box3d.hh
+ *
+ * \brief Routines to construct an mln::box3d.
+ */
+
+# include <mln/core/box3d.hh>
+# include <mln/make/point3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::box3d.
+ *
+ * \param[in] nslis Number of slis.
+ * \param[in] nrows Number of rows.
+ * \param[in] ncols Number of cols.
+ *
+ * \pre \p ninds != 0 and \p ncols != 0 and \p nslis != 0.
+ *
+ * \return A 3D box.
+ */
+ mln::box3d box3d(unsigned nslis, unsigned nrows, unsigned ncols);
+
+
+ /*! \brief Create an mln::box3d.
+ *
+ * \overload
+ *
+ * \param[in] min_sli Sliex of the top most sli.
+ * \param[in] max_sli Sliex of the botton most sli.
+ * \param[in] min_row Rowex of the top most row.
+ * \param[in] max_row Rowex of the botton most row.
+ * \param[in] min_col Colex of the top most col.
+ * \param[in] max_col Colex of the botton most col.
+ *
+ * \pre \p max_sli >= \p min_sli.
+ * \pre \p max_row >= \p min_row.
+ * \pre \p max_col >= \p min_col.
+ *
+ * \return A 3D box.
+ */
+ mln::box3d box3d(int min_sli, int max_sli,
+ int min_row, int max_row,
+ int min_col, int max_col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::box3d box3d(unsigned nslis, unsigned nrows, unsigned ncols)
+ {
+ mln_precondition(nrows != 0 && ncols != 0 && nslis != 0);
+ mln::box3d tmp(make::point3d(0, 0, 0),
+ make::point3d(nslis - 1, nrows - 1, ncols - 1));
+ return tmp;
+ }
+
+ mln::box3d box3d(int min_sli, int max_sli,
+ int min_row, int max_row,
+ int min_col, int max_col)
+ {
+ mln_precondition(max_row >= min_row && max_sli >= min_sli &&
max_col >= min_col);
+ mln::box3d tmp(make::point3d(min_sli, min_row, min_col),
+ make::point3d(max_sli, max_row, max_col));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_BOX3D_HH
Index: trunk/milena/mln/make/point3d.hh
===================================================================
--- trunk/milena/mln/make/point3d.hh (revision 0)
+++ trunk/milena/mln/make/point3d.hh (revision 1110)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_POINT3D_HH
+# define MLN_MAKE_POINT3D_HH
+
+/*! \file mln/make/point3d.hh
+ *
+ * \brief Routine to construct an mln::point3d.
+ */
+
+# include <mln/core/point3d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::point3d.
+ *
+ * \param[in] sli Slice coordinate.
+ * \param[in] row Row coordinate.
+ * \param[in] col Column coordinate.
+ *
+ * \return A 3D point.
+ */
+ mln::point3d point3d(int sli, int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::point3d point3d(int sli, int row, int col)
+ {
+ mln::point3d tmp;
+ tmp[0] = sli;
+ tmp[1] = row;
+ tmp[2] = col;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_POINT3D_HH