Last minute refactoring

This commit is contained in:
Thomas Krijnen
2026-08-08 07:42:45 +02:00
parent 8870ffb018
commit af58eaf79f
300 changed files with 5230 additions and 5150 deletions
+15 -15
View File
@@ -41,7 +41,7 @@ struct is_ifc4_or_higher : std::false_type {};
template <typename Schema>
struct is_ifc4_or_higher<Schema, std::void_t<typename Schema::IfcMaterialDefinition>> : std::true_type {};
std::string schema_name(const express::Base& instance) {
std::string schema_name(const express::base& instance) {
return instance.declaration().schema()->name();
}
@@ -87,7 +87,7 @@ std::optional<std::string> format_scalar(const attribute_value& value) {
// ifcopenshell.util.element.get_type: the construction type of an occurrence
// (get_type(type_element) == type_element).
template <typename Schema>
express::Base get_type_s(const express::Base& element) {
express::base get_type_s(const express::base& element) {
if (element.template as<typename Schema::IfcTypeObject>()) {
return element;
}
@@ -111,9 +111,9 @@ express::Base get_type_s(const express::Base& element) {
}
template <typename Schema>
std::optional<std::string> get_predefined_type_s(const express::Base& element) {
std::optional<std::string> get_predefined_type_s(const express::base& element) {
// Prefer the associated type element's predefined type.
if (const express::Base type = get_type_s<Schema>(element)) {
if (const express::base type = get_type_s<Schema>(element)) {
std::optional<std::string> predefined_type = get_string_attribute(type, "PredefinedType");
if (!predefined_type || *predefined_type == "USERDEFINED") {
// ElementType (IfcElementType) or ProcessType (IfcTypeProcess) — the
@@ -140,7 +140,7 @@ std::optional<std::string> get_predefined_type_s(const express::Base& element) {
// ifcopenshell.util.element.get_aggregate: the aggregate parent, via the
// Decomposes inverse (IfcRelAggregates.RelatingObject).
template <typename Schema>
express::Base get_aggregate_s(const express::Base& element) {
express::base get_aggregate_s(const express::base& element) {
const auto object = element.template as<typename Schema::IfcObjectDefinition>();
if (!object) {
return {};
@@ -162,8 +162,8 @@ express::Base get_aggregate_s(const express::Base& element) {
// The spatial-structure children aggregated under this element (IsDecomposedBy →
// RelatedObjects, filtered to spatial elements).
template <typename Schema>
std::vector<express::Base> get_spatial_children_s(const express::Base& element) {
std::vector<express::Base> children;
std::vector<express::base> get_spatial_children_s(const express::base& element) {
std::vector<express::base> children;
const auto object = element.template as<typename Schema::IfcObjectDefinition>();
if (!object) {
return children;
@@ -182,14 +182,14 @@ std::vector<express::Base> get_spatial_children_s(const express::Base& element)
// ifc_class): the directly containing spatial element, or the container of the
// aggregate parent for an aggregated part.
template <typename Schema>
express::Base get_container_s(const express::Base& element) {
express::base get_container_s(const express::base& element) {
if (const auto product = element.template as<typename Schema::IfcElement>()) {
const auto relationships = product.ContainedInStructure();
if (!relationships.empty()) {
return relationships.front().RelatingStructure();
}
}
if (const express::Base aggregate = get_aggregate_s<Schema>(element)) {
if (const express::base aggregate = get_aggregate_s<Schema>(element)) {
return get_container_s<Schema>(aggregate);
}
return {};
@@ -197,7 +197,7 @@ express::Base get_container_s(const express::Base& element) {
} // namespace
std::optional<std::string> get_predefined_type(const express::Base& element) {
std::optional<std::string> get_predefined_type(const express::base& element) {
if (!element) {
return std::nullopt;
}
@@ -211,7 +211,7 @@ std::optional<std::string> get_predefined_type(const express::Base& element) {
unsupported_schema(name);
}
std::vector<std::pair<std::string, std::string>> get_scalar_attributes(const express::Base& element) {
std::vector<std::pair<std::string, std::string>> get_scalar_attributes(const express::base& element) {
std::vector<std::pair<std::string, std::string>> result;
if (!element) {
return result;
@@ -230,7 +230,7 @@ std::vector<std::pair<std::string, std::string>> get_scalar_attributes(const exp
return result;
}
express::Base get_type(const express::Base& element) {
express::base get_type(const express::base& element) {
if (!element) {
return {};
}
@@ -244,7 +244,7 @@ express::Base get_type(const express::Base& element) {
unsupported_schema(name);
}
express::Base get_container(const express::Base& element) {
express::base get_container(const express::base& element) {
if (!element) {
return {};
}
@@ -258,7 +258,7 @@ express::Base get_container(const express::Base& element) {
unsupported_schema(name);
}
std::vector<express::Base> get_spatial_children(const express::Base& element) {
std::vector<express::base> get_spatial_children(const express::base& element) {
if (!element) {
return {};
}
@@ -275,7 +275,7 @@ std::vector<express::Base> get_spatial_children(const express::Base& element) {
// getattr(element, name) for a string- or enum-valued attribute. Reads by name,
// so it works uniformly across the various subtypes that carry a given
// attribute (PredefinedType, Name, ...).
std::optional<std::string> get_string_attribute(const express::Base& element,
std::optional<std::string> get_string_attribute(const express::base& element,
const std::string& name) {
if (!element) {
return std::nullopt;
+7 -7
View File
@@ -35,35 +35,35 @@
// type of the associated type element (via IsTypedBy / IsDefinedBy) first.
// std::nullopt when there is no such attribute (e.g. the element is not an
// IfcObject, or a geometry-only proxy with no live IFC data).
std::optional<std::string> get_predefined_type(const express::Base& element);
std::optional<std::string> get_predefined_type(const express::base& element);
// Mirrors ifcopenshell.util.element.get_type: the construction type element of
// an occurrence (via IsTypedBy on IFC4+, IsDefinedBy on IFC2X3). A type element
// returns itself. Empty express::Base when the element is untyped.
express::Base get_type(const express::Base& element);
// returns itself. Empty express::base when the element is untyped.
express::base get_type(const express::base& element);
// Mirrors ifcopenshell.util.element.get_container (indirect, no ifc_class
// filter): the spatial element that contains this element — the directly
// containing spatial structure, or, for an aggregated part, the container of its
// aggregate parent. Empty when uncontained. (The nest / filled-void /
// voided-element branches of the Python original are not ported.)
express::Base get_container(const express::Base& element);
express::base get_container(const express::base& element);
// Safely read a string- or enum-valued attribute by name (Python's getattr).
// std::nullopt when the attribute is absent for this entity's type or IFC null.
std::optional<std::string> get_string_attribute(const express::Base& element,
std::optional<std::string> get_string_attribute(const express::base& element,
const std::string& name);
// The spatial-structure elements aggregated directly under `element` (its
// IsDecomposedBy → RelatedObjects, filtered to spatial elements). Used to walk
// the IfcProject → IfcSite → IfcBuilding → IfcBuildingStorey → IfcSpace tree.
std::vector<express::Base> get_spatial_children(const express::Base& element);
std::vector<express::base> get_spatial_children(const express::base& element);
// The element's direct EXPRESS attributes that have a primitive scalar value
// (string / enum / integer / real / boolean / logical), as (name, formatted
// value) pairs in declaration order. Attributes that are entity references,
// aggregates / lists, or unset (IFC null) are omitted — so the caller gets a
// flat, display-ready view with no nested objects.
std::vector<std::pair<std::string, std::string>> get_scalar_attributes(const express::Base& element);
std::vector<std::pair<std::string, std::string>> get_scalar_attributes(const express::base& element);
#endif // ELEMENT_H
+4 -4
View File
@@ -83,7 +83,7 @@ double numeric_property(const property_map& properties,
return fallback;
}
double selected_number(const express::Base& selected, double fallback) {
double selected_number(const express::base& selected, double fallback) {
if (!selected) {
return fallback;
}
@@ -184,7 +184,7 @@ template <typename Schema>
std::optional<Eigen::Matrix4d> get_wcs_s(ifcopenshell::file* ifc_file) {
const auto contexts =
ifc_file->template instances_by_type_excl_subtypes<typename Schema::IfcGeometricRepresentationContext>();
express::Base wcs;
express::base wcs;
for (const auto& context : contexts) {
const auto placement = context.WorldCoordinateSystem();
if (!placement) {
@@ -202,7 +202,7 @@ std::optional<Eigen::Matrix4d> get_wcs_s(ifcopenshell::file* ifc_file) {
}
template <typename Schema>
std::optional<express::Base> get_map_unit_s(ifcopenshell::file* ifc_file) {
std::optional<express::base> get_map_unit_s(ifcopenshell::file* ifc_file) {
if constexpr (!is_ifc4_or_higher<Schema>::value) {
return std::nullopt;
} else {
@@ -328,7 +328,7 @@ Eigen::Matrix4d helmert_meters_from_parameters(const HelmertTransformation& p,
return M;
}
std::optional<express::Base> get_map_unit(ifcopenshell::file* ifc_file) {
std::optional<express::base> get_map_unit(ifcopenshell::file* ifc_file) {
const auto name = ifc_file->schema()->name();
#define IFCOPENSHELL_DISPATCH(Schema, Identifier) \
if (name == Identifier) \
+1 -1
View File
@@ -98,7 +98,7 @@ Eigen::Matrix4d helmert_meters_from_parameters(const HelmertTransformation& para
// when MapUnit is absent on the IfcProjectedCRS. This is retained for UI /
// metadata inspection; transform composition derives map unit scale from
// IfcMapConversion.Scale instead.
std::optional<express::Base> get_map_unit(ifcopenshell::file* ifc_file);
std::optional<express::base> get_map_unit(ifcopenshell::file* ifc_file);
// "How do I rotate project east to get to grid east?" — i.e. -atan2(xao, xaa)
// converted to degrees, anticlockwise positive. Mirrors
+6 -6
View File
@@ -84,7 +84,7 @@ Eigen::Matrix4d axis2_placement_3d_s(const Placement& placement) {
}
template <typename Schema>
Eigen::Matrix4d get_axis2_placement_s(const express::Base& placement) {
Eigen::Matrix4d get_axis2_placement_s(const express::base& placement) {
if (auto axis3 = placement.template as<typename Schema::IfcAxis2Placement3D>()) {
return axis2_placement_3d_s<Schema>(axis3);
}
@@ -113,7 +113,7 @@ Eigen::Matrix4d get_axis2_placement_s(const express::Base& placement) {
}
template <typename Schema>
Eigen::Matrix4d get_local_placement_s(const express::Base& placement) {
Eigen::Matrix4d get_local_placement_s(const express::base& placement) {
if (auto local = placement.template as<typename Schema::IfcLocalPlacement>()) {
Eigen::Matrix4d parent = Eigen::Matrix4d::Identity();
if (const auto relative_to = local.PlacementRelTo()) {
@@ -131,7 +131,7 @@ Eigen::Matrix4d get_local_placement_s(const express::Base& placement) {
// ifcopenshell.util.placement.get_storey_elevation: the Z of the storey's
// placement in project units, falling back to the Elevation attribute.
template <typename Schema>
double get_storey_elevation_s(const express::Base& storey) {
double get_storey_elevation_s(const express::base& storey) {
const auto typed = storey.template as<typename Schema::IfcBuildingStorey>();
if (!typed) {
return 0.0;
@@ -170,7 +170,7 @@ Eigen::Matrix4d axes_to_placement(const Eigen::Vector3d& origin,
return m;
}
Eigen::Matrix4d get_axis2_placement(const express::Base& placement) {
Eigen::Matrix4d get_axis2_placement(const express::base& placement) {
if (!placement) {
return Eigen::Matrix4d::Identity();
}
@@ -183,7 +183,7 @@ Eigen::Matrix4d get_axis2_placement(const express::Base& placement) {
unsupported_schema(name);
}
Eigen::Matrix4d get_local_placement(const express::Base& placement) {
Eigen::Matrix4d get_local_placement(const express::base& placement) {
if (!placement) {
return Eigen::Matrix4d::Identity();
}
@@ -196,7 +196,7 @@ Eigen::Matrix4d get_local_placement(const express::Base& placement) {
unsupported_schema(name);
}
double get_storey_elevation(const express::Base& storey) {
double get_storey_elevation(const express::base& storey) {
if (!storey) {
return 0.0;
}
+3 -3
View File
@@ -39,17 +39,17 @@ Eigen::Matrix4d axes_to_placement(const Eigen::Vector3d& origin,
// IfcAxis2Placement{2D,3D,Linear} / IfcAxis1Placement -> 4x4 matrix. Mirrors
// ifcopenshell.util.placement.get_axis2placement. Returns identity for null
// or unparseable inputs. Translation is in the IFC's project length unit.
Eigen::Matrix4d get_axis2_placement(const express::Base& placement);
Eigen::Matrix4d get_axis2_placement(const express::base& placement);
// Resolve an IfcLocalPlacement (or an IfcAxis2Placement* directly) into a
// 4x4 matrix in the IFC project's length unit, walking the PlacementRelTo
// chain. Mirrors ifcopenshell.util.placement.get_local_placement. Returns
// identity for a null input.
Eigen::Matrix4d get_local_placement(const express::Base& placement);
Eigen::Matrix4d get_local_placement(const express::base& placement);
// ifcopenshell.util.placement.get_storey_elevation: the Z elevation of an
// IfcBuildingStorey in the project's length unit — the Z of its placement, or
// the Elevation attribute as a fallback. 0 for a non-storey or null input.
double get_storey_elevation(const express::Base& storey);
double get_storey_elevation(const express::base& storey);
#endif // PLACEMENT_H
+21 -21
View File
@@ -61,7 +61,7 @@ struct has_curve_interpolation : std::false_type {};
template <typename T>
struct has_curve_interpolation<T, std::void_t<decltype(std::declval<T>().CurveInterpolation())>> : std::true_type {};
std::string schema_name(const express::Base& instance) {
std::string schema_name(const express::base& instance) {
return instance.declaration().schema()->name();
}
@@ -113,7 +113,7 @@ property_value from_attribute(const attribute_value& value) {
return result;
}
case ifcopenshell::Argument_ENTITY_INSTANCE: {
const express::Base instance = value;
const express::base instance = value;
if (instance && !instance.declaration().as_entity()) {
return from_attribute(instance.get_attribute_value(0));
}
@@ -127,7 +127,7 @@ property_value from_attribute(const attribute_value& value) {
return scalar_list(static_cast<std::vector<std::string>>(value));
case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
property_list result;
for (const auto& instance : static_cast<std::vector<express::Base>>(value)) {
for (const auto& instance : static_cast<std::vector<express::base>>(value)) {
if (instance && !instance.declaration().as_entity()) {
result.push_back(from_attribute(instance.get_attribute_value(0)));
} else {
@@ -171,7 +171,7 @@ property_value from_select_values(const Values& maybe_values) {
}
}
property_value verbose_value(const express::Base& instance,
property_value verbose_value(const express::base& instance,
property_value value,
const std::optional<std::string>& value_type = std::nullopt) {
property_map result = {
@@ -355,7 +355,7 @@ std::optional<property_value> predefined_properties_s(
template <typename Schema>
std::optional<property_value> get_property_definition_s(
const express::Base& definition,
const express::base& definition,
const std::optional<std::string>& property_name,
bool verbose) {
if (!definition) {
@@ -405,8 +405,8 @@ std::optional<property_value> get_property_definition_s(
}
template <typename Definition>
express::Base concrete_definition(const Definition& definition) {
if constexpr (std::is_base_of_v<express::Select, Definition>) {
express::base concrete_definition(const Definition& definition) {
if constexpr (std::is_base_of_v<express::select, Definition>) {
return definition.concrete();
} else {
return definition;
@@ -414,7 +414,7 @@ express::Base concrete_definition(const Definition& definition) {
}
template <typename Schema>
bool definition_is_pset_s(const express::Base& definition) {
bool definition_is_pset_s(const express::base& definition) {
if (definition.template as<typename Schema::IfcPropertySet>()) {
return true;
}
@@ -432,7 +432,7 @@ bool definition_is_pset_s(const express::Base& definition) {
}
template <typename Schema>
std::optional<std::string> definition_name_s(const express::Base& definition) {
std::optional<std::string> definition_name_s(const express::base& definition) {
if (auto pset = definition.template as<typename Schema::IfcPropertySet>()) {
return pset.Name();
}
@@ -458,7 +458,7 @@ std::optional<std::string> definition_name_s(const express::Base& definition) {
template <typename Schema>
void merge_definition_s(element_properties& result,
const express::Base& definition,
const express::base& definition,
bool psets_only,
bool qtos_only,
bool verbose) {
@@ -505,7 +505,7 @@ typename Schema::IfcTypeObject get_type_s(const typename Schema::IfcObject& obje
}
template <typename Schema>
element_properties get_psets_s(const express::Base& element,
element_properties get_psets_s(const express::base& element,
bool psets_only,
bool qtos_only,
bool should_inherit,
@@ -578,7 +578,7 @@ element_properties get_psets_s(const express::Base& element,
}
template <typename Schema>
std::optional<property_value> get_inherited_property_s(const express::Base& element,
std::optional<property_value> get_inherited_property_s(const express::base& element,
const std::string& pset_name,
const std::string& property_name,
bool psets_only,
@@ -605,7 +605,7 @@ std::optional<property_value> get_inherited_property_s(const express::Base& elem
}
template <typename Schema, typename Entity>
std::vector<Entity> cast_entities(const std::vector<express::Base>& values) {
std::vector<Entity> cast_entities(const std::vector<express::base>& values) {
std::vector<Entity> result;
result.reserve(values.size());
for (const auto& value : values) {
@@ -624,7 +624,7 @@ void print_value(std::ostream& stream, const property_value& value) {
stream << "null";
} else if constexpr (std::is_same_v<T, bool>) {
stream << (item ? "true" : "false");
} else if constexpr (std::is_same_v<T, express::Base>) {
} else if constexpr (std::is_same_v<T, express::base>) {
if (item) {
item.to_string(stream);
} else {
@@ -667,7 +667,7 @@ std::ostream& operator<<(std::ostream& stream, const property_value& value) {
return stream;
}
element_properties get_psets(const express::Base& element,
element_properties get_psets(const express::base& element,
bool psets_only,
bool qtos_only,
bool should_inherit,
@@ -685,7 +685,7 @@ element_properties get_psets(const express::Base& element,
unsupported_schema(name);
}
std::optional<property_value> get_pset(const express::Base& element,
std::optional<property_value> get_pset(const express::base& element,
const std::string& name,
const std::optional<std::string>& property_name,
bool psets_only,
@@ -719,7 +719,7 @@ std::optional<property_value> get_pset(const express::Base& element,
}
std::optional<property_value> get_property_definition(
const express::Base& definition,
const express::base& definition,
const std::optional<std::string>& property_name,
bool verbose) {
if (!definition) {
@@ -734,7 +734,7 @@ std::optional<property_value> get_property_definition(
unsupported_schema(name);
}
std::optional<property_value> get_quantity(const std::vector<express::Base>& quantities,
std::optional<property_value> get_quantity(const std::vector<express::base>& quantities,
const std::string& name,
bool verbose) {
if (quantities.empty()) {
@@ -752,7 +752,7 @@ std::optional<property_value> get_quantity(const std::vector<express::Base>& qua
unsupported_schema(schema);
}
property_map get_quantities(const std::vector<express::Base>& quantities, bool verbose) {
property_map get_quantities(const std::vector<express::base>& quantities, bool verbose) {
if (quantities.empty()) {
return {};
}
@@ -767,7 +767,7 @@ property_map get_quantities(const std::vector<express::Base>& quantities, bool v
unsupported_schema(schema);
}
std::optional<property_value> get_property(const std::vector<express::Base>& properties,
std::optional<property_value> get_property(const std::vector<express::base>& properties,
const std::string& name,
bool verbose) {
if (properties.empty()) {
@@ -785,7 +785,7 @@ std::optional<property_value> get_property(const std::vector<express::Base>& pro
unsupported_schema(schema);
}
property_map get_properties(const std::vector<express::Base>& properties, bool verbose) {
property_map get_properties(const std::vector<express::base>& properties, bool verbose) {
if (properties.empty()) {
return {};
}
+9 -9
View File
@@ -43,7 +43,7 @@ using element_properties = std::map<std::string, property_map>;
// IFC null. Entity values are retained for compound property metadata that
// cannot be flattened to a scalar.
struct property_value {
using storage_type = std::variant<std::monostate, bool, std::int64_t, double, std::string, express::Base, property_list, property_map>;
using storage_type = std::variant<std::monostate, bool, std::int64_t, double, std::string, express::base, property_list, property_map>;
storage_type value;
@@ -55,7 +55,7 @@ struct property_value {
property_value(double value) : value(value) {}
property_value(const char* value) : value(std::string(value)) {}
property_value(std::string value) : value(std::move(value)) {}
property_value(express::Base value) : value(std::move(value)) {}
property_value(express::base value) : value(std::move(value)) {}
property_value(property_list value) : value(std::move(value)) {}
property_value(property_map value) : value(std::move(value)) {}
@@ -73,7 +73,7 @@ std::ostream& operator<<(std::ostream& stream, const property_value& value);
// the returned value contains a property_map. A selected IFC null property is
// represented by an engaged optional containing a null property_value.
std::optional<property_value> get_pset(
const express::Base& element,
const express::base& element,
const std::string& name,
const std::optional<std::string>& property_name = std::nullopt,
bool psets_only = false,
@@ -83,27 +83,27 @@ std::optional<property_value> get_pset(
// Mirrors ifcopenshell.util.element.get_psets, including occurrence-over-type
// precedence and the definition instance id in each returned property map.
element_properties get_psets(const express::Base& element,
element_properties get_psets(const express::base& element,
bool psets_only = false,
bool qtos_only = false,
bool should_inherit = true,
bool verbose = false);
std::optional<property_value> get_property_definition(
const express::Base& definition,
const express::base& definition,
const std::optional<std::string>& property_name = std::nullopt,
bool verbose = false);
std::optional<property_value> get_quantity(const std::vector<express::Base>& quantities,
std::optional<property_value> get_quantity(const std::vector<express::base>& quantities,
const std::string& name,
bool verbose = false);
property_map get_quantities(const std::vector<express::Base>& quantities,
property_map get_quantities(const std::vector<express::base>& quantities,
bool verbose = false);
std::optional<property_value> get_property(const std::vector<express::Base>& properties,
std::optional<property_value> get_property(const std::vector<express::base>& properties,
const std::string& name,
bool verbose = false);
property_map get_properties(const std::vector<express::Base>& properties,
property_map get_properties(const std::vector<express::base>& properties,
bool verbose = false);
#endif // PSET_H
+10 -10
View File
@@ -212,7 +212,7 @@ std::string to_lower(const std::string& s) {
throw ifcopenshell::exception("No helper implementation was built for schema " + name);
}
std::optional<double> numeric_value(const express::Base& value) {
std::optional<double> numeric_value(const express::base& value) {
if (!value) {
return std::nullopt;
}
@@ -230,7 +230,7 @@ std::optional<double> numeric_value(const express::Base& value) {
}
template <typename Schema>
std::optional<double> si_scale_from_named_unit_s(express::Base unit) {
std::optional<double> si_scale_from_named_unit_s(express::base unit) {
double scale = 1.0;
while (auto conversion = unit.template as<typename Schema::IfcConversionBasedUnit>()) {
if (const auto it = SI_CONVERSIONS.find(to_lower(conversion.Name()));
@@ -271,7 +271,7 @@ std::optional<double> si_scale_from_named_unit_s(express::Base unit) {
}
template <typename Schema>
std::optional<express::Base> get_unit_assignment_s(ifcopenshell::file* ifc_file) {
std::optional<express::base> get_unit_assignment_s(ifcopenshell::file* ifc_file) {
const auto projects = ifc_file->template instances_by_type<typename Schema::IfcProject>();
if (projects.empty()) {
return std::nullopt;
@@ -284,7 +284,7 @@ std::optional<express::Base> get_unit_assignment_s(ifcopenshell::file* ifc_file)
}
template <typename Schema>
std::optional<express::Base> get_project_unit_s(ifcopenshell::file* ifc_file,
std::optional<express::base> get_project_unit_s(ifcopenshell::file* ifc_file,
const std::string& unit_type) {
const auto assignment = get_unit_assignment_s<Schema>(ifc_file);
if (!assignment) {
@@ -316,7 +316,7 @@ double calculate_unit_scale_s(ifcopenshell::file* ifc_file, const std::string& u
}
template <typename Schema>
void unit_name_s(const express::Base& unit, std::string& prefix, std::string& name) {
void unit_name_s(const express::base& unit, std::string& prefix, std::string& name) {
prefix.clear();
name.clear();
if (auto si = unit.template as<typename Schema::IfcSIUnit>()) {
@@ -332,7 +332,7 @@ void unit_name_s(const express::Base& unit, std::string& prefix, std::string& na
}
template <typename Schema>
double convert_unit_s(double value, const express::Base& from_unit, const express::Base& to_unit) {
double convert_unit_s(double value, const express::base& from_unit, const express::base& to_unit) {
std::string from_prefix;
std::string from_name;
std::string to_prefix;
@@ -352,7 +352,7 @@ double get_prefix_multiplier(const std::string& prefix) {
return (it == SI_PREFIXES.end()) ? 1.0 : it->second;
}
std::optional<double> si_scale_from_named_unit(express::Base unit) {
std::optional<double> si_scale_from_named_unit(express::base unit) {
if (!unit) {
return std::nullopt;
}
@@ -365,7 +365,7 @@ std::optional<double> si_scale_from_named_unit(express::Base unit) {
unsupported_schema(name);
}
std::optional<express::Base> get_unit_assignment(ifcopenshell::file* ifc_file) {
std::optional<express::base> get_unit_assignment(ifcopenshell::file* ifc_file) {
const auto name = ifc_file->schema()->name();
#define IFCOPENSHELL_DISPATCH(Schema, Identifier) \
if (name == Identifier) \
@@ -375,7 +375,7 @@ std::optional<express::Base> get_unit_assignment(ifcopenshell::file* ifc_file) {
unsupported_schema(name);
}
std::optional<express::Base> get_project_unit(ifcopenshell::file* ifc_file,
std::optional<express::base> get_project_unit(ifcopenshell::file* ifc_file,
const std::string& unit_type) {
const auto name = ifc_file->schema()->name();
#define IFCOPENSHELL_DISPATCH(Schema, Identifier) \
@@ -434,7 +434,7 @@ double convert(double value,
return value;
}
double convert_unit(double value, express::Base from_unit, express::Base to_unit) {
double convert_unit(double value, express::base from_unit, express::base to_unit) {
if (!from_unit || !to_unit) {
return value;
}
+4 -4
View File
@@ -58,15 +58,15 @@ double get_prefix_multiplier(const std::string& prefix);
// value_in_unit * scale == value_in_si_base
// Walks IfcConversionBasedUnit chains down to IfcSIUnit. Returns nullopt
// when the chain bottoms out in IfcContextDependentUnit (cannot convert).
std::optional<double> si_scale_from_named_unit(express::Base named_unit);
std::optional<double> si_scale_from_named_unit(express::base named_unit);
// IfcProject.UnitsInContext (the IfcUnitAssignment). Returns nullopt if
// the file has no project or no assignment.
std::optional<express::Base> get_unit_assignment(ifcopenshell::file* ifc_file);
std::optional<express::base> get_unit_assignment(ifcopenshell::file* ifc_file);
// First unit in the project's IfcUnitAssignment matching `unit_type`
// (e.g. "LENGTHUNIT"). Returns nullopt if not found.
std::optional<express::Base> get_project_unit(ifcopenshell::file* ifc_file,
std::optional<express::base> get_project_unit(ifcopenshell::file* ifc_file,
const std::string& unit_type);
// Project unit -> SI base scale (e.g. project in mm => 0.001). Defaults
@@ -86,6 +86,6 @@ double convert(double value,
// Convert between two IfcNamedUnit entities. Pulls Name and Prefix off each
// and delegates to convert(). IfcConversionBasedUnit names that don't appear
// in SI_CONVERSIONS return the value unchanged.
double convert_unit(double value, express::Base from_unit, express::Base to_unit);
double convert_unit(double value, express::base from_unit, express::base to_unit);
#endif // UNIT_H