From 08e4d16f28f7531e22e22acfa5d72b6467bc1f70 Mon Sep 17 00:00:00 2001 From: Tristan Zimpfer Date: Fri, 21 Apr 2017 18:05:35 +0200 Subject: [PATCH] Modified the condition checking if the parent had changed so an object without parent isn't placed in a storey. --- src/ifcconvert/ColladaSerializer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index b87d33ebdd..1512b2836f 100644 --- a/src/ifcconvert/ColladaSerializer.cpp +++ b/src/ifcconvert/ColladaSerializer.cpp @@ -369,7 +369,6 @@ void ColladaSerializer::ColladaExporter::endDocument() { // In fact due the XML based nature of Collada and its dependency on library nodes, // only at this point all objects are written to the stream. materials.write(); - std::set geometries_written; @@ -391,16 +390,19 @@ void ColladaSerializer::ColladaExporter::endDocument() { for (std::vector::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it){ const std::string object_name = it->unique_id; - //if the setting USE_ELEMENT_HIERARCHY is in use, we check if the parent changed - if (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) && it->parent != NULL && parent_id != it->parent->id()){ + //if the setting USE_ELEMENT_HIERARCHY is in use, we check if the parent has changed + if (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) && ((it->parent == NULL && parent_id != -1) || (it->parent != NULL && parent_id != it->parent->id()))){ //close the parent tag, if one is already open. if (!is_parent_empty){ scene.closeParent(); } - parent_id = it->parent->id(); - scene.addParent(*it->parent); - is_parent_empty = false; + + if (it->parent != NULL){ + parent_id = it->parent->id(); + scene.addParent(*it->parent); + is_parent_empty = false; + } } /// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name