From 29fd32be75696aee6dbb975e40cdbc24999851ee Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 18 Apr 2024 21:15:40 +0200 Subject: [PATCH] Fixes after settings rework --- src/ifcgeom/mapping/IfcRepresentation.cpp | 15 ++++++++++----- src/ifcgeom/mapping/mapping.cpp | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ifcgeom/mapping/IfcRepresentation.cpp b/src/ifcgeom/mapping/IfcRepresentation.cpp index 614db96690..27ddea3267 100644 --- a/src/ifcgeom/mapping/IfcRepresentation.cpp +++ b/src/ifcgeom/mapping/IfcRepresentation.cpp @@ -22,8 +22,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) { - // @todo - const bool use_body = !this->settings_.get().get(); + const bool items_to_include = !this->settings_.get().get(); auto items = map_to_collection(this, inst->Items()); if (!items) { @@ -42,9 +41,15 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) { // @todo // if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) { - auto filtered = filter_in_place(items, [&use_body](taxonomy::ptr i) { - // @todo just filter loops for now. - return (i->kind() != taxonomy::LOOP && i->kind() != taxonomy::PIECEWISE_FUNCTION) == use_body; + auto filtered = filter_in_place(items, [&items_to_include](taxonomy::ptr i) { + auto is_curve = (i->kind() == taxonomy::EDGE || i->kind() == taxonomy::LOOP || i->kind() == taxonomy::PIECEWISE_FUNCTION); + if (is_curve && items_to_include == settings::SURFACES_AND_SOLIDS) { + return false; + } else if (!is_curve && items_to_include == settings::CURVES) { + return false; + } else { + return true; + } }); if (filtered->children.empty()) { diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 73f05196cd..5bfc33177f 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -952,7 +952,7 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation allowed_context_types.insert("notdefined"); std::set context_types; - if (settings_.get().get()) { + if (this->settings_.get().get() != settings::CURVES) { // Really this should only be 'Model', as per // the standard 'Design' is deprecated. So, // just for backwards compatibility: @@ -962,7 +962,7 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation context_types.insert("model view"); context_types.insert("detail view"); } - if (settings_.get().get()) { + if (this->settings_.get().get() != settings::SURFACES_AND_SOLIDS) { context_types.insert("plan"); } @@ -1051,7 +1051,7 @@ IfcUtil::IfcBaseEntity* mapping::representation_of(const IfcUtil::IfcBaseEntity* } } - if (intersection->size() == 0 && settings_.get().has() && settings_.get().get() && !settings_.get().get()) { + if (intersection->size() == 0 && settings_.get().has() && this->settings_.get().get() == settings::CURVES) { for (auto& r : *of_product) { if (r->RepresentationIdentifier() && *r->RepresentationIdentifier() == "Axis") { intersection->push(r);