21 auto const material_ids_strings =
24 std::vector<int> material_ids;
25 for (
auto& mid_str : material_ids_strings)
27 std::size_t num_chars_processed = 0;
31 material_id = std::stoi(mid_str, &num_chars_processed);
33 catch (std::invalid_argument&)
36 "Could not parse material ID from '{}' to a valid integer.",
39 catch (std::out_of_range&)
42 "Could not parse material ID from '{}'. The integer value of "
43 "the given string exceeds the permitted range.",
47 if (num_chars_processed != mid_str.size())
50 if (
auto const it = std::find_if_not(
51 begin(mid_str) + num_chars_processed, end(mid_str),
52 [](
unsigned char const c) {
return std::isspace(c); });
56 "Could not parse material ID from '{}'. Please separate "
57 "multiple material IDs by comma only. Invalid character: "
58 "'{}' at position {}.",
59 mid_str, *it, distance(begin(mid_str), it));
63 material_ids.push_back(material_id);
70 std::string
const& material_id_string,
73 if (material_id_string ==
"*")
75 if (material_ids ==
nullptr)
78 "MaterialIDs property is not defined in the mesh but it is "
79 "required to parse '*' definition.");
82 std::vector<int>
const material_ids_of_this_medium =
83 *material_ids | ranges::views::unique | ranges::to_vector |
84 ranges::actions::sort | ranges::actions::unique |
85 ranges::to<std::vector>;
86 DBUG(
"Catch all medium definition for material ids {}.",
87 fmt::join(material_ids_of_this_medium,
", "));
88 return material_ids_of_this_medium;