From 33a4b6d7ba916c30016ce83175515262a33b49e2 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sun, 27 Apr 2014 16:45:46 -0400 Subject: [PATCH] fixes #1319 allow Part.makeHelix to use 'vertical height' parm correct lefthanded conical helixes in TopoShape::makeHelix --- src/Mod/Part/App/AppPartPy.cpp | 11 +++++++++-- src/Mod/Part/App/TopoShape.cpp | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 113a239bd..f2421ba3c 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -858,12 +858,19 @@ static PyObject * makeTorus(PyObject *self, PyObject *args) static PyObject * makeHelix(PyObject *self, PyObject *args) { double pitch, height, radius, angle=-1.0; - if (!PyArg_ParseTuple(args, "ddd|d", &pitch, &height, &radius, &angle)) + PyObject *pleft=Py_False; + PyObject *pvertHeight=Py_False; + if (!PyArg_ParseTuple(args, "ddd|dO!O!", &pitch, &height, &radius, &angle, + &(PyBool_Type), &pleft, + &(PyBool_Type), &pvertHeight)) return 0; try { TopoShape helix; - TopoDS_Shape wire = helix.makeHelix(pitch, height, radius, angle); + Standard_Boolean anIsLeft = PyObject_IsTrue(pleft) ? Standard_True : Standard_False; + Standard_Boolean anIsVertHeight = PyObject_IsTrue(pvertHeight) ? Standard_True : Standard_False; + TopoDS_Shape wire = helix.makeHelix(pitch, height, radius, angle, + anIsLeft, anIsVertHeight); return new TopoShapeWirePy(new TopoShape(wire)); } catch (Standard_Failure) { diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 228295ecd..4125ba2f3 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1610,11 +1610,13 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, gp_Pnt2d aPnt(0, 0); gp_Dir2d aDir(2. * M_PI, pitch); + Standard_Real coneDir = 1.0; if (leftHanded) { //aPnt.SetCoord(0.0, height); //aDir.SetCoord(2.0 * PI, -pitch); aPnt.SetCoord(2. * M_PI, 0.0); aDir.SetCoord(-2. * M_PI, pitch); + coneDir = -1.0; } gp_Ax2d aAx2d(aPnt, aDir); @@ -1627,7 +1629,7 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, if (angle >= Precision::Confusion()) { // calculate end point for conical helix Standard_Real v = height / cos(angle); - Standard_Real u = (height/pitch) * 2.0 * M_PI; + Standard_Real u = coneDir * (height/pitch) * 2.0 * M_PI; gp_Pnt2d cend(u, v); end = cend; }