From 460fd5ca87bac666ab0b14d3133e9444899a15ec Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 11 Apr 2022 14:12:17 +0200 Subject: [PATCH] #2133 faceset helper: compare index vectors by address instead of value --- src/ifcgeom/IfcGeom.h | 18 +++++++++++++++--- src/ifcgeom/IfcGeomFunctions.cpp | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index 687a437c4c..69a04f1339 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -111,6 +111,18 @@ public: std::map Shape; }; +namespace util { + template + typename std::enable_if::value, T&>::type conditional_address_of(T& t) { + return t; + } + + template + typename std::enable_if::value, T*>::type conditional_address_of(T& t) { + return &t; + } +} + class IFC_GEOM_API MAKE_TYPE_NAME(Kernel) : public IfcGeom::Kernel { private: @@ -126,7 +138,7 @@ private: class faceset_helper { private: MAKE_TYPE_NAME(Kernel)* kernel_; - std::set duplicates_; + std::set::value, LP, const LP*>::type> duplicates_; std::map vertex_mapping_; std::map, TopoDS_Edge> edges_; // not always in use @@ -225,8 +237,8 @@ private: return true; } - bool wire(LP loop, TopoDS_Wire& wire) { - if (duplicates_.find(loop) != duplicates_.end()) { + bool wire(const LP& loop, TopoDS_Wire& wire) { + if (duplicates_.find(util::conditional_address_of(loop)) != duplicates_.end()) { return false; } BRep_Builder builder; diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 130f919425..f156692b0d 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -5613,7 +5613,7 @@ IfcGeom::Kernel::faceset_helper::faceset_helper( if (edge_sets.find(segment_set) != edge_sets.end()) { duplicate_faces++; - duplicates_.insert(*ps); + duplicates_.insert(util::conditional_address_of(*ps)); continue; } edge_sets.insert(segment_set);