MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / get_object

Method get_object

src/ifcgeom/Iterator.cpp:594–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) {
595 ifcopenshell::geometry::taxonomy::matrix4::ptr m4;
596 int parent_id = -1;
597 std::string instance_type, product_name, product_guid;
598 IfcUtil::IfcBaseEntity* ifc_product = 0;
599
600 try {
601 ifc_product = ifc_file->instance_by_id(id)->as<IfcUtil::IfcBaseEntity>();
602 instance_type = ifc_product->declaration().name();
603
604 if (ifc_product->declaration().is("IfcRoot")) {
605 product_guid = (std::string)ifc_product->get("GlobalId");
606 product_name = ifc_product->get_value<std::string>("Name", "");
607 }
608
609 auto parent_object = converter_->mapping()->get_decomposing_entity(ifc_product);
610 if (parent_object) {
611 parent_id = parent_object->id();
612 }
613
614 // fails in case of IfcProject
615 auto mapped = converter_->mapping()->map(ifc_product);
616 auto casted = mapped ? ifcopenshell::geometry::taxonomy::dcast<ifcopenshell::geometry::taxonomy::geom_item>(mapped) : nullptr;
617
618 if (casted) {
619 m4 = casted->matrix;
620 }
621 } catch (const std::exception& e) {
622 Logger::Error(e);
623 } catch (...) {
624 Logger::Error("Unknown error returning product");
625 }
626
627 Element* ifc_object = new Element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product);
628 return ifc_object;
629}
630
631const IfcUtil::IfcBaseClass* IfcGeom::Iterator::create() {
632 const IfcUtil::IfcBaseClass* product = nullptr;

Callers 2

calculateMethod · 0.45
patchMethod · 0.45

Calls 8

isMethod · 0.80
ErrorFunction · 0.50
instance_by_idMethod · 0.45
nameMethod · 0.45
getMethod · 0.45
idMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected