From c8c41a54d3050c51a1a1cc24c15ee232101d8f8f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 3 Dec 2020 14:50:31 +0100 Subject: [PATCH] NOT WORKING --- BGL/test/BGL/test_bgl_read_write.cpp | 49 +++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp index 605163f1a12..54f4a20489d 100644 --- a/BGL/test/BGL/test_bgl_read_write.cpp +++ b/BGL/test/BGL/test_bgl_read_write.cpp @@ -121,7 +121,13 @@ void test_bgl_OFF(const char* filename) bool ok = CGAL::read_OFF(is, fg); assert(ok); assert(num_vertices(fg) != 0 && num_faces(fg) != 0); + is.close(); + fg.clear(); + is.open(filename, std::ios::binary); + ok = CGAL::read_OFF(is, fg); + assert(ok); + assert(num_vertices(fg) != 0 && num_faces(fg) != 0); // write with OFF { std::ofstream os("tmp.off"); @@ -281,6 +287,17 @@ void test_bgl_OFF(const char* filename) for(const auto f : faces(fg)) assert(get(fcm, f) != CGAL::Color()); + fg.clear(); + is.close(); + is.open("data/full.off", std::ios::binary); + VertexNormalMap vnm2 = get(CGAL::dynamic_vertex_property_t(), fg); + VertexColorMap vcm2 = get(CGAL::dynamic_vertex_property_t(), fg); + VertexTextureMap vtm2 = get(CGAL::dynamic_vertex_property_t(), fg); + FaceColorMap fcm2 = get(CGAL::dynamic_face_property_t(), fg); + ok = CGAL::read_OFF(is, fg, CGAL::parameters::vertex_normal_map(vnm2) + .vertex_color_map(vcm2) + .vertex_texture_map(vtm2) + .face_color_map(fcm2)); // write with OFF { @@ -451,8 +468,18 @@ void test_bgl_PLY(const std::string filename, Mesh fg; std::ifstream is(filename); bool ok = CGAL::read_PLY(is, fg, CGAL::parameters::use_binary_mode(false)); + is.close(); assert(ok); assert(filename != "data/colored_tetra.ply" || (num_vertices(fg) == 4 && num_faces(fg) == 4)); + if(!binary) + { + fg.clear(); + is.open(filename, std::ios::binary); + bool ok = CGAL::read_PLY(is, fg, CGAL::parameters::use_binary_mode(false)); + is.close(); + assert(ok); + assert(filename != "data/colored_tetra.ply" || (num_vertices(fg) == 4 && num_faces(fg) == 4)); + } // write with PLY { @@ -643,6 +670,18 @@ void test_bgl_STL(const std::string filename) assert(num_vertices(fg) == num_vertices(fg2) && num_faces(fg) == num_faces(fg2)); } + // write with ASCII in binary mode + { + ok = CGAL::write_polygon_mesh("ascii.stl", fg, CGAL::parameters::use_binary_mode(false)); + assert(ok); + std::ifstream test_ascii("ascii.stl", std::ios::binary); + Mesh fg2; + ok = CGAL::read_STL(test_ascii, fg2, CGAL::parameters::use_binary_mode(false)); + test_ascii.close(); + assert(ok); + assert(num_vertices(fg) == num_vertices(fg2) && num_faces(fg) == num_faces(fg2)); + } + std::cerr << " ########### Error text is expected to follow." << std::endl; ok = CGAL::read_STL("data/mesh_that_doesnt_exist.stl", fg); assert(!ok); @@ -861,13 +900,13 @@ int main(int argc, char** argv) { // OFF const char* off_file = (argc > 1) ? argv[1] : "data/prim.off"; - test_bgl_OFF(off_file); - Polyhedron fg; - bool ok = CGAL::read_OFF("data/invalid_header.off", fg); // wrong header (NOFF but no normals) - assert(ok); + //test_bgl_OFF(off_file); + //Polyhedron fg; + //bool ok = CGAL::read_OFF("data/invalid_header.off", fg); // wrong header (NOFF but no normals) + //assert(ok); test_bgl_OFF(off_file); SM sm; - ok = CGAL::read_OFF("data/invalid_header.off", sm); // wrong header (NOFF but no normals) + bool ok = CGAL::read_OFF("data/invalid_header.off", sm); // wrong header (NOFF but no normals) assert(!ok); test_bgl_OFF(off_file); LCC lcc;