From 4c976c8b70f44d488d4adb69d3b721d0c8947b0e Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 26 Nov 2014 14:32:54 +0000 Subject: [PATCH] Track the surface style of an IfcBooleanResult --- src/ifcgeom/IfcGeomRenderStyles.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ifcgeom/IfcGeomRenderStyles.h b/src/ifcgeom/IfcGeomRenderStyles.h index 99124760cf..2838cee1f6 100644 --- a/src/ifcgeom/IfcGeomRenderStyles.h +++ b/src/ifcgeom/IfcGeomRenderStyles.h @@ -103,6 +103,27 @@ namespace IfcGeom { template std::pair get_surface_style(const IfcSchema::IfcRepresentationItem* representation_item) { IfcSchema::IfcStyledItem::list::ptr styled_items = representation_item->StyledByItem(); + + // Preferably this item-specific logic should not be here, but it easier than somehow associating this information + // with a bare TopoDS_Shape. Perhaps the real solution is to 'upgrade' IfcBooleanResult from a SHAPE to SHAPES in + // IfcRegister.h so that surface style information can be tied to actual implementation of the conversion function. + if (styled_items->Size() == 0 && representation_item->is(IfcSchema::Type::IfcBooleanResult)) { + IfcSchema::IfcBooleanResult* boolean_result = (IfcSchema::IfcBooleanResult*) representation_item; + while (true) { + IfcSchema::IfcRepresentationItem* boolean_op = (IfcSchema::IfcRepresentationItem*) boolean_result->FirstOperand(); + IfcSchema::IfcStyledItem::list::ptr op_styled_items = boolean_op->StyledByItem(); + if (op_styled_items->Size() > 0) { + styled_items = op_styled_items; + break; + } + if (boolean_op->is(IfcSchema::Type::IfcBooleanResult)) { + boolean_result = (IfcSchema::IfcBooleanResult*) boolean_op; + } else { + break; + } + } + } + for (IfcSchema::IfcStyledItem::list::it jt = styled_items->begin(); jt != styled_items->end(); ++jt) { #ifdef USE_IFC4 IfcUtil::IfcAbstractSelect::list::ptr style_assignments = (*jt)->Styles();