diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index 7e6b3ec184..a931b3fc46 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -342,6 +342,11 @@ namespace IfcGeom { // WR31: The parent context shall not be another geometric representation sub context. } + for (auto context_id : settings.context_ids()) { + IfcSchema::IfcGeometricRepresentationContext* context = ifc_file->instance_by_id(context_id)->as(); + representations->push(context->RepresentationsInContext()); + } + if (any_precision_encountered) { // Some arbitrary factor that has proven to work better for the models in the set of test files. lowest_precision_encountered *= kernel.getValue(IfcGeom::Kernel::GV_PRECISION_FACTOR); diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index 5f8dc82bb6..30e572f7b9 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -112,6 +112,7 @@ namespace IfcGeom double deflection_tolerance() const { return deflection_tolerance_; } double angular_tolerance() const { return angular_tolerance_; } double force_space_transparency() const { return force_space_transparency_; } + std::set context_ids() const { return context_ids_; } void set_deflection_tolerance(double value) { @@ -130,7 +131,11 @@ namespace IfcGeom void force_space_transparency(double value) { force_space_transparency_ = value; - } + } + + void set_context_ids(std::vector value) { + context_ids_ = std::set(value.begin(), value.end()); + } /// Get boolean value for a single settings or for a combination of settings. bool get(unsigned setting) const @@ -158,6 +163,7 @@ namespace IfcGeom protected: unsigned settings_; double deflection_tolerance_, angular_tolerance_, force_space_transparency_; + std::set context_ids_; }; class IFC_GEOM_API ElementSettings : public IteratorSettings diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index 8ea57cc6f9..6ee793cbd8 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -887,8 +887,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta // @nb the selection is partly duplicated from convert_curves() but it's needed as a // geometric set by it's static class definition does not inform us of the type of elements. // @todo handle this better so that this doesn't log an error. - const bool include_curves = getValue(GV_DIMENSIONALITY) != +1; - const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1; aggregate_of_instance::ptr elements = l->Elements(); if ( !elements->size() ) return false; @@ -902,11 +900,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta if (!(convert_shapes(element, items) && flatten_shape_list(items, s, false))) { continue; } - } else if (shape_type(element) == ST_SHAPE && include_solids_and_surfaces) { + } else if (shape_type(element) == ST_SHAPE) { if (!convert_shape(element, s)) { continue; } - } else if (shape_type(element) == ST_WIRE && include_curves) { + } else if (shape_type(element) == ST_WIRE) { TopoDS_Wire w; if (!convert_wire(element, w)) { continue; diff --git a/src/ifcgeom/IfcRegister.cpp b/src/ifcgeom/IfcRegister.cpp index 77de689e3d..3c4340d520 100644 --- a/src/ifcgeom/IfcRegister.cpp +++ b/src/ifcgeom/IfcRegister.cpp @@ -54,34 +54,30 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r) const unsigned int id = l->data().id(); bool success = false; bool processed = false; - bool ignored = false; #ifndef NO_CACHE std::map::const_iterator it = cache.Shape.find(id); if ( it != cache.Shape.end() ) { r = it->second; return true; } #endif - const bool include_curves = getValue(GV_DIMENSIONALITY) != +1; - const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1; IfcGeom::ShapeType st = shape_type(l); - ignored = (!include_solids_and_surfaces && (st == ST_SHAPE || st == ST_FACE)) || (!include_curves && (st == ST_WIRE || st == ST_CURVE)); if (st == ST_SHAPELIST) { processed = true; IfcRepresentationShapeItems items; success = convert_shapes(l, items) && flatten_shape_list(items, r, false); - } else if (st == ST_SHAPE && include_solids_and_surfaces) { + } else if (st == ST_SHAPE) { #include "IfcRegisterConvertShape.h" - } else if (st == ST_FACE && include_solids_and_surfaces) { + } else if (st == ST_FACE) { processed = true; success = convert_face(l, r); - } else if (st == ST_WIRE && include_curves) { + } else if (st == ST_WIRE) { processed = true; TopoDS_Wire w; success = convert_wire(l, w); if (success) { r = w; } - } else if (st == ST_CURVE && include_curves) { + } else if (st == ST_CURVE) { processed = true; Handle(Geom_Curve) crv; TopoDS_Wire w; @@ -102,7 +98,7 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r) BRepCheck_Analyzer ana(r); Logger::Notice("Valid: " + std::to_string(ana.IsValid()), l); } - } else if (!ignored) { + } else { const char* const msg = processed ? "Failed to convert:" : "No operation defined for:"; @@ -131,4 +127,4 @@ bool IfcGeom::Kernel::convert_curve(const IfcBaseInterface* l, Handle(Geom_Curve #include "IfcRegisterConvertCurve.h" Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l); return false; -} \ No newline at end of file +}