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

Method get

src/ifcgeom/Iterator.cpp:536–592  ·  view source on GitHub ↗

Gets the representation of the current geometrical entity.

Source from the content-addressed store, hash-verified

534
535/// Gets the representation of the current geometrical entity.
536IfcGeom::Element* IfcGeom::Iterator::get()
537{
538 validate_iterator_state();
539
540 auto ret = *task_result_iterator_;
541
542 // If we want to organize the element considering their hierarchy
543 if (settings_.get<ifcopenshell::geometry::settings::UseElementHierarchy>().get()) {
544 // We are going to build a vector with the element parents.
545 // First, create the parent vector
546 std::vector<const IfcGeom::Element*> parents;
547
548 // if the element has a parent
549 if (ret->parent_id() != -1) {
550 const IfcGeom::Element* parent_object = NULL;
551 bool hasParent = true;
552
553 // get the parent
554 try {
555 parent_object = get_object(ret->parent_id());
556 } catch (const std::exception& e) {
557 Logger::Error(e);
558 hasParent = false;
559 }
560
561 // Add the previously found parent to the vector
562 if (hasParent) parents.insert(parents.begin(), parent_object);
563
564 // We need to find all the parents
565 while (parent_object != NULL && hasParent && parent_object->parent_id() != -1) {
566 // Find the next parent
567 auto pid = parent_object->parent_id();
568 auto ifc_product = ifc_file->instance_by_id(pid)->as<IfcUtil::IfcBaseEntity>();
569 if (ifc_product->declaration().name() == "IfcProject") {
570 hasParent = false;
571 } else {
572 try {
573 parent_object = get_object(pid);
574 } catch (const std::exception& e) {
575 Logger::Error(e);
576 hasParent = false;
577 }
578 }
579
580 // Add the previously found parent to the vector
581 if (hasParent) parents.insert(parents.begin(), parent_object);
582
583 hasParent = hasParent && parent_object->parent_id() != -1;
584 }
585
586 // when done push the parent list in the Element object
587 ret->SetParents(parents);
588 }
589 }
590
591 return ret;
592}
593

Callers 15

get_fileMethod · 0.45
before_allFunction · 0.45
step_implFunction · 0.45
step_implFunction · 0.45
step_implFunction · 0.45
load_ifcMethod · 0.45
add_collision_objectsMethod · 0.45
export_jsonMethod · 0.45
read_colour_componentFunction · 0.45
object_idMethod · 0.45

Calls 7

parent_idMethod · 0.80
SetParentsMethod · 0.80
ErrorFunction · 0.50
insertMethod · 0.45
beginMethod · 0.45
instance_by_idMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected