diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index 8fea20fa6e..2015e7791c 100644 --- a/src/ifcconvert/ColladaSerializer.cpp +++ b/src/ifcconvert/ColladaSerializer.cpp @@ -363,8 +363,8 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme material_references.push_back(material_name); } - DeferredObject defered = (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) ? - DeferredObject(name, representation_id, o->type(), o->transformation().matrix().data(), mesh.verts(), mesh.normals(), + DeferredObject defered = (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) && o->storey() != NULL ? + DeferredObject(name, representation_id, o->type(), o->transformation().matrix().data(), mesh.verts(), mesh.normals(), mesh.faces(), mesh.edges(), mesh.material_ids(), mesh.materials(), material_references, mesh.uvs(), *(o->storey())) : DeferredObject(name, representation_id, o->type(), o->transformation().matrix().data(), mesh.verts(), mesh.normals(), mesh.faces(), mesh.edges(), mesh.material_ids(), mesh.materials(), material_references, mesh.uvs())); @@ -373,20 +373,30 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme std::string ColladaSerializer::ColladaExporter::differentiateSlabTypes(const IfcGeom::TriangulationElement* o) { IfcSlab* slab = (IfcSlab*)o->product(); - switch (slab->PredefinedType()){ - case (IfcSlabTypeEnum::IfcSlabType_ROOF): - return "_Roof"; - break; - case (IfcSlabTypeEnum::IfcSlabType_LANDING): - return "_Landing"; - break; - case (IfcSlabTypeEnum::IfcSlabType_BASESLAB): - return "_BasesLab"; - break; - default: - return "_Unknown"; - break; - } + switch (slab->PredefinedType()) + { + case (IfcSlabTypeEnum::IfcSlabType_FLOOR): + return "_Floor"; + break; + case (IfcSlabTypeEnum::IfcSlabType_ROOF): + return "_Roof"; + break; + case (IfcSlabTypeEnum::IfcSlabType_LANDING): + return "_Landing"; + break; + case (IfcSlabTypeEnum::IfcSlabType_BASESLAB): + return "_BaseSlab"; + break; + case (IfcSlabTypeEnum::IfcSlabType_USERDEFINED): + return "_" + slab->ObjectType(); + break; + case (IfcSlabTypeEnum::IfcSlabType_NOTDEFINED): + return "_NotDefined"; + break; + default: + return "_Unknown"; + break; + } } void ColladaSerializer::ColladaExporter::endDocument() { diff --git a/src/ifcconvert/ColladaSerializer.h b/src/ifcconvert/ColladaSerializer.h index 15bf6f84b8..60fd39370f 100644 --- a/src/ifcconvert/ColladaSerializer.h +++ b/src/ifcconvert/ColladaSerializer.h @@ -127,17 +127,34 @@ private: class DeferredObject { friend bool operator < (const DeferredObject & def_obj1, const DeferredObject & def_obj2) { + // Retrieve the parents of the objects to compare const IfcGeom::Element* parent1 = def_obj1.parent; const IfcGeom::Element* parent2 = def_obj2.parent; + // If a parent is null if (parent1 == NULL || parent2 == NULL) { - bool res = (def_obj1.unique_id < def_obj2.unique_id ? true : false); + bool res = (parent1 == NULL) ? true : false; return res; } + // If both parent are not null else { - bool res = parent1->name() < parent2->name() ? true : false; + // Retrieve the IfcBuildingStorey + Ifc2x3::IfcBuildingStorey* storey1 = (Ifc2x3::IfcBuildingStorey*)parent1->product(); + Ifc2x3::IfcBuildingStorey* storey2 = (Ifc2x3::IfcBuildingStorey*)parent2->product(); + + bool res = true; + + // Check if the storeys both have an elevation value + if (storey1->hasElevation() && storey2->hasElevation()) + { + // Use the elevation in order to sort + res = storey1->Elevation() > storey2->Elevation() ? true : false; + } + // If the evelations are not set, use the names to sort + else { res = parent1->name().compare(parent2->name()) > 0 ? true : false; } + return res; } } diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index 8b90046e69..223704bb6a 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -604,6 +604,7 @@ namespace IfcGeom { } if (hasParent) { ret->SetFloor(parent_object); } + else { ret->SetFloor(NULL); } // Set it so null in order to know that we didn't found any IfcBuildingStorey type parent } }