Fix bug in IfcHierarchyHelper.addRelatedObject

Noticed that `file.addRelatedObject<IfcSchema::IfcRelDefinesByType>(door_style, door);` was resulting in list with `door` assigned as RelatingObject and `door_style` assigned as RelatedObjects.
This commit is contained in:
Andrej730
2024-02-07 16:56:06 +05:00
parent 4617834578
commit 8b50f1bcd6
2 changed files with 5 additions and 3 deletions
+3 -3
View File
@@ -436,13 +436,13 @@ public:
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set<std::string>(IfcParse::IfcGlobalId()); data->setArgument(0, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(owner_hist); data->setArgument(1, attr); }
int relating_index = 4, related_index = 5;
if (T::Class().name() == "IfcRelContainedInSpatialStructure") {
// IfcRelContainedInSpatialStructure has attributes reversed.
if (T::Class().name() == "IfcRelContainedInSpatialStructure" || std::is_base_of<Schema::IfcRelDefines, T>::value) {
// some classes have attributes reversed.
std::swap(relating_index, related_index);
}
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(relating_object); data->setArgument(relating_index, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(related_objects); data->setArgument(related_index, attr); }
T* t = (T*)Schema::get_schema().instantiate(data);
addEntity(t);
}