@@ -233,14 +233,19 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
233233
234234 std::string context_string = " " ;
235235
236- /*
237- // @todo
238- if (representation->RepresentationIdentifier()) {
239- context_string = *representation->RepresentationIdentifier();
240- } else if (representation->ContextOfItems()->ContextType()) {
241- context_string = *representation->ContextOfItems()->ContextType();
236+ // IfcShapeRepresentation.
237+ const IfcUtil::IfcBaseEntity *representation = representation_node->instance ->as <IfcUtil::IfcBaseEntity>();
238+ auto representation_identifier = representation->get (" RepresentationIdentifier" );
239+ if (!representation_identifier->isNull ()) {
240+ context_string = *representation_identifier;
241+ }
242+ else {
243+ IfcUtil::IfcBaseClass *context = (IfcUtil::IfcBaseClass *) *representation->get (" ContextOfItems" );
244+ auto context_type = context->as <IfcUtil::IfcBaseEntity>()->get (" ContextType" );
245+ if (!context_type->isNull ()) {
246+ context_string = *context_type;
247+ }
242248 }
243- */
244249
245250 auto elem = new IfcGeom::BRepElement (
246251 product->data ().id (),
@@ -343,26 +348,16 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
343348
344349 const std::string guid = product->get_value <std::string>(" GlobalId" );
345350 const std::string name = product->get_value <std::string>(" Name" , " " );
346-
347- /*
348- std::string context_string = "";
349- if (representation->hasRepresentationIdentifier()) {
350- context_string = representation->RepresentationIdentifier();
351- } else if (representation->ContextOfItems()->hasContextType()) {
352- context_string = representation->ContextOfItems()->ContextType();
353- }
354- */
355-
356351 const std::string product_type = product->declaration ().name ();
352+ const std::string context_string = brep->context ();
357353
358354 return new IfcGeom::BRepElement (
359355 product->data ().id (),
360356 parent_id,
361357 name,
362358 product_type,
363359 guid,
364- // @todo
365- " " ,
360+ context_string,
366361 place,
367362 brep->geometry_pointer (),
368363 product
0 commit comments