27 auto const material_ids_strings =
30 std::vector<int> material_ids;
31 for (
auto& mid_str : material_ids_strings)
33 std::size_t num_chars_processed = 0;
37 material_id = std::stoi(mid_str, &num_chars_processed);
39 catch (std::invalid_argument&)
42 "Could not parse material ID from '{}' to a valid integer.",
45 catch (std::out_of_range&)
48 "Could not parse material ID from '{}'. The integer value of "
49 "the given string exceeds the permitted range.",
53 if (num_chars_processed != mid_str.size())
56 if (
auto const it = std::find_if_not(
57 begin(mid_str) + num_chars_processed, end(mid_str),
58 [](
unsigned char const c) {
return std::isspace(c); });
62 "Could not parse material ID from '{}'. Please separate "
63 "multiple material IDs by comma only. Invalid character: "
64 "'{}' at position {}.",
65 mid_str, *it, distance(begin(mid_str), it));
69 material_ids.push_back(material_id);
76 std::string
const& material_id_string,
79 if (material_id_string ==
"*")
81 if (material_ids ==
nullptr)
84 "MaterialIDs property is not defined in the mesh but it is "
85 "required to parse '*' definition.");
88 std::vector<int>
const material_ids_of_this_medium =
89 *material_ids | ranges::views::unique | ranges::to_vector |
90 ranges::actions::sort | ranges::actions::unique |
91 ranges::to<std::vector>;
92 DBUG(
"Catch all medium definition for material ids {}.",
93 fmt::join(material_ids_of_this_medium,
", "));
94 return material_ids_of_this_medium;