Remaining cpp changes

This commit is contained in:
Thomas Krijnen
2026-01-10 10:20:34 +01:00
parent 7f4d9e31c3
commit 69a4ad35a1
6 changed files with 32 additions and 10 deletions
+1 -1
View File
@@ -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);
}
+18
View File
@@ -191,6 +191,24 @@ struct hash<express::Entity> {
} // namespace std
namespace boost {
template <>
struct hash<express::Base> {
std::size_t operator()(const express::Base& c) const noexcept {
return std::hash<uint32_t>{}(c.identity());
}
};
template <>
struct hash<express::Entity> {
std::size_t operator()(const express::Entity& c) const noexcept {
return std::hash<uint32_t>{}(c.identity());
}
};
} // namespace boost
template <typename T, typename U>
std::vector<T> cast_vector(const std::vector<U>& vs) {
std::vector<T> result;
+4 -4
View File
@@ -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<ifcopenshell::geometry::settings::UseElementTypes>().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;
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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<IfcUtil::IfcBaseEntity>();
gss.instance = f.instance_by_id(s.id).as<express::Entity>();
}
}
@@ -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<std::string>(representation_group, "geom_id");
auto inst = f.instance_by_id(id)->as<IfcUtil::IfcBaseEntity>();
auto inst = f.instance_by_id(id).as<express::Entity>();
boost::shared_ptr<IfcGeom::Representation::BRep> brep_geometry;
boost::shared_ptr<IfcGeom::Representation::Triangulation> 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<IfcUtil::IfcBaseClass>();
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);
@@ -52,6 +52,8 @@ namespace {
class format_value_visitor : public boost::static_visitor<std::string> {
public:
format_value_visitor() = default;
template <typename T>
json operator()(const T& t) const {
if constexpr (std::is_same_v<std::decay_t<T>, Derived> || std::is_same_v<std::decay_t<T>, boost::dynamic_bitset<>> || std::is_same_v<std::decay_t<T>, express::Base> || std::is_same_v<std::decay_t<T>, std::vector<int>> || std::is_same_v<std::decay_t<T>, std::vector<double>> || std::is_same_v<std::decay_t<T>, std::vector<std::string>> || std::is_same_v<std::decay_t<T>, std::vector<boost::dynamic_bitset<>>> || std::is_same_v<std::decay_t<T>, std::vector<express::Base>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<express::Base>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<int>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<double>>> || std::is_same_v<std::decay_t<T>, empty_aggregate_t> || std::is_same_v<std::decay_t<T>, empty_aggregate_of_aggregate_t> || std::is_same_v<std::decay_t<T>, Blank>) {
@@ -71,6 +73,8 @@ class format_value_visitor : public boost::static_visitor<std::string> {
class get_type_visitor : public boost::static_visitor<std::string> {
public:
get_type_visitor() = default;
template <typename T>
std::string operator()(const T& t) const {
// @todo more types