Skip to content

Commit ad5444b

Browse files
committed
Inverse attributes with 0-1 cardinality not as ifcXML aggregates
1 parent c0d4110 commit ad5444b

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/ifcparse/parse_ifcxml.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,28 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
484484
});
485485
if (found == inverses.end()) {
486486
Logger::Error("Unknown attribute " + tagname);
487+
state->stack.push_back(state->stack.back());
487488
} else {
488-
state->stack.push_back(stack_node::inverse(state->stack.back().inst(), *found));
489+
if ((*found)->bound1() == 0 && (*found)->bound2() == 1) {
490+
auto inst_or_ref = create_instance((*found)->entity_reference());
491+
IfcUtil::IfcBaseClass* inst;
492+
Argument* attr;
493+
instance_to_attribute(inst_or_ref, attr, inst);
494+
if (inst != nullptr) {
495+
int idx = (*found)->entity_reference()->attribute_index(
496+
(*found)->attribute_reference()
497+
);
498+
IfcWrite::IfcWriteArgument* attr_inv = new IfcWrite::IfcWriteArgument();
499+
attr_inv->set(state->stack.back().inst());
500+
inst->data().setArgument(idx, attr_inv);
501+
state->stack.push_back(stack_node::instance(id_in_file, inst));
502+
} else {
503+
Logger::Error("Unknown attribute " + tagname);
504+
state->stack.push_back(state->stack.back());
505+
}
506+
} else {
507+
state->stack.push_back(stack_node::inverse(state->stack.back().inst(), *found));
508+
}
489509
}
490510
} else {
491511
const IfcParse::parameter_type* attribute_type = current->attribute_by_index(idx)->type_of_attribute();

0 commit comments

Comments
 (0)