From 1bc39542d33196d585630b3a943f93b269c4f55c Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 11 Dec 2020 14:40:09 +0100 Subject: [PATCH] Part: [skip ci] support of keywords in Part.GeometrySurface.toBSpline() --- src/Mod/Part/App/GeometrySurfacePy.xml | 2 +- src/Mod/Part/App/GeometrySurfacePyImp.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Mod/Part/App/GeometrySurfacePy.xml b/src/Mod/Part/App/GeometrySurfacePy.xml index c4378cb449..339ad0eef2 100644 --- a/src/Mod/Part/App/GeometrySurfacePy.xml +++ b/src/Mod/Part/App/GeometrySurfacePy.xml @@ -172,7 +172,7 @@ Checks if the surface is planar within a certain tolerance. of the nearest orthogonal projection of the point. - + Returns a B-Spline representation of this surface. diff --git a/src/Mod/Part/App/GeometrySurfacePyImp.cpp b/src/Mod/Part/App/GeometrySurfacePyImp.cpp index 0a397ef058..67bfe22da1 100644 --- a/src/Mod/Part/App/GeometrySurfacePyImp.cpp +++ b/src/Mod/Part/App/GeometrySurfacePyImp.cpp @@ -706,20 +706,25 @@ Py::String GeometrySurfacePy::getContinuity(void) const return Py::String(str); } -PyObject* GeometrySurfacePy::toBSpline(PyObject * args) +PyObject* GeometrySurfacePy::toBSpline(PyObject * args, PyObject * kwds) { double tol3d=Precision::Confusion(); char *ucont="C1", *vcont="C1"; int maxDegU=Geom_BSplineSurface::MaxDegree(); int maxDegV=Geom_BSplineSurface::MaxDegree(); int maxSegm=1000, prec=0; - if (!PyArg_ParseTuple(args, "|dssiiii",&tol3d,&ucont,&vcont, - &maxDegU,&maxDegV,&maxSegm,&prec)) - return 0; - std::string uc = ucont; + static char *kwlist[] = {"Tol3d", "UContinuity", "VContinuity", "MaxDegreeU", "MaxDegreeV", "MaxSegments", "PrecisCode", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|dssiiii", kwlist, + &tol3d, &ucont, &vcont, + &maxDegU, &maxDegV, &maxSegm, &prec)) + return nullptr; + GeomAbs_Shape absU, absV; - if (uc == "C0") + std::string uc = ucont; + if (maxDegU <= 1) + absU = GeomAbs_C0; + else if (uc == "C0") absU = GeomAbs_C0; else if (uc == "C1") absU = GeomAbs_C1; @@ -735,7 +740,9 @@ PyObject* GeometrySurfacePy::toBSpline(PyObject * args) absU = GeomAbs_G2; std::string vc = vcont; - if (vc == "C0") + if (maxDegV <= 1) + absV = GeomAbs_C0; + else if (vc == "C0") absV = GeomAbs_C0; else if (vc == "C1") absV = GeomAbs_C1;