diff --git a/src/ifcgeom/ConversionSettings.h b/src/ifcgeom/ConversionSettings.h index 0d10fa9a5b..f49941ec4b 100644 --- a/src/ifcgeom/ConversionSettings.h +++ b/src/ifcgeom/ConversionSettings.h @@ -187,6 +187,13 @@ namespace ifcopenshell { static constexpr bool defaultvalue = false; }; + struct UseMaterialNames : public SettingBase { + static constexpr const char* const name = "use-material-names"; + static constexpr const char* const description = "Use material names instead of unique IDs for naming materials upon serialization. " + "Applicable for OBJ and DAE output."; + static constexpr bool defaultvalue = false; + }; + struct ConvertBackUnits : public SettingBase { static constexpr const char* const name = "convert-back-units"; static constexpr const char* const description = "Specifies whether to convert back geometrical output back to the " @@ -433,7 +440,7 @@ namespace ifcopenshell { }; class IFC_GEOM_API Settings : public SettingsContainer< - std::tuple + std::tuple > {}; } diff --git a/src/ifcgeom/GeometrySerializer.h b/src/ifcgeom/GeometrySerializer.h index 8dd9a4a4f2..3154cae9be 100644 --- a/src/ifcgeom/GeometrySerializer.h +++ b/src/ifcgeom/GeometrySerializer.h @@ -49,13 +49,6 @@ inline namespace settings { static constexpr bool defaultvalue = false; }; - struct UseMaterialNames : public SettingBase { - static constexpr const char* const name = "use-material-names"; - static constexpr const char* const description = "Use material names instead of unique IDs for naming materials upon serialization. " - "Applicable for OBJ and DAE output."; - static constexpr bool defaultvalue = false; - }; - struct UseElementTypes : public SettingBase { static constexpr const char* const name = "use-element-types"; static constexpr const char* const description = "Use element types instead of unique IDs for naming elements upon serialization. " diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index e87c69d6bc..93692dd59e 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -50,6 +50,35 @@ enum segment_type_t { // @todo use std::numbers::pi when upgrading to C++ 20 static const double PI = boost::math::constants::pi(); + +namespace { + double translate_to_length_measure(const IfcSchema::IfcCurve* crv, double param_value) { + if (std::abs(param_value) < 1.e-7) { + return param_value; + } else if (crv->as()) { + // @todo we should actually check magnitude of the vector + return param_value; + } else if (crv->as()) { + // @todo this is wrong. + return param_value; + } else if (auto circ = crv->as()) { + return circ->Radius() * param_value; + } else { + throw std::runtime_error("Unsupported curve measure type"); + } + } + + double translate_if_param_value(const IfcSchema::IfcCurve* crv, IfcSchema::IfcCurveMeasureSelect* val) { + if (auto param = val->as()) { + // We don't care whether length- or positive length measure. + return translate_to_length_measure(crv, *param); + } else { + return *val->data().getArgument(0); + } + } +} + + // Current implementation uses the same segment_geometry_adjuster for all ParentCurve types. // Comment/Uncomment to change the type of segment geometry adjuster // Future implementations could use specialized adjusters based on ParentCurve type