Skip to content

Commit b712f30

Browse files
committed
Don't assign material as style when it doesn't have any styles #6314
1 parent 0bbe1aa commit b712f30

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/ifcgeom/Converter.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
126126
}
127127

128128
if (single_material) {
129-
auto s = taxonomy::cast<taxonomy::style>(mapping_->map(single_material));
130-
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
131-
if (!it->hasStyle() && s) {
132-
it->setStyle(s);
133-
material_style_applied = true;
129+
if (auto itm = mapping_->map(single_material)) {
130+
auto s = taxonomy::cast<taxonomy::style>(itm);
131+
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
132+
if (!it->hasStyle() && s) {
133+
it->setStyle(s);
134+
material_style_applied = true;
135+
}
134136
}
135137
}
136138
} else {

src/ifcgeom/mapping/mapping.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
556556
}
557557
}
558558

559+
// When material does not have a representation we don't create a style from it
560+
return nullptr;
561+
562+
/*
559563
taxonomy::style::ptr material_style = taxonomy::make<taxonomy::style>();
560564
material_style->instance = material;
561565
if (settings_.get<settings::UseMaterialNames>().get()) {
@@ -566,6 +570,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
566570
material_style->name = oss.str();
567571
}
568572
return material_style;
573+
*/
569574

570575
// @todo
571576
// IfcGeom::SurfaceStyle material_style = IfcGeom::SurfaceStyle(material->data().id(), material->Name());

0 commit comments

Comments
 (0)