Commit 75d01478 authored by Roland Levillain's avatar Roland Levillain
Browse files

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.
parent 5f6cc931
2010-07-28 Roland Levillain <roland@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@lrde.epita.fr>
 
* mln/io/vtk/save.hh: Fix documentation.
......@@ -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 >
{
......@@ -176,6 +193,14 @@ namespace mln
trace::exiting("mln::io::vtk::save");
}
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)
{
......@@ -566,6 +591,13 @@ namespace mln
write_scalar_data(ostr, ima, "unsigned_char");
}
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
......
......@@ -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
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment