From 69a4ad35a14a290c816f7c40efc1f43afde6ef40 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 10 Jan 2026 10:20:34 +0100 Subject: [PATCH] Remaining cpp changes --- src/ifcconvert/IfcConvert.cpp | 2 +- src/ifcparse/express.h | 18 ++++++++++++++++++ src/serializers/ColladaSerializer.cpp | 8 ++++---- src/serializers/ColladaSerializer.h | 2 +- src/serializers/HdfSerializer.cpp | 8 ++++---- .../schema_dependent/JsonSerializer.cpp | 4 ++++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index acd220862b..b84a33d8f4 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -1556,7 +1556,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std auto IfcRelDefinesByProperties = f.schema()->declaration_by_name("IfcRelDefinesByProperties"); for (auto& eq : element_quantities) { - auto rels = eq.data()->file()->getInverse(eq.id(), IfcRelDefinesByProperties, -1); + auto rels = eq.file()->getInverse(eq.id(), IfcRelDefinesByProperties, -1); for (auto& rel : rels) { relationships.push_back(rel); } diff --git a/src/ifcparse/express.h b/src/ifcparse/express.h index 0897108bf8..5bed012af8 100644 --- a/src/ifcparse/express.h +++ b/src/ifcparse/express.h @@ -191,6 +191,24 @@ struct hash { } // namespace std +namespace boost { + +template <> +struct hash { + std::size_t operator()(const express::Base& c) const noexcept { + return std::hash{}(c.identity()); + } +}; + +template <> +struct hash { + std::size_t operator()(const express::Entity& c) const noexcept { + return std::hash{}(c.identity()); + } +}; + +} // namespace boost + template std::vector cast_vector(const std::vector& vs) { std::vector result; diff --git a/src/serializers/ColladaSerializer.cpp b/src/serializers/ColladaSerializer.cpp index 0b1676c338..6a929faf60 100644 --- a/src/serializers/ColladaSerializer.cpp +++ b/src/serializers/ColladaSerializer.cpp @@ -412,9 +412,9 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme deferreds.push_back(deferred); } -std::string ColladaSerializer::differentiateSlabTypes(const IfcUtil::IfcBaseEntity* slab) +std::string ColladaSerializer::differentiateSlabTypes(const express::Entity& slab) { - auto value = slab->get("PredefinedType"); + auto value = slab.get("PredefinedType"); if (value.isNull()) { return "_Unknown"; @@ -434,7 +434,7 @@ std::string ColladaSerializer::differentiateSlabTypes(const IfcUtil::IfcBaseEnti } else if (str_value == "NOTDEFINED") { result = "_NotDefined"; } else { - auto otype = slab->get("ObjectType"); + auto otype = slab.get("ObjectType"); if (otype.isNull()) { result = "_Unknown"; } else { @@ -448,7 +448,7 @@ std::string ColladaSerializer::differentiateSlabTypes(const IfcUtil::IfcBaseEnti std::string ColladaSerializer::object_id(const IfcGeom::Element* o) /*override*/ { if (settings_.get().get()) { - const std::string slabSuffix = (o->product() && o->product()->declaration().name() == "IfcSlab") + const std::string slabSuffix = (o->product() && o->product().declaration().name() == "IfcSlab") ? differentiateSlabTypes(o->product()) : ""; return o->type() + slabSuffix; diff --git a/src/serializers/ColladaSerializer.h b/src/serializers/ColladaSerializer.h index 690b8b7c6c..b599ab2bb7 100644 --- a/src/serializers/ColladaSerializer.h +++ b/src/serializers/ColladaSerializer.h @@ -243,7 +243,7 @@ public: std::string object_id(const IfcGeom::Element* o) /*override*/; private: - static std::string differentiateSlabTypes(const IfcUtil::IfcBaseEntity* slab); + static std::string differentiateSlabTypes(const express::Entity& slab); }; #endif diff --git a/src/serializers/HdfSerializer.cpp b/src/serializers/HdfSerializer.cpp index 2fceb0eec0..a684d02027 100644 --- a/src/serializers/HdfSerializer.cpp +++ b/src/serializers/HdfSerializer.cpp @@ -251,7 +251,7 @@ void HdfSerializer::read_surface_style(const surface_style_serialization& s, gss.specularity = s.specularity; } if (s.id != 0) { - gss.instance = f.instance_by_id(s.id)->as(); + gss.instance = f.instance_by_id(s.id).as(); } } @@ -290,7 +290,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g auto representation_group = element_group.openGroup(representation_id_str); std::string geom_id = read_scalar_attribute(representation_group, "geom_id"); - auto inst = f.instance_by_id(id)->as(); + auto inst = f.instance_by_id(id).as(); boost::shared_ptr brep_geometry; boost::shared_ptr triangulation_geometry; @@ -550,8 +550,8 @@ void HdfSerializer::write_style(surface_style_serialization& data, const ifcopen data.name = s.name.c_str(); // @todo data.original_name = s.name.c_str(); - auto instance = s.instance->as(); - data.id = instance ? instance->id() : 0; + auto& instance = s.instance; + data.id = instance ? instance.id() : 0; if (s.diffuse) { data.diffuse[0] = s.diffuse.ccomponents()(0); data.diffuse[1] = s.diffuse.ccomponents()(1); diff --git a/src/serializers/schema_dependent/JsonSerializer.cpp b/src/serializers/schema_dependent/JsonSerializer.cpp index 45cda654fd..15e3120146 100644 --- a/src/serializers/schema_dependent/JsonSerializer.cpp +++ b/src/serializers/schema_dependent/JsonSerializer.cpp @@ -52,6 +52,8 @@ namespace { class format_value_visitor : public boost::static_visitor { public: + format_value_visitor() = default; + template json operator()(const T& t) const { if constexpr (std::is_same_v, Derived> || std::is_same_v, boost::dynamic_bitset<>> || std::is_same_v, express::Base> || std::is_same_v, std::vector> || std::is_same_v, std::vector> || std::is_same_v, std::vector> || std::is_same_v, std::vector>> || std::is_same_v, std::vector> || std::is_same_v, std::vector>> || std::is_same_v, std::vector>> || std::is_same_v, std::vector>> || std::is_same_v, empty_aggregate_t> || std::is_same_v, empty_aggregate_of_aggregate_t> || std::is_same_v, Blank>) { @@ -71,6 +73,8 @@ class format_value_visitor : public boost::static_visitor { class get_type_visitor : public boost::static_visitor { public: + get_type_visitor() = default; + template std::string operator()(const T& t) const { // @todo more types