@@ -70,7 +70,7 @@ namespace
7070 {
7171 geode::index_t result;
7272 const auto ok = absl::SimpleAtoi ( token, &result );
73- OPENGEODE_EXCEPTION ( ok, " [string_to_index] Error in file reading" );
73+ OPENGEODE_EXCEPTION ( ok, " [string_to_index] Error while file reading" );
7474 return result;
7575 }
7676
@@ -685,7 +685,9 @@ namespace
685685 void set_msh_version ( const std::string& line )
686686 {
687687 const auto header_tokens = get_tokens ( line );
688- absl::SimpleAtod ( header_tokens[0 ], &version_ );
688+ const auto ok = absl::SimpleAtod ( header_tokens[0 ], &version_ );
689+ OPENGEODE_EXCEPTION ( ok, " [MSHInput::set_msh_version] Error while "
690+ " reading file version" );
689691 OPENGEODE_EXCEPTION ( version () == 2 || version () == 4 ,
690692 " [MSHInput::set_msh_version] Only MSH file format "
691693 " versions 2 and 4 are supported for now." );
@@ -769,8 +771,12 @@ namespace
769771 tokens.at ( 8 + nb_physical_tags ) ) } )
770772 {
771773 geode::signed_index_t boundary_msh_id;
772- absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
773- &boundary_msh_id );
774+ const auto ok =
775+ absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
776+ &boundary_msh_id );
777+ OPENGEODE_EXCEPTION ( ok,
778+ " [MSHInput::create_lines] "
779+ " Error while reading boundary entity index" );
774780 boundary_msh_id = std::abs ( boundary_msh_id );
775781 builder_.add_corner_line_boundary_relationship (
776782 brep_.corner ( gmsh_id2uuids_.elementary_ids .at (
@@ -800,8 +806,12 @@ namespace
800806 tokens.at ( 8 + nb_physical_tags ) ) } )
801807 {
802808 geode::signed_index_t boundary_msh_id;
803- absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
804- &boundary_msh_id );
809+ const auto ok =
810+ absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
811+ &boundary_msh_id );
812+ OPENGEODE_EXCEPTION ( ok,
813+ " [MSHInput::create_surfaces] "
814+ " Error while reading boundary entity index" );
805815 boundary_msh_id = std::abs ( boundary_msh_id );
806816 builder_.add_line_surface_boundary_relationship (
807817 brep_.line ( gmsh_id2uuids_.elementary_ids .at (
@@ -832,8 +842,12 @@ namespace
832842 tokens.at ( 8 + nb_physical_tags ) ) } )
833843 {
834844 geode::signed_index_t boundary_msh_id;
835- absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
836- &boundary_msh_id );
845+ const auto ok =
846+ absl::SimpleAtoi ( tokens.at ( 9 + nb_physical_tags + b ),
847+ &boundary_msh_id );
848+ OPENGEODE_EXCEPTION ( ok,
849+ " [MSHInput::create_blocks] "
850+ " Error while reading boundary entity index" );
837851 boundary_msh_id = std::abs ( boundary_msh_id );
838852 builder_.add_surface_block_boundary_relationship (
839853 brep_.surface ( gmsh_id2uuids_.elementary_ids .at (
@@ -850,9 +864,15 @@ namespace
850864 absl::string_view z_str )
851865 {
852866 double x, y, z;
853- absl::SimpleAtod ( x_str, &x );
854- absl::SimpleAtod ( y_str, &y );
855- absl::SimpleAtod ( z_str, &z );
867+ auto ok = absl::SimpleAtod ( x_str, &x );
868+ OPENGEODE_EXCEPTION ( ok, " [MSHInput::read_node_coordinates] "
869+ " Error while reading node coordinates" );
870+ ok = absl::SimpleAtod ( y_str, &y );
871+ OPENGEODE_EXCEPTION ( ok, " [MSHInput::read_node_coordinates] "
872+ " Error while reading node coordinates" );
873+ ok = absl::SimpleAtod ( z_str, &z );
874+ OPENGEODE_EXCEPTION ( ok, " [MSHInput::read_node_coordinates] "
875+ " Error while reading node coordinates" );
856876 return geode::Point3D{ { x, y, z } };
857877 }
858878
@@ -861,7 +881,8 @@ namespace
861881 go_to_section ( " $Nodes" );
862882 std::string line;
863883 std::getline ( file_, line );
864- const auto nb_nodes = std::stoi ( line );
884+ const auto tokens = get_tokens ( line );
885+ const auto nb_nodes = string_to_index ( tokens.at ( 0 ) );
865886 nodes_.resize ( nb_nodes );
866887 for ( const auto unused : geode::Range{ nb_nodes } )
867888 {
@@ -940,7 +961,8 @@ namespace
940961 go_to_section ( " $Elements" );
941962 std::string line;
942963 std::getline ( file_, line );
943- const auto nb_elements = std::stoi ( line );
964+ const auto tokens = get_tokens ( line );
965+ const auto nb_elements = string_to_index ( tokens.at ( 0 ) );
944966 for ( auto e_id : geode::Range{ nb_elements } )
945967 {
946968 std::getline ( file_, line );
@@ -969,11 +991,7 @@ namespace
969991 " should be at least 2." );
970992 const auto physical_entity = string_to_index ( tokens.at ( t++ ) );
971993 const auto elementary_entity = string_to_index ( tokens.at ( t++ ) );
972- for ( const auto unused : geode::Range{ 2 , nb_tags } )
973- {
974- geode_unused ( unused );
975- t++;
976- }
994+ t += nb_tags - 2 ;
977995 // TODO: create relation to the parent
978996 absl::Span< const absl::string_view > vertex_ids (
979997 &tokens[t], tokens.size () - t );
0 commit comments