mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Some basic code to lookup lengths for pre ADD2 schemas
This commit is contained in:
@@ -187,6 +187,13 @@ namespace ifcopenshell {
|
||||
static constexpr bool defaultvalue = false;
|
||||
};
|
||||
|
||||
struct UseMaterialNames : public SettingBase<UseMaterialNames, bool> {
|
||||
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<ConvertBackUnits, bool> {
|
||||
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<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>
|
||||
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, OutputDimensionality, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, WeldVertices, UseWorldCoords, UseMaterialNames, ConvertBackUnits, ContextIds, ContextTypes, ContextIdentifiers, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, KeepBoundingBoxes, PiecewiseStepType, PiecewiseStepParam>
|
||||
>
|
||||
{};
|
||||
}
|
||||
|
||||
@@ -49,13 +49,6 @@ inline namespace settings {
|
||||
static constexpr bool defaultvalue = false;
|
||||
};
|
||||
|
||||
struct UseMaterialNames : public SettingBase<UseMaterialNames, bool> {
|
||||
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<UseElementTypes, bool> {
|
||||
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. "
|
||||
|
||||
@@ -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<double>();
|
||||
|
||||
|
||||
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<IfcSchema::IfcLine>()) {
|
||||
// @todo we should actually check magnitude of the vector
|
||||
return param_value;
|
||||
} else if (crv->as<IfcSchema::IfcClothoid>()) {
|
||||
// @todo this is wrong.
|
||||
return param_value;
|
||||
} else if (auto circ = crv->as<IfcSchema::IfcCircle>()) {
|
||||
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<IfcSchema::IfcParameterValue>()) {
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user