From 1d8235c234e8f559168179972d4a476b1bed82f0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 18 May 2020 13:17:26 +0200 Subject: [PATCH] Part: [skip ci] get n-th derivative of a surface via Python --- src/Mod/Part/App/GeometrySurfacePy.xml | 10 +++++ src/Mod/Part/App/GeometrySurfacePyImp.cpp | 46 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/Mod/Part/App/GeometrySurfacePy.xml b/src/Mod/Part/App/GeometrySurfacePy.xml index 16fbc7135e..a15a2d63fd 100644 --- a/src/Mod/Part/App/GeometrySurfacePy.xml +++ b/src/Mod/Part/App/GeometrySurfacePy.xml @@ -22,6 +22,16 @@ Return the shape for the geometry. + + + Returns the point of given parameter + + + + + Returns the n-th derivative + + value(u,v) -> Point diff --git a/src/Mod/Part/App/GeometrySurfacePyImp.cpp b/src/Mod/Part/App/GeometrySurfacePyImp.cpp index 5dd47e04c8..a75a0a961d 100644 --- a/src/Mod/Part/App/GeometrySurfacePyImp.cpp +++ b/src/Mod/Part/App/GeometrySurfacePyImp.cpp @@ -281,6 +281,52 @@ PyObject* GeometrySurfacePy::toShape(PyObject *args) return 0; } +PyObject* GeometrySurfacePy::getD0(PyObject *args) +{ + Handle(Geom_Geometry) g = getGeometryPtr()->handle(); + Handle(Geom_Surface) s = Handle(Geom_Surface)::DownCast(g); + try { + if (!s.IsNull()) { + double u,v; + if (!PyArg_ParseTuple(args, "dd", &u, &v)) + return nullptr; + gp_Pnt p; + s->D0(u, v, p); + return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z())); + } + } + catch (Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return nullptr; + } + + PyErr_SetString(PartExceptionOCCError, "Geometry is not a surface"); + return nullptr; +} + +PyObject* GeometrySurfacePy::getDN(PyObject *args) +{ + Handle(Geom_Geometry) g = getGeometryPtr()->handle(); + Handle(Geom_Surface) s = Handle(Geom_Surface)::DownCast(g); + try { + if (!s.IsNull()) { + int nu, nv; + double u,v; + if (!PyArg_ParseTuple(args, "ddii", &u, &v, &nu, &nv)) + return nullptr; + gp_Vec v1 = s->DN(u, v, nu, nv); + return new Base::VectorPy(Base::Vector3d(v1.X(),v1.Y(),v1.Z())); + } + } + catch (Standard_Failure& e) { + PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); + return nullptr; + } + + PyErr_SetString(PartExceptionOCCError, "Geometry is not a surface"); + return nullptr; +} + PyObject* GeometrySurfacePy::value(PyObject *args) { Handle(Geom_Geometry) g = getGeometryPtr()->handle();