Part: use of ShapeMapHasher for code simplification
This commit is contained in:
@@ -92,6 +92,7 @@
|
||||
|
||||
#include "OCCError.h"
|
||||
#include "PartPyCXX.h"
|
||||
#include "ShapeMapHasher.h"
|
||||
|
||||
|
||||
using namespace Part;
|
||||
@@ -1306,11 +1307,7 @@ PyObject* TopoShapePy::ancestorsOfType(PyObject *args)
|
||||
TopTools_ListIteratorOfListOfShape it(ancestors);
|
||||
for (; it.More(); it.Next()) {
|
||||
// make sure to avoid duplicates
|
||||
#if OCC_VERSION_HEX >= 0x070800
|
||||
const size_t code = std::hash<TopoDS_Shape>{}(static_cast<TopoDS_Shape>(it.Value()));
|
||||
#else
|
||||
Standard_Integer code = it.Value().HashCode(INT_MAX);
|
||||
#endif
|
||||
Standard_Integer code = ShapeMapHasher{}(it.Value());
|
||||
if (hashes.find(code) == hashes.end()) {
|
||||
list.append(shape2pyshape(it.Value()));
|
||||
hashes.insert(code);
|
||||
@@ -1932,11 +1929,7 @@ PyObject* TopoShapePy::hashCode(PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "|i",&upper))
|
||||
return nullptr;
|
||||
|
||||
#if OCC_VERSION_HEX >= 0x070800
|
||||
int hc = std::hash<TopoDS_Shape>{}(getTopoShapePtr()->getShape());
|
||||
#else
|
||||
int hc = getTopoShapePtr()->getShape().HashCode(upper);
|
||||
#endif
|
||||
int hc = ShapeMapHasher{}(getTopoShapePtr()->getShape());
|
||||
return Py_BuildValue("i", hc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user