* mln/io/vtk/save.hh
(io::vtk::save(const unsigned_2complex_image3df&, const std::string&)):
New function.
(io::vtk::internal::unsigned_vtk_saver): New structure.
* tests/io/vtk/save.cc: Add a tests case for images of unsigneds.
* tests/io/vtk/Makefile.am (MOSTLYCLEANFILES):
Add save-tetrahedron-unsigned.vtk.
---
milena/ChangeLog | 12 ++++++++++++
milena/mln/io/vtk/save.hh | 32 ++++++++++++++++++++++++++++++++
milena/tests/io/vtk/Makefile.am | 1 +
milena/tests/io/vtk/save.cc | 9 +++++++++
4 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d27ada3..338ea73 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2010-07-28 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a VTK output for images of unsigned integers.
+
+ * mln/io/vtk/save.hh
+ (io::vtk::save(const unsigned_2complex_image3df&, const std::string&)):
+ New function.
+ (io::vtk::internal::unsigned_vtk_saver): New structure.
+ * tests/io/vtk/save.cc: Add a tests case for images of unsigneds.
+ * tests/io/vtk/Makefile.am (MOSTLYCLEANFILES):
+ Add save-tetrahedron-unsigned.vtk.
+
+2010-07-28 Roland Levillain <roland(a)lrde.epita.fr>
+
* mln/io/vtk/save.hh: Fix documentation.
2010-07-27 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/io/vtk/save.hh b/milena/mln/io/vtk/save.hh
index 2a4a51f..fbe5a85 100644
--- a/milena/mln/io/vtk/save.hh
+++ b/milena/mln/io/vtk/save.hh
@@ -73,6 +73,14 @@ namespace mln
void save(const int_u8_2complex_image3df& ima,
const std::string& filename);
+ /** \brief Save a gray-level VTK image into a complex image.
+
+ \param[in] ima The image to save.
+ \param[in] filename The name of the file where to save the
+ image. */
+ void save(const unsigned_2complex_image3df& ima,
+ const std::string& filename);
+
/** \brief Save a floating-point value gray-level VTK image into
a complex image.
@@ -127,6 +135,7 @@ namespace mln
void write_face_data(std::ostream& ostr, const image& ima) const;
};
+
struct int_u8_vtk_saver
: public vtk_saver< int_u8_2complex_image3df, int_u8_vtk_saver >
{
@@ -135,6 +144,14 @@ namespace mln
};
+ struct unsigned_vtk_saver
+ : public vtk_saver< unsigned_2complex_image3df, unsigned_vtk_saver >
+ {
+ /// \brief Save face data.
+ void write_face_data(std::ostream& ostr, const image& ima) const;
+ };
+
+
struct float_vtk_saver
: public vtk_saver< float_2complex_image3df, float_vtk_saver >
{
@@ -177,6 +194,14 @@ namespace mln
}
void
+ save(const unsigned_2complex_image3df& ima, const std::string& filename)
+ {
+ trace::entering("mln::io::vtk::save");
+ internal::unsigned_vtk_saver()(ima, filename);
+ trace::exiting("mln::io::vtk::save");
+ }
+
+ void
save(const float_2complex_image3df& ima, const std::string& filename)
{
trace::entering("mln::io::vtk::save");
@@ -567,6 +592,13 @@ namespace mln
}
void
+ unsigned_vtk_saver::write_face_data(std::ostream& ostr,
+ const image& ima) const
+ {
+ write_scalar_data(ostr, ima, "unsigned_int");
+ }
+
+ void
float_vtk_saver::write_face_data(std::ostream& ostr,
const image& ima) const
{
diff --git a/milena/tests/io/vtk/Makefile.am b/milena/tests/io/vtk/Makefile.am
index 3467f78..548f1b5 100644
--- a/milena/tests/io/vtk/Makefile.am
+++ b/milena/tests/io/vtk/Makefile.am
@@ -25,5 +25,6 @@ TESTS = $(check_PROGRAMS)
MOSTLYCLEANFILES = \
save-tetrahedron-bool.vtk \
save-tetrahedron-int_u8.vtk \
+ save-tetrahedron-unsigned.vtk \
save-tetrahedron-float.vtk \
save-tetrahedron-rgb8.vtk
diff --git a/milena/tests/io/vtk/save.cc b/milena/tests/io/vtk/save.cc
index 908636b..5d4a112 100644
--- a/milena/tests/io/vtk/save.cc
+++ b/milena/tests/io/vtk/save.cc
@@ -73,6 +73,15 @@ main()
"save-tetrahedron-int_u8.vtk");
}
+ // Unsigned integer values.
+ {
+ std::vector<unsigned> values(nfaces);
+ for (unsigned i = 0; i < nfaces; ++i)
+ values[i] = mln_max(unsigned) / nfaces * i;
+ io::vtk::save(make_image<unsigned_2complex_image3df>(bin_ima, values),
+ "save-tetrahedron-unsigned.vtk");
+ }
+
// Floating-point values.
{
std::vector<float> values(nfaces);
--
1.5.6.5
Show replies by date