From c9c65299788f248cb866b359557647a7720b5357 Mon Sep 17 00:00:00 2001 From: Jesse Vander Does Date: Fri, 5 Feb 2021 14:00:23 -0600 Subject: [PATCH] Added '--no-wire-intersection-check' --- src/ifcconvert/IfcConvert.cpp | 5 ++++- src/ifcgeom/IfcGeom.h | 2 ++ src/ifcgeom/IfcGeomFunctions.cpp | 12 +++++++++++- src/ifcgeom/IfcGeomIteratorImplementation.h | 6 ++++++ src/ifcgeom/IfcGeomIteratorSettings.h | 5 ++++- src/ifcgeom_schema_agnostic/Kernel.h | 3 ++- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 2e792f704c..dfdf468dd2 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -339,7 +339,8 @@ int main(int argc, char** argv) { ("default-material-file", new po::typed_value(&default_material_filename), "Specifies a material file that describes the material object types will have" "if an object does not have any specified material in the IFC file.") - ("validate", "Checks whether geometrical output conforms to the included explicit quantities."); + ("validate", "Checks whether geometrical output conforms to the included explicit quantities.") + ("no-wire-intersection-check", "Skip wire intersection check"); std::string bounds; #ifdef HAVE_ICU @@ -481,6 +482,7 @@ int main(int argc, char** argv) { const bool generate_uvs = vmap.count("generate-uvs") != 0; const bool validate = vmap.count("validate") != 0; const bool edge_arrows = vmap.count("edge-arrows") != 0; + const bool no_wire_intersection_check = vmap.count("no-wire-intersection-check") != 0; if (!quiet || vmap.count("version")) { print_version(); @@ -741,6 +743,7 @@ int main(int argc, char** argv) { settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement); settings.set(IfcGeom::IteratorSettings::BUILDING_LOCAL_PLACEMENT, building_local_placement); settings.set(IfcGeom::IteratorSettings::VALIDATE_QUANTITIES, validate); + settings.set(IfcGeom::IteratorSettings::NO_WIRE_INTERSECTION_CHECK, no_wire_intersection_check); settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names); settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids); diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index ada7140745..3a2fa22883 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -224,6 +224,7 @@ private: double modelling_precision; double dimensionality; double layerset_first; + double no_wire_intersection_check; // For stopping PlacementRelTo recursion in convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf) const IfcParse::declaration* placement_rel_to; @@ -256,6 +257,7 @@ public: , faceset_helper_(nullptr) , layerset_first(-1.) , disable_boolean_result(-1.) + , no_wire_intersection_check(-1) {} MAKE_TYPE_NAME(Kernel)(const MAKE_TYPE_NAME(Kernel)& other) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 48cd927d6c..b8d32cf691 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1157,7 +1157,12 @@ bool IfcGeom::Kernel::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compoun } TopTools_ListOfShape results; - results.Append(w); + if (getValue(GV_NO_WIRE_INTERSECTION_CHECK) < 0. && wire_intersections(w, results)) { + Logger::Warning("Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); + } else { + results.Clear(); + results.Append(w); + } TopoDS_Compound C; BRep_Builder B; @@ -1410,6 +1415,9 @@ void IfcGeom::Kernel::setValue(GeomValue var, double value) { case GV_DISABLE_BOOLEAN_RESULT: disable_boolean_result = value; break; + case GV_NO_WIRE_INTERSECTION_CHECK: + no_wire_intersection_check = value; + break; default: throw std::runtime_error("Invalid setting"); } @@ -1439,6 +1447,8 @@ double IfcGeom::Kernel::getValue(GeomValue var) const { return layerset_first; case GV_DISABLE_BOOLEAN_RESULT: return disable_boolean_result; + case GV_NO_WIRE_INTERSECTION_CHECK: + return no_wire_intersection_check; } throw std::runtime_error("Invalid setting"); } diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index 590a2c16c5..18b1a8edaa 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -1003,6 +1003,12 @@ namespace IfcGeom { ? +1.0 : -1.0 ); + kernel.setValue(IfcGeom::Kernel::GV_NO_WIRE_INTERSECTION_CHECK, + settings.get(IteratorSettings::NO_WIRE_INTERSECTION_CHECK) + ? +1.0 + : -1.0 + ); + kernel.setValue(IfcGeom::Kernel::GV_DISABLE_BOOLEAN_RESULT, settings.get(IteratorSettings::DISABLE_BOOLEAN_RESULT) ? +1.0 diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index d0c57f6381..a589d99988 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -94,8 +94,11 @@ namespace IfcGeom EDGE_ARROWS = 1 << 19, /// Disables the evaluation of IfcBooleanResult and simply returns FirstOperand DISABLE_BOOLEAN_RESULT = 1 << 20, + // Disables wire intersection checks + NO_WIRE_INTERSECTION_CHECK = 1 << 21, + /// Number of different setting flags. - NUM_SETTINGS = 20 + NUM_SETTINGS = 21, }; /// Used to store logical OR combination of setting flags. typedef unsigned SettingField; diff --git a/src/ifcgeom_schema_agnostic/Kernel.h b/src/ifcgeom_schema_agnostic/Kernel.h index cabe346f62..1b13e8eada 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.h +++ b/src/ifcgeom_schema_agnostic/Kernel.h @@ -54,7 +54,8 @@ namespace IfcGeom { // Whether to process shapes of type Face or higher (1) Wire or lower (-1) or all (0) GV_DIMENSIONALITY, GV_LAYERSET_FIRST, - GV_DISABLE_BOOLEAN_RESULT + GV_DISABLE_BOOLEAN_RESULT, + GV_NO_WIRE_INTERSECTION_CHECK }; Kernel(IfcParse::IfcFile* file_ = 0);