URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-17 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Improve pnm support.
* mln/io/fits/load.hh: start debug, only the first column of the image
is filled
* mln/io/internal/pnm/load.hh: add a second funtion to load a function
load(ima, filename). Then we can check if ima is the right type to
load the image in the file filename.
* mln/io/internal/pnm/load_header.hh: update read_header to get the
maxvalue of the pnm header. We need it to check if max(mln_value(I))
== maxval
* mln/io/internal/pnm/save.hh:
* mln/io/internal/pnm/save_header.hh: change save_header(type, maxval,
ima, filename, file) to save_header(type, maxval, ima, filename,
file)
* mln/io/pbm/save.hh:
* mln/io/pgm/load.hh:
* mln/io/pgm/save.hh:
* mln/io/ppm/load.hh: update to support save_header changes
* sandbox/garrigues/io_fits.cc: start debuging io fits
* tests/io_pgm.cc:
* tests/io_pgm19.cc:
* tests/io_pgm27.cc:
* tests/io_ppm23.cc:
* tests/new_io_pgm.cc: tests. save pgm and ppm N bits works.
---
mln/io/fits/load.hh | 3 +
mln/io/internal/pnm/load.hh | 49 ++++++++++++++++
mln/io/internal/pnm/load_header.hh | 27 ++++++---
mln/io/internal/pnm/save.hh | 7 +-
mln/io/internal/pnm/save_header.hh | 26 ++++++--
mln/io/pbm/save.hh | 3 -
mln/io/pgm/load.hh | 7 ++
mln/io/pgm/save.hh | 20 +-----
mln/io/ppm/load.hh | 7 ++
sandbox/garrigues/io_fits.cc | 14 ++++
tests/io_pgm.cc | 7 --
tests/io_pgm19.cc | 95 +++++++++++++++++++++++++++++++
tests/io_pgm27.cc | 94 +++++++++++++++++++++++++++++++
tests/io_ppm23.cc | 110 +++++++++++++++++++++++++++++++++++++
tests/new_io_pgm.cc | 55 ++++++++++++++++++
15 files changed, 478 insertions(+), 46 deletions(-)
Index: trunk/milena/tests/io_pgm.cc
===================================================================
--- trunk/milena/tests/io_pgm.cc (revision 1119)
+++ trunk/milena/tests/io_pgm.cc (revision 1120)
@@ -33,7 +33,6 @@
#include <mln/core/image2d_b.hh>
#include <mln/value/int_u8.hh>
-#include <mln/value/rgb8.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
@@ -42,12 +41,6 @@
{
using namespace mln;
using value::int_u8;
- using value::rgb8;
-
- // {
- // // image2d_b<rgb8>
- // // lena = io::pgm::load<rgb8>("../img/lena.pgm");
- // }
{
image2d_b<int_u8>
Index: trunk/milena/tests/io_pgm19.cc
===================================================================
--- trunk/milena/tests/io_pgm19.cc (revision 0)
+++ trunk/milena/tests/io_pgm19.cc (revision 1120)
@@ -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.
+
+/*! \file tests/pbm_load.cc
+ *
+ * \brief Test on mln::io::pbm::load.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/level/compare.hh>
+
+
+ using namespace mln;
+
+struct to19bits : mln::Function_v2v<to19bits>
+{
+
+ typedef value::int_u<19> result;
+ result operator()(value::int_u8 v) const
+ {
+ result ret(v * 524288);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::int_u8 result;
+ result operator()(value::int_u<19> v) const
+ {
+ result ret(v / 524288);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u;
+ typedef value::int_u<19> int_u19;
+
+ border::thickness = 52;
+
+ image2d_b<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+ image2d_b<int_u19> out(lena.domain());
+
+ level::transform(lena, to19bits(), out);
+
+ io::pgm::save(out, "out19.pgm");
+
+ image2d_b<int_u19>
+ lena2 = io::pgm::load<int_u19>("out19.pgm");
+ image2d_b<int_u8> out2(lena.domain());
+
+ level::transform(lena2, to8bits(), out2);
+
+ io::pgm::save(out2, "out8.pgm");
+
+ assert(out2 == lena);
+
+}
Index: trunk/milena/tests/io_ppm23.cc
===================================================================
--- trunk/milena/tests/io_ppm23.cc (revision 0)
+++ trunk/milena/tests/io_ppm23.cc (revision 1120)
@@ -0,0 +1,110 @@
+// 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/pbm_load.cc
+ *
+ * \brief Test on mln::io::pbm::load for 23bits ppm
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/win/rectangle2d.hh>
+
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/level/compare.hh>
+
+
+using namespace mln;
+
+typedef value::rgb<23> rgb23;
+
+struct to23bits : mln::Function_v2v<to23bits>
+{
+
+ typedef rgb23 result;
+ result operator()(value::rgb8 v) const
+ {
+ result ret(v.red().to_enc() * 256,
+ v.green().to_enc() * 256,
+ v.blue().to_enc() * 256);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::rgb8 result;
+ result operator()(rgb23 v) const
+ {
+ result ret(v.red().to_enc() / 256,
+ v.green().to_enc() / 256,
+ v.blue().to_enc() / 256);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+
+ typedef image2d_b<rgb8> I;
+
+
+ // load a 8bits image A
+ image2d_b<rgb8>
+ a = io::ppm::load<rgb8>("../img/lena.ppm");
+ image2d_b<rgb23> b(a.domain());
+
+ image2d_b<rgb8>::fwd_piter p(b.domain());
+
+ // save it as a 23bits ppm image B
+ to23bits f;
+ for_all(p)
+ b(p) = f(a(p));
+ io::ppm::save(b, "out23.ppm");
+
+ // reload B into C
+ image2d_b<rgb23>
+ c = io::ppm::load<rgb23>("out23.ppm");
+ image2d_b<rgb8> d(a.domain());
+
+
+ // save C as a 8bits ppm image D
+ to8bits g;
+ for_all(p)
+ d(p) = g(c(p));
+ io::ppm::save(d, "out8.ppm");
+
+ // D should equals A
+ mln_assertion(d == a);
+
+}
Index: trunk/milena/tests/new_io_pgm.cc
===================================================================
--- trunk/milena/tests/new_io_pgm.cc (revision 0)
+++ trunk/milena/tests/new_io_pgm.cc (revision 1120)
@@ -0,0 +1,55 @@
+// 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/ppm_load.cc
+ *
+ * \brief Test on mln::io::ppm::load.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ {
+ image2d_b< value::int_u<8> >
+ lena;
+ io::pgm::load(lena, "../img/lena.pgm");
+
+ io::pgm::save(lena, "out.pgm");
+ }
+}
Index: trunk/milena/tests/io_pgm27.cc
===================================================================
--- trunk/milena/tests/io_pgm27.cc (revision 0)
+++ trunk/milena/tests/io_pgm27.cc (revision 1120)
@@ -0,0 +1,94 @@
+// 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/pbm_load.cc
+ *
+ * \brief Test on mln::io::pbm::load.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/level/compare.hh>
+
+
+ using namespace mln;
+
+struct to27bits : mln::Function_v2v<to27bits>
+{
+
+ typedef value::int_u<27> result;
+ result operator()(value::int_u8 v) const
+ {
+ result ret(v * 524288);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::int_u8 result;
+ result operator()(value::int_u<27> v) const
+ {
+ result ret(v / 524288);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u;
+ typedef value::int_u<27> int_u27;
+
+ image2d_b<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+ image2d_b<int_u27> out(lena.domain());
+
+ level::transform(lena, to27bits(), out);
+
+ io::pgm::save(out, "out27.pgm");
+
+ image2d_b<int_u27> lena2;
+ io::pgm::load(lena2, "out27.pgm");
+
+ image2d_b<int_u8> out2(lena.domain());
+
+ level::transform(lena2, to8bits(), out2);
+
+ io::pgm::save(out2, "out8.pgm");
+
+ assert(out2 == lena);
+
+}
Index: trunk/milena/mln/io/pgm/save.hh
===================================================================
--- trunk/milena/mln/io/pgm/save.hh (revision 1119)
+++ trunk/milena/mln/io/pgm/save.hh (revision 1120)
@@ -35,7 +35,7 @@
# include <mln/io/internal/pnm/save.hh>
# include <mln/geom/size2d.hh>
-# include <mln/metal/equal.hh>
+# include <mln/metal/templated_by.hh>
# include <mln/metal/bexpr.hh>
@@ -61,26 +61,12 @@
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
-
- } // end of namespace mln::io::impl
-
-
template <typename I>
void save(const Image<I>& ima, const std::string& filename)
{
mln::metal::or_<
- mln::metal::equal<mln_value(I), value::int_u<8> >,
-
- mln::metal::or_<
- mln::metal::equal<mln_value(I), value::int_u_sat<8> >,
-
- mln::metal::or_<
- mln::metal::equal<mln_value(I), value::int_u<16> >,
- mln::metal::equal<mln_value(I), value::int_u_sat<16> >
- >
- >
+ mln::metal::templated_by<mln_value(I), value::int_u >,
+ mln::metal::templated_by<mln_value(I), value::int_u_sat >
>::check();
io::internal::pnm::save(PGM, exact(ima), filename);
}
Index: trunk/milena/mln/io/pgm/load.hh
===================================================================
--- trunk/milena/mln/io/pgm/load.hh (revision 1119)
+++ trunk/milena/mln/io/pgm/load.hh (revision 1120)
@@ -34,6 +34,7 @@
# include <string>
# include <mln/core/image2d_b.hh>
+
# include <mln/value/int_u8.hh>
# include <mln/io/internal/pnm/load.hh>
@@ -59,6 +60,12 @@
return load<value::int_u8>(filename);
}
+ template <typename I>
+ void load(Image<I>& ima,
+ const std::string& filename)
+ {
+ io::internal::pnm::load<I>(PGM, ima, filename);
+ }
} // end of namespace mln::io::pgm
} // end of namespace mln::io
Index: trunk/milena/mln/io/fits/load.hh
===================================================================
--- trunk/milena/mln/io/fits/load.hh (revision 1119)
+++ trunk/milena/mln/io/fits/load.hh (revision 1120)
@@ -75,6 +75,9 @@
const int ncols = naxes[0], nrows = naxes[1];
+ std::cout << "ncols : " << ncols
+ << "nrows : " << nrows << std::endl;
+
image2d_b<float> output(nrows, ncols);
nullval = 0; // don't check null values
Index: trunk/milena/mln/io/ppm/load.hh
===================================================================
--- trunk/milena/mln/io/ppm/load.hh (revision 1119)
+++ trunk/milena/mln/io/ppm/load.hh (revision 1120)
@@ -57,6 +57,13 @@
return load< value::rgb8 >(filename);
}
+ template <typename I>
+ void load(Image<I>& ima,
+ const std::string& filename)
+ {
+ io::internal::pnm::load<I>(PPM, ima, filename);
+ }
+
} // end of namespace mln::io::ppm
} // end of namespace mln::io
Index: trunk/milena/mln/io/internal/pnm/save_header.hh
===================================================================
--- trunk/milena/mln/io/internal/pnm/save_header.hh (revision 1119)
+++ trunk/milena/mln/io/internal/pnm/save_header.hh (revision 1120)
@@ -32,6 +32,8 @@
# include <iostream>
# include <fstream>
+# include <mln/value/rgb.hh>
+
namespace mln
{
@@ -46,6 +48,20 @@
namespace pnm
{
+ template <typename V>
+ void save_max_val(V&, std::ofstream& file)
+ {
+ if (mln_max(V) > 1)
+ file << mln_max(V) << std::endl;
+ }
+
+ template <unsigned int n>
+ void save_max_val(value::rgb<n>&, std::ofstream& file)
+ {
+ typedef typename value::rgb<n>::enc E;
+ file << mln_max(E) << std::endl;
+ }
+
template <typename I>
void save_header(const char type,
const I& ima, const std::string& filename,
@@ -60,15 +76,9 @@
file << "P" << type << std::endl;
file << "# milena" << std::endl;
file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
- }
- template <typename I>
- void save_header(const char type, const int maxval,
- const I& ima, const std::string& filename,
- std::ofstream& file)
- {
- save_header(type, ima, filename, file);
- file << maxval << std::endl;
+ mln_value(I) i;
+ save_max_val(i, file);
}
} // end of namespace mln::io::internal::pnm
Index: trunk/milena/mln/io/internal/pnm/load_header.hh
===================================================================
--- trunk/milena/mln/io/internal/pnm/load_header.hh (revision 1119)
+++ trunk/milena/mln/io/internal/pnm/load_header.hh (revision 1120)
@@ -46,9 +46,10 @@
{
- bool read_header(std::istream& istr,
+ bool read_header(std::ifstream& istr,
char& type,
int& nrows, int& ncols,
+ unsigned int& maxval,
bool test = false)
{
// check magic
@@ -73,13 +74,14 @@
if (nrows <= 0 || ncols <= 0)
goto err;
- // skip maxvalue
+ // get maxvalue
if (istr.get() != '\n')
goto err;
if (type != '1' && type != '4')
{
- std::string line;
- std::getline(istr, line);
+ istr >> maxval;
+ if (istr.get() != '\n')
+ goto err;
}
return true;
@@ -93,11 +95,12 @@
}
void read_header(char ascii, char raw,
- std::istream& istr,
+ std::ifstream& istr,
char& type,
- int& nrows, int& ncols)
+ int& nrows, int& ncols,
+ unsigned int& maxval)
{
- read_header(istr, type, nrows, ncols);
+ read_header(istr, type, nrows, ncols, maxval);
if (! (type == ascii || type == raw))
{
std::cerr << "error: bad pnm type; "
@@ -108,6 +111,16 @@
}
}
+ void read_header(char ascii, char raw,
+ std::ifstream& istr,
+ char& type,
+ int& nrows, int& ncols)
+ {
+ unsigned int maxval;
+ read_header(ascii, raw, istr, type,
+ nrows, ncols, maxval);
+ }
+
} // end of namespace mln::io::internal::pnm
} // end of namespace mln::io::internal
Index: trunk/milena/mln/io/internal/pnm/save.hh
===================================================================
--- trunk/milena/mln/io/internal/pnm/save.hh (revision 1119)
+++ trunk/milena/mln/io/internal/pnm/save.hh (revision 1120)
@@ -41,8 +41,11 @@
# include <mln/core/concept/image.hh>
# include <mln/value/rgb.hh>
+# include <mln/value/rgb8.hh>
# include <mln/value/int_u8.hh>
+# include <mln/metal/templated_by.hh>
+
# include <mln/io/internal/pnm/save_header.hh>
# include <mln/io/internal/pnm/macros.hh>
@@ -150,8 +153,8 @@
{
const I& ima = exact(ima_);
std::ofstream file(filename.c_str());
- io::internal::pnm::save_header(type, mln_max(mln_value(I)::enc),
- ima, filename, file);
+ io::internal::pnm::save_header(type, ima, filename, file);
+
save_data(file, ima);
}
Index: trunk/milena/mln/io/internal/pnm/load.hh
===================================================================
--- trunk/milena/mln/io/internal/pnm/load.hh (revision 1119)
+++ trunk/milena/mln/io/internal/pnm/load.hh (revision 1120)
@@ -158,7 +158,9 @@
}
char type = 0;
int nrows, ncols;
- read_header(type_ - 3, type_, file, type, nrows, ncols);
+ unsigned int maxval;
+ read_header(type_ - 3, type_, file, type,
+ nrows, ncols, maxval);
image2d_b<V> ima(nrows, ncols);
if (type == type_)
@@ -170,6 +172,51 @@
}
+ /// a new function to load pnm files :
+ /// the destination is an argument to check if
+ /// the type match the file to load.
+ template <typename I>
+ void load(char type_,
+ Image<I>& ima_,
+ const std::string& filename)
+ {
+ std::ifstream file(filename.c_str());
+ if (! file)
+ {
+ std::cerr << "error: file '" << filename
+ << "' not found!";
+ abort();
+ }
+
+ I& ima = exact(ima_);
+
+ char type = 0;
+ int nrows, ncols;
+ unsigned int maxval;
+ read_header(type_ - 3, type_, file, type,
+ nrows, ncols, maxval);
+
+ if (value::props< mln_value(I) >::max() != maxval)
+ {
+ std::cerr << "max ref : " << value::props< mln_value(I) >::max()
+ << "max image : " << maxval
+ << std::endl;
+
+ std::cerr << "error: file '" << filename
+ << "' cannot be loaded into this type of image"
+ << std::endl;
+ abort();
+ }
+
+ ima.init_with(nrows, ncols);
+ if (type == type_)
+ load_raw_2d(file, ima);
+ else
+ if (type == (type_ - 3))
+ pnm::load_ascii(file, ima);
+
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::io::internal::pnm
Index: trunk/milena/mln/io/pbm/save.hh
===================================================================
--- trunk/milena/mln/io/pbm/save.hh (revision 1119)
+++ trunk/milena/mln/io/pbm/save.hh (revision 1120)
@@ -70,8 +70,7 @@
const I& ima = exact(ima_);
std::ofstream file(filename.c_str());
- //FIXME : why do we need a max val???
- io::internal::pnm::save_header(PBM, 255, ima, filename, file);
+ io::internal::pnm::save_header(PBM, ima, filename, file);
const int
min_row = geom::min_row(ima),
Index: trunk/milena/sandbox/garrigues/io_fits.cc
===================================================================
--- trunk/milena/sandbox/garrigues/io_fits.cc (revision 1119)
+++ trunk/milena/sandbox/garrigues/io_fits.cc (revision 1120)
@@ -33,6 +33,7 @@
#include <mln/core/image2d_b.hh>
#include <mln/level/compare.hh>
+#include <mln/debug/println.hh>
#include <mln/io/fits/load.hh>
#include <mln/io/pfm/save.hh>
@@ -43,7 +44,9 @@
using namespace mln;
{
image2d_b<float>
- fits_in = io::fits::load("../img/test.fits");
+ fits_in = io::fits::load("../../img/test.fits");
+
+ debug::println(fits_in);
io::pfm::save(fits_in, "out.pfm");
@@ -55,7 +58,14 @@
image2d_b<float>
pfm2 = io::pfm::load("out2.pfm");
- mln_assertion(pfm == pfm2);
+ image2d_b<float>::fwd_piter p(fits_in.domain());
+ for_all(p)
+ if (fits_in(p) != pfm(p))
+ std::cout << "at " << p
+ << " ref :" << fits_in(p)
+ << " pfm2 : " << pfm(p) << std::endl;
+
+ mln_assertion(fits_in == pfm2);
// }
// {
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-17 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix duplicate for border in sandbox.
* border_duplicate.cc: Test for duplicate border.
* border_duplicate.hh: Fix duplicate border.
* border_fill.hh: .
---
border_duplicate.cc | 61 ++++++++++++++++++++++
border_duplicate.hh | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
border_fill.hh | 2
3 files changed, 203 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/duhamel/border_fill.hh
===================================================================
--- trunk/milena/sandbox/duhamel/border_fill.hh (revision 1118)
+++ trunk/milena/sandbox/duhamel/border_fill.hh (revision 1119)
@@ -80,8 +80,6 @@
std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
- mln_value(I) tmp;
- tmp = v;
point2d p = ima.bbox ().pmin ();
// FIXME : REMOVE THIS LOOP BY MEMSET
Index: trunk/milena/sandbox/duhamel/border_duplicate.hh
===================================================================
--- trunk/milena/sandbox/duhamel/border_duplicate.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/border_duplicate.hh (revision 1119)
@@ -0,0 +1,142 @@
+// 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_BORDER_DUPLICATE_HH
+# define MLN_BORDER_DUPLICATE_HH
+
+/*! \file mln/border/duplicate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/internal/fixme.hh>
+# include <mln/level/memset_.hh>
+//# include <mln/core/line_piter.hh>
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/pixel.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Assign the virtual (outer) border of image \p ima with the
+ * dupplicate of the inner border of this image.
+ *
+ * \param[in,out] ima The image whose border is to be duplicated.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memcpy if possible.
+ */
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void duplicate(const Fast_Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima.has_data());
+
+ // internal::fixme();
+ // FIX
+ std::size_t border = ima.border ();
+ std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
+ std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
+ std::size_t real_nbcols = (nbcols + 1) + 2 * border;
+ std::size_t start = real_nbcols * border + border;
+ std::size_t s = start;
+ // duplicate top left corner
+ for (std::size_t i = 0; i < border + 1; ++i)
+ for (std::size_t j = 0; j < border + 1; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + j] = ima[s];
+
+ // duplicate top border
+ s = start;
+ for (std::size_t i = 1; i <= nbcols - 1; ++i)
+ for (std::size_t j = 0; j <= border; ++j)
+ const_cast<I&>(ima)[s + i - (j * real_nbcols)] = ima[s + i];
+
+ // duplicate top left corner
+ s = start + nbcols;
+ for (std::size_t i = 0; i <= border; ++i)
+ for (std::size_t j = 0; j <= border; ++j)
+ const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)] = ima[s];
+
+ // duplicate left border
+ s = start;
+ for (std::size_t i = 1; i <= nbrows - 1; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s - j + (i * real_nbcols)] = ima[s + (i * real_nbcols)];
+
+ // duplicate right border
+ s = start;
+ for (std::size_t i = 1; i <= nbrows - 1; ++i)
+ for (std::size_t j = 1; j <= border; ++j)
+ const_cast<I&>(ima)[s + (i * real_nbcols + nbcols) + j] = ima[s + (i * real_nbcols + nbcols)];
+
+
+ // duplicate bottom left corner
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 0; i <= border; ++i)
+ for (std::size_t j = 0; j <= border; ++j)
+ const_cast<I&>(ima)[s - i + (j * (real_nbcols))] = ima[s];
+
+ // duplicate bottom border
+ s = start + (nbrows * real_nbcols);
+ for (std::size_t i = 1; i <= nbcols - 1; ++i)
+ for (std::size_t j = 0; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s + i];
+
+ // duplicate bottom right corner
+ s = start + (nbrows * real_nbcols) + nbcols;
+ for (std::size_t i = 0; i <= border; ++i)
+ for (std::size_t j = 0; j <= border; ++j)
+ const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s];
+
+
+
+ //END FIX
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_DUPLICATE_HH
Index: trunk/milena/sandbox/duhamel/border_duplicate.cc
===================================================================
--- trunk/milena/sandbox/duhamel/border_duplicate.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/border_duplicate.cc (revision 1119)
@@ -0,0 +1,61 @@
+// 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/border_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include "border_duplicate.hh"
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/pw/all.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ image2d_b<value::int_u8> i1(5, 7);
+
+ // Fill with randomized value.
+ for (unsigned int i = 0; i < i1.ncells (); ++i)
+ i1[i] = i;//(i * 4452) % 10;
+ std::cout << "before duplicate"
+ << std::endl
+ << std::endl;
+ debug::println_with_border(i1);
+
+ border::duplicate (i1);
+ std::cout << "after duplicate"
+ << std::endl
+ << std::endl;
+ debug::println_with_border(i1);
+}
+
+
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-17 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix fill for border in sandbox.
* border_fill.cc: Test file of fill border with println_with_border.
* border_fill.hh: Fix fill for border, but need to be optimize.
---
border_fill.cc | 48 ++++++++++++++++++++++++
border_fill.hh | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 162 insertions(+)
Index: trunk/milena/sandbox/duhamel/border_fill.hh
===================================================================
--- trunk/milena/sandbox/duhamel/border_fill.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/border_fill.hh (revision 1118)
@@ -0,0 +1,114 @@
+// 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_BORDER_FILL_HH
+# define MLN_BORDER_FILL_HH
+
+/*! \file mln/border/fill.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/internal/fixme.hh>
+# include <mln/level/memset_.hh>
+//# include <mln/core/line_piter.hh>
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/pixel.hh>
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ /*! Fill the virtual (outer) border of image \p ima with the
+ * single value \p v.
+ *
+ * \param[in,out] ima The image whose border is to be filled.
+ * \param[in] v The value to assign to all border pixels.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Implement it + optimize with memset if possible.
+ */
+ template <typename I>
+ void fill(const Fast_Image<I>& ima, const mln_value(I)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ void fill(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ {
+ const I& ima = exact(ima_);
+ mln_precondition(ima.has_data());
+ // FIX
+ typedef mln_point(I) point;
+ typedef mln_dpoint(I) delta_point;
+
+ Fast_Image<I> im (ima);
+ // internal::fixme();
+ std::size_t border = ima.border ();
+ std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
+ std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
+
+ mln_value(I) tmp;
+ tmp = v;
+ point2d p = ima.bbox ().pmin ();
+
+ // FIXME : REMOVE THIS LOOP BY MEMSET
+ for (std::size_t i = 0; i < border * (2 * (border + 1) + nbcols); ++i)
+ const_cast<I&>(ima)[i] = v;
+
+ // ACCESS TO RIGHT UP CORNER
+ for (std::size_t i = 0; i < nbcols + 1; ++i)
+ p = p + right;
+
+ // FILL BORDER
+ for (std::size_t i = 0; i < nbrows; ++i)
+ {
+ level::memset_(const_cast<I&>(ima), p, v, 2 * border);
+ p = p + down;
+ }
+
+ // FILL THE BOTTOM OF BORDER
+ level::memset_(const_cast<I&>(ima), p, v, border * (2 * (border + 1) + nbcols));
+ // END FIX
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_FILL_HH
Index: trunk/milena/sandbox/duhamel/border_fill.cc
===================================================================
--- trunk/milena/sandbox/duhamel/border_fill.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/border_fill.cc (revision 1118)
@@ -0,0 +1,48 @@
+// 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/border_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include "border_fill.hh"
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/pw/all.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ image2d_b<value::int_u8> i1(9, 7);
+
+ border::fill (i1, 8);
+ debug::println_with_border(i1);
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-17 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
move the io_fits test
from:
* sandbox/garrigues/io_fits.cc:
to:
* tests/io_fits.cc: Remove.
because it can't compile without the cfitsio library
---
io_fits.cc | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
Index: trunk/milena/tests/io_fits.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/garrigues/io_fits.cc
===================================================================
--- trunk/milena/sandbox/garrigues/io_fits.cc (revision 0)
+++ trunk/milena/sandbox/garrigues/io_fits.cc (revision 1114)
@@ -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.
+
+/*! \file tests/fits_load.cc
+ *
+ * \brief Test on mln::io::fits::load.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/io/fits/load.hh>
+#include <mln/io/pfm/save.hh>
+#include <mln/io/pfm/load.hh>
+
+int main()
+{
+ using namespace mln;
+ {
+ image2d_b<float>
+ fits_in = io::fits::load("../img/test.fits");
+
+ io::pfm::save(fits_in, "out.pfm");
+
+ image2d_b<float>
+ pfm = io::pfm::load("out.pfm");
+
+ io::pfm::save(fits_in, "out2.pfm");
+
+ image2d_b<float>
+ pfm2 = io::pfm::load("out2.pfm");
+
+ mln_assertion(pfm == pfm2);
+
+// }
+// {
+// image2d_b<int_u8>
+// lena = io::fits::load<int_u8>("../img/lena.fits");
+
+// io::fits::save(lena, "out.fits");
+ }
+}
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