From 463cc08f3f0c2216cff868ab65ba5e1f4455e83d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 19 Nov 2024 22:46:17 +0100 Subject: [PATCH] Part: Expose Geometry::isSame() to Python --- src/Mod/Part/App/GeometryPy.xml | 8 ++++++++ src/Mod/Part/App/GeometryPyImp.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Mod/Part/App/GeometryPy.xml b/src/Mod/Part/App/GeometryPy.xml index b8d5cc425f..d259660688 100644 --- a/src/Mod/Part/App/GeometryPy.xml +++ b/src/Mod/Part/App/GeometryPy.xml @@ -53,6 +53,14 @@ It describes the common behavior of these objects when: Create a clone of this geometry with the same Tag + + + + isSame(geom, tol, angulartol) -> boolean + + Compare this geometry to another one + + Returns a boolean indicating whether a geometry extension of the type indicated as a string exists. diff --git a/src/Mod/Part/App/GeometryPyImp.cpp b/src/Mod/Part/App/GeometryPyImp.cpp index 095ef90d54..8cc3b90743 100644 --- a/src/Mod/Part/App/GeometryPyImp.cpp +++ b/src/Mod/Part/App/GeometryPyImp.cpp @@ -203,6 +203,20 @@ PyObject* GeometryPy::clone(PyObject *args) return cpy; } +PyObject* GeometryPy::isSame(PyObject *args) +{ + PyObject* other {}; + double tol {}; + double angular {}; + if (!PyArg_ParseTuple(args, "O!dd", &GeometryPy::Type, &other, &tol, &angular)) { + return nullptr; + } + + Part::Geometry* geom = this->getGeometryPtr(); + bool same = geom->isSame(*static_cast(other)->getGeometryPtr(), tol, angular); + return Py::new_reference_to(Py::Boolean(same)); +} + PyObject* GeometryPy::setExtension(PyObject *args) { PyObject* o;