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;
}
+27 -17
View File
@@ -23,6 +23,7 @@ namespace po = boost::program_options;
namespace std {
istream& operator>>(istream& in, set<int>& ints);
istream& operator>>(istream& in, set<string>& ints);
}
#endif
@@ -120,21 +121,6 @@ namespace ifcopenshell {
static constexpr double defaultvalue = 0.00001;
};
struct IncludeCurves : public SettingBase<IncludeCurves, bool> {
static constexpr const char* const name = "plan";
static constexpr const char* const description = "Specifies whether to include curves in the output result. Typically "
"these are representations of type Plan or Axis. Excluded by default.";
static constexpr bool defaultvalue = false;
};
struct IncludeSurfaces : public SettingBase<IncludeSurfaces, bool> {
static constexpr const char* const name = "model";
static constexpr const char* const description = "Specifies whether to include surfaces and solids in the output result. "
"Typically these are representations of type Body or Facetation. "
"Included by default.";
static constexpr bool defaultvalue = true;
};
struct LayersetFirst : public SettingBase<LayersetFirst, bool> {
static constexpr const char* const name = "layerset-first";
static constexpr const char* const description = "Assigns the first layer material of the layerset "
@@ -214,6 +200,30 @@ namespace ifcopenshell {
static constexpr const char* const description = "";
};
struct ContextTypes : public SettingBase<ContextIds, std::set<std::string>> {
static constexpr const char* const name = "context-types";
static constexpr const char* const description = "";
};
struct ContextIdentifiers : public SettingBase<ContextIds, std::set<std::string>> {
static constexpr const char* const name = "context-identifiers";
static constexpr const char* const description = "";
};
enum OutputDimensionalityTypes {
CURVES,
SURFACES_AND_SOLIDS,
CURVES_SURFACES_AND_SOLIDS
};
std::istream& operator>>(std::istream& in, OutputDimensionalityTypes& ioo);
struct OutputDimensionality : public SettingBase<OutputDimensionality, OutputDimensionalityTypes> {
static constexpr const char* const name = "dimensionality";
static constexpr const char* const description = "Specifies whether to include curves and/or surfaces and solids in the output result. Defaults to only surfaces and solids.";
static constexpr OutputDimensionalityTypes defaultvalue = CURVES_SURFACES_AND_SOLIDS;
};
enum IteratorOutputOptions {
TRIANGULATED,
NATIVE,
@@ -336,7 +346,7 @@ namespace ifcopenshell {
template <typename settings_t>
class IFC_GEOM_API SettingsContainer {
public:
typedef boost::variant<bool, int, double, std::string, std::set<int>, IteratorOutputOptions, PiecewiseStepMethod> value_variant_t;
typedef boost::variant<bool, int, double, std::string, std::set<int>, std::set<std::string>, IteratorOutputOptions, PiecewiseStepMethod, OutputDimensionalityTypes> value_variant_t;
private:
settings_t settings;
@@ -416,7 +426,7 @@ namespace ifcopenshell {
};
class IFC_GEOM_API Settings : public SettingsContainer<
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, IncludeCurves, IncludeSurfaces, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, WeldVertices, UseWorldCoords, ConvertBackUnits, ContextIds, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, KeepBoundingBoxes, PiecewiseStepType, PiecewiseStepParam>
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, OutputDimensionality, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, WeldVertices, UseWorldCoords, ConvertBackUnits, ContextIds, ContextTypes, ContextIdentifiers, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, KeepBoundingBoxes, PiecewiseStepType, PiecewiseStepParam>
>
{};
}
@@ -80,8 +80,8 @@ namespace IfcGeom {
struct clash {
int clash_type; // 0 = protrusion, 1 = pierce, 2 = collision, 3 = clearance
IfcUtil::IfcBaseClass* a;
IfcUtil::IfcBaseClass* b;
const IfcUtil::IfcBaseClass* a;
const IfcUtil::IfcBaseClass* b;
double distance;
std::array<double, 3> p1;
std::array<double, 3> p2;