Skip to content

Commit dedbf70

Browse files
committed
fill context attribute of the shape elements (similar to v0.7.0) #4832
1 parent d8cf6ca commit dedbf70

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

src/ifcgeom/Converter.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/ifcgeom/IfcGeomElement.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ namespace IfcGeom {
9292
const std::string& name() const { return _name; }
9393
const std::string& type() const { return _type; }
9494
const std::string& guid() const { return _guid; }
95+
// Return the representation's identifier (e.g. "Body") if present, or it's context type (e.g. "Model").
9596
const std::string& context() const { return _context; }
9697
const std::string& unique_id() const { return _unique_id; }
9798
const Transformation& transformation() const { return _transformation; }

0 commit comments

Comments
 (0)