From e07189e6b183534c460b7d490f57b76c18485b7d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 8 Dec 2017 13:26:23 +0100 Subject: [PATCH] Work on LOD use case --- src/hdf5_usecases/lod.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/hdf5_usecases/lod.cpp b/src/hdf5_usecases/lod.cpp index c2a5a27960..7d36823acd 100644 --- a/src/hdf5_usecases/lod.cpp +++ b/src/hdf5_usecases/lod.cpp @@ -94,7 +94,10 @@ void find_geometric_types(IfcParse::IfcFile& f, const std::string& tfn) { return a->data().id() < b->data().id(); }); - std::set geometric_types{ IfcSchema::Type::IfcStyledItem, IfcSchema::Type::IfcMaterialDefinitionRepresentation, IfcSchema::Type::IfcStyledRepresentation }; + std::set geometric_types{ + IfcSchema::Type::IfcStyledItem, IfcSchema::Type::IfcMaterialDefinitionRepresentation, IfcSchema::Type::IfcStyledRepresentation, + IfcSchema::Type::IfcSurfaceStyleRendering, IfcSchema::Type::IfcSurfaceStyle, IfcSchema::Type::IfcPresentationLayerAssignment + }; std::set other_types; std::set geometric_instances; @@ -108,6 +111,20 @@ void find_geometric_types(IfcParse::IfcFile& f, const std::string& tfn) { int N, n; + // Not referenced. Revit generates unused IfcExtrudedAreaSolids some times. + auto repitems = f.entitiesByType(IfcSchema::Type::IfcRepresentationItem); + std::for_each(repitems->begin(), repitems->end(), [&f, &geometric_instances](IfcUtil::IfcBaseClass* inst) { + auto invs = f.getInverse(inst->data().id(), IfcSchema::Type::UNDEFINED, -1); + if (invs->size() == 0) { + auto refs = f.traverse(inst); + std::for_each(refs->begin(), refs->end(), [&geometric_instances](IfcUtil::IfcBaseClass* inst2) { + if (inst2->declaration().as_entity()) { + geometric_instances.insert(inst2); + } + }); + } + }); + auto vist_geometric = [&f, &geometric_types, &geometric_instances, &N, &n](IfcUtil::IfcBaseEntity* def) { auto refs = f.traverse(def); geometric_instances.insert(refs->begin(), refs->end()); @@ -137,15 +154,6 @@ void find_geometric_types(IfcParse::IfcFile& f, const std::string& tfn) { fn = [&f, &geometric_instances, &other_types, &fn](IfcUtil::IfcBaseClass* root, IfcUtil::IfcBaseClass* inst) { if (geometric_instances.find(inst) == geometric_instances.end()) { auto ty = inst->declaration().type(); - if (ty == IfcSchema::Type::IfcExtrudedAreaSolid) { - std::cerr << inst->data().toString() << " reachded by " << root->data().toString() << std::endl; - } - - // Not referenced. Revit generates unused IfcExtrudedAreaSolids some times. - auto invs = f.getInverse(inst->data().id(), IfcSchema::Type::UNDEFINED, -1); - if (root == inst && invs->size() == 0) { - return; - } other_types.insert(ty); auto refs = f.traverse(inst, 1); @@ -173,6 +181,7 @@ void find_geometric_types(IfcParse::IfcFile& f, const std::string& tfn) { std::inserter(only_geometric, only_geometric.begin())); only_geometric.erase(IfcSchema::Type::IfcGeometricRepresentationContext); + only_geometric.erase(IfcSchema::Type::IfcGeometricRepresentationSubContext); std::cerr << "\nOnly geometric:" << std::endl; @@ -233,6 +242,8 @@ int main(int argc, char** argv) { IfcSchema::Type::IfcProperty, IfcSchema::Type::IfcPhysicalQuantity, IfcSchema::Type::IfcRelAssociatesClassification, + IfcSchema::Type::IfcClassification, + IfcSchema::Type::IfcClassificationReference, IfcSchema::Type::IfcRelAssociatesMaterial, IfcSchema::Type::IfcMaterialList, IfcSchema::Type::IfcMaterialLayerSetUsage,