From c817c3334e02268865a578de1c94ebe221e6668f Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 25 Nov 2016 18:11:37 +0100 Subject: [PATCH] implement ArcOfParabola2d --- .../Part/App/Geom2d/ArcOfCircle2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp | 2 +- .../Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp | 2 +- .../Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml | 4 +- .../Part/App/Geom2d/ArcOfParabola2dPyImp.cpp | 80 +++++-------------- .../Part/App/Geom2d/BSplineCurve2dPyImp.cpp | 2 +- .../Part/App/Geom2d/BezierCurve2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/Conic2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/Hyperbola2dPyImp.cpp | 2 +- .../Part/App/Geom2d/OffsetCurve2dPyImp.cpp | 2 +- src/Mod/Part/App/Geom2d/Parabola2dPyImp.cpp | 5 +- 14 files changed, 35 insertions(+), 76 deletions(-) diff --git a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp index 6b6559a0679f..5511225bb99f 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2011 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp index 8fe7f56502a4..62927220a0d7 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2011 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp index 2796f1944343..acf8556bde19 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2014 Abdullah Tahiri * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp index 1db93b2ce621..66fd922ab872 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2014 Abdullah Tahiri * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml index 47f8ba1dd6bc..dcc7b51a95e9 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml @@ -12,9 +12,8 @@ Constructor="true"> - Describes a portion of an parabola + Describes a portion of a parabola - diff --git a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp index f182430cf643..66f9cf03e8f1 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2014 Abdullah Tahiri * * * * This file is part of the FreeCAD CAx development system. * * * @@ -23,21 +23,19 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +# include +# include +# include +# include #endif #include #include #include -#include +#include #include #include -#include using namespace Part; @@ -46,39 +44,7 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et); // returns a string which represents the object e.g. when printed in python std::string ArcOfParabola2dPy::representation(void) const { -#if 0 - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfParabolaPtr()->handle()); - Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve()); - - gp_Ax1 axis = parabola->Axis(); - gp_Dir dir = axis.Direction(); - gp_Pnt loc = axis.Location(); - Standard_Real fFocal = parabola->Focal(); - Standard_Real u1 = trim->FirstParameter(); - Standard_Real u2 = trim->LastParameter(); - - gp_Dir normal = parabola->Axis().Direction(); - gp_Dir xdir = parabola->XAxis().Direction(); - - gp_Ax2 xdirref(loc, normal); // this is a reference XY for the parabola - - Standard_Real fAngleXU = -xdir.AngleWithRef(xdirref.XDirection(),normal); - - - std::stringstream str; - str << "ArcOfParabola ("; - str << "Focal : " << fFocal << ", "; - str << "AngleXU : " << fAngleXU << ", "; - str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), "; - str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << "), "; - str << "Parameter : (" << u1 << ", " << u2 << ")"; - str << ")"; - - return str.str(); -#else - return ""; -#endif + return ""; } PyObject *ArcOfParabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper @@ -90,23 +56,20 @@ PyObject *ArcOfParabola2dPy::PyMake(struct _typeobject *, PyObject *, PyObject * // constructor method int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/) { -#if 1 - return 0; -#else PyObject* o; double u1, u2; PyObject *sense=Py_True; - if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::ParabolaPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) { + if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Parabola2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) { try { - Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast - (static_cast(o)->getGeomParabolaPtr()->handle()); - GC_MakeArcOfParabola arc(parabola->Parab(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False); + Handle_Geom2d_Parabola parabola = Handle_Geom2d_Parabola::DownCast + (static_cast(o)->getGeom2dParabolaPtr()->handle()); + GCE2d_MakeArcOfParabola arc(parabola->Parab2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False); if (!arc.IsDone()) { PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status())); return -1; } - getGeomArcOfParabolaPtr()->setHandle(arc.Value()); + getGeom2dArcOfParabolaPtr()->setHandle(arc.Value()); return 0; } catch (Standard_Failure) { @@ -122,29 +85,28 @@ int ArcOfParabola2dPy::PyInit(PyObject* args, PyObject* /*kwds*/) // All checks failed PyErr_SetString(PyExc_TypeError, - "ArcOfParabola constructor expects an parabola curve and a parameter range"); + "ArcOfParabola2d constructor expects an parabola curve and a parameter range"); return -1; -#endif } -#if 0 + Py::Float ArcOfParabola2dPy::getFocal(void) const { - return Py::Float(getGeomArcOfParabolaPtr()->getFocal()); + return Py::Float(getGeom2dArcOfParabolaPtr()->getFocal()); } void ArcOfParabola2dPy::setFocal(Py::Float arg) { - getGeomArcOfParabolaPtr()->setFocal((double)arg); + getGeom2dArcOfParabolaPtr()->setFocal((double)arg); } Py::Object ArcOfParabola2dPy::getParabola(void) const { - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfParabolaPtr()->handle()); - Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve()); - return Py::Object(new ParabolaPy(new GeomParabola(parabola)), true); + Handle_Geom2d_TrimmedCurve trim = Handle_Geom2d_TrimmedCurve::DownCast + (getGeom2dArcOfParabolaPtr()->handle()); + Handle_Geom2d_Parabola parabola = Handle_Geom2d_Parabola::DownCast(trim->BasisCurve()); + return Py::asObject(new Parabola2dPy(new Geom2dParabola(parabola))); } -#endif + PyObject *ArcOfParabola2dPy::getCustomAttributes(const char* ) const { return 0; diff --git a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp index 477d4c63685f..b90abd62cc81 100644 --- a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/BezierCurve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/BezierCurve2dPyImp.cpp index 388d2a70e98e..c645df6a1a2b 100644 --- a/src/Mod/Part/App/Geom2d/BezierCurve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/BezierCurve2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp index eecf23c4cccb..ad37b8626607 100644 --- a/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Circle2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/Conic2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Conic2dPyImp.cpp index 996b1aaa0786..bc255d7c87e1 100644 --- a/src/Mod/Part/App/Geom2d/Conic2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Conic2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp index 3cd39b44e03f..a3343681eba7 100644 --- a/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/Hyperbola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Hyperbola2dPyImp.cpp index a3fb008de94c..8dd3cbb4c642 100644 --- a/src/Mod/Part/App/Geom2d/Hyperbola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Hyperbola2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/OffsetCurve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/OffsetCurve2dPyImp.cpp index ef424604b626..9acb59993cea 100644 --- a/src/Mod/Part/App/Geom2d/OffsetCurve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/OffsetCurve2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Part/App/Geom2d/Parabola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Parabola2dPyImp.cpp index a72232b3b8d9..d09127daa09e 100644 --- a/src/Mod/Part/App/Geom2d/Parabola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Parabola2dPyImp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Werner Mayer * + * Copyright (c) 2016 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * @@ -23,10 +23,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +# include #endif -#include #include #include