From a6ffa7fc4287bc9476bfa6153a17830ec95c1b23 Mon Sep 17 00:00:00 2001 From: Balleux Benjamin Date: Tue, 9 May 2017 14:40:23 +0200 Subject: [PATCH 1/3] Fix : fill the storey property of an Element with NULL when we don't find any IfcBuildingStorey parent --- src/ifcconvert/ColladaSerializer.cpp | 4 ++-- src/ifcconvert/ColladaSerializer.h | 4 ++-- src/ifcgeom/IfcGeomIterator.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index 8fea20fa6e..7097b6febd 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())); diff --git a/src/ifcconvert/ColladaSerializer.h b/src/ifcconvert/ColladaSerializer.h index 15bf6f84b8..fe7ac48765 100644 --- a/src/ifcconvert/ColladaSerializer.h +++ b/src/ifcconvert/ColladaSerializer.h @@ -132,12 +132,12 @@ private: 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; } else { - bool res = parent1->name() < parent2->name() ? true : false; + bool 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 } } From 3c2fbcc4e17aa2b0fb1c85e8c232284d51492019 Mon Sep 17 00:00:00 2001 From: Balleux Benjamin Date: Tue, 9 May 2017 15:54:21 +0200 Subject: [PATCH 2/3] Feature : Handle every IfcSlabTypeEnum (3 were missing) and sort the floors by elevation --- src/ifcconvert/ColladaSerializer.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ifcconvert/ColladaSerializer.h b/src/ifcconvert/ColladaSerializer.h index fe7ac48765..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 = (parent1 == NULL) ? true : false; return res; } + // If both parent are not null else { - bool res = parent1->name().compare(parent2->name()) > 0 ? 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; } } From ef0e9d9eb4d1e6c2600bd9b636d341e1008cf6f0 Mon Sep 17 00:00:00 2001 From: Balleux Benjamin Date: Tue, 9 May 2017 15:55:37 +0200 Subject: [PATCH 3/3] Feature : Handle every IfcSlabTypeEnum (3 were missing) and sort the floors by elevation --- src/ifcconvert/ColladaSerializer.cpp | 38 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index 7097b6febd..2015e7791c 100644 --- a/src/ifcconvert/ColladaSerializer.cpp +++ b/src/ifcconvert/ColladaSerializer.cpp @@ -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() {