26 #ifndef APPS_MESH_SEGM_SKEL_SAVE_BIN_ALT_HH
27 # define APPS_MESH_SEGM_SKEL_SAVE_BIN_ALT_HH
43 # include <mln/core/alias/complex_image.hh>
44 # include <mln/core/image/complex_neighborhoods.hh>
45 # include <mln/core/image/complex_neighborhood_piter.hh>
67 const std::string me =
"mln::io::off::save";
69 std::ofstream ostr(filename.c_str());
72 std::cerr << me <<
": `" << filename <<
"' invalid file."
86 static const unsigned D = I::dim;
87 typedef mln_geom(I) G;
94 ostr <<
"OFF" << std::endl;
97 ostr <<
"# Generated by Milena 1.0 http://olena.lrde.epita.fr\n"
98 <<
"# EPITA Research and Development Laboratory (LRDE)"
102 unsigned n2faces = 0;
119 ostr << ima.domain().cplx().template nfaces_of_static_dim<0>() <<
' '
121 << ima.domain().cplx().template nfaces_of_static_dim<1>()
139 mln_invariant(v.to_site().size() == 1);
140 ostr << v.to_site().front()[0] <<
' '
141 << v.to_site().front()[1] <<
' '
142 << v.to_site().front()[2] << std::endl;
159 mln_fwd_niter(nbh_t) u(nbh, f);
170 unsigned nvertices = 0;
171 std::ostringstream vertices;
175 vertices <<
' ' << u.unproxy_().face().face_id();
178 ostr << nvertices << vertices.str();
197 template <
typename I>
201 const std::string me =
"mln::io::vtk::save";
203 std::ofstream ostr(filename.c_str());
206 std::cerr << me <<
": `" << filename <<
"' invalid file."
233 ostr <<
"# vtk DataFile Version 2.0" << std::endl;
240 ostr <<
"Generated by Milena 1.0 http://olena.lrde.epita.fr"
247 ostr <<
"ASCII" << std::endl;
268 ostr <<
"DATASET POLYDATA" << std::endl << std::endl;
274 static const unsigned D = I::dim;
275 typedef mln_geom(I) G;
293 << ima.domain().cplx().template nfaces_of_static_dim<0>()
294 <<
" float" << std::endl;
299 mln_invariant(v.to_site().size() == 1);
300 ostr << v.to_site().front()[0] <<
' '
301 << v.to_site().front()[1] <<
' '
302 << v.to_site().front()[2] << std::endl;
338 unsigned nvertices = 0;
339 for_all(v)
if (ima(v))
342 ostr <<
"VERTICES " << nvertices <<
' '
347 << nvertices * 2 << std::endl;
349 for_all(v)
if (ima(v))
350 ostr <<
"1 " << v.unproxy_().face().face_id() << std::endl;
368 for_all (e)
if (ima(e))
371 ostr <<
"LINES " << nedges <<
' '
376 << nedges * 3 << std::endl;
380 adj_vertices_nbh_t adj_vertices_nbh;
381 mln_niter(adj_vertices_nbh_t) adj_v(adj_vertices_nbh, e);
383 for_all (e)
if (ima(e))
390 ostr <<
" " << adj_v.unproxy_().face().face_id();
409 unsigned npolygons = 0;
414 for_all (
p)
if (ima(
p))
421 mln_fwd_niter(nbh_t) u(nbh,
p);
429 unsigned polygons_size = 0;
431 for_all(
p)
if (ima(
p))
433 unsigned nvertices = 0;
443 polygons_size += 1 + nvertices;
445 ostr <<
"POLYGONS " << npolygons <<
' ' << polygons_size
451 for_all(
p)
if (ima(
p))
453 unsigned nvertices = 0;
454 std::ostringstream vertices;
459 vertices <<
' ' << u.unproxy_().face().face_id();
462 ostr << nvertices << vertices.str() << std::endl;
487 #endif // ! APPS_MESH_SEGM_SKEL_SAVE_BIN_ALT_HH