From b712f30ad38b56adae6d3b477466f47494b41190 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 7 Apr 2025 21:25:33 +0200 Subject: [PATCH] Don't assign material as style when it doesn't have any styles #6314 --- src/ifcgeom/Converter.cpp | 12 +++++++----- src/ifcgeom/mapping/mapping.cpp | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ifcgeom/Converter.cpp b/src/ifcgeom/Converter.cpp index 9c6739292d..3b1aecc1fb 100644 --- a/src/ifcgeom/Converter.cpp +++ b/src/ifcgeom/Converter.cpp @@ -126,11 +126,13 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } if (single_material) { - auto s = taxonomy::cast(mapping_->map(single_material)); - for (auto it = shapes.begin(); it != shapes.end(); ++it) { - if (!it->hasStyle() && s) { - it->setStyle(s); - material_style_applied = true; + if (auto itm = mapping_->map(single_material)) { + auto s = taxonomy::cast(itm); + for (auto it = shapes.begin(); it != shapes.end(); ++it) { + if (!it->hasStyle() && s) { + it->setStyle(s); + material_style_applied = true; + } } } } else { diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 3abb7e41fe..b4685a7a86 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -556,6 +556,10 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) { } } + // When material does not have a representation we don't create a style from it + return nullptr; + + /* taxonomy::style::ptr material_style = taxonomy::make(); material_style->instance = material; if (settings_.get().get()) { @@ -566,6 +570,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) { material_style->name = oss.str(); } return material_style; + */ // @todo // IfcGeom::SurfaceStyle material_style = IfcGeom::SurfaceStyle(material->data().id(), material->Name());