diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index a71e38f8c43..7b250380193 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -596,24 +596,22 @@ bool build_triangulation_from_file(std::istream& is, bool is_CGAL_mesh = false; - while(is >> word && word != "End") + std::string line; + while(std::getline(is, line) && line != "End") { - if (word.at(0) == '#') + // remove trailing whitespace, in particular a possible '\r' from Windows + // end-of-line encoding + if(!line.empty() && std::isspace(line.back())) { + line.pop_back(); + } + if (line.size() > 0 && line.at(0) == '#' && + line.find("CGAL::Mesh_complex_3_in_triangulation_3") != std::string::npos) { - is >> word; - if (word == "End") - { - break; - } - else if (word == "CGAL::Mesh_complex_3_in_triangulation_3") - { - is_CGAL_mesh = true; // with CGAL meshes, domain 0 should be kept - continue; - } - //else skip other comments + is_CGAL_mesh = true; // with CGAL meshes, domain 0 should be kept + continue; } - if(word == "Vertices") + if(line == "Vertices") { is >> nv; for(int i=0; i> nf; for(int i=0; i> ntet; for(int i=0; i