Settings rework for plan/model/context and interfacing with python

This commit is contained in:
Thomas Krijnen
2024-04-18 21:04:02 +02:00
parent b62b328f1d
commit 0edfb0e791
8 changed files with 164 additions and 44 deletions
+34 -4
View File
@@ -10,14 +10,28 @@ double ifcopenshell::geometry::ConversionSettings::getValue(GeomValue var) const
}
*/
std::istream& std::operator>>(istream& in, set<int>& ints) {
string tokens;
template <typename T>
void istream_helper(std::istream& in, std::set<T>& ints) {
std::string tokens;
in >> tokens;
vector<string> strs;
std::vector<std::string> strs;
boost::split(strs, tokens, boost::is_any_of(","));
for (auto& s : strs) {
ints.insert(boost::lexical_cast<int>(s));
if constexpr (std::is_same_v<T, std::string>) {
ints.insert(s);
} else {
ints.insert(boost::lexical_cast<T>(s));
}
}
}
std::istream& std::operator>>(istream& in, set<int>& ints) {
istream_helper<int>(in, ints);
return in;
}
std::istream& std::operator>>(istream& in, set<string>& strs) {
istream_helper<std::string>(in, strs);
return in;
}
@@ -51,3 +65,19 @@ std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, Pie
}
return in;
}
std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, OutputDimensionalityTypes& v) {
std::string token;
in >> token;
boost::to_upper(token);
if (token == "CURVES") {
v = CURVES;
} else if (token == "SURFACES_AND_SOLIDS") {
v = SURFACES_AND_SOLIDS;
} else if (token == "CURVES_SURFACES_AND_SOLIDS") {
v = CURVES_SURFACES_AND_SOLIDS;
} else {
in.setstate(std::ios_base::failbit);
}
return in;
}