From 529f791c788a3a2bab51fa9ee63c5d182ef56004 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Wed, 17 May 2023 16:31:09 +0200 Subject: [PATCH] Part: add optional tolerance to python sortEdges() --- src/Mod/Part/App/AppPartPy.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 98960575fe..0847f92431 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -598,9 +598,10 @@ public: "The sorted list can be used to create a Wire." ); add_varargs_method("sortEdges",&Module::sortEdges2, - "sortEdges(list of edges) -- list of lists of edges\n" + "sortEdges(list of edges, [tol3d]) -- list of lists of edges\n" "It does basically the same as __sortEdges__ but sorts all input edges and thus returns\n" - "a list of lists of edges" + "a list of lists of edges\n" + "optional 3D tolerance defaults to Precision::Confusion" ); add_varargs_method("__toPythonOCC__",&Module::toPythonOCC, "__toPythonOCC__(shape) -- Helper method to convert an internal shape to pythonocc shape" @@ -2168,7 +2169,8 @@ private: Py::Object sortEdges2(const Py::Tuple& args) { PyObject *obj; - if (!PyArg_ParseTuple(args.ptr(), "O", &obj)) { + double tol3d = Precision::Confusion(); + if (!PyArg_ParseTuple(args.ptr(), "O|d", &obj, &tol3d)) { throw Py::Exception(PartExceptionOCCError, "list of edges expected"); } @@ -2191,7 +2193,7 @@ private: Py::List root_list; while(!edges.empty()) { - std::list sorted = sort_Edges(Precision::Confusion(), edges); + std::list sorted = sort_Edges(tol3d, edges); Py::List sorted_list; for (std::list::iterator it = sorted.begin(); it != sorted.end(); ++it) { sorted_list.append(Py::Object(new TopoShapeEdgePy(new TopoShape(*it)),true));