diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index f3a19f68776..cdfa4773c72 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -134,7 +134,7 @@ if (VTK_FOUND) include_directories(${3MF_INCLUDE_DIR}) create_single_source_cgal_program( test_3mf_to_sm.cpp ) target_link_libraries(test_3mf_to_sm PRIVATE ${3MF_LIBRARIES}) - add_definitions(-DCGAL_LINKED_WITH_3MF) + target_compile_definitions(test_3mf_to_sm PRIVATE -DCGAL_LINKED_WITH_3MF) else() message(STATUS "NOTICE : This program requires the lib3MF library, and will not be compiled.") endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index 441b9835e95..7e6c6cdf4dc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -93,7 +93,7 @@ if(3MF_LIBRARIES AND 3MF_INCLUDE_DIR AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NM include_directories(${3MF_INCLUDE_DIR}) polyhedron_demo_plugin(3mf_io_plugin 3mf_io_plugin KEYWORDS IO PMP) target_link_libraries(3mf_io_plugin PRIVATE scene_surface_mesh_item scene_points_with_normal_item scene_polylines_item ${3MF_LIBRARIES}) - add_definitions(-DCGAL_LINKED_WITH_3MF) + target_compile_definitions(3mf_io_plugin PRIVATE -DCGAL_LINKED_WITH_3MF) else() message(STATUS "NOTICE : The 3mf_io_plugin requires the lib3MF library in a version < 2.0, and will not be compiled.") endif() diff --git a/Stream_support/include/CGAL/IO/GOCAD.h b/Stream_support/include/CGAL/IO/GOCAD.h index fe8f8f250a4..def9446fca7 100644 --- a/Stream_support/include/CGAL/IO/GOCAD.h +++ b/Stream_support/include/CGAL/IO/GOCAD.h @@ -61,13 +61,23 @@ bool read_GOCAD(std::istream& input, if((idx = s.find("name")) != std::string::npos) { std::istringstream str(s.substr(idx + 5)); - str >> name_and_color.first; + if(!(str >> name_and_color.first)) + { + if(verbose) + std::cerr<<"error while reading expected name. "<> name_and_color.second; + if(!(str >> name_and_color.second)) + { + if(verbose) + std::cerr<<"error while reading expected color. "<> s >> i >> p; // @fixme check for failure + if(!(input >> s >> i >> p)) + { + if(verbose) + std::cerr<<"error while reading vertex. "<> c >> c >> c >> i >> j >> k; + if(!(input >> c >> c >> c >> i >> j >> k)) + { + if(verbose) + std::cerr<<"error while reading triangle. "<> p; // @fixme check successful reading - if(!iss) + if(!(iss >> p) || !iss) + { + if(verbose) + std::cerr<<"error while reading OBJ vertex. "<> dummy; + if(!(iss >> dummy)) + { + if(verbose) + std::cerr<<"error while reading OBJ vertex normal. "<> nx >> ny >> nz) *vn_out++ = Normal(nx, ny, nz); // @fixme check that every vertex has a normal? diff --git a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h index b72389f3d76..ba839c7e86e 100644 --- a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h +++ b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h @@ -71,11 +71,23 @@ public: else { skip_comment(); - m_in >> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw); + if(!(m_in >> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(x); - m_in >> iformat(y); - m_in >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading vertex."<> iformat(fx) >> iformat(fy) >> iformat(fw); + if(!(m_in >> iformat(fx) >> iformat(fy) >> iformat(fw))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading texture."<> iformat(x) >> iformat(y); + if(!(m_in >> iformat(x) >> iformat(y))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading texture."<> iformat(fx) >> iformat(fy) >> iformat(fw); + if(!(m_in >> iformat(fx) >> iformat(fy) >> iformat(fw))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading texture."<> iformat(x) >> iformat(y); + if(!(m_in >> iformat(x) >> iformat(y))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading texture."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw); + if(!(m_in >> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw); + if(!(m_in >> iformat(fx) >> iformat(fy) >> iformat(fz) >> iformat(fw))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(x) >> iformat(y) >> iformat(z); + if(!(m_in >> iformat(x) >> iformat(y) >> iformat(z))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(w); + if(!(m_in >> iformat(w))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> iformat(d); + if(!(m_in >> iformat(d))) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading normal."<> dummy >> dummy >> dummy >> dummy; + if(!(m_in >> dummy >> dummy >> dummy >> dummy)) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading. Missing expected characters."<> dummy >> dummy >> dummy; + if(!(m_in >> dummy >> dummy >> dummy)) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading. Missing expected characters."<> size; + if(!(m_in >> size)) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading facet. Missing size."<> index; + if(!(m_in >> index)) + { + m_in.clear(std::ios::badbit); + if(verbose()) + std::cerr<<"error while reading facet. Missing index."<> s; - c = static_cast(s); + if(stream >> s) + c = static_cast(s); + else + stream.clear(std::ios::badbit); } void read_ascii(std::istream& stream, signed char& c) const { short s; - stream >> s; - c = static_cast(s); + if(stream >> s) + c = static_cast(s); + else + stream.clear(std::ios::badbit); } void read_ascii(std::istream& stream, unsigned char& c) const { unsigned short s; - stream >> s; - c = static_cast(s); + if(stream >> s) + c = static_cast(s); + else + stream.clear(std::ios::badbit); } void read_ascii(std::istream& stream, float& t) const { - stream >> iformat(t); + if(!(stream >> iformat(t))) + stream.clear(std::ios::badbit); } void read_ascii(std::istream& stream, double& t) const { - stream >> iformat(t); + if(!(stream >> iformat(t))) + stream.clear(std::ios::badbit); } // Default template when Type is not a char type template void read_ascii(std::istream& stream, Type& t) const { - stream >> t; + if(!(stream >> t)) + stream.clear(std::ios::badbit); }