Part: use of ShapeMapHasher for code simplification

This commit is contained in:
wmayer
2024-02-10 19:47:37 +01:00
committed by Chris Hennes
parent b45fcead7a
commit cc8452a545
7 changed files with 30 additions and 111 deletions

View File

@@ -82,6 +82,7 @@
#include <Gui/SoFCSelectionAction.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/ViewParams.h>
#include <Mod/Part/App/ShapeMapHasher.h>
#include <Mod/Part/App/Tools.h>
#include "ViewProviderExt.h"
@@ -981,12 +982,9 @@ void ViewProviderPartExt::updateVisual()
}
TopExp_Explorer xp;
for (xp.Init(faceMap(i),TopAbs_EDGE);xp.More();xp.Next())
#if OCC_VERSION_HEX >= 0x070800
faceEdges.insert(std::hash<TopoDS_Shape>{}(xp.Current()));
#else
faceEdges.insert(xp.Current().HashCode(INT_MAX));
#endif
for (xp.Init(faceMap(i),TopAbs_EDGE);xp.More();xp.Next()) {
faceEdges.insert(Part::ShapeMapHasher{}(xp.Current()));
}
numFaces++;
}
@@ -1014,11 +1012,7 @@ void ViewProviderPartExt::updateVisual()
// So, we have to store the hashes of the edges associated to a face.
// If the hash of a given edge is not in this list we know it's really
// a free edge.
#if OCC_VERSION_HEX >= 0x070800
int hash = std::hash<TopoDS_Shape>{}(aEdge);
#else
int hash = aEdge.HashCode(INT_MAX);
#endif
int hash = Part::ShapeMapHasher{}(aEdge);
if (faceEdges.find(hash) == faceEdges.end()) {
Handle(Poly_Polygon3D) aPoly = Part::Tools::polygonOfEdge(aEdge, aLoc);
if (!aPoly.IsNull()) {
@@ -1217,11 +1211,7 @@ void ViewProviderPartExt::updateVisual()
TopLoc_Location aLoc;
// handling of the free edge that are not associated to a face
#if OCC_VERSION_HEX >= 0x070800
int hash = std::hash<TopoDS_Shape>{}(aEdge);
#else
int hash = aEdge.HashCode(INT_MAX);
#endif
int hash = Part::ShapeMapHasher{}(aEdge);
if (faceEdges.find(hash) == faceEdges.end()) {
Handle(Poly_Polygon3D) aPoly = Part::Tools::polygonOfEdge(aEdge, aLoc);
if (!aPoly.IsNull()) {