From efb403b8f93077038aa781f2513920d8e7012b23 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Fri, 28 Aug 2020 17:47:17 +0200 Subject: [PATCH] Edge.curveOnSurface : add placement to the output tuple --- src/Mod/Part/App/TopoShapeEdgePy.xml | 4 ++-- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/TopoShapeEdgePy.xml b/src/Mod/Part/App/TopoShapeEdgePy.xml index 9600346492..828cff90ba 100644 --- a/src/Mod/Part/App/TopoShapeEdgePy.xml +++ b/src/Mod/Part/App/TopoShapeEdgePy.xml @@ -531,9 +531,9 @@ coordinate system. curveOnSurface(idx) -> None or tuple -Returns the 2D curve, the surface and the parameter range of index idx. +Returns the 2D curve, the surface, the placement and the parameter range of index idx. Returns None if index idx is out of range. -Returns a 4-items tuple of a curve, a surface, first parameter and last parameter. +Returns a 5-items tuple of a curve, a surface, a placement, first parameter and last parameter. diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index 068c91b716..2f3c6723b4 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -1071,12 +1071,21 @@ PyObject* TopoShapeEdgePy::curveOnSurface(PyObject *args) Part::GeomSurface* geosurf = makeFromSurface(surf); if (!geosurf) Py_Return; - - Py::Tuple tuple(4); + + gp_Trsf trsf = loc.Transformation(); + gp_XYZ pos = trsf.TranslationPart(); + gp_XYZ axis; + Standard_Real angle; + trsf.GetRotation(axis, angle); + Base::Rotation rot(Base::Vector3d(axis.X(), axis.Y(), axis.Z()), angle); + Base::Placement placement(Base::Vector3d(pos.X(), pos.Y(), pos.Z()), rot); + + Py::Tuple tuple(5); tuple.setItem(0, Py::asObject(geo2d->getPyObject())); tuple.setItem(1, Py::asObject(geosurf->getPyObject())); - tuple.setItem(2, Py::Float(first)); - tuple.setItem(3, Py::Float(last)); + tuple.setItem(2, Py::Object(new Base::PlacementPy(placement), true)); + tuple.setItem(3, Py::Float(first)); + tuple.setItem(4, Py::Float(last)); return Py::new_reference_to(tuple); } catch (Standard_Failure& e) {