mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Work towards v1.0 data model with encapsulated weak_ptr as basis for instances
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
********************************************************************************/
|
||||
|
||||
#include "IfcSIPrefix.h"
|
||||
#include "InstanceData.h"
|
||||
|
||||
#ifdef HAS_SCHEMA_2x3
|
||||
#include "Ifc2x3.h"
|
||||
@@ -109,25 +110,23 @@ double IfcParse::IfcSIPrefixToValue(const std::string& prefix) {
|
||||
}
|
||||
|
||||
template <typename Schema>
|
||||
double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
|
||||
double IfcParse::get_SI_equivalent(const typename Schema::IfcNamedUnit& named_unit) {
|
||||
double scale = 1.;
|
||||
typename Schema::IfcSIUnit* si_unit = 0;
|
||||
typename Schema::IfcSIUnit si_unit;
|
||||
|
||||
if (named_unit->declaration().is(Schema::IfcConversionBasedUnit::Class())) {
|
||||
typename Schema::IfcConversionBasedUnit* conv_unit = named_unit->template as<typename Schema::IfcConversionBasedUnit>();
|
||||
typename Schema::IfcMeasureWithUnit* factor = conv_unit->ConversionFactor();
|
||||
typename Schema::IfcUnit* component = factor->UnitComponent();
|
||||
if (component->declaration().is(Schema::IfcSIUnit::Class())) {
|
||||
si_unit = component->template as<typename Schema::IfcSIUnit>();
|
||||
typename Schema::IfcValue* value = factor->ValueComponent();
|
||||
scale = value->template as<IfcUtil::IfcBaseClass>()->get_attribute_value(0);
|
||||
if (auto conv_unit = named_unit.template as<typename Schema::IfcConversionBasedUnit>()) {
|
||||
auto factor = conv_unit.ConversionFactor();
|
||||
auto component = factor.UnitComponent();
|
||||
if (si_unit = component.concrete().template as<typename Schema::IfcSIUnit>()) {
|
||||
auto value = factor.ValueComponent();
|
||||
scale = value.get_attribute_value(0);
|
||||
}
|
||||
} else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) {
|
||||
si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
|
||||
} else {
|
||||
si_unit = named_unit.template as<typename Schema::IfcSIUnit>();
|
||||
}
|
||||
if (si_unit) {
|
||||
if (si_unit->Prefix()) {
|
||||
scale *= IfcSIPrefixToValue(Schema::IfcSIPrefix::ToString(*si_unit->Prefix()));
|
||||
if (si_unit.Prefix()) {
|
||||
scale *= IfcSIPrefixToValue(Schema::IfcSIPrefix::ToString(*si_unit.Prefix()));
|
||||
}
|
||||
} else {
|
||||
scale = 0.;
|
||||
@@ -139,76 +138,79 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
#ifdef HAS_SCHEMA_2x3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc2x3>(Ifc2x3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc2x3>(const Ifc2x3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4>(Ifc4::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4>(const Ifc4::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x1>(Ifc4x1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x1>(const Ifc4x1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x2>(Ifc4x2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x2>(const Ifc4x2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc1>(Ifc4x3_rc1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc1>(const Ifc4x3_rc1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc2>(Ifc4x3_rc2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc2>(const Ifc4x3_rc2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc3>(Ifc4x3_rc3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc3>(const Ifc4x3_rc3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc4
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc4>(Ifc4x3_rc4::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc4>(const Ifc4x3_rc4::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3>(Ifc4x3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3>(const Ifc4x3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_tc1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_tc1>(const Ifc4x3_tc1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_add1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add1>(Ifc4x3_add1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add1>(const Ifc4x3_add1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_add2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add2>(Ifc4x3_add2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add2>(const Ifc4x3_add2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef HAS_SCHEMA_2x3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc2x3>(typename Ifc2x3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc2x3>(const typename Ifc2x3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4>(typename Ifc4::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4>(const typename Ifc4::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x1>(typename Ifc4x1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x1>(const typename Ifc4x1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x2>(typename Ifc4x2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x2>(const typename Ifc4x2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc1>(typename Ifc4x3_rc1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc1>(const typename Ifc4x3_rc1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc2>(typename Ifc4x3_rc2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc2>(const typename Ifc4x3_rc2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc3>(typename Ifc4x3_rc3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc3>(const typename Ifc4x3_rc3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_rc4
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc4>(typename Ifc4x3_rc4::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_rc4>(const typename Ifc4x3_rc4::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3>(typename Ifc4x3::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3>(const typename Ifc4x3::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_tc1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_tc1>(typename Ifc4x3_tc1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_tc1>(const typename Ifc4x3_tc1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_add1
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add1>(typename Ifc4x3_add1::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add1>(const typename Ifc4x3_add1::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
#ifdef HAS_SCHEMA_4x3_add2
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add2>(typename Ifc4x3_add2::IfcNamedUnit* named_unit);
|
||||
template double IFC_PARSE_API IfcParse::get_SI_equivalent<Ifc4x3_add2>(const typename Ifc4x3_add2::IfcNamedUnit& named_unit);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user