diff --git a/BGL/include/CGAL/boost/graph/IO/VTK.h b/BGL/include/CGAL/boost/graph/IO/VTK.h index 0d9084667db..6f90299bb13 100644 --- a/BGL/include/CGAL/boost/graph/IO/VTK.h +++ b/BGL/include/CGAL/boost/graph/IO/VTK.h @@ -531,7 +531,14 @@ bool write_VTP(std::ostream& os, template bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) { - std::ofstream os(fname); + const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); + std::ofstream os; + if(binary){ + os.open(fname, std::ios::binary); + CGAL::set_mode(os, CGAL::IO::BINARY); + } + else + os.open(fname); return write_VTP(os, g, np); } diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp index 50dd2d1794d..d9e1fa68cb4 100644 --- a/BGL/test/BGL/test_bgl_read_write.cpp +++ b/BGL/test/BGL/test_bgl_read_write.cpp @@ -750,14 +750,18 @@ void test_bgl_VTP(const char* filename, // write with VTP { - std::ofstream os("tmp.vtp"); - if(binary) + std::ofstream os; + if(binary){ + os.open("tmp.vtp", std::ios::binary); CGAL::set_mode(os, CGAL::IO::BINARY); - ok = CGAL::write_VTP(os, fg); + } + else + os.open("tmp.vtp"); + ok = CGAL::write_VTP(os, fg, CGAL::parameters::use_binary_mode(binary)); assert(ok); Mesh fg2; - ok = CGAL::read_VTP("tmp.vtp", fg2); + ok = CGAL::read_VTP("tmp.vtp", fg2, CGAL::parameters::use_binary_mode(binary)); assert(ok); assert(are_equal_meshes(fg, fg2)); } @@ -771,7 +775,7 @@ void test_bgl_VTP(const char* filename, assert(ok); Mesh fg2; - ok = CGAL::read_polygon_mesh("tmp.vtp", fg2); + ok = CGAL::read_polygon_mesh("tmp.vtp", fg2, CGAL::parameters::use_binary_mode(binary)); assert(ok); assert(are_equal_meshes(fg, fg2)); } @@ -799,15 +803,22 @@ void test_bgl_VTP(const char* filename, // write with VTP { - std::ofstream os("tmp.vtp"); + std::ofstream os; if(binary) + { + os.open("tmp.vtp", std::ios::binary); CGAL::set_mode(os, CGAL::IO::BINARY); - ok = CGAL::write_VTP(os, fg); + } + else + { + os.open("tmp.vtp"); + } + ok = CGAL::write_VTP(os, fg, CGAL::parameters::use_binary_mode(binary)); assert(ok); Mesh fg2; - ok = CGAL::read_polygon_mesh("tmp.vtp", fg2); + ok = CGAL::read_polygon_mesh("tmp.vtp", fg2, CGAL::parameters::use_binary_mode(binary)); assert(ok); assert(are_equal_meshes(fg, fg2)); } @@ -822,7 +833,7 @@ void test_bgl_VTP(const char* filename, Mesh fg2; - ok = CGAL::read_polygon_mesh("tmp.vtp", fg2); + ok = CGAL::read_polygon_mesh("tmp.vtp", fg2, CGAL::parameters::use_binary_mode(binary)); assert(ok); assert(are_equal_meshes(fg, fg2)); } @@ -898,8 +909,8 @@ int main(int argc, char** argv) #ifdef CGAL_USE_VTK const char* vtp_file = (argc > 6) ? argv[6] : "data/bones.vtp"; - //test_bgl_VTP(vtp_file, false); - //test_bgl_VTP(vtp_file, false); + test_bgl_VTP(vtp_file, false); + test_bgl_VTP(vtp_file, false); test_bgl_VTP(vtp_file, false); test_bgl_VTP(vtp_file, true);