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

Method get_decomposing_entity

src/ifcgeom/mapping/mapping.cpp:741–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739}
740
741IfcUtil::IfcBaseEntity* mapping::get_decomposing_entity(const IfcUtil::IfcBaseEntity* inst, bool include_openings) {
742 IfcSchema::IfcObjectDefinition* parent = 0;
743
744 auto product = inst->as<IfcSchema::IfcProduct>();
745 if (!product) {
746 return parent;
747 }
748
749 /* In case of an opening element, parent to the RelatingBuildingElement */
750 if (include_openings && product->declaration().is(IfcSchema::IfcOpeningElement::Class())) {
751 IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
752 IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
753 if (voids->size()) {
754 IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin();
755 parent = ifc_void->RelatingBuildingElement();
756 }
757 } else if (product->declaration().is(IfcSchema::IfcElement::Class())) {
758 IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
759 IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
760 /* In case of a RelatedBuildingElement parent to the opening element */
761 if (fills->size() && include_openings) {
762 for (IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++it) {
763 IfcSchema::IfcRelFillsElement* fill = *it;
764 IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
765 if (product == ifc_objectdef) continue;
766 parent = ifc_objectdef;
767 }
768 }
769 /* Else simply parent to the containing structure */
770 if (!parent) {
771 IfcSchema::IfcRelContainedInSpatialStructure::list::ptr parents = element->ContainedInStructure();
772 if (parents->size()) {
773 IfcSchema::IfcRelContainedInSpatialStructure* container = *parents->begin();
774 parent = container->RelatingStructure();
775 }
776 }
777 }
778
779 /* Parent decompositions to the RelatingObject */
780 if (!parent) {
781 aggregate_of_instance::ptr parents = product->file_->getInverse(product->id(), (&IfcSchema::IfcRelAggregates::Class()), -1);
782 parents->push(product->file_->getInverse(product->id(), (&IfcSchema::IfcRelNests::Class()), -1));
783 for (aggregate_of_instance::it it = parents->begin(); it != parents->end(); ++it) {
784 IfcSchema::IfcRelDecomposes* decompose = (*it)->as<IfcSchema::IfcRelDecomposes>();
785 IfcUtil::IfcBaseEntity* ifc_objectdef;
786
787 ifc_objectdef = get_RelatingObject(decompose);
788
789 if (!ifc_objectdef || product == ifc_objectdef) continue;
790 parent = ifc_objectdef->as<IfcSchema::IfcObjectDefinition>();
791 }
792 }
793 return parent;
794}
795
796std::map<std::string, IfcUtil::IfcBaseEntity*> mapping::get_layers(IfcUtil::IfcBaseEntity* inst) {
797 auto prod = inst->as<IfcSchema::IfcProduct>();

Calls 8

get_RelatingObjectFunction · 0.85
isMethod · 0.80
getInverseMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
idMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected