From 8385b98c84a375cfea7ff95853aa937eb4b9f622 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 27 Apr 2026 11:21:45 +0200 Subject: [PATCH 1/6] fix(Library): better handle exception and library --- bindings/python/image_io.py | 3 +- bindings/python/mesh_io.py | 3 +- bindings/python/model_io.py | 3 +- bindings/python/src/image_io/image_io.cpp | 5 +- bindings/python/src/mesh_io/mesh_io.cpp | 5 +- bindings/python/src/model_io/model_io.cpp | 5 +- include/geode/io/image/common.hpp | 3 +- include/geode/io/image/detail/vtk_output.hpp | 5 +- include/geode/io/mesh/common.hpp | 3 +- include/geode/io/mesh/detail/vtk_input.hpp | 73 ++++--- .../geode/io/mesh/detail/vtk_mesh_input.hpp | 32 +-- .../io/mesh/detail/vtu_hybrid_output.hpp | 2 + .../geode/io/mesh/detail/vtu_input_impl.hpp | 19 +- .../geode/io/mesh/internal/assimp_input.hpp | 4 +- .../geode/io/mesh/internal/assimp_output.hpp | 9 +- include/geode/io/model/common.hpp | 3 +- include/geode/io/model/detail/vtm_output.hpp | 10 +- .../geode/io/model/internal/gid_output.hpp | 2 + .../geode/io/model/internal/msh_common.hpp | 3 +- include/geode/io/model/internal/svg_input.hpp | 2 + include/geode/io/project.hpp | 35 ++++ src/geode/io/image/common.cpp | 2 +- src/geode/io/image/gdal_file.cpp | 8 +- src/geode/io/image/raster_image_input.cpp | 3 +- src/geode/io/mesh/assimp_input.cpp | 3 +- src/geode/io/mesh/common.cpp | 4 +- src/geode/io/mesh/obj_input.cpp | 6 +- src/geode/io/mesh/vtp_input.cpp | 5 +- src/geode/io/mesh/vtu_hybrid_output.cpp | 3 +- src/geode/io/model/common.cpp | 4 +- src/geode/io/model/gid_output.cpp | 3 +- src/geode/io/model/msh_input.cpp | 127 ++++++------ src/geode/io/model/msh_output.cpp | 4 +- src/geode/io/model/svg_input.cpp | 31 +-- src/geode/io/model/vtm_brep_output.cpp | 5 +- tests/image/test-raster-image.cpp | 22 ++- tests/mesh/test-dot.cpp | 2 +- tests/mesh/test-dxf.cpp | 10 +- tests/mesh/test-gexf.cpp | 2 +- tests/mesh/test-obj.cpp | 18 +- tests/mesh/test-ply.cpp | 20 +- tests/mesh/test-smesh-curve.cpp | 10 +- tests/mesh/test-smesh-trgl.cpp | 10 +- tests/mesh/test-stl.cpp | 18 +- tests/mesh/test-vti.cpp | 47 +++-- tests/mesh/test-vtp.cpp | 22 +-- tests/mesh/test-vtu.cpp | 30 +-- tests/model/test-gid.cpp | 57 +++--- tests/model/test-msh.cpp | 182 ++++++++++-------- tests/model/test-svg.cpp | 22 +-- tests/model/test-vtm.cpp | 4 +- 51 files changed, 519 insertions(+), 394 deletions(-) create mode 100644 include/geode/io/project.hpp diff --git a/bindings/python/image_io.py b/bindings/python/image_io.py index 3ba2d71..57a094e 100644 --- a/bindings/python/image_io.py +++ b/bindings/python/image_io.py @@ -21,4 +21,5 @@ import opengeode from opengeode_io_py_image import * -IOImageLibrary.initialize() + +OpenGeodeIOImageLibrary.initialize() diff --git a/bindings/python/mesh_io.py b/bindings/python/mesh_io.py index 0aa216d..f26ef1a 100644 --- a/bindings/python/mesh_io.py +++ b/bindings/python/mesh_io.py @@ -21,4 +21,5 @@ import opengeode from opengeode_io_py_mesh import * -IOMeshLibrary.initialize() + +OpenGeodeIOMeshLibrary.initialize() diff --git a/bindings/python/model_io.py b/bindings/python/model_io.py index a630e95..3049d55 100644 --- a/bindings/python/model_io.py +++ b/bindings/python/model_io.py @@ -21,4 +21,5 @@ import opengeode from opengeode_io_py_model import * -IOModelLibrary.initialize() + +OpenGeodeIOModelLibrary.initialize() diff --git a/bindings/python/src/image_io/image_io.cpp b/bindings/python/src/image_io/image_io.cpp index 92f8956..67da8bd 100644 --- a/bindings/python/src/image_io/image_io.cpp +++ b/bindings/python/src/image_io/image_io.cpp @@ -28,6 +28,7 @@ PYBIND11_MODULE( opengeode_io_py_image, module ) { module.doc() = "OpenGeode-IO Python binding for image"; - pybind11::class_< geode::IOImageLibrary >( module, "IOImageLibrary" ) - .def( "initialize", &geode::IOImageLibrary::initialize ); + pybind11::class_< geode::OpenGeodeIOImageLibrary >( + module, "OpenGeodeIOImageLibrary" ) + .def( "initialize", &geode::OpenGeodeIOImageLibrary::initialize ); } \ No newline at end of file diff --git a/bindings/python/src/mesh_io/mesh_io.cpp b/bindings/python/src/mesh_io/mesh_io.cpp index 41c2da7..ea6374b 100644 --- a/bindings/python/src/mesh_io/mesh_io.cpp +++ b/bindings/python/src/mesh_io/mesh_io.cpp @@ -28,6 +28,7 @@ PYBIND11_MODULE( opengeode_io_py_mesh, module ) { module.doc() = "OpenGeode-IO Python binding for mesh"; - pybind11::class_< geode::IOMeshLibrary >( module, "IOMeshLibrary" ) - .def( "initialize", &geode::IOMeshLibrary::initialize ); + pybind11::class_< geode::OpenGeodeIOMeshLibrary >( + module, "OpenGeodeIOMeshLibrary" ) + .def( "initialize", &geode::OpenGeodeIOMeshLibrary::initialize ); } \ No newline at end of file diff --git a/bindings/python/src/model_io/model_io.cpp b/bindings/python/src/model_io/model_io.cpp index 1a082af..c9453c9 100644 --- a/bindings/python/src/model_io/model_io.cpp +++ b/bindings/python/src/model_io/model_io.cpp @@ -28,6 +28,7 @@ PYBIND11_MODULE( opengeode_io_py_model, module ) { module.doc() = "OpenGeode-IO Python binding for model"; - pybind11::class_< geode::IOModelLibrary >( module, "IOModelLibrary" ) - .def( "initialize", &geode::IOModelLibrary::initialize ); + pybind11::class_< geode::OpenGeodeIOModelLibrary >( + module, "OpenGeodeIOModelLibrary" ) + .def( "initialize", &geode::OpenGeodeIOModelLibrary::initialize ); } \ No newline at end of file diff --git a/include/geode/io/image/common.hpp b/include/geode/io/image/common.hpp index 8b67dde..f4067a0 100644 --- a/include/geode/io/image/common.hpp +++ b/include/geode/io/image/common.hpp @@ -26,8 +26,9 @@ #include #include +#include namespace geode { - OPENGEODE_LIBRARY( opengeode_io_image_api, IOImage ); + OPENGEODE_LIBRARY( opengeode_io_image_api, OpenGeodeIO, Image ); } // namespace geode diff --git a/include/geode/io/image/detail/vtk_output.hpp b/include/geode/io/image/detail/vtk_output.hpp index eb51522..60e04ce 100644 --- a/include/geode/io/image/detail/vtk_output.hpp +++ b/include/geode/io/image/detail/vtk_output.hpp @@ -23,7 +23,7 @@ #pragma once -#include +#include #include @@ -54,7 +54,8 @@ namespace geode mesh_( mesh ), type_{ type } { - OPENGEODE_EXCEPTION( file_.good(), + OpenGeodeIOImageException::check( file_.good(), nullptr, + OpenGeodeException::TYPE::data, "[VTKOutput] Error while writing file: ", filename ); } diff --git a/include/geode/io/mesh/common.hpp b/include/geode/io/mesh/common.hpp index 00af1fb..58073f6 100644 --- a/include/geode/io/mesh/common.hpp +++ b/include/geode/io/mesh/common.hpp @@ -26,8 +26,9 @@ #include #include +#include namespace geode { - OPENGEODE_LIBRARY( opengeode_io_mesh_api, IOMesh ); + OPENGEODE_LIBRARY( opengeode_io_mesh_api, OpenGeodeIO, Mesh ); } // namespace geode diff --git a/include/geode/io/mesh/detail/vtk_input.hpp b/include/geode/io/mesh/detail/vtk_input.hpp index ba644d0..6041a74 100644 --- a/include/geode/io/mesh/detail/vtk_input.hpp +++ b/include/geode/io/mesh/detail/vtk_input.hpp @@ -84,12 +84,14 @@ namespace geode VTKInputImpl( std::string_view filename, const char* type ) : file_{ to_string( filename ) }, type_{ type } { - OPENGEODE_EXCEPTION( file_.good(), + OpenGeodeIOMeshException::check( file_.good(), nullptr, + OpenGeodeException::TYPE::data, "[VTKInput] Error while opening file: ", filename ); const auto status = document_.load_file( to_string( filename ).c_str() ); - OPENGEODE_EXCEPTION( status, "[VTKInput] Error ", - status.description(), " while parsing file: ", filename ); + OpenGeodeIOMeshException::check( status, nullptr, + OpenGeodeException::TYPE::internal, status.description(), + "[VTKInput] Error while parsing file: ", filename ); root_ = document_.child( "VTKFile" ); } @@ -122,13 +124,8 @@ namespace geode index_t read_attribute( const pugi::xml_node& piece, std::string_view attribute ) const { - index_t value; - const auto ok = absl::SimpleAtoi( - piece.attribute( attribute.data() ).value(), &value ); - OPENGEODE_EXCEPTION( ok, - "[VTKInput::read_attribute] Failed to read attribute: ", - attribute ); - return value; + return string_to_index( + piece.attribute( attribute.data() ).value() ); } template < typename T > @@ -218,7 +215,9 @@ namespace geode index_t nb_components, index_t offset ) { - OPENGEODE_EXCEPTION( values.size() % nb_components == 0, + OpenGeodeIOMeshException::check( + values.size() % nb_components == 0, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::build_attribute] Number of attribute " "values is not a multiple of number of components" ); if( manager.find_generic_attribute( name ) ) @@ -322,9 +321,10 @@ namespace geode } else { - throw OpenGeodeException( + throw OpenGeodeIOMeshException{ nullptr, + OpenGeodeException::TYPE::internal, "[VTKInput::read_data] Attribute of type ", - data_array_type, " is not supported" ); + data_array_type, " is not supported" }; } } @@ -392,19 +392,22 @@ namespace geode void read_root_attributes() { - OPENGEODE_EXCEPTION( - match( root_.attribute( "type" ).value(), type_ ), + OpenGeodeIOMeshException::check( + match( root_.attribute( "type" ).value(), type_ ), nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::read_root_attributes] VTK File type should be ", type_ ); little_endian_ = match( root_.attribute( "byte_order" ).value(), "LittleEndian" ); - OPENGEODE_EXCEPTION( little_endian_, - "[VTKInput::read_root_attributes] Big " - "Endian not supported" ); + OpenGeodeIOMeshException::check( little_endian_, nullptr, + OpenGeodeException::TYPE::internal, + "[VTKInput::read_root_attributes] Big Endian not " + "supported" ); const auto compressor = root_.attribute( "compressor" ).value(); - OPENGEODE_EXCEPTION( + OpenGeodeIOMeshException::check( std::string_view( compressor ).empty() || match( compressor, "vtkZLibDataCompressor" ), + nullptr, OpenGeodeException::TYPE::internal, "[VTKInput::read_root_attributes] Only " "vtkZLibDataCompressor is supported for now" ); compressed_ = !std::string_view( compressor ).empty(); @@ -412,9 +415,10 @@ namespace geode if( const auto header_type = root_.attribute( "header_type" ) ) { const auto& header_type_value = header_type.value(); - OPENGEODE_EXCEPTION( + OpenGeodeIOMeshException::check( match( header_type_value, "UInt32" ) || match( header_type_value, "UInt64" ), + nullptr, OpenGeodeException::TYPE::internal, "[VTKInput::read_root_attributes] Cannot read VTKFile " "with header_type ", header_type_value, @@ -430,8 +434,9 @@ namespace geode { return; } - OPENGEODE_EXCEPTION( + OpenGeodeIOMeshException::check( match( node.attribute( "encoding" ).value(), "base64" ), + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_appended_data] VTK AppendedData " "section should be encoded" ); appended_data_ = node.child_value(); @@ -502,12 +507,14 @@ namespace geode input.substr( fixed_header_length, nb_characters ); const auto decoded_optional_header = decode_base64( optional_header ); - OPENGEODE_ASSERT( decoded_optional_header.size() - == nb_data_blocks * sizeof( UInt ), - absl::StrCat( "[VTKInput::decode] Optional header size is " - "wrong (should be ", - nb_data_blocks * sizeof( UInt ), " bytes, got ", - decoded_optional_header.size(), " bytes)" ) ); + OpenGeodeIOMeshException::check( + decoded_optional_header.size() + == nb_data_blocks * sizeof( UInt ), + nullptr, OpenGeodeException::TYPE::data, + "[VTKInput::decode] Optional header size is " + "wrong (should be ", + nb_data_blocks * sizeof( UInt ), " bytes, got ", + decoded_optional_header.size(), " bytes)" ); const auto optional_header_values = reinterpret_cast< const UInt* >( decoded_optional_header.c_str() ); @@ -548,7 +555,8 @@ namespace geode &decompressed_data_length, &compressed_data_bytes[cur_data_offset], compressed_data_length ); - OPENGEODE_EXCEPTION( uncompress_result == Z_OK, + OpenGeodeIOMeshException::check( uncompress_result == Z_OK, + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::decode] Error in zlib decompressing data" ); const auto values = reinterpret_cast< const T* >( decompressed_data_bytes.data() ); @@ -567,7 +575,8 @@ namespace geode { std::string bytes; auto decode_status = absl::Base64Unescape( input, &bytes ); - OPENGEODE_EXCEPTION( decode_status, + OpenGeodeIOMeshException::check( decode_status, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::decode_base64] Error in decoding base64 data" ); return bytes; } @@ -581,8 +590,10 @@ namespace geode { T value; const auto ok = ( *string_convert )( string, &value ); - OPENGEODE_EXCEPTION( ok, "[VTKINPUT::read_ascii_data_array]" - " Failed to read value" ); + OpenGeodeIOMeshException::check( ok, nullptr, + OpenGeodeException::TYPE::data, + "[VTKINPUT::read_ascii_data_array] Failed to read " + "value" ); results.push_back( value ); } return results; diff --git a/include/geode/io/mesh/detail/vtk_mesh_input.hpp b/include/geode/io/mesh/detail/vtk_mesh_input.hpp index c2a652b..e8d39a0 100644 --- a/include/geode/io/mesh/detail/vtk_mesh_input.hpp +++ b/include/geode/io/mesh/detail/vtk_mesh_input.hpp @@ -35,6 +35,7 @@ #include #include +#include #include @@ -136,9 +137,10 @@ namespace geode absl::FixedArray< Point3D > get_points( const std::vector< T >& coords ) { - OPENGEODE_ASSERT( coords.size() % 3 == 0, - "[VTKInput::get_points] Number of " - "coordinates is not multiple of 3" ); + OpenGeodeIOMeshException::check( coords.size() % 3 == 0, + nullptr, OpenGeodeException::TYPE::data, + "[VTKInput::get_points] Number of coordinates is not " + "multiple of 3" ); const auto nb_points = coords.size() / 3; absl::FixedArray< Point3D > points( nb_points ); for( const auto p : Range{ nb_points } ) @@ -159,11 +161,14 @@ namespace geode const auto nb_components = this->read_attribute( points, "NumberOfComponents" ); const auto type = points.attribute( "type" ).value(); - OPENGEODE_EXCEPTION( this->match( type, "Float32" ) - || this->match( type, "Float64" ), + OpenGeodeIOMeshException::check( + this->match( type, "Float32" ) + || this->match( type, "Float64" ), + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_points] Cannot read points of type ", type, ". Only Float32 and Float64 are accepted" ); - OPENGEODE_EXCEPTION( nb_components == 3, + OpenGeodeIOMeshException::check( nb_components == 3, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::read_points] Trying to import 2D VTK object " "into a 3D Surface is not allowed" ); const auto format = points.attribute( "format" ).value(); @@ -187,7 +192,9 @@ namespace geode absl::RemoveExtraAsciiWhitespace( &string ); const auto coords = read_ascii_coordinates( string, nb_points ); - OPENGEODE_ASSERT( coords.size() == 3 * nb_points, + OpenGeodeIOMeshException::check( + coords.size() == 3 * nb_points, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::read_points] Wrong number of " "coordinates" ); return get_points( coords ); @@ -206,8 +213,8 @@ namespace geode std::string_view coords_string, index_t nb_points ) { const auto coords = this->template decode< T >( coords_string ); - geode_unused( nb_points ); - OPENGEODE_ASSERT( coords.size() == 3 * nb_points, + OpenGeodeIOMeshException::check( coords.size() == 3 * nb_points, + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_points] Wrong number of coordinates" ); return get_points( coords ); } @@ -219,12 +226,7 @@ namespace geode results.reserve( 3 * nb_points ); for( auto string : absl::StrSplit( coords, ' ' ) ) { - double coord; - const auto ok = absl::SimpleAtod( string, &coord ); - OPENGEODE_EXCEPTION( ok, - "[VTKInput::read_ascii_coordinates] Failed to read " - "coordinate" ); - results.push_back( coord ); + results.push_back( string_to_double( string ) ); } return results; } diff --git a/include/geode/io/mesh/detail/vtu_hybrid_output.hpp b/include/geode/io/mesh/detail/vtu_hybrid_output.hpp index 477fc86..6663a1a 100644 --- a/include/geode/io/mesh/detail/vtu_hybrid_output.hpp +++ b/include/geode/io/mesh/detail/vtu_hybrid_output.hpp @@ -28,6 +28,8 @@ #include +#include + namespace geode { FORWARD_DECLARATION_DIMENSION_CLASS( HybridSolid ); diff --git a/include/geode/io/mesh/detail/vtu_input_impl.hpp b/include/geode/io/mesh/detail/vtu_input_impl.hpp index a53dfa9..e51eb9c 100644 --- a/include/geode/io/mesh/detail/vtu_input_impl.hpp +++ b/include/geode/io/mesh/detail/vtu_input_impl.hpp @@ -53,25 +53,27 @@ namespace geode if( this->match( data.attribute( "Name" ).value(), "offsets" ) ) { - OPENGEODE_EXCEPTION( + OpenGeodeIOMeshException::check( this->match( data.attribute( "type" ).value(), "Int64" ), + nullptr, OpenGeodeException::TYPE::data, "[VTUInputImpl::read_cells] Wrong offset type, " "supports only Int64" ); offsets_values = this->template read_integer_data_array< int64_t >( data ); - OPENGEODE_ASSERT( offsets_values.size() == nb_cells, + OpenGeodeIOMeshException::assertion( + offsets_values.size() == nb_cells, "[VTUInputImpl::read_cells] Wrong number of " "offsets" ); - geode_unused( nb_cells ); } else if( this->match( data.attribute( "Name" ).value(), "connectivity" ) ) { - OPENGEODE_EXCEPTION( + OpenGeodeIOMeshException::check( this->match( data.attribute( "type" ).value(), "Int64" ), + nullptr, OpenGeodeException::TYPE::data, "[VTUInputImpl::read_cells] Wrong connectivity " "type, supports only Int64" ); connectivity_values = @@ -102,13 +104,14 @@ namespace geode } else { - throw OpenGeodeException( - "[VTUInputImpl::read_cells] Wrong types type" ); + throw OpenGeodeIOMeshException{ nullptr, + OpenGeodeException::TYPE::data, + "[VTUInputImpl::read_cells] Wrong types type" }; } - OPENGEODE_ASSERT( types_values.size() == nb_cells, + OpenGeodeIOMeshException::assertion( + types_values.size() == nb_cells, "[VTUInputImpl::read_cells] Wrong number of " "types" ); - geode_unused( nb_cells ); } } return std::tuple{ this->get_cell_vertices( diff --git a/include/geode/io/mesh/internal/assimp_input.hpp b/include/geode/io/mesh/internal/assimp_input.hpp index 6b233b8..0026947 100644 --- a/include/geode/io/mesh/internal/assimp_input.hpp +++ b/include/geode/io/mesh/internal/assimp_input.hpp @@ -42,7 +42,9 @@ namespace geode explicit AssimpMeshInput( std::string_view filename ) : file_( filename ) { - OPENGEODE_EXCEPTION( std::ifstream{ to_string( file_ ) }.good(), + OpenGeodeIOMeshException::check( + std::ifstream{ to_string( file_ ) }.good(), nullptr, + OpenGeodeException::TYPE::data, "[AssimpMeshInput] Error while opening file: ", file_ ); } diff --git a/include/geode/io/mesh/internal/assimp_output.hpp b/include/geode/io/mesh/internal/assimp_output.hpp index 178e574..bafc89e 100644 --- a/include/geode/io/mesh/internal/assimp_output.hpp +++ b/include/geode/io/mesh/internal/assimp_output.hpp @@ -32,6 +32,8 @@ #include +#include + namespace geode { namespace internal @@ -47,7 +49,9 @@ namespace geode surface_mesh_( surface_mesh ), export_id_{ assimp_export_id } { - OPENGEODE_EXCEPTION( std::ofstream{ to_string( file_ ) }.good(), + OpenGeodeIOMeshException::check( + std::ofstream{ to_string( file_ ) }.good(), nullptr, + OpenGeodeException::TYPE::data, "[AssimpMeshOutput] Error while opening file: ", file_ ); } @@ -63,7 +67,8 @@ namespace geode Assimp::Exporter exporter; const auto status = exporter.Export( &assimp_scene_, to_string( export_id_ ), to_string( file_ ) ); - OPENGEODE_EXCEPTION( status == AI_SUCCESS, + OpenGeodeIOMeshException::check( status == AI_SUCCESS, nullptr, + OpenGeodeException::TYPE::internal, "[AssimpMeshOutput::write_file] Export in file \"", file_, "\" has failed." ); } diff --git a/include/geode/io/model/common.hpp b/include/geode/io/model/common.hpp index f1bf54a..fbd8d63 100644 --- a/include/geode/io/model/common.hpp +++ b/include/geode/io/model/common.hpp @@ -26,8 +26,9 @@ #include #include +#include namespace geode { - OPENGEODE_LIBRARY( opengeode_io_model_api, IOModel ); + OPENGEODE_LIBRARY( opengeode_io_model_api, OpenGeodeIO, Model ); } // namespace geode diff --git a/include/geode/io/model/detail/vtm_output.hpp b/include/geode/io/model/detail/vtm_output.hpp index 0750904..de45090 100644 --- a/include/geode/io/model/detail/vtm_output.hpp +++ b/include/geode/io/model/detail/vtm_output.hpp @@ -52,6 +52,7 @@ #include #include +#include namespace geode { @@ -304,9 +305,10 @@ namespace geode } else { - throw OpenGeodeException( + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::internal, "[Surfaces::save_surfaces] Cannot find the " - "explicit SurfaceMesh type" ); + "explicit SurfaceMesh type" }; } } ); } @@ -320,9 +322,9 @@ namespace geode } private: - DEBUG_CONST std::string files_directory_; + std::string files_directory_; std::vector< std::string > files_; - DEBUG_CONST std::string prefix_; + std::string prefix_; }; } // namespace detail } // namespace geode \ No newline at end of file diff --git a/include/geode/io/model/internal/gid_output.hpp b/include/geode/io/model/internal/gid_output.hpp index 0cb5727..6034e48 100644 --- a/include/geode/io/model/internal/gid_output.hpp +++ b/include/geode/io/model/internal/gid_output.hpp @@ -28,6 +28,8 @@ #include +#include + namespace geode::internal { class GIDOutput final : public BRepOutput diff --git a/include/geode/io/model/internal/msh_common.hpp b/include/geode/io/model/internal/msh_common.hpp index debfc88..06dd07d 100644 --- a/include/geode/io/model/internal/msh_common.hpp +++ b/include/geode/io/model/internal/msh_common.hpp @@ -131,7 +131,8 @@ namespace geode nb_vertices_( nb_vertices ), vertex_ids_str_( vertex_ids ) { - OPENGEODE_EXCEPTION( elementary_entity_id > 0, + OpenGeodeIOModelException::check( elementary_entity_id > 0, + nullptr, OpenGeodeException::TYPE::data, "[GMSHElement] GMSH tag for elementary entity " "(second tag) should not be null" ); try diff --git a/include/geode/io/model/internal/svg_input.hpp b/include/geode/io/model/internal/svg_input.hpp index 8e25f3d..b5c5a7a 100644 --- a/include/geode/io/model/internal/svg_input.hpp +++ b/include/geode/io/model/internal/svg_input.hpp @@ -25,6 +25,8 @@ #include +#include + namespace geode { namespace internal diff --git a/include/geode/io/project.hpp b/include/geode/io/project.hpp new file mode 100644 index 0000000..28f12cc --- /dev/null +++ b/include/geode/io/project.hpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 - 2026 Geode-solutions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#pragma once + +#include + +namespace geode +{ + class OpenGeodeIOException : public OpenGeodeException + { + protected: + using OpenGeodeException::OpenGeodeException; + }; +} // namespace geode diff --git a/src/geode/io/image/common.cpp b/src/geode/io/image/common.cpp index bdfe970..7b28bf8 100644 --- a/src/geode/io/image/common.cpp +++ b/src/geode/io/image/common.cpp @@ -71,7 +71,7 @@ namespace namespace geode { - OPENGEODE_LIBRARY_IMPLEMENTATION( IOImage ) + OPENGEODE_LIBRARY_IMPLEMENTATION( OpenGeodeIO, Image ) { OpenGeodeImageLibrary::initialize(); register_raster_input(); diff --git a/src/geode/io/image/gdal_file.cpp b/src/geode/io/image/gdal_file.cpp index 4030a32..2da53c5 100644 --- a/src/geode/io/image/gdal_file.cpp +++ b/src/geode/io/image/gdal_file.cpp @@ -40,8 +40,9 @@ namespace geode : dataset_{ GDALDataset::Open( geode::to_string( filename ).c_str(), GDAL_OF_READONLY ) } { - OPENGEODE_EXCEPTION( - dataset_, "[GDALFile] Failed to open file ", filename ); + OpenGeodeIOImageException::check( dataset_ != nullptr, nullptr, + OpenGeodeException::TYPE::data, + "[GDALFile] Failed to open file ", filename ); } GDALDataset& dataset() @@ -54,7 +55,8 @@ namespace geode std::array< double, 6 > geo_transform; const auto status = dataset_->GetGeoTransform( geo_transform.data() ); - OPENGEODE_EXCEPTION( status == CE_None, + OpenGeodeIOImageException::check( status == CE_None, nullptr, + OpenGeodeException::TYPE::data, "Failed to read geotransform from GDALDataset" ); Point2D origin; Vector2D x_direction; diff --git a/src/geode/io/image/raster_image_input.cpp b/src/geode/io/image/raster_image_input.cpp index b83e01f..10a0b67 100644 --- a/src/geode/io/image/raster_image_input.cpp +++ b/src/geode/io/image/raster_image_input.cpp @@ -46,7 +46,8 @@ namespace gdal_data.GetRasterBand( component ) ->RasterIO( GF_Read, 0, 0, width, height, values.data(), width, height, GDT_Byte, 0, 0 ); - OPENGEODE_EXCEPTION( status == CE_None, + geode::OpenGeodeIOImageException::check( status == CE_None, nullptr, + geode::OpenGeodeException::TYPE::data, "[ImageInputImpl] Failed to read color component" ); return values; } diff --git a/src/geode/io/mesh/assimp_input.cpp b/src/geode/io/mesh/assimp_input.cpp index f772f55..3c71f30 100644 --- a/src/geode/io/mesh/assimp_input.cpp +++ b/src/geode/io/mesh/assimp_input.cpp @@ -95,7 +95,8 @@ namespace geode Assimp::Importer importer; const auto* assimp_scene = importer.ReadFile( to_string( file_ ), 0 ); - OPENGEODE_EXCEPTION( assimp_scene, "[AssimpMeshInput::read_file] ", + OpenGeodeIOMeshException::check( assimp_scene, nullptr, + OpenGeodeException::TYPE::data, "[AssimpMeshInput::read_file] ", importer.GetErrorString() ); read_materials( assimp_scene ); read_meshes( assimp_scene ); diff --git a/src/geode/io/mesh/common.cpp b/src/geode/io/mesh/common.cpp index 79c5786..d323eef 100644 --- a/src/geode/io/mesh/common.cpp +++ b/src/geode/io/mesh/common.cpp @@ -266,10 +266,10 @@ namespace namespace geode { - OPENGEODE_LIBRARY_IMPLEMENTATION( IOMesh ) + OPENGEODE_LIBRARY_IMPLEMENTATION( OpenGeodeIO, Mesh ) { OpenGeodeMeshLibrary::initialize(); - IOImageLibrary::initialize(); + OpenGeodeIOImageLibrary::initialize(); GDALAllRegister(); register_edged_curve_input(); diff --git a/src/geode/io/mesh/obj_input.cpp b/src/geode/io/mesh/obj_input.cpp index 7c3f82e..b961e46 100644 --- a/src/geode/io/mesh/obj_input.cpp +++ b/src/geode/io/mesh/obj_input.cpp @@ -47,7 +47,8 @@ namespace geode auto OBJInput::additional_files() const -> AdditionalFiles { std::ifstream obj_file{ to_string( filename() ) }; - OPENGEODE_EXCEPTION( obj_file, + OpenGeodeIOMeshException::check( !obj_file.fail(), nullptr, + OpenGeodeException::TYPE::data, "[OBJInput::additional_files] Failed to open file: ", filename() ); const auto mtllib_line = @@ -72,7 +73,8 @@ namespace geode } std::ifstream mtl_file{ mtl_file_path }; - OPENGEODE_EXCEPTION( mtl_file, + OpenGeodeIOMeshException::check( !mtl_file.fail(), nullptr, + OpenGeodeException::TYPE::data, "[OBJInput::additional_files] Failed to open file: ", mtl_file_path ); while( const auto texture_line = diff --git a/src/geode/io/mesh/vtp_input.cpp b/src/geode/io/mesh/vtp_input.cpp index 5171243..11e5a4e 100644 --- a/src/geode/io/mesh/vtp_input.cpp +++ b/src/geode/io/mesh/vtp_input.cpp @@ -70,9 +70,10 @@ namespace if( match( data.attribute( "Name" ).value(), "offsets" ) ) { offsets_values = read_integer_data_array< int64_t >( data ); - OPENGEODE_ASSERT( offsets_values.size() == nb_polygons, + geode::OpenGeodeIOMeshException::assertion( + offsets_values.size() == nb_polygons, nullptr, + geode::OpenGeodeException::TYPE::data, "[VTPInput::read_polygons] Wrong number of offsets" ); - geode_unused( nb_polygons ); } else if( match( data.attribute( "Name" ).value(), "connectivity" ) ) diff --git a/src/geode/io/mesh/vtu_hybrid_output.cpp b/src/geode/io/mesh/vtu_hybrid_output.cpp index 2dc8b9e..1c41a79 100644 --- a/src/geode/io/mesh/vtu_hybrid_output.cpp +++ b/src/geode/io/mesh/vtu_hybrid_output.cpp @@ -51,7 +51,8 @@ namespace const auto nb_vertices = this->mesh().nb_polyhedron_vertices( p ); const auto vtk_type = geode::detail::VTK_NB_VERTICES_TO_CELL_TYPE[nb_vertices]; - OPENGEODE_EXCEPTION( vtk_type != 0, + geode::OpenGeodeIOMeshException::check( vtk_type != 0, nullptr, + geode::OpenGeodeException::TYPE::data, "[VTUHybridOutputImpl::write_vtk_cell] Polyhedron with ", nb_vertices, " vertices not supported" ); absl::StrAppend( &cell_types, vtk_type, " " ); diff --git a/src/geode/io/model/common.cpp b/src/geode/io/model/common.cpp index f3f31bb..c0c1cf1 100644 --- a/src/geode/io/model/common.cpp +++ b/src/geode/io/model/common.cpp @@ -75,10 +75,10 @@ namespace namespace geode { - OPENGEODE_LIBRARY_IMPLEMENTATION( IOModel ) + OPENGEODE_LIBRARY_IMPLEMENTATION( OpenGeodeIO, Model ) { OpenGeodeModelLibrary::initialize(); - IOMeshLibrary::initialize(); + OpenGeodeIOMeshLibrary::initialize(); register_brep_input(); register_section_input(); diff --git a/src/geode/io/model/gid_output.cpp b/src/geode/io/model/gid_output.cpp index b43ef57..518dabd 100644 --- a/src/geode/io/model/gid_output.cpp +++ b/src/geode/io/model/gid_output.cpp @@ -76,7 +76,8 @@ namespace GIDOutputImpl( std::string_view filename, const geode::BRep& brep ) : file_{ geode::to_string( filename ) }, brep_( brep ) { - OPENGEODE_EXCEPTION( file_.good(), + geode::OpenGeodeIOModelException::check( file_.good(), nullptr, + geode::OpenGeodeException::TYPE::data, "[GIDOutput] Error while opening file: ", filename ); } diff --git a/src/geode/io/model/msh_input.cpp b/src/geode/io/model/msh_input.cpp index 9fc948c..1903aa1 100644 --- a/src/geode/io/model/msh_input.cpp +++ b/src/geode/io/model/msh_input.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ #include #include +#include #include namespace @@ -69,7 +71,8 @@ namespace brep_( brep ), builder_{ brep } { - OPENGEODE_EXCEPTION( file_.good(), + geode::OpenGeodeIOModelException::check( file_.good(), nullptr, + geode::OpenGeodeException::TYPE::data, "[MSHInput] Error while opening file: ", filename ); first_read( filename ); } @@ -94,9 +97,10 @@ namespace } else { - OPENGEODE_ASSERT_NOT_REACHED( + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_file] Only MSH file format " - "versions 2 and 4 are supported for now." ); + "versions 2 and 4 are supported for now." }; } } @@ -184,16 +188,7 @@ namespace void check_keyword( const std::string& keyword ) { - check_keyword( file_, keyword ); - } - - void check_keyword( std::ifstream& reader, const std::string& keyword ) - { - std::string line; - std::getline( reader, line ); - OPENGEODE_EXCEPTION( geode::string_starts_with( line, keyword ), - "[MSHInput::check_keyword] Line should starts with \"", keyword, - "\"" ); + geode::check_keyword( file_, keyword ); } void go_to_section( const std::string& section_header ) @@ -206,37 +201,38 @@ namespace return; } } - throw geode::OpenGeodeException{ - "[MSHInput::go_to_section] Cannot find the section " - + section_header - }; + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::data, + "[MSHInput::go_to_section] Cannot find the section ", + section_header }; } void set_msh_version( const std::string& line ) { const auto header_tokens = geode::string_split( line ); - const auto ok = absl::SimpleAtod( header_tokens[0], &version_ ); - OPENGEODE_EXCEPTION( ok, "[MSHInput::set_msh_version] Error while " - "reading file version" ); - OPENGEODE_EXCEPTION( version() == 2 || version() == 4, + version_ = geode::string_to_double( header_tokens[0] ); + geode::OpenGeodeIOModelException::check( + version() == 2 || version() == 4, nullptr, + geode::OpenGeodeException::TYPE::data, "[MSHInput::set_msh_version] Only MSH file format " "versions 2 and 4 are supported for now." ); if( geode::string_to_index( header_tokens[1] ) != 0 ) { binary_ = false; - throw geode::OpenGeodeException{ "[MSHInput::set_msh_version]" - " Binary format is not " - "supported for now." }; + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::internal, + "[MSHInput::set_msh_version] Binary format is not " + "supported for now." }; } } void read_header( std::ifstream& reader ) { - check_keyword( reader, "$MeshFormat" ); + geode::check_keyword( reader, "$MeshFormat" ); std::string line; std::getline( reader, line ); set_msh_version( line ); - check_keyword( reader, "$EndMeshFormat" ); + geode::check_keyword( reader, "$EndMeshFormat" ); read_section_names( reader ); } @@ -303,14 +299,9 @@ namespace for( const auto b : geode::Range{ geode::string_to_index( tokens.at( 8 + nb_physical_tags ) ) } ) { - geode::signed_index_t boundary_msh_id; - const auto ok = - absl::SimpleAtoi( tokens.at( 9 + nb_physical_tags + b ), - &boundary_msh_id ); - OPENGEODE_EXCEPTION( ok, - "[MSHInput::create_lines] " - "Error while reading boundary entity index" ); - boundary_msh_id = std::abs( boundary_msh_id ); + const auto boundary_msh_id = + std::abs( geode::string_to_double( + tokens.at( 9 + nb_physical_tags + b ) ) ); builder_.add_corner_line_boundary_relationship( brep_.corner( gmsh_id2uuids_.elementary_ids.at( { geode::Corner3D::component_type_static(), @@ -343,13 +334,8 @@ namespace for( const auto b : geode::Range{ geode::string_to_index( tokens.at( 8 + nb_physical_tags ) ) } ) { - geode::signed_index_t boundary_msh_id; - const auto ok = - absl::SimpleAtoi( tokens.at( 9 + nb_physical_tags + b ), - &boundary_msh_id ); - OPENGEODE_EXCEPTION( ok, - "[MSHInput::create_surfaces] " - "Error while reading boundary entity index" ); + const auto boundary_msh_id = geode::string_to_double( + tokens.at( 9 + nb_physical_tags + b ) ); auto it = boundary_counter.emplace( static_cast< geode::index_t >( std::abs( boundary_msh_id ) ), @@ -372,7 +358,9 @@ namespace } else { - OPENGEODE_ASSERT( boundary.second == 2, + geode::OpenGeodeIOModelException::check( + boundary.second == 2, nullptr, + geode::OpenGeodeException::TYPE::data, "[MSHInput::create_surfaces] Wrong Surface/Line " "relationship" ); builder_.add_line_surface_internal_relationship( @@ -404,14 +392,8 @@ namespace for( const auto b : geode::Range{ geode::string_to_index( tokens.at( 8 + nb_physical_tags ) ) } ) { - geode::signed_index_t boundary_msh_id; - const auto ok = - absl::SimpleAtoi( tokens.at( 9 + nb_physical_tags + b ), - &boundary_msh_id ); - OPENGEODE_EXCEPTION( ok, - "[MSHInput::create_blocks] " - "Error while reading boundary entity index" ); - boundary_msh_id = std::abs( boundary_msh_id ); + const auto boundary_msh_id = std::abs( geode::string_to_int( + tokens.at( 9 + nb_physical_tags + b ) ) ); builder_.add_surface_block_boundary_relationship( brep_.surface( gmsh_id2uuids_.elementary_ids.at( { geode::Surface3D::component_type_static(), @@ -426,17 +408,9 @@ namespace std::string_view y_str, std::string_view z_str ) { - double x, y, z; - auto ok = absl::SimpleAtod( x_str, &x ); - OPENGEODE_EXCEPTION( ok, "[MSHInput::read_node_coordinates] " - "Error while reading node coordinates" ); - ok = absl::SimpleAtod( y_str, &y ); - OPENGEODE_EXCEPTION( ok, "[MSHInput::read_node_coordinates] " - "Error while reading node coordinates" ); - ok = absl::SimpleAtod( z_str, &z ); - OPENGEODE_EXCEPTION( ok, "[MSHInput::read_node_coordinates] " - "Error while reading node coordinates" ); - return geode::Point3D{ { x, y, z } }; + return geode::Point3D{ { geode::string_to_double( x_str ), + geode::string_to_double( y_str ), + geode::string_to_double( z_str ) } }; } void read_node_section_v2() @@ -479,8 +453,9 @@ namespace geode::string_to_index( tokens.at( 1 ) ); const auto min_node_id = geode::string_to_index( tokens.at( 2 ) ); const auto max_node_id = geode::string_to_index( tokens.at( 3 ) ); - OPENGEODE_EXCEPTION( - min_node_id == 1 && max_node_id == nb_total_nodes, + geode::OpenGeodeIOModelException::check( + min_node_id == 1 && max_node_id == nb_total_nodes, nullptr, + geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_node_section_v4] Non continuous node indexing " "is not supported for now" ); nodes_.resize( nb_total_nodes ); @@ -500,7 +475,9 @@ namespace std::getline( file_, line ); const auto tokens = geode::string_split( line ); const auto nb_nodes = geode::string_to_index( tokens.at( 3 ) ); - OPENGEODE_EXCEPTION( geode::string_to_index( tokens.at( 2 ) ) == 0, + geode::OpenGeodeIOModelException::check( + geode::string_to_index( tokens.at( 2 ) ) == 0, nullptr, + geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_node_group] Parametric node coordinates " "is not supported for now" ); absl::FixedArray< geode::index_t > node_ids( nb_nodes ); @@ -540,9 +517,10 @@ namespace { const auto tokens = geode::string_split( line ); geode::index_t t{ 0 }; - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOModelException::check( expected_element_id == geode::string_to_index( tokens.at( t++ ) ), + nullptr, geode::OpenGeodeException::TYPE::data, "[MSHInput::read_element] Element indices should be " "continuous." ); @@ -551,9 +529,10 @@ namespace geode::string_to_index( tokens.at( t++ ) ); // Tags const auto nb_tags = geode::string_to_index( tokens.at( t++ ) ); - OPENGEODE_EXCEPTION( nb_tags >= 2, "[MSHInput::read_element] " - "Number of tags for an element " - "should be at least 2." ); + geode::OpenGeodeIOModelException::check( nb_tags >= 2, nullptr, + geode::OpenGeodeException::TYPE::data, + "[MSHInput::read_element] Number of tags for an element should " + "be at least 2." ); const auto physical_entity = geode::string_to_index( tokens.at( t++ ) ); const auto elementary_entity = @@ -581,8 +560,9 @@ namespace geode::string_to_index( tokens.at( 2 ) ); const auto max_element_id = geode::string_to_index( tokens.at( 3 ) ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOModelException::check( min_element_id == 1 && max_element_id == nb_total_elements, + nullptr, geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_element_section_v4] Non continuous element " "indexing is not supported for now" ); for( const auto unused : @@ -730,7 +710,8 @@ namespace { const auto edges = line.mesh().edges_around_vertex( old_line_vertex_id ); - OPENGEODE_ASSERT( edges.size() == 1, + geode::OpenGeodeIOModelException::check( edges.size() == 1, nullptr, + geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "edge pointing to each vertex at this point." ); mesh_builder.set_edge_vertex( edges[0], new_line_vertex_id ); @@ -743,7 +724,8 @@ namespace { const auto polygons = surface.mesh().polygons_around_vertex( old_surface_vertex_id ); - OPENGEODE_ASSERT( polygons.size() == 1, + geode::OpenGeodeIOModelException::check( polygons.size() == 1, + nullptr, geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "polygon pointing to each vertex at this point." ); mesh_builder.set_polygon_vertex( @@ -757,7 +739,8 @@ namespace { const auto polyhedra = block.mesh().polyhedra_around_vertex( old_block_vertex_id ); - OPENGEODE_ASSERT( polyhedra.size() == 1, + geode::OpenGeodeIOModelException::check( polyhedra.size() == 1, + nullptr, geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "polyhedron pointing to each vertex at this point." ); mesh_builder.set_polyhedron_vertex( diff --git a/src/geode/io/model/msh_output.cpp b/src/geode/io/model/msh_output.cpp index 6ae6deb..6af50f3 100644 --- a/src/geode/io/model/msh_output.cpp +++ b/src/geode/io/model/msh_output.cpp @@ -45,6 +45,7 @@ #include #include +#include #include namespace @@ -57,7 +58,8 @@ namespace MSHOutputImpl( std::string_view filename, const geode::BRep& brep ) : file_{ geode::to_string( filename ) }, brep_( brep ) { - OPENGEODE_EXCEPTION( file_.good(), + geode::OpenGeodeIOModelException::check( file_.good(), nullptr, + geode::OpenGeodeException::TYPE::data, "[MSHOutput] Error while opening file: ", filename ); } diff --git a/src/geode/io/model/svg_input.cpp b/src/geode/io/model/svg_input.cpp index 061dd63..ef59caa 100644 --- a/src/geode/io/model/svg_input.cpp +++ b/src/geode/io/model/svg_input.cpp @@ -54,12 +54,14 @@ namespace section_( section ), builder_{ section } { - OPENGEODE_EXCEPTION( file_.good(), + geode::OpenGeodeIOModelException::check( file_.good(), nullptr, + geode::OpenGeodeException::TYPE::data, "[SVGInput] Error while opening file: ", filename ); const auto loaded = document_.load_file( geode::to_string( filename ).c_str() ); - OPENGEODE_EXCEPTION( - loaded, "[SVGInput] Error while parsing file: ", filename ); + geode::OpenGeodeIOModelException::check( loaded, nullptr, + geode::OpenGeodeException::TYPE::internal, + "[SVGInput] Error while parsing file: ", filename ); } void read_file() @@ -133,7 +135,8 @@ namespace [[nodiscard]] geode::Point2D apply( const geode::Point2D& position, const std::vector< double >& params ) const { - OPENGEODE_ASSERT( params.size() == get_nb_params(), + geode::OpenGeodeIOModelException::assertion( + params.size() == get_nb_params(), "[SVGInput::Command::apply] Wrong number of parameters" ); if( letter == 'm' || letter == 'l' ) { @@ -147,9 +150,10 @@ namespace { return apply_v( position, params ); } - throw geode::OpenGeodeException( + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::internal, "[SVGInput::Command::apply] Command not supported: ", - std::string{ letter } ); + std::string{ letter } }; return position; } @@ -244,11 +248,11 @@ namespace } catch( std::invalid_argument& /*unused*/ ) { - throw geode::OpenGeodeException{ + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::data, "[SVGInputImpl::get_params] Path token is not a " - "number: " - + token - }; + "number: ", + token }; } } return params; @@ -261,9 +265,10 @@ namespace const auto& token = tokens[token_id]; if( string_isalpha( token ) ) { - OPENGEODE_EXCEPTION( token.size() == 1, - "[SVGInputImpl::update_command] Command " - "should be single letter" ); + geode::OpenGeodeIOModelException::check( token.size() == 1, + nullptr, geode::OpenGeodeException::TYPE::data, + "[SVGInputImpl::update_command] Command should be single " + "letter" ); command.update( *token.c_str() ); return token_id + 1; } diff --git a/src/geode/io/model/vtm_brep_output.cpp b/src/geode/io/model/vtm_brep_output.cpp index 8358d85..444eaec 100644 --- a/src/geode/io/model/vtm_brep_output.cpp +++ b/src/geode/io/model/vtm_brep_output.cpp @@ -139,9 +139,10 @@ namespace } else { - throw geode::OpenGeodeException( + throw geode::OpenGeodeIOModelException{ nullptr, + geode::OpenGeodeException::TYPE::internal, "[Blocks::save_blocks] Cannot find the explicit " - "SolidMesh type." ); + "SolidMesh type." }; } } ); } diff --git a/tests/image/test-raster-image.cpp b/tests/image/test-raster-image.cpp index 83ceddc..a018e1c 100644 --- a/tests/image/test-raster-image.cpp +++ b/tests/image/test-raster-image.cpp @@ -45,14 +45,15 @@ void test_jpg_from_gimp_input() absl::StrCat( geode::DATA_PATH, "grid_image_from_gimp.jpg" ) ); auto grid = geode::load_regular_grid< 2 >( absl::StrCat( geode::DATA_PATH, "grid_from_gimp_image.og_rgd2d" ) ); - OPENGEODE_EXCEPTION( raster.nb_cells() == grid->nb_cells(), + geode::OpenGeodeIOImageException::test( + raster.nb_cells() == grid->nb_cells(), "[TEST] Wrong number of cells." ); auto comparison_attribute = grid->cell_attribute_manager().find_attribute< geode::RGBColor >( "RGB_data" ); for( const auto cell_id : geode::Range{ raster.nb_cells() } ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOImageException::test( raster.color( cell_id ) == comparison_attribute->value( cell_id ), "[TEST] Wrong color value for pixel ", cell_id, " on image loaded from grid_image_from_gimp.jpg." ); @@ -67,14 +68,15 @@ void test_jpg_from_paraview_input() absl::StrCat( geode::DATA_PATH, "grid_image_from_paraview.jpg" ) ); auto grid = geode::load_regular_grid< 2 >( absl::StrCat( geode::DATA_PATH, "grid_from_paraview_image.og_rgd2d" ) ); - OPENGEODE_EXCEPTION( raster.nb_cells() == grid->nb_cells(), + geode::OpenGeodeIOImageException::test( + raster.nb_cells() == grid->nb_cells(), "[TEST] Wrong number of cells." ); auto comparison_attribute = grid->cell_attribute_manager().find_attribute< geode::RGBColor >( "RGB_data" ); for( const auto cell_id : geode::Range{ raster.nb_cells() } ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOImageException::test( raster.color( cell_id ) == comparison_attribute->value( cell_id ), "[TEST] Wrong color value for pixel ", cell_id, " on image loaded from grid_image_from_paraview.jpg." ); @@ -90,14 +92,15 @@ void test_png_input() absl::StrCat( geode::DATA_PATH, "grid_image.png" ) ); auto grid = geode::load_regular_grid< 2 >( absl::StrCat( geode::DATA_PATH, "grid_from_image.og_rgd2d" ) ); - OPENGEODE_EXCEPTION( raster.nb_cells() == grid->nb_cells(), + geode::OpenGeodeIOImageException::test( + raster.nb_cells() == grid->nb_cells(), "[TEST] Wrong number of cells." ); auto comparison_attribute = grid->cell_attribute_manager().find_attribute< geode::RGBColor >( "RGB_data" ); for( const auto cell_id : geode::Range{ raster.nb_cells() } ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOImageException::test( raster.color( cell_id ) == comparison_attribute->value( cell_id ), "[TEST] Wrong color value for pixel ", cell_id, " on image loaded from grid_image.png." ); @@ -112,11 +115,12 @@ void test_tiff_input() absl::StrCat( geode::DATA_PATH, "cea.tiff" ) ); auto ref_raster = geode::load_raster_image< 2 >( absl::StrCat( geode::DATA_PATH, "cea.og_img2d" ) ); - OPENGEODE_EXCEPTION( raster.nb_cells() == ref_raster.nb_cells(), + geode::OpenGeodeIOImageException::test( + raster.nb_cells() == ref_raster.nb_cells(), "[TEST] Wrong number of cells." ); for( const auto cell_id : geode::Range{ ref_raster.nb_cells() } ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOImageException::test( raster.color( cell_id ) == ref_raster.color( cell_id ), "[TEST] Wrong color value for pixel ", cell_id, " on image loaded from reference pixel." ); @@ -130,7 +134,7 @@ int main() try { geode::OpenGeodeMeshLibrary::initialize(); - geode::IOImageLibrary::initialize(); + geode::OpenGeodeIOImageLibrary::initialize(); test_jpg_from_gimp_input(); test_jpg_from_paraview_input(); diff --git a/tests/mesh/test-dot.cpp b/tests/mesh/test-dot.cpp index 7a1e256..8e5c702 100644 --- a/tests/mesh/test-dot.cpp +++ b/tests/mesh/test-dot.cpp @@ -36,7 +36,7 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); auto surface = geode::PolygonalSurface3D::create(); auto builder = geode::PolygonalSurfaceBuilder3D::create( *surface ); diff --git a/tests/mesh/test-dxf.cpp b/tests/mesh/test-dxf.cpp index 6edc63b..5ca468f 100644 --- a/tests/mesh/test-dxf.cpp +++ b/tests/mesh/test-dxf.cpp @@ -36,14 +36,14 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto surface = geode::load_polygonal_surface< 3 >( absl::StrCat( geode::DATA_PATH, "3D_faces.dxf" ) ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 49323, - "[Test] Number of vertices in the loaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 97966, - "[Test] Number of polygons in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 49323, + "Number of vertices in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 97966, + "Number of polygons in the loaded Surface is not correct" ); // Save file const auto output_file_og = diff --git a/tests/mesh/test-gexf.cpp b/tests/mesh/test-gexf.cpp index da1fbb2..fae53f3 100644 --- a/tests/mesh/test-gexf.cpp +++ b/tests/mesh/test-gexf.cpp @@ -36,7 +36,7 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Build graph auto graph = geode::Graph::create(); auto builder = geode::GraphBuilder::create( *graph ); diff --git a/tests/mesh/test-obj.cpp b/tests/mesh/test-obj.cpp index 34b546e..2c6928c 100644 --- a/tests/mesh/test-obj.cpp +++ b/tests/mesh/test-obj.cpp @@ -38,14 +38,14 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto surface = geode::load_polygonal_surface< 3 >( absl::StrCat( geode::DATA_PATH, "TopHat.obj" ) ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 363, - "[Test] Number of vertices in the loaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 380, - "[Test] Number of polygons in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 363, + "Number of vertices in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 380, + "Number of polygons in the loaded Surface is not correct" ); // Save file geode::save_polygonal_surface( @@ -56,11 +56,11 @@ int main() // Reload file auto reloaded_surface = geode::load_polygonal_surface< 3 >( output_file_obj ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 363, - "[Test] Number of vertices in the " + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 363, + "Number of vertices in the " "reloaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 380, - "[Test] Number of polygons in the " + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 380, + "Number of polygons in the " "reloaded Surface is not correct" ); geode::Logger::info( "TEST SUCCESS" ); diff --git a/tests/mesh/test-ply.cpp b/tests/mesh/test-ply.cpp index 2a7eec0..2eb6ae5 100644 --- a/tests/mesh/test-ply.cpp +++ b/tests/mesh/test-ply.cpp @@ -36,14 +36,14 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto surface = geode::load_polygonal_surface< 3 >( absl::StrCat( geode::DATA_PATH, "Armadillo.ply" ) ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 172974, - "[Test] Number of vertices in the loaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 345944, - "[Test] Number of polygons in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 172974, + "Number of vertices in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 345944, + "Number of polygons in the loaded Surface is not correct" ); // Save file const auto output_file_og = @@ -55,11 +55,13 @@ int main() // Reload file auto reloaded_surface = geode::load_polygonal_surface< 3 >( output_file_ply ); - OPENGEODE_EXCEPTION( reloaded_surface->nb_vertices() == 172974, - "[Test] Number of vertices in the reloaded Surface is not " + geode::OpenGeodeIOMeshException::test( + reloaded_surface->nb_vertices() == 172974, + "Number of vertices in the reloaded Surface is not " "correct" ); - OPENGEODE_EXCEPTION( reloaded_surface->nb_polygons() == 345944, - "[Test] Number of polygons in the reloaded Surface is not " + geode::OpenGeodeIOMeshException::test( + reloaded_surface->nb_polygons() == 345944, + "Number of polygons in the reloaded Surface is not " "correct" ); geode::Logger::info( "TEST SUCCESS" ); diff --git a/tests/mesh/test-smesh-curve.cpp b/tests/mesh/test-smesh-curve.cpp index 2f383ef..c784dca 100644 --- a/tests/mesh/test-smesh-curve.cpp +++ b/tests/mesh/test-smesh-curve.cpp @@ -35,15 +35,15 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto curve = geode::load_edged_curve< 3 >( absl::StrCat( geode::DATA_PATH, "curve.smesh" ) ); - OPENGEODE_EXCEPTION( curve->nb_vertices() == 1023, - "[Test] Number of vertices in the " + geode::OpenGeodeIOMeshException::test( curve->nb_vertices() == 1023, + "Number of vertices in the " "loaded EdgedCurve is not correct" ); - OPENGEODE_EXCEPTION( curve->nb_edges() == 1022, - "[Test] Number of edges in the loaded EdgedCurve is not correct" ); + geode::OpenGeodeIOMeshException::test( curve->nb_edges() == 1022, + "Number of edges in the loaded EdgedCurve is not correct" ); geode::Logger::info( "TEST SUCCESS" ); return 0; diff --git a/tests/mesh/test-smesh-trgl.cpp b/tests/mesh/test-smesh-trgl.cpp index 73b190f..86839ef 100644 --- a/tests/mesh/test-smesh-trgl.cpp +++ b/tests/mesh/test-smesh-trgl.cpp @@ -35,14 +35,14 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto surface = geode::load_triangulated_surface< 3 >( absl::StrCat( geode::DATA_PATH, "triangulated.smesh" ) ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 111, - "[Test] Number of vertices in the loaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 186, - "[Test] Number of polygons in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 111, + "Number of vertices in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 186, + "Number of polygons in the loaded Surface is not correct" ); geode::Logger::info( "TEST SUCCESS" ); return 0; diff --git a/tests/mesh/test-stl.cpp b/tests/mesh/test-stl.cpp index 7ba6e36..9ff9fdd 100644 --- a/tests/mesh/test-stl.cpp +++ b/tests/mesh/test-stl.cpp @@ -36,14 +36,14 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); // Load file auto surface = geode::load_triangulated_surface< 3 >( absl::StrCat( geode::DATA_PATH, "thumbwheel.stl" ) ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 525, - "[Test] Number of vertices in the loaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 1027, - "[Test] Number of polygons in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 525, + "Number of vertices in the loaded Surface is not correct" ); + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 1027, + "Number of polygons in the loaded Surface is not correct" ); // Save file geode::save_triangulated_surface( *surface, @@ -54,11 +54,11 @@ int main() // Reload file auto reloaded_surface = geode::load_triangulated_surface< 3 >( output_file_stl ); - OPENGEODE_EXCEPTION( surface->nb_vertices() == 525, - "[Test] Number of vertices in the " + geode::OpenGeodeIOMeshException::test( surface->nb_vertices() == 525, + "Number of vertices in the " "reloaded Surface is not correct" ); - OPENGEODE_EXCEPTION( surface->nb_polygons() == 1027, - "[Test] Number of polygons in the " + geode::OpenGeodeIOMeshException::test( surface->nb_polygons() == 1027, + "Number of polygons in the " "reloaded Surface is not correct" ); geode::Logger::info( "TEST SUCCESS" ); diff --git a/tests/mesh/test-vti.cpp b/tests/mesh/test-vti.cpp index 29194cd..008584d 100644 --- a/tests/mesh/test-vti.cpp +++ b/tests/mesh/test-vti.cpp @@ -63,25 +63,30 @@ void test_regular_grid( const geode::RegularGrid3D& grid ) { geode::save_regular_grid( grid, "test.vti" ); const auto reload_grid = geode::load_regular_grid< 3 >( "test.vti" ); - OPENGEODE_EXCEPTION( grid.nb_cells() == reload_grid->nb_cells(), + geode::OpenGeodeIOMeshException::test( + grid.nb_cells() == reload_grid->nb_cells(), "[TEST] Wrong number of cells." ); - OPENGEODE_EXCEPTION( grid.nb_vertices() == reload_grid->nb_vertices(), + geode::OpenGeodeIOMeshException::test( + grid.nb_vertices() == reload_grid->nb_vertices(), "[TEST] Wrong number of vertices." ); for( const auto d : geode::LRange{ 3 } ) { - OPENGEODE_EXCEPTION( grid.nb_cells_in_direction( d ) - == reload_grid->nb_cells_in_direction( d ), + geode::OpenGeodeIOMeshException::test( + grid.nb_cells_in_direction( d ) + == reload_grid->nb_cells_in_direction( d ), "[TEST] Wrong number of cells in direction ", d ); - OPENGEODE_EXCEPTION( grid.cell_length_in_direction( d ) - == reload_grid->cell_length_in_direction( d ), + geode::OpenGeodeIOMeshException::test( + grid.cell_length_in_direction( d ) + == reload_grid->cell_length_in_direction( d ), "[TEST] Wrong cell length in direction ", d ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( grid.grid_coordinate_system().direction( d ).inexact_equal( reload_grid->grid_coordinate_system().direction( d ) ), "[TEST] Wrong direction in direction ", d ); } - OPENGEODE_EXCEPTION( grid.grid_coordinate_system().origin().inexact_equal( - reload_grid->grid_coordinate_system().origin() ), + geode::OpenGeodeIOMeshException::test( + grid.grid_coordinate_system().origin().inexact_equal( + reload_grid->grid_coordinate_system().origin() ), "[TEST] Wrong origin." ); geode::save_regular_grid( *reload_grid, "test2.vti" ); } @@ -90,26 +95,30 @@ void test_light_regular_grid( const geode::LightRegularGrid3D& grid ) { geode::save_light_regular_grid( grid, "test3.vti" ); const auto reload_grid = geode::load_light_regular_grid< 3 >( "test3.vti" ); - OPENGEODE_EXCEPTION( grid.nb_cells() == reload_grid.nb_cells(), + geode::OpenGeodeIOMeshException::test( + grid.nb_cells() == reload_grid.nb_cells(), "[TEST] Wrong number of cells." ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( grid.nb_grid_vertices() == reload_grid.nb_grid_vertices(), "[TEST] Wrong number of vertices." ); for( const auto d : geode::LRange{ 3 } ) { - OPENGEODE_EXCEPTION( grid.nb_cells_in_direction( d ) - == reload_grid.nb_cells_in_direction( d ), + geode::OpenGeodeIOMeshException::test( + grid.nb_cells_in_direction( d ) + == reload_grid.nb_cells_in_direction( d ), "[TEST] Wrong number of cells in direction ", d ); - OPENGEODE_EXCEPTION( grid.cell_length_in_direction( d ) - == reload_grid.cell_length_in_direction( d ), + geode::OpenGeodeIOMeshException::test( + grid.cell_length_in_direction( d ) + == reload_grid.cell_length_in_direction( d ), "[TEST] Wrong cell length in direction ", d ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( grid.grid_coordinate_system().direction( d ).inexact_equal( reload_grid.grid_coordinate_system().direction( d ) ), "[TEST] Wrong direction in direction ", d ); } - OPENGEODE_EXCEPTION( grid.grid_coordinate_system().origin().inexact_equal( - reload_grid.grid_coordinate_system().origin() ), + geode::OpenGeodeIOMeshException::test( + grid.grid_coordinate_system().origin().inexact_equal( + reload_grid.grid_coordinate_system().origin() ), "[TEST] Wrong origin." ); geode::save_light_regular_grid( reload_grid, "test4.vti" ); } @@ -118,7 +127,7 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); auto grid = geode::RegularGrid3D::create(); auto builder = geode::RegularGridBuilder3D::create( *grid ); diff --git a/tests/mesh/test-vtp.cpp b/tests/mesh/test-vtp.cpp index 94f0498..20e5a7b 100644 --- a/tests/mesh/test-vtp.cpp +++ b/tests/mesh/test-vtp.cpp @@ -38,27 +38,27 @@ void check( const geode::PolygonalSurface3D& surface, absl::Span< const std::string_view > vertex_attributes, absl::Span< const std::string_view > polygon_attributes ) { - OPENGEODE_EXCEPTION( surface.nb_vertices() == test_answers[0], - "[Test] Number of vertices in the loaded Surface is not correct: " + geode::OpenGeodeIOMeshException::test( + surface.nb_vertices() == test_answers[0], + "Number of vertices in the loaded Surface is not correct: " "should be ", test_answers[0], ", get ", surface.nb_vertices() ); - OPENGEODE_EXCEPTION( surface.nb_polygons() == test_answers[1], - "[Test] Number of polygons in the loaded Surface is not correct: " + geode::OpenGeodeIOMeshException::test( + surface.nb_polygons() == test_answers[1], + "Number of polygons in the loaded Surface is not correct: " "should be ", test_answers[1], ", get ", surface.nb_polygons() ); for( const auto& name : vertex_attributes ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( surface.vertex_attribute_manager().attribute_exists( name ), - "[Test] Attribute ", name, - " was not be loaded as attribute on vertices" ); + "Attribute ", name, " was not be loaded as attribute on vertices" ); } for( const auto& name : polygon_attributes ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( surface.polygon_attribute_manager().attribute_exists( name ), - "[Test] Attribute ", name, - " was not be loaded as attribute on polygons" ); + "Attribute ", name, " was not be loaded as attribute on polygons" ); } } @@ -101,7 +101,7 @@ int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); run_test( "dfn1_ascii.vtp", { 187, 10 }, { "FractureSize" }, { "FractureId", "FractureSize", "FractureArea" } ); diff --git a/tests/mesh/test-vtu.cpp b/tests/mesh/test-vtu.cpp index df6c105..4851c1a 100644 --- a/tests/mesh/test-vtu.cpp +++ b/tests/mesh/test-vtu.cpp @@ -42,12 +42,14 @@ void check( const geode::SolidMesh< 3 >& solid, const std::array< geode::index_t, 2 >& test_answers ) { - OPENGEODE_EXCEPTION( solid.nb_vertices() == test_answers[0], - "[Test] Number of vertices in the loaded Solid is not correct: " + geode::OpenGeodeIOMeshException::test( + solid.nb_vertices() == test_answers[0], + "Number of vertices in the loaded Solid is not correct: " "should be ", test_answers[0], ", get ", solid.nb_vertices() ); - OPENGEODE_EXCEPTION( solid.nb_polyhedra() == test_answers[1], - "[Test] Number of polyhedra in the loaded Solid is not correct: " + geode::OpenGeodeIOMeshException::test( + solid.nb_polyhedra() == test_answers[1], + "Number of polyhedra in the loaded Solid is not correct: " "should be ", test_answers[1], ", get ", solid.nb_polyhedra() ); } @@ -55,12 +57,14 @@ void check( const geode::SolidMesh< 3 >& solid, void check( const geode::SurfaceMesh< 3 >& surface, const std::array< geode::index_t, 2 >& test_answers ) { - OPENGEODE_EXCEPTION( surface.nb_vertices() == test_answers[0], - "[Test] Number of vertices in the loaded Surface is not correct: " + geode::OpenGeodeIOMeshException::test( + surface.nb_vertices() == test_answers[0], + "Number of vertices in the loaded Surface is not correct: " "should be ", test_answers[0], ", get ", surface.nb_vertices() ); - OPENGEODE_EXCEPTION( surface.nb_polygons() == test_answers[1], - "[Test] Number of polygons in the loaded Surface is not correct: " + geode::OpenGeodeIOMeshException::test( + surface.nb_polygons() == test_answers[1], + "Number of polygons in the loaded Surface is not correct: " "should be ", test_answers[1], ", get ", surface.nb_polygons() ); } @@ -94,11 +98,11 @@ void run_solid_test( std::string_view filename, auto reload_vtu = geode::load_hybrid_solid< 3 >( output_filename_vtu ); check( *reload_vtu, test_answers ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( std::fabs( geode::is_tetrahedral_solid_loadable< 3 >( file ).value() - loadability ) < geode::GLOBAL_EPSILON, - "[Test] File should be loadable" ); + "File should be loadable" ); } void run_surface_test( std::string_view filename, @@ -115,18 +119,18 @@ void run_surface_test( std::string_view filename, geode::save_triangulated_surface( *surface, absl::StrCat( filename_without_ext, ".og_tsf3d" ) ); - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOMeshException::test( std::fabs( geode::is_triangulated_surface_loadable< 3 >( file ).value() - loadability ) < geode::GLOBAL_EPSILON, - "[Test] File should be loadable" ); + "File should be loadable" ); } int main() { try { - geode::IOMeshLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); geode::Logger::set_level( geode::Logger::LEVEL::debug ); run_solid_test( "cone.vtu", { 580, 2197 }, 0.624858 ); diff --git a/tests/model/test-gid.cpp b/tests/model/test-gid.cpp index 3d1f4a7..4c31c79 100644 --- a/tests/model/test-gid.cpp +++ b/tests/model/test-gid.cpp @@ -54,25 +54,26 @@ namespace void check_count_components( const BrepDescription& brep_description ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_corners() == brep_description.nb_corners, - "[Test] Number of corners is not correct" ); - OPENGEODE_EXCEPTION( + "Number of corners is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_lines() == brep_description.nb_lines, - "[Test] Number of lines is not correct" ); - OPENGEODE_EXCEPTION( + "Number of lines is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_surfaces() == brep_description.nb_surfaces, - "[Test] Number of surfaces is not correct" ); - OPENGEODE_EXCEPTION( + "Number of surfaces is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_blocks() == brep_description.nb_blocks, - "[Test] Number of blocks is not correct" ); + "Number of blocks is not correct" ); } void check_corners( const geode::BRep& brep ) { for( const auto& corner : brep.corners() ) { - OPENGEODE_EXCEPTION( corner.mesh().nb_vertices() == 1, - "[Test] Number of vertices in corners should be 1" ); + geode::OpenGeodeIOModelException::test( + corner.mesh().nb_vertices() == 1, + "Number of vertices in corners should be 1" ); } } void check_lines( const geode::BRep& brep ) @@ -80,10 +81,10 @@ namespace for( const auto& line : brep.lines() ) { const auto& mesh = line.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in lines should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_edges() > 0, - "[Test] Number of edges in lines should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in lines should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_edges() > 0, + "Number of edges in lines should not be null" ); } } geode::index_t count_surface_edge_on_border( @@ -109,12 +110,13 @@ namespace for( const auto& surface : brep.surfaces() ) { const auto& mesh = surface.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in surfaces should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_polygons() > 0, - "[Test] Number of polygons in surfaces should not be null" ); - OPENGEODE_EXCEPTION( count_surface_edge_on_border( mesh ) != 0, - "[Test] No polygon adjacency" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in surfaces should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_polygons() > 0, + "Number of polygons in surfaces should not be null" ); + geode::OpenGeodeIOModelException::test( + count_surface_edge_on_border( mesh ) != 0, + "No polygon adjacency" ); } } geode::index_t count_polyhedron_facet_on_borders( @@ -141,12 +143,13 @@ namespace for( const auto& block : brep.blocks() ) { const auto& mesh = block.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in blocks should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_polyhedra() > 0, - "[Test] Number of polyhedra in blocks should not be null" ); - OPENGEODE_EXCEPTION( count_polyhedron_facet_on_borders( mesh ) != 0, - "[Test] No polyhedron adjacency" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in blocks should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_polyhedra() > 0, + "Number of polyhedra in blocks should not be null" ); + geode::OpenGeodeIOModelException::test( + count_polyhedron_facet_on_borders( mesh ) != 0, + "No polyhedron adjacency" ); } } @@ -185,7 +188,7 @@ int main() { try { - geode::IOModelLibrary::initialize(); + geode::OpenGeodeIOModelLibrary::initialize(); run_test( "mss", &test_brep_mss ); diff --git a/tests/model/test-msh.cpp b/tests/model/test-msh.cpp index 11893cc..e39e19d 100644 --- a/tests/model/test-msh.cpp +++ b/tests/model/test-msh.cpp @@ -54,25 +54,26 @@ namespace void check_count_components( const BrepDescription& brep_description ) { - OPENGEODE_EXCEPTION( + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_corners() == brep_description.nb_corners, - "[Test] Number of corners is not correct" ); - OPENGEODE_EXCEPTION( + "Number of corners is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_lines() == brep_description.nb_lines, - "[Test] Number of lines is not correct" ); - OPENGEODE_EXCEPTION( + "Number of lines is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_surfaces() == brep_description.nb_surfaces, - "[Test] Number of surfaces is not correct" ); - OPENGEODE_EXCEPTION( + "Number of surfaces is not correct" ); + geode::OpenGeodeIOModelException::test( brep_description.brep.nb_blocks() == brep_description.nb_blocks, - "[Test] Number of blocks is not correct" ); + "Number of blocks is not correct" ); } void check_corners( const geode::BRep& brep ) { for( const auto& corner : brep.corners() ) { - OPENGEODE_EXCEPTION( corner.mesh().nb_vertices() == 1, - "[Test] Number of vertices in corners should be 1" ); + geode::OpenGeodeIOModelException::test( + corner.mesh().nb_vertices() == 1, + "Number of vertices in corners should be 1" ); } } void check_lines( const geode::BRep& brep ) @@ -80,10 +81,10 @@ namespace for( const auto& line : brep.lines() ) { const auto& mesh = line.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in lines should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_edges() > 0, - "[Test] Number of edges in lines should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in lines should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_edges() > 0, + "Number of edges in lines should not be null" ); } } geode::index_t count_surface_edge_on_border( @@ -109,12 +110,13 @@ namespace for( const auto& surface : brep.surfaces() ) { const auto& mesh = surface.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in surfaces should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_polygons() > 0, - "[Test] Number of polygons in surfaces should not be null" ); - OPENGEODE_EXCEPTION( count_surface_edge_on_border( mesh ) != 0, - "[Test] No polygon adjacency" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in surfaces should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_polygons() > 0, + "Number of polygons in surfaces should not be null" ); + geode::OpenGeodeIOModelException::test( + count_surface_edge_on_border( mesh ) != 0, + "No polygon adjacency" ); } } geode::index_t count_polyhedron_facet_on_borders( @@ -141,12 +143,13 @@ namespace for( const auto& block : brep.blocks() ) { const auto& mesh = block.mesh(); - OPENGEODE_EXCEPTION( mesh.nb_vertices() > 0, - "[Test] Number of vertices in blocks should not be null" ); - OPENGEODE_EXCEPTION( mesh.nb_polyhedra() > 0, - "[Test] Number of polyhedra in blocks should not be null" ); - OPENGEODE_EXCEPTION( count_polyhedron_facet_on_borders( mesh ) != 0, - "[Test] No polyhedron adjacency" ); + geode::OpenGeodeIOModelException::test( mesh.nb_vertices() > 0, + "Number of vertices in blocks should not be null" ); + geode::OpenGeodeIOModelException::test( mesh.nb_polyhedra() > 0, + "Number of polyhedra in blocks should not be null" ); + geode::OpenGeodeIOModelException::test( + count_polyhedron_facet_on_borders( mesh ) != 0, + "No polyhedron adjacency" ); } } @@ -169,31 +172,39 @@ namespace // Number of component boundaries and incidences for( const auto& c : brep.corners() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( c.id() ) == 0, - "[Test] Number of corner boundary should be 0" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( c.id() ) == 3, - "[Test] Number of corner incidences should be 3" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( c.id() ) == 0, + "Number of corner boundary should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( c.id() ) == 3, + "Number of corner incidences should be 3" ); } for( const auto& l : brep.lines() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( l.id() ) == 2, - "[Test] Number of line boundary should be 2" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( l.id() ) == 2, - "[Test] Number of line incidences should be 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( l.id() ) == 2, + "Number of line boundary should be 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( l.id() ) == 2, + "Number of line incidences should be 2" ); } for( const auto& s : brep.surfaces() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( s.id() ) == 4, - "[Test] Number of surface boundary should be 4" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( s.id() ) == 1, - "[Test] Number of surface incidences should be 1" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( s.id() ) == 4, + "Number of surface boundary should be 4" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( s.id() ) == 1, + "Number of surface incidences should be 1" ); } for( const auto& b : brep.blocks() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( b.id() ) == 6, - "[Test] Number of block boundary should be 6" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( b.id() ) == 0, - "[Test] Number of block incidences should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( b.id() ) == 6, + "Number of block boundary should be 6" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( b.id() ) == 0, + "Number of block incidences should be 0" ); } } @@ -207,34 +218,42 @@ namespace // Number of component boundaries and incidences for( const auto& c : brep.corners() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( c.id() ) == 0, - "[Test] Number of corner boundary should be 0" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( c.id() ) == 4 - || brep.nb_incidences( c.id() ) == 5, - "[Test] Number of corner incidences should be 4 or 5" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( c.id() ) == 0, + "Number of corner boundary should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( c.id() ) == 4 + || brep.nb_incidences( c.id() ) == 5, + "Number of corner incidences should be 4 or 5" ); } for( const auto& l : brep.lines() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( l.id() ) == 2, - "[Test] Number of line boundary should be 2" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( l.id() ) > 1 - && brep.nb_incidences( l.id() ) < 5, - "[Test] Number of line incidences should be 2, 3 or 4" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( l.id() ) == 2, + "Number of line boundary should be 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( l.id() ) > 1 + && brep.nb_incidences( l.id() ) < 5, + "Number of line incidences should be 2, 3 or 4" ); } for( const auto& s : brep.surfaces() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( s.id() ) == 3, - "[Test] Number of surface boundary should be 3" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( s.id() ) == 1 - || brep.nb_incidences( s.id() ) == 2, - "[Test] Number of surface incidences should be 1 or 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( s.id() ) == 3, + "Number of surface boundary should be 3" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( s.id() ) == 1 + || brep.nb_incidences( s.id() ) == 2, + "Number of surface incidences should be 1 or 2" ); } for( const auto& b : brep.blocks() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( b.id() ) == 4, - "[Test] Number of block boundary should be 4" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( b.id() ) == 0, - "[Test] Number of block incidences should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( b.id() ) == 4, + "Number of block boundary should be 4" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( b.id() ) == 0, + "Number of block incidences should be 0" ); } } @@ -248,30 +267,37 @@ namespace // Number of component boundaries and incidences for( const auto& c : brep.corners() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( c.id() ) == 0, - "[Test] Number of corner boundary should be 0" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( c.id() ) == 1 - || brep.nb_incidences( c.id() ) == 2, - "[Test] Number of corner incidences should be 1 or 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( c.id() ) == 0, + "Number of corner boundary should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( c.id() ) == 1 + || brep.nb_incidences( c.id() ) == 2, + "Number of corner incidences should be 1 or 2" ); } for( const auto& l : brep.lines() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( l.id() ) == 2, - "[Test] Number of line boundary should be 2" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( l.id() ) == 1 - || brep.nb_embedding_surfaces( l ) == 1, - "[Test] Number of line incidences should be 1 or embedding in " + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( l.id() ) == 2, + "Number of line boundary should be 2" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( l.id() ) == 1 + || brep.nb_embedding_surfaces( l ) == 1, + "Number of line incidences should be 1 or embedding in " "1 " "surface" ); } for( const auto& s : brep.surfaces() ) { - OPENGEODE_EXCEPTION( brep.nb_boundaries( s.id() ) == 3, - "[Test] Number of surface boundary should be 3" ); - OPENGEODE_EXCEPTION( brep.nb_internal_lines( s ) == 1, - "[Test] Number of surface internal should be 1" ); - OPENGEODE_EXCEPTION( brep.nb_incidences( s.id() ) == 0, - "[Test] Number of surface incidences should be 0" ); + geode::OpenGeodeIOModelException::test( + brep.nb_boundaries( s.id() ) == 3, + "Number of surface boundary should be 3" ); + geode::OpenGeodeIOModelException::test( + brep.nb_internal_lines( s ) == 1, + "Number of surface internal should be 1" ); + geode::OpenGeodeIOModelException::test( + brep.nb_incidences( s.id() ) == 0, + "Number of surface incidences should be 0" ); } } @@ -302,7 +328,7 @@ int main() { try { - geode::IOModelLibrary::initialize(); + geode::OpenGeodeIOModelLibrary::initialize(); run_test( "triangle_internal", &test_brep_internal ); run_test( "cube_v22", &test_brep_cube ); diff --git a/tests/model/test-svg.cpp b/tests/model/test-svg.cpp index 9fb4f0f..7bf1080 100644 --- a/tests/model/test-svg.cpp +++ b/tests/model/test-svg.cpp @@ -55,19 +55,19 @@ geode::index_t nb_closed_lines( const geode::Section& section ) void test_section( const geode::Section& section ) { - OPENGEODE_EXCEPTION( - section.nb_corners() == 31, "[Test] Number of corners is not correct" ); - OPENGEODE_EXCEPTION( - section.nb_lines() == 31, "[Test] Number of lines is not correct" ); - OPENGEODE_EXCEPTION( nb_closed_lines( section ) == 27, - "[Test] Number of closed lines is not correct" ); - OPENGEODE_EXCEPTION( section.nb_surfaces() == 0, - "[Test] Number of surfaces is not correct" ); + geode::OpenGeodeIOModelException::test( + section.nb_corners() == 31, "Number of corners is not correct" ); + geode::OpenGeodeIOModelException::test( + section.nb_lines() == 31, "Number of lines is not correct" ); + geode::OpenGeodeIOModelException::test( nb_closed_lines( section ) == 27, + "Number of closed lines is not correct" ); + geode::OpenGeodeIOModelException::test( + section.nb_surfaces() == 0, "Number of surfaces is not correct" ); for( const auto uv : geode::Range{ section.nb_unique_vertices() } ) { const auto nb_cmv = section.component_mesh_vertices( uv ).size(); - OPENGEODE_EXCEPTION( nb_cmv == 1 || nb_cmv == 3, - "[Test] Wrong number of mesh component " + geode::OpenGeodeIOModelException::test( nb_cmv == 1 || nb_cmv == 3, + "Wrong number of mesh component " "vertices for one unique vertex" ); } } @@ -76,7 +76,7 @@ int main() { try { - geode::IOModelLibrary::initialize(); + geode::OpenGeodeIOModelLibrary::initialize(); // Load file auto section = geode::load_section( diff --git a/tests/model/test-vtm.cpp b/tests/model/test-vtm.cpp index 8b5c543..cba351c 100644 --- a/tests/model/test-vtm.cpp +++ b/tests/model/test-vtm.cpp @@ -40,8 +40,8 @@ int main() { try { - geode::IOMeshLibrary::initialize(); - geode::IOModelLibrary::initialize(); + geode::OpenGeodeIOMeshLibrary::initialize(); + geode::OpenGeodeIOModelLibrary::initialize(); auto brep = geode::load_brep( absl::StrCat( geode::DATA_PATH, "mss.og_brep" ) ); From 4cb89487589feff3f626d53f695cb295926a0337 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 27 Apr 2026 14:18:49 +0200 Subject: [PATCH 2/6] test --- cmake/OpenGeode-IO.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/OpenGeode-IO.cmake b/cmake/OpenGeode-IO.cmake index 7df421c..f015e05 100644 --- a/cmake/OpenGeode-IO.cmake +++ b/cmake/OpenGeode-IO.cmake @@ -53,6 +53,13 @@ if(NOT BUILD_SHARED_LIBS) ) endif() + +install( + FILES include/geode/io/project.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geode/io/project.hpp + COMPONENT public +) + # ------------------------------------------------------------------------------------------------ # Configure the OpenGeode-IO libraries add_subdirectory(src/geode) From df06b71710586d16218acebc9b45809d5c5d4c87 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 27 Apr 2026 16:06:23 +0200 Subject: [PATCH 3/6] fix --- cmake/OpenGeode-IO.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenGeode-IO.cmake b/cmake/OpenGeode-IO.cmake index f015e05..1b44777 100644 --- a/cmake/OpenGeode-IO.cmake +++ b/cmake/OpenGeode-IO.cmake @@ -56,7 +56,7 @@ endif() install( FILES include/geode/io/project.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geode/io/project.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geode/io COMPONENT public ) From 88dfb7141b7b62427ec0fb28e117729258a0d901 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 27 Apr 2026 16:17:23 +0200 Subject: [PATCH 4/6] fix python --- bindings/python/tests/mesh_io/test-py-obj.py | 19 ++++--- bindings/python/tests/mesh_io/test-py-ply.py | 19 ++++--- bindings/python/tests/mesh_io/test-py-stl.py | 19 ++++--- bindings/python/tests/mesh_io/test-py-vtp.py | 25 +++++---- bindings/python/tests/model_io/test-py-msh.py | 55 +++++++------------ bindings/python/tests/model_io/test-py-svg.py | 13 +++-- 6 files changed, 73 insertions(+), 77 deletions(-) diff --git a/bindings/python/tests/mesh_io/test-py-obj.py b/bindings/python/tests/mesh_io/test-py-obj.py index a2dacdf..7b44220 100644 --- a/bindings/python/tests/mesh_io/test-py-obj.py +++ b/bindings/python/tests/mesh_io/test-py-obj.py @@ -22,26 +22,27 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode import opengeode_io_py_mesh as mesh_io -if __name__ == '__main__': - mesh_io.IOMeshLibrary.initialize() +if __name__ == "__main__": + mesh_io.OpenGeodeIOMeshLibrary.initialize() test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) - surface = opengeode.load_polygonal_surface3D( - os.path.join(data_dir, "TopHat.obj")) + surface = opengeode.load_polygonal_surface3D(os.path.join(data_dir, "TopHat.obj")) if surface.nb_vertices() != 363: raise ValueError( - "[Test] Number of vertices in the loaded Surface is not correct") + "[Test] Number of vertices in the loaded Surface is not correct" + ) if surface.nb_polygons() != 380: raise ValueError( - "[Test] Number of polygons in the loaded Surface is not correct") + "[Test] Number of polygons in the loaded Surface is not correct" + ) opengeode.save_polygonal_surface3D(surface, "TopHat_save.obj") diff --git a/bindings/python/tests/mesh_io/test-py-ply.py b/bindings/python/tests/mesh_io/test-py-ply.py index 1a3153e..89aca7e 100644 --- a/bindings/python/tests/mesh_io/test-py-ply.py +++ b/bindings/python/tests/mesh_io/test-py-ply.py @@ -22,26 +22,29 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode import opengeode_io_py_mesh as mesh_io -if __name__ == '__main__': - mesh_io.IOMeshLibrary.initialize() +if __name__ == "__main__": + mesh_io.OpenGeodeIOMeshLibrary.initialize() test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) surface = opengeode.load_polygonal_surface3D( - os.path.join(data_dir, "Armadillo.ply")) + os.path.join(data_dir, "Armadillo.ply") + ) if surface.nb_vertices() != 172974: raise ValueError( - "[Test] Number of vertices in the loaded Surface is not correct") + "[Test] Number of vertices in the loaded Surface is not correct" + ) if surface.nb_polygons() != 345944: raise ValueError( - "[Test] Number of polygons in the loaded Surface is not correct") + "[Test] Number of polygons in the loaded Surface is not correct" + ) opengeode.save_polygonal_surface3D(surface, "Armadillo_save.ply") diff --git a/bindings/python/tests/mesh_io/test-py-stl.py b/bindings/python/tests/mesh_io/test-py-stl.py index 1a3b6c5..195cd62 100644 --- a/bindings/python/tests/mesh_io/test-py-stl.py +++ b/bindings/python/tests/mesh_io/test-py-stl.py @@ -22,26 +22,29 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode import opengeode_io_py_mesh as mesh_io -if __name__ == '__main__': - mesh_io.IOMeshLibrary.initialize() +if __name__ == "__main__": + mesh_io.OpenGeodeIOMeshLibrary.initialize() test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) surface = opengeode.load_triangulated_surface3D( - os.path.join(data_dir, "thumbwheel.stl")) + os.path.join(data_dir, "thumbwheel.stl") + ) if surface.nb_vertices() != 525: raise ValueError( - "[Test] Number of vertices in the loaded Surface is not correct") + "[Test] Number of vertices in the loaded Surface is not correct" + ) if surface.nb_polygons() != 1027: raise ValueError( - "[Test] Number of polygons in the loaded Surface is not correct") + "[Test] Number of polygons in the loaded Surface is not correct" + ) opengeode.save_triangulated_surface3D(surface, "thumbwheel_save.stl") diff --git a/bindings/python/tests/mesh_io/test-py-vtp.py b/bindings/python/tests/mesh_io/test-py-vtp.py index 6dcb885..4906e45 100644 --- a/bindings/python/tests/mesh_io/test-py-vtp.py +++ b/bindings/python/tests/mesh_io/test-py-vtp.py @@ -22,8 +22,9 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode @@ -33,27 +34,29 @@ def check(surface, nb_vertices, nb_polygons): if surface.nb_vertices() != nb_vertices: raise ValueError( - "[Test] Number of vertices in the loaded Surface is not correct") + "[Test] Number of vertices in the loaded Surface is not correct" + ) if surface.nb_polygons() != nb_polygons: raise ValueError( - "[Test] Number of polygons in the loaded Surface is not correct") + "[Test] Number of polygons in the loaded Surface is not correct" + ) def run_test(filename, nb_vertices, nb_polygons): test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) surface = opengeode.load_polygonal_surface3D( - os.path.join(data_dir, filename + ".vtp")) + os.path.join(data_dir, filename + ".vtp") + ) check(surface, nb_vertices, nb_polygons) - opengeode.save_polygonal_surface3D( - surface, os.path.join(filename + ".og_psf3d")) + opengeode.save_polygonal_surface3D(surface, os.path.join(filename + ".og_psf3d")) reloaded_surface = opengeode.load_polygonal_surface3D( - os.path.join(filename + ".og_psf3d")) + os.path.join(filename + ".og_psf3d") + ) check(surface, nb_vertices, nb_polygons) -if __name__ == '__main__': - mesh_io.IOMeshLibrary.initialize() +if __name__ == "__main__": + mesh_io.OpenGeodeIOMeshLibrary.initialize() run_test("dfn1_ascii", 187, 10) run_test("dfn2_mesh_compressed", 33413, 58820) diff --git a/bindings/python/tests/model_io/test-py-msh.py b/bindings/python/tests/model_io/test-py-msh.py index 92bfcbb..f15a667 100644 --- a/bindings/python/tests/model_io/test-py-msh.py +++ b/bindings/python/tests/model_io/test-py-msh.py @@ -22,8 +22,9 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode @@ -44,8 +45,7 @@ def test_brep_cube(brep): # Number of vertices and elements in components for c in brep.corners(): if c.mesh().nb_vertices() != 1: - raise ValueError( - "[Test] Number of vertices in corners should be 1") + raise ValueError("[Test] Number of vertices in corners should be 1") for l in brep.lines(): if l.mesh().nb_vertices() != 5: raise ValueError("[Test] Number of vertices in lines should be 5") @@ -53,18 +53,14 @@ def test_brep_cube(brep): raise ValueError("[Test] Number of edges in lines should be 4") for s in brep.surfaces(): if s.mesh().nb_vertices() != 29: - raise ValueError( - "[Test] Number of vertices in surfaces should be 29") + raise ValueError("[Test] Number of vertices in surfaces should be 29") if s.mesh().nb_polygons() != 40: - raise ValueError( - "[Test] Number of polygons in surfaces should be 40") + raise ValueError("[Test] Number of polygons in surfaces should be 40") for b in brep.blocks(): if b.mesh().nb_vertices() != 131: - raise ValueError( - "[Test] Number of vertices in blocks should be 131") + raise ValueError("[Test] Number of vertices in blocks should be 131") if b.mesh().nb_polyhedra() != 364: - raise ValueError( - "[Test] Number of polyhedra in blocks should be 364") + raise ValueError("[Test] Number of polyhedra in blocks should be 364") # Number of component boundaries and incidences for c in brep.corners(): @@ -103,49 +99,39 @@ def test_brep_cone(brep): # Number of vertices and elements in components for c in brep.corners(): if c.mesh().nb_vertices() != 1: - raise ValueError( - "[Test] Number of vertices in corners should be 1") + raise ValueError("[Test] Number of vertices in corners should be 1") for l in brep.lines(): if l.mesh().nb_vertices() == 0: - raise ValueError( - "[Test] Number of vertices in lines should not be null") + raise ValueError("[Test] Number of vertices in lines should not be null") if l.mesh().nb_edges() == 0: - raise ValueError( - "[Test] Number of edges in lines should not be null") + raise ValueError("[Test] Number of edges in lines should not be null") for s in brep.surfaces(): if s.mesh().nb_vertices() == 0: - raise ValueError( - "[Test] Number of vertices in surfaces should not be null") + raise ValueError("[Test] Number of vertices in surfaces should not be null") if s.mesh().nb_polygons() == 0: - raise ValueError( - "[Test] Number of polygons in surfaces should not be null") + raise ValueError("[Test] Number of polygons in surfaces should not be null") for b in brep.blocks(): if b.mesh().nb_vertices() == 0: - raise ValueError( - "[Test] Number of vertices in blocks should not be null") + raise ValueError("[Test] Number of vertices in blocks should not be null") if b.mesh().nb_polyhedra() == 0: - raise ValueError( - "[Test] Number of polyhedra in blocks should not be null") + raise ValueError("[Test] Number of polyhedra in blocks should not be null") # Number of component boundaries and incidences for c in brep.corners(): if brep.nb_boundaries(c.id()) != 0: raise ValueError("[Test] Number of corner boundary should be 0") if brep.nb_incidences(c.id()) != 4 and brep.nb_incidences(c.id()) != 5: - raise ValueError( - "[Test] Number of corner incidences should be 4 or 5") + raise ValueError("[Test] Number of corner incidences should be 4 or 5") for l in brep.lines(): if brep.nb_boundaries(l.id()) != 2: raise ValueError("[Test] Number of line boundary should be 2") if brep.nb_incidences(l.id()) < 2 or brep.nb_incidences(l.id()) > 4: - raise ValueError( - "[Test] Number of line incidences should be 2, 3 or 4") + raise ValueError("[Test] Number of line incidences should be 2, 3 or 4") for s in brep.surfaces(): if brep.nb_boundaries(s.id()) != 3: raise ValueError("[Test] Number of surface boundary should be 3") if brep.nb_incidences(s.id()) != 1 and brep.nb_incidences(s.id()) != 2: - raise ValueError( - "[Test] Number of surface incidences should be 1 or 2") + raise ValueError("[Test] Number of surface incidences should be 1 or 2") for b in brep.blocks(): if brep.nb_boundaries(b.id()) != 4: raise ValueError("[Test] Number of block boundary should be 4") @@ -153,11 +139,10 @@ def test_brep_cone(brep): raise ValueError("[Test] Number of block incidences should be 0") -if __name__ == '__main__': - model_io.IOModelLibrary.initialize() +if __name__ == "__main__": + model_io.OpenGeodeIOModelLibrary.initialize() test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) brep_cube = opengeode.load_brep(os.path.join(data_dir, "cube_v22.msh")) test_brep_cube(brep_cube) diff --git a/bindings/python/tests/model_io/test-py-svg.py b/bindings/python/tests/model_io/test-py-svg.py index 18f3adc..ad9d301 100644 --- a/bindings/python/tests/model_io/test-py-svg.py +++ b/bindings/python/tests/model_io/test-py-svg.py @@ -22,8 +22,9 @@ import os import sys import platform + if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": - for path in [x.strip() for x in os.environ['PATH'].split(';') if x]: + for path in [x.strip() for x in os.environ["PATH"].split(";") if x]: os.add_dll_directory(path) import opengeode @@ -51,14 +52,14 @@ def test_section(section): nb_cmv = len(section.component_mesh_vertices(uv)) if nb_cmv != 1 and nb_cmv != 3: raise ValueError( - "[Test] Wrong number of mesh component vertices for one unique vertex") + "[Test] Wrong number of mesh component vertices for one unique vertex" + ) -if __name__ == '__main__': - model_io.IOModelLibrary.initialize() +if __name__ == "__main__": + model_io.OpenGeodeIOModelLibrary.initialize() test_dir = os.path.dirname(__file__) - data_dir = os.path.abspath(os.path.join( - test_dir, "../../../../tests/data")) + data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) section = opengeode.load_section(os.path.join(data_dir, "logo.svg")) test_section(section) From 294881acf4a8838be2493dceb572709ab86c3484 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 27 Apr 2026 16:24:43 +0200 Subject: [PATCH 5/6] fix --- src/geode/io/model/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/geode/io/model/CMakeLists.txt b/src/geode/io/model/CMakeLists.txt index bab023e..4f0ebc5 100644 --- a/src/geode/io/model/CMakeLists.txt +++ b/src/geode/io/model/CMakeLists.txt @@ -49,4 +49,5 @@ add_geode_library( pugixml::pugixml ZLIB::ZLIB ${PROJECT_NAME}::mesh + ${PROJECT_NAME}::image ) From d0da5d626035ec13d97141af84291e1d64bd2427 Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Tue, 5 May 2026 14:26:43 +0200 Subject: [PATCH 6/6] check_ --- include/geode/io/image/detail/vtk_output.hpp | 4 +-- include/geode/io/mesh/detail/vtk_input.hpp | 33 ++++++++++--------- .../geode/io/mesh/detail/vtk_mesh_input.hpp | 18 +++++----- .../geode/io/mesh/detail/vtu_input_impl.hpp | 8 ++--- .../geode/io/mesh/internal/assimp_input.hpp | 2 +- .../geode/io/mesh/internal/assimp_output.hpp | 6 ++-- .../geode/io/model/internal/msh_common.hpp | 5 +-- src/geode/io/image/gdal_file.cpp | 8 ++--- src/geode/io/image/raster_image_input.cpp | 4 +-- src/geode/io/mesh/assimp_input.cpp | 2 +- src/geode/io/mesh/obj_input.cpp | 8 ++--- src/geode/io/mesh/vtp_input.cpp | 2 +- src/geode/io/mesh/vtu_hybrid_output.cpp | 4 +-- src/geode/io/model/gid_output.cpp | 4 +-- src/geode/io/model/msh_input.cpp | 33 ++++++++++--------- src/geode/io/model/msh_output.cpp | 4 +-- src/geode/io/model/svg_input.cpp | 13 ++++---- 17 files changed, 83 insertions(+), 75 deletions(-) diff --git a/include/geode/io/image/detail/vtk_output.hpp b/include/geode/io/image/detail/vtk_output.hpp index 60e04ce..cc9dd57 100644 --- a/include/geode/io/image/detail/vtk_output.hpp +++ b/include/geode/io/image/detail/vtk_output.hpp @@ -54,8 +54,8 @@ namespace geode mesh_( mesh ), type_{ type } { - OpenGeodeIOImageException::check( file_.good(), nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOImageException::check_exception( file_.good(), + nullptr, OpenGeodeException::TYPE::data, "[VTKOutput] Error while writing file: ", filename ); } diff --git a/include/geode/io/mesh/detail/vtk_input.hpp b/include/geode/io/mesh/detail/vtk_input.hpp index 6041a74..40c7704 100644 --- a/include/geode/io/mesh/detail/vtk_input.hpp +++ b/include/geode/io/mesh/detail/vtk_input.hpp @@ -84,12 +84,12 @@ namespace geode VTKInputImpl( std::string_view filename, const char* type ) : file_{ to_string( filename ) }, type_{ type } { - OpenGeodeIOMeshException::check( file_.good(), nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( file_.good(), + nullptr, OpenGeodeException::TYPE::data, "[VTKInput] Error while opening file: ", filename ); const auto status = document_.load_file( to_string( filename ).c_str() ); - OpenGeodeIOMeshException::check( status, nullptr, + OpenGeodeIOMeshException::check_exception( status, nullptr, OpenGeodeException::TYPE::internal, status.description(), "[VTKInput] Error while parsing file: ", filename ); root_ = document_.child( "VTKFile" ); @@ -215,7 +215,7 @@ namespace geode index_t nb_components, index_t offset ) { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( values.size() % nb_components == 0, nullptr, OpenGeodeException::TYPE::data, "[VTKInput::build_attribute] Number of attribute " @@ -392,19 +392,19 @@ namespace geode void read_root_attributes() { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( match( root_.attribute( "type" ).value(), type_ ), nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_root_attributes] VTK File type should be ", type_ ); little_endian_ = match( root_.attribute( "byte_order" ).value(), "LittleEndian" ); - OpenGeodeIOMeshException::check( little_endian_, nullptr, - OpenGeodeException::TYPE::internal, + OpenGeodeIOMeshException::check_exception( little_endian_, + nullptr, OpenGeodeException::TYPE::internal, "[VTKInput::read_root_attributes] Big Endian not " "supported" ); const auto compressor = root_.attribute( "compressor" ).value(); - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( std::string_view( compressor ).empty() || match( compressor, "vtkZLibDataCompressor" ), nullptr, OpenGeodeException::TYPE::internal, @@ -415,7 +415,7 @@ namespace geode if( const auto header_type = root_.attribute( "header_type" ) ) { const auto& header_type_value = header_type.value(); - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( match( header_type_value, "UInt32" ) || match( header_type_value, "UInt64" ), nullptr, OpenGeodeException::TYPE::internal, @@ -434,7 +434,7 @@ namespace geode { return; } - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( match( node.attribute( "encoding" ).value(), "base64" ), nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_appended_data] VTK AppendedData " @@ -507,7 +507,7 @@ namespace geode input.substr( fixed_header_length, nb_characters ); const auto decoded_optional_header = decode_base64( optional_header ); - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( decoded_optional_header.size() == nb_data_blocks * sizeof( UInt ), nullptr, OpenGeodeException::TYPE::data, @@ -555,8 +555,9 @@ namespace geode &decompressed_data_length, &compressed_data_bytes[cur_data_offset], compressed_data_length ); - OpenGeodeIOMeshException::check( uncompress_result == Z_OK, - nullptr, OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( + uncompress_result == Z_OK, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::decode] Error in zlib decompressing data" ); const auto values = reinterpret_cast< const T* >( decompressed_data_bytes.data() ); @@ -575,8 +576,8 @@ namespace geode { std::string bytes; auto decode_status = absl::Base64Unescape( input, &bytes ); - OpenGeodeIOMeshException::check( decode_status, nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( decode_status, + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::decode_base64] Error in decoding base64 data" ); return bytes; } @@ -590,7 +591,7 @@ namespace geode { T value; const auto ok = ( *string_convert )( string, &value ); - OpenGeodeIOMeshException::check( ok, nullptr, + OpenGeodeIOMeshException::check_exception( ok, nullptr, OpenGeodeException::TYPE::data, "[VTKINPUT::read_ascii_data_array] Failed to read " "value" ); diff --git a/include/geode/io/mesh/detail/vtk_mesh_input.hpp b/include/geode/io/mesh/detail/vtk_mesh_input.hpp index e8d39a0..47b9d5a 100644 --- a/include/geode/io/mesh/detail/vtk_mesh_input.hpp +++ b/include/geode/io/mesh/detail/vtk_mesh_input.hpp @@ -137,8 +137,9 @@ namespace geode absl::FixedArray< Point3D > get_points( const std::vector< T >& coords ) { - OpenGeodeIOMeshException::check( coords.size() % 3 == 0, - nullptr, OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( + coords.size() % 3 == 0, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::get_points] Number of coordinates is not " "multiple of 3" ); const auto nb_points = coords.size() / 3; @@ -161,14 +162,14 @@ namespace geode const auto nb_components = this->read_attribute( points, "NumberOfComponents" ); const auto type = points.attribute( "type" ).value(); - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( this->match( type, "Float32" ) || this->match( type, "Float64" ), nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_points] Cannot read points of type ", type, ". Only Float32 and Float64 are accepted" ); - OpenGeodeIOMeshException::check( nb_components == 3, nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( nb_components == 3, + nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_points] Trying to import 2D VTK object " "into a 3D Surface is not allowed" ); const auto format = points.attribute( "format" ).value(); @@ -192,7 +193,7 @@ namespace geode absl::RemoveExtraAsciiWhitespace( &string ); const auto coords = read_ascii_coordinates( string, nb_points ); - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( coords.size() == 3 * nb_points, nullptr, OpenGeodeException::TYPE::data, "[VTKInput::read_points] Wrong number of " @@ -213,8 +214,9 @@ namespace geode std::string_view coords_string, index_t nb_points ) { const auto coords = this->template decode< T >( coords_string ); - OpenGeodeIOMeshException::check( coords.size() == 3 * nb_points, - nullptr, OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( + coords.size() == 3 * nb_points, nullptr, + OpenGeodeException::TYPE::data, "[VTKInput::read_points] Wrong number of coordinates" ); return get_points( coords ); } diff --git a/include/geode/io/mesh/detail/vtu_input_impl.hpp b/include/geode/io/mesh/detail/vtu_input_impl.hpp index e51eb9c..7c77db1 100644 --- a/include/geode/io/mesh/detail/vtu_input_impl.hpp +++ b/include/geode/io/mesh/detail/vtu_input_impl.hpp @@ -53,7 +53,7 @@ namespace geode if( this->match( data.attribute( "Name" ).value(), "offsets" ) ) { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( this->match( data.attribute( "type" ).value(), "Int64" ), nullptr, OpenGeodeException::TYPE::data, @@ -62,7 +62,7 @@ namespace geode offsets_values = this->template read_integer_data_array< int64_t >( data ); - OpenGeodeIOMeshException::assertion( + OpenGeodeIOMeshException::check_assertion( offsets_values.size() == nb_cells, "[VTUInputImpl::read_cells] Wrong number of " "offsets" ); @@ -70,7 +70,7 @@ namespace geode else if( this->match( data.attribute( "Name" ).value(), "connectivity" ) ) { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( this->match( data.attribute( "type" ).value(), "Int64" ), nullptr, OpenGeodeException::TYPE::data, @@ -108,7 +108,7 @@ namespace geode OpenGeodeException::TYPE::data, "[VTUInputImpl::read_cells] Wrong types type" }; } - OpenGeodeIOMeshException::assertion( + OpenGeodeIOMeshException::check_assertion( types_values.size() == nb_cells, "[VTUInputImpl::read_cells] Wrong number of " "types" ); diff --git a/include/geode/io/mesh/internal/assimp_input.hpp b/include/geode/io/mesh/internal/assimp_input.hpp index 0026947..bf08134 100644 --- a/include/geode/io/mesh/internal/assimp_input.hpp +++ b/include/geode/io/mesh/internal/assimp_input.hpp @@ -42,7 +42,7 @@ namespace geode explicit AssimpMeshInput( std::string_view filename ) : file_( filename ) { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( std::ifstream{ to_string( file_ ) }.good(), nullptr, OpenGeodeException::TYPE::data, "[AssimpMeshInput] Error while opening file: ", file_ ); diff --git a/include/geode/io/mesh/internal/assimp_output.hpp b/include/geode/io/mesh/internal/assimp_output.hpp index bafc89e..981bd95 100644 --- a/include/geode/io/mesh/internal/assimp_output.hpp +++ b/include/geode/io/mesh/internal/assimp_output.hpp @@ -49,7 +49,7 @@ namespace geode surface_mesh_( surface_mesh ), export_id_{ assimp_export_id } { - OpenGeodeIOMeshException::check( + OpenGeodeIOMeshException::check_exception( std::ofstream{ to_string( file_ ) }.good(), nullptr, OpenGeodeException::TYPE::data, "[AssimpMeshOutput] Error while opening file: ", file_ ); @@ -67,8 +67,8 @@ namespace geode Assimp::Exporter exporter; const auto status = exporter.Export( &assimp_scene_, to_string( export_id_ ), to_string( file_ ) ); - OpenGeodeIOMeshException::check( status == AI_SUCCESS, nullptr, - OpenGeodeException::TYPE::internal, + OpenGeodeIOMeshException::check_exception( status == AI_SUCCESS, + nullptr, OpenGeodeException::TYPE::internal, "[AssimpMeshOutput::write_file] Export in file \"", file_, "\" has failed." ); } diff --git a/include/geode/io/model/internal/msh_common.hpp b/include/geode/io/model/internal/msh_common.hpp index 06dd07d..ce5e403 100644 --- a/include/geode/io/model/internal/msh_common.hpp +++ b/include/geode/io/model/internal/msh_common.hpp @@ -131,8 +131,9 @@ namespace geode nb_vertices_( nb_vertices ), vertex_ids_str_( vertex_ids ) { - OpenGeodeIOModelException::check( elementary_entity_id > 0, - nullptr, OpenGeodeException::TYPE::data, + OpenGeodeIOModelException::check_exception( + elementary_entity_id > 0, nullptr, + OpenGeodeException::TYPE::data, "[GMSHElement] GMSH tag for elementary entity " "(second tag) should not be null" ); try diff --git a/src/geode/io/image/gdal_file.cpp b/src/geode/io/image/gdal_file.cpp index 2da53c5..ba8defc 100644 --- a/src/geode/io/image/gdal_file.cpp +++ b/src/geode/io/image/gdal_file.cpp @@ -40,8 +40,8 @@ namespace geode : dataset_{ GDALDataset::Open( geode::to_string( filename ).c_str(), GDAL_OF_READONLY ) } { - OpenGeodeIOImageException::check( dataset_ != nullptr, nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOImageException::check_exception( dataset_ != nullptr, + nullptr, OpenGeodeException::TYPE::data, "[GDALFile] Failed to open file ", filename ); } @@ -55,8 +55,8 @@ namespace geode std::array< double, 6 > geo_transform; const auto status = dataset_->GetGeoTransform( geo_transform.data() ); - OpenGeodeIOImageException::check( status == CE_None, nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOImageException::check_exception( status == CE_None, + nullptr, OpenGeodeException::TYPE::data, "Failed to read geotransform from GDALDataset" ); Point2D origin; Vector2D x_direction; diff --git a/src/geode/io/image/raster_image_input.cpp b/src/geode/io/image/raster_image_input.cpp index 10a0b67..af926ee 100644 --- a/src/geode/io/image/raster_image_input.cpp +++ b/src/geode/io/image/raster_image_input.cpp @@ -46,8 +46,8 @@ namespace gdal_data.GetRasterBand( component ) ->RasterIO( GF_Read, 0, 0, width, height, values.data(), width, height, GDT_Byte, 0, 0 ); - geode::OpenGeodeIOImageException::check( status == CE_None, nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOImageException::check_exception( status == CE_None, + nullptr, geode::OpenGeodeException::TYPE::data, "[ImageInputImpl] Failed to read color component" ); return values; } diff --git a/src/geode/io/mesh/assimp_input.cpp b/src/geode/io/mesh/assimp_input.cpp index 3c71f30..b95238c 100644 --- a/src/geode/io/mesh/assimp_input.cpp +++ b/src/geode/io/mesh/assimp_input.cpp @@ -95,7 +95,7 @@ namespace geode Assimp::Importer importer; const auto* assimp_scene = importer.ReadFile( to_string( file_ ), 0 ); - OpenGeodeIOMeshException::check( assimp_scene, nullptr, + OpenGeodeIOMeshException::check_exception( assimp_scene, nullptr, OpenGeodeException::TYPE::data, "[AssimpMeshInput::read_file] ", importer.GetErrorString() ); read_materials( assimp_scene ); diff --git a/src/geode/io/mesh/obj_input.cpp b/src/geode/io/mesh/obj_input.cpp index b961e46..23e1896 100644 --- a/src/geode/io/mesh/obj_input.cpp +++ b/src/geode/io/mesh/obj_input.cpp @@ -47,8 +47,8 @@ namespace geode auto OBJInput::additional_files() const -> AdditionalFiles { std::ifstream obj_file{ to_string( filename() ) }; - OpenGeodeIOMeshException::check( !obj_file.fail(), nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( !obj_file.fail(), + nullptr, OpenGeodeException::TYPE::data, "[OBJInput::additional_files] Failed to open file: ", filename() ); const auto mtllib_line = @@ -73,8 +73,8 @@ namespace geode } std::ifstream mtl_file{ mtl_file_path }; - OpenGeodeIOMeshException::check( !mtl_file.fail(), nullptr, - OpenGeodeException::TYPE::data, + OpenGeodeIOMeshException::check_exception( !mtl_file.fail(), + nullptr, OpenGeodeException::TYPE::data, "[OBJInput::additional_files] Failed to open file: ", mtl_file_path ); while( const auto texture_line = diff --git a/src/geode/io/mesh/vtp_input.cpp b/src/geode/io/mesh/vtp_input.cpp index 11e5a4e..9c47e21 100644 --- a/src/geode/io/mesh/vtp_input.cpp +++ b/src/geode/io/mesh/vtp_input.cpp @@ -70,7 +70,7 @@ namespace if( match( data.attribute( "Name" ).value(), "offsets" ) ) { offsets_values = read_integer_data_array< int64_t >( data ); - geode::OpenGeodeIOMeshException::assertion( + geode::OpenGeodeIOMeshException::check_assertion( offsets_values.size() == nb_polygons, nullptr, geode::OpenGeodeException::TYPE::data, "[VTPInput::read_polygons] Wrong number of offsets" ); diff --git a/src/geode/io/mesh/vtu_hybrid_output.cpp b/src/geode/io/mesh/vtu_hybrid_output.cpp index 1c41a79..a4ae300 100644 --- a/src/geode/io/mesh/vtu_hybrid_output.cpp +++ b/src/geode/io/mesh/vtu_hybrid_output.cpp @@ -51,8 +51,8 @@ namespace const auto nb_vertices = this->mesh().nb_polyhedron_vertices( p ); const auto vtk_type = geode::detail::VTK_NB_VERTICES_TO_CELL_TYPE[nb_vertices]; - geode::OpenGeodeIOMeshException::check( vtk_type != 0, nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOMeshException::check_exception( vtk_type != 0, + nullptr, geode::OpenGeodeException::TYPE::data, "[VTUHybridOutputImpl::write_vtk_cell] Polyhedron with ", nb_vertices, " vertices not supported" ); absl::StrAppend( &cell_types, vtk_type, " " ); diff --git a/src/geode/io/model/gid_output.cpp b/src/geode/io/model/gid_output.cpp index 518dabd..d3da4d0 100644 --- a/src/geode/io/model/gid_output.cpp +++ b/src/geode/io/model/gid_output.cpp @@ -76,8 +76,8 @@ namespace GIDOutputImpl( std::string_view filename, const geode::BRep& brep ) : file_{ geode::to_string( filename ) }, brep_( brep ) { - geode::OpenGeodeIOModelException::check( file_.good(), nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( file_.good(), + nullptr, geode::OpenGeodeException::TYPE::data, "[GIDOutput] Error while opening file: ", filename ); } diff --git a/src/geode/io/model/msh_input.cpp b/src/geode/io/model/msh_input.cpp index 1903aa1..fb2e1fd 100644 --- a/src/geode/io/model/msh_input.cpp +++ b/src/geode/io/model/msh_input.cpp @@ -71,8 +71,8 @@ namespace brep_( brep ), builder_{ brep } { - geode::OpenGeodeIOModelException::check( file_.good(), nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( file_.good(), + nullptr, geode::OpenGeodeException::TYPE::data, "[MSHInput] Error while opening file: ", filename ); first_read( filename ); } @@ -211,7 +211,7 @@ namespace { const auto header_tokens = geode::string_split( line ); version_ = geode::string_to_double( header_tokens[0] ); - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( version() == 2 || version() == 4, nullptr, geode::OpenGeodeException::TYPE::data, "[MSHInput::set_msh_version] Only MSH file format " @@ -358,7 +358,7 @@ namespace } else { - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( boundary.second == 2, nullptr, geode::OpenGeodeException::TYPE::data, "[MSHInput::create_surfaces] Wrong Surface/Line " @@ -453,7 +453,7 @@ namespace geode::string_to_index( tokens.at( 1 ) ); const auto min_node_id = geode::string_to_index( tokens.at( 2 ) ); const auto max_node_id = geode::string_to_index( tokens.at( 3 ) ); - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( min_node_id == 1 && max_node_id == nb_total_nodes, nullptr, geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_node_section_v4] Non continuous node indexing " @@ -475,7 +475,7 @@ namespace std::getline( file_, line ); const auto tokens = geode::string_split( line ); const auto nb_nodes = geode::string_to_index( tokens.at( 3 ) ); - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( geode::string_to_index( tokens.at( 2 ) ) == 0, nullptr, geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_node_group] Parametric node coordinates " @@ -517,7 +517,7 @@ namespace { const auto tokens = geode::string_split( line ); geode::index_t t{ 0 }; - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( expected_element_id == geode::string_to_index( tokens.at( t++ ) ), nullptr, geode::OpenGeodeException::TYPE::data, @@ -529,8 +529,8 @@ namespace geode::string_to_index( tokens.at( t++ ) ); // Tags const auto nb_tags = geode::string_to_index( tokens.at( t++ ) ); - geode::OpenGeodeIOModelException::check( nb_tags >= 2, nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( nb_tags >= 2, + nullptr, geode::OpenGeodeException::TYPE::data, "[MSHInput::read_element] Number of tags for an element should " "be at least 2." ); const auto physical_entity = @@ -560,7 +560,7 @@ namespace geode::string_to_index( tokens.at( 2 ) ); const auto max_element_id = geode::string_to_index( tokens.at( 3 ) ); - geode::OpenGeodeIOModelException::check( + geode::OpenGeodeIOModelException::check_exception( min_element_id == 1 && max_element_id == nb_total_elements, nullptr, geode::OpenGeodeException::TYPE::internal, "[MSHInput::read_element_section_v4] Non continuous element " @@ -710,7 +710,8 @@ namespace { const auto edges = line.mesh().edges_around_vertex( old_line_vertex_id ); - geode::OpenGeodeIOModelException::check( edges.size() == 1, nullptr, + geode::OpenGeodeIOModelException::check_exception( + edges.size() == 1, nullptr, geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "edge pointing to each vertex at this point." ); @@ -724,8 +725,9 @@ namespace { const auto polygons = surface.mesh().polygons_around_vertex( old_surface_vertex_id ); - geode::OpenGeodeIOModelException::check( polygons.size() == 1, - nullptr, geode::OpenGeodeException::TYPE::internal, + geode::OpenGeodeIOModelException::check_exception( + polygons.size() == 1, nullptr, + geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "polygon pointing to each vertex at this point." ); mesh_builder.set_polygon_vertex( @@ -739,8 +741,9 @@ namespace { const auto polyhedra = block.mesh().polyhedra_around_vertex( old_block_vertex_id ); - geode::OpenGeodeIOModelException::check( polyhedra.size() == 1, - nullptr, geode::OpenGeodeException::TYPE::internal, + geode::OpenGeodeIOModelException::check_exception( + polyhedra.size() == 1, nullptr, + geode::OpenGeodeException::TYPE::internal, "By construction, there should be one and only one " "polyhedron pointing to each vertex at this point." ); mesh_builder.set_polyhedron_vertex( diff --git a/src/geode/io/model/msh_output.cpp b/src/geode/io/model/msh_output.cpp index 6af50f3..18f5b4a 100644 --- a/src/geode/io/model/msh_output.cpp +++ b/src/geode/io/model/msh_output.cpp @@ -58,8 +58,8 @@ namespace MSHOutputImpl( std::string_view filename, const geode::BRep& brep ) : file_{ geode::to_string( filename ) }, brep_( brep ) { - geode::OpenGeodeIOModelException::check( file_.good(), nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( file_.good(), + nullptr, geode::OpenGeodeException::TYPE::data, "[MSHOutput] Error while opening file: ", filename ); } diff --git a/src/geode/io/model/svg_input.cpp b/src/geode/io/model/svg_input.cpp index ef59caa..b0b34bd 100644 --- a/src/geode/io/model/svg_input.cpp +++ b/src/geode/io/model/svg_input.cpp @@ -54,12 +54,12 @@ namespace section_( section ), builder_{ section } { - geode::OpenGeodeIOModelException::check( file_.good(), nullptr, - geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( file_.good(), + nullptr, geode::OpenGeodeException::TYPE::data, "[SVGInput] Error while opening file: ", filename ); const auto loaded = document_.load_file( geode::to_string( filename ).c_str() ); - geode::OpenGeodeIOModelException::check( loaded, nullptr, + geode::OpenGeodeIOModelException::check_exception( loaded, nullptr, geode::OpenGeodeException::TYPE::internal, "[SVGInput] Error while parsing file: ", filename ); } @@ -135,7 +135,7 @@ namespace [[nodiscard]] geode::Point2D apply( const geode::Point2D& position, const std::vector< double >& params ) const { - geode::OpenGeodeIOModelException::assertion( + geode::OpenGeodeIOModelException::check_assertion( params.size() == get_nb_params(), "[SVGInput::Command::apply] Wrong number of parameters" ); if( letter == 'm' || letter == 'l' ) @@ -265,8 +265,9 @@ namespace const auto& token = tokens[token_id]; if( string_isalpha( token ) ) { - geode::OpenGeodeIOModelException::check( token.size() == 1, - nullptr, geode::OpenGeodeException::TYPE::data, + geode::OpenGeodeIOModelException::check_exception( + token.size() == 1, nullptr, + geode::OpenGeodeException::TYPE::data, "[SVGInputImpl::update_command] Command should be single " "letter" ); command.update( *token.c_str() );