From 3d8874559d2c983e782ca813894d67ff92cbc634 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 21 Aug 2024 15:38:03 +0200 Subject: [PATCH] Changes after merge and fixes for examples --- src/examples/IfcParseExamples.cpp | 24 +++++++++++++----------- src/ifcgeom/mapping/mapping.cpp | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index a437a719d4..961c4749db 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -22,6 +22,7 @@ #include "../ifcparse/IfcFile.h" #include "../ifcparse/IfcLogger.h" +#include "../ifcparse/Ifc2x3.h" #include #include @@ -79,31 +80,31 @@ struct is_ifc4_or_higher> : s typedef std::map> element_properties; -std::string format_string(const Argument* argument) { +std::string format_string(const AttributeValue& argument) { // Argument is a runtime tagged variant for the various data types in a IFC model, // in this particular case we only care about flattening it to a string. // @todo mostly duplicated from XmlSerializer.cpp - if (argument->isNull()) { + if (argument.isNull()) { return "-"; } - auto argument_type = argument->type(); + auto argument_type = argument.type(); switch (argument_type) { case IfcUtil::Argument_BOOL: { - const bool b = *argument; + const bool b = argument; return b ? "true" : "false"; } case IfcUtil::Argument_DOUBLE: { - const double d = *argument; + const double d = argument; std::stringstream stream; stream << std::setprecision(std::numeric_limits< double >::max_digits10) << d; return stream.str(); break; } case IfcUtil::Argument_STRING: case IfcUtil::Argument_ENUMERATION: { - return static_cast(*argument); + return static_cast(argument); break; } case IfcUtil::Argument_INT: { - const int v = *argument; + const int v = argument; std::stringstream stream; stream << v; return stream.str(); @@ -136,7 +137,7 @@ void process_pset(element_properties& props, const T* inst) { if (!singleval->NominalValue()) { propvalue = "-"; } else { - props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as()->data().getArgument(0)); + props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as()->data().get_attribute_value(0)); } } } @@ -148,8 +149,8 @@ void process_pset(element_properties& props, const T* inst) { auto qs = qset->Quantities(); for (auto it = qs->begin(); it != qs->end(); ++it) { auto& q = *it; - if (q->template as() && q->data().getArgument(3)->type() == IfcUtil::Argument_DOUBLE) { - double v = *q->data().getArgument(3); + if (q->template as() && q->data().get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) { + double v = q->data().get_attribute_value(3); props[*qset->Name()][q->Name()] = std::to_string(v); } } @@ -264,7 +265,8 @@ int main(int argc, char** argv) { for (auto it = elements->begin(); it != elements->end(); ++it) { const auto* element = *it; - std::cout << element->data().toString() << std::endl; + element->toString(std::cout); + std::cout << std::endl; const IfcSchema::IfcWindow* window; if ((window = element->as()) != 0) { diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 2c4c40ea1a..b709c1696b 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -303,7 +303,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc if (associated_material->as() || associated_material->as()) { IfcSchema::IfcMaterialLayerSet* layerset; if (auto *m = associated_material->as()) { - if (m->get("ForLayerSet")->isNull()) { + if (m->get("ForLayerSet").isNull()) { Logger::Warning("Missing ForLayerSet for:", m); return nullptr; } @@ -322,7 +322,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc if (associated_material->as() || associated_material->as()) { IfcSchema::IfcMaterialProfileSet* profileset; if (auto* m = associated_material->as()) { - if (m->get("ForProfileSet")->isNull()) { + if (m->get("ForProfileSet").isNull()) { Logger::Warning("Missing ForProfileSet for:", m); return nullptr; }