diff --git a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPy.xml index 4e319f71f..561d86abb 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPy.xml @@ -14,31 +14,17 @@ Describes a portion of a circle - diff --git a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp index 33cbc0291..6b6559a06 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfCircle2dPyImp.cpp @@ -23,21 +23,20 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include #endif +#include #include #include #include -//#include "CirclePy.h" -//#include "OCCError.h" +#include #include -#include using namespace Part; @@ -46,30 +45,7 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et); // returns a string which represents the object e.g. when printed in python std::string ArcOfCircle2dPy::representation(void) const { -#if 0 - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - - gp_Ax1 axis = circle->Axis(); - gp_Dir dir = axis.Direction(); - gp_Pnt loc = axis.Location(); - Standard_Real fRad = circle->Radius(); - Standard_Real u1 = trim->FirstParameter(); - Standard_Real u2 = trim->LastParameter(); - - std::stringstream str; - str << "ArcOfCircle ("; - str << "Radius : " << fRad << ", "; - 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 *ArcOfCircle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper @@ -81,23 +57,20 @@ PyObject *ArcOfCircle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // constructor method int ArcOfCircle2dPy::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::CirclePy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) { + if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Circle2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) { try { - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast - (static_cast(o)->getGeomCirclePtr()->handle()); - GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False); + Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast + (static_cast(o)->getGeom2dCirclePtr()->handle()); + GCE2d_MakeArcOfCircle arc(circle->Circ2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False); if (!arc.IsDone()) { PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status())); return -1; } - getGeomArcOfCirclePtr()->setHandle(arc.Value()); + getGeom2dArcOfCirclePtr()->setHandle(arc.Value()); return 0; } catch (Standard_Failure) { @@ -113,113 +86,48 @@ int ArcOfCircle2dPy::PyInit(PyObject* args, PyObject* /*kwds*/) PyErr_Clear(); PyObject *pV1, *pV2, *pV3; - if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), &pV1, - &(Base::VectorPy::Type), &pV2, - &(Base::VectorPy::Type), &pV3)) { - Base::Vector3d v1 = static_cast(pV1)->value(); - Base::Vector3d v2 = static_cast(pV2)->value(); - Base::Vector3d v3 = static_cast(pV3)->value(); + if (PyArg_ParseTuple(args, "O!O!O!", Base::Vector2dPy::type_object(), &pV1, + Base::Vector2dPy::type_object(), &pV2, + Base::Vector2dPy::type_object(), &pV3)) { + Base::Vector2d v1 = Py::Vector2d(pV1).getCxxObject()->value(); + Base::Vector2d v2 = Py::Vector2d(pV2).getCxxObject()->value(); + Base::Vector2d v3 = Py::Vector2d(pV3).getCxxObject()->value(); - GC_MakeArcOfCircle arc(gp_Pnt(v1.x,v1.y,v1.z), - gp_Pnt(v2.x,v2.y,v2.z), - gp_Pnt(v3.x,v3.y,v3.z)); + GCE2d_MakeArcOfCircle arc(gp_Pnt2d(v1.x,v1.y), + gp_Pnt2d(v2.x,v2.y), + gp_Pnt2d(v3.x,v3.y)); if (!arc.IsDone()) { PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status())); return -1; } - getGeomArcOfCirclePtr()->setHandle(arc.Value()); + getGeom2dArcOfCirclePtr()->setHandle(arc.Value()); return 0; } // All checks failed PyErr_SetString(PyExc_TypeError, - "ArcOfCircle constructor expects a circle curve and a parameter range or three points"); + "ArcOfCircle2d constructor expects a circle curve and a parameter range or three points"); return -1; -#endif } -#if 0 + Py::Float ArcOfCircle2dPy::getRadius(void) const { - return Py::Float(getGeomArcOfCirclePtr()->getRadius()); + return Py::Float(getGeom2dArcOfCirclePtr()->getRadius()); } void ArcOfCircle2dPy::setRadius(Py::Float arg) { - getGeomArcOfCirclePtr()->setRadius((double)arg); -} - -Py::Object ArcOfCircle2dPy::getCenter(void) const -{ - return Py::Vector(getGeomArcOfCirclePtr()->getCenter()); -} - -void ArcOfCircle2dPy::setCenter(Py::Object arg) -{ - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - getGeomArcOfCirclePtr()->setCenter(loc); - } - else if (PyObject_TypeCheck(p, &PyTuple_Type)) { - Base::Vector3d loc = Base::getVectorFromTuple(p); - getGeomArcOfCirclePtr()->setCenter(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object ArcOfCircle2dPy::getAxis(void) const -{ - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - gp_Ax1 axis = circle->Axis(); - gp_Dir dir = axis.Direction(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); -} - -void ArcOfCircle2dPy::setAxis(Py::Object arg) -{ - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - try { - gp_Ax1 axis; - axis.SetLocation(circle->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - circle->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } + getGeom2dArcOfCirclePtr()->setRadius((double)arg); } Py::Object ArcOfCircle2dPy::getCircle(void) const { - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - return Py::Object(new CirclePy(new GeomCircle(circle)), true); + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(curve->BasisCurve()); + return Py::asObject(new Circle2dPy(new Geom2dCircle(circle))); } -#endif + PyObject *ArcOfCircle2dPy::getCustomAttributes(const char* ) const { return 0; diff --git a/src/Mod/Part/App/Geom2d/ArcOfConic2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfConic2dPy.xml index 2ec3f35c3..fcb759a39 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfConic2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfConic2dPy.xml @@ -12,27 +12,37 @@ Constructor="true"> - Describes a portion of a circle + Describes an abstract arc of conic in 2d space - diff --git a/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp index 97ad399ef..8fe7f5650 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfConic2dPyImp.cpp @@ -23,11 +23,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +# include +# include #endif #include @@ -36,176 +33,100 @@ #include #include -#include using namespace Part; -extern const char* gce_ErrorStatusText(gce_ErrorType et); - // returns a string which represents the object e.g. when printed in python std::string ArcOfConic2dPy::representation(void) const { -#if 0 - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - - gp_Ax1 axis = circle->Axis(); - gp_Dir dir = axis.Direction(); - gp_Pnt loc = axis.Location(); - Standard_Real fRad = circle->Radius(); - Standard_Real u1 = trim->FirstParameter(); - Standard_Real u2 = trim->LastParameter(); - - std::stringstream str; - str << "ArcOfCircle ("; - str << "Radius : " << fRad << ", "; - 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 *ArcOfConic2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper { + // never create such objects with the constructor + PyErr_SetString(PyExc_RuntimeError, + "You cannot create an instance of the abstract class 'ArcOfConic2d'."); return 0; } // constructor method int ArcOfConic2dPy::PyInit(PyObject* args, PyObject* /*kwds*/) { -#if 0 - PyObject* o; - double u1, u2; - PyObject *sense=Py_True; - if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::CirclePy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) { - try { - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast - (static_cast(o)->getGeomCirclePtr()->handle()); - GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False); - if (!arc.IsDone()) { - PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status())); - return -1; - } - - getGeomArcOfCirclePtr()->setHandle(arc.Value()); - return 0; - } - catch (Standard_Failure) { - Handle_Standard_Failure e = Standard_Failure::Caught(); - PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); - return -1; - } - catch (...) { - PyErr_SetString(PartExceptionOCCError, "creation of arc failed"); - return -1; - } - } - - PyErr_Clear(); - PyObject *pV1, *pV2, *pV3; - if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), &pV1, - &(Base::VectorPy::Type), &pV2, - &(Base::VectorPy::Type), &pV3)) { - Base::Vector3d v1 = static_cast(pV1)->value(); - Base::Vector3d v2 = static_cast(pV2)->value(); - Base::Vector3d v3 = static_cast(pV3)->value(); - - GC_MakeArcOfCircle arc(gp_Pnt(v1.x,v1.y,v1.z), - gp_Pnt(v2.x,v2.y,v2.z), - gp_Pnt(v3.x,v3.y,v3.z)); - if (!arc.IsDone()) { - PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status())); - return -1; - } - - getGeomArcOfCirclePtr()->setHandle(arc.Value()); - return 0; - } - - // All checks failed - PyErr_SetString(PyExc_TypeError, - "ArcOfCircle constructor expects a circle curve and a parameter range or three points"); -#endif return -1; } -#if 0 -Py::Object ArcOfConic2dPy::getCenter(void) const + +Py::Object ArcOfConic2dPy::getLocation(void) const { - return Py::Vector(getGeomArcOfCirclePtr()->getCenter()); + Base::Vector2d loc = getGeom2dArcOfConicPtr()->getLocation(); + + Py::Module module("__FreeCADBase__"); + Py::Callable method(module.getAttr("Vector2d")); + Py::Tuple arg(2); + arg.setItem(0, Py::Float(loc.x)); + arg.setItem(1, Py::Float(loc.y)); + return method.apply(arg); } -void ArcOfConic2dPy::setCenter(Py::Object arg) +void ArcOfConic2dPy::setLocation(Py::Object arg) { - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - getGeomArcOfCirclePtr()->setCenter(loc); - } - else if (PyObject_TypeCheck(p, &PyTuple_Type)) { - Base::Vector3d loc = Base::getVectorFromTuple(p); - getGeomArcOfCirclePtr()->setCenter(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } + Base::Vector2d loc = Py::Vector2d(arg.ptr()).getCxxObject()->value(); + getGeom2dArcOfConicPtr()->setLocation(loc); } -Py::Object ArcOfConic2dPy::getAxis(void) const +Py::Float ArcOfConic2dPy::getEccentricity(void) const { - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - gp_Ax1 axis = circle->Axis(); - gp_Dir dir = axis.Direction(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); + return Py::Float(conic->Eccentricity()); } -void ArcOfConic2dPy::setAxis(Py::Object arg) +Py::Object ArcOfConic2dPy::getXAxis(void) const { - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - try { - gp_Ax1 axis; - axis.SetLocation(circle->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - circle->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); + gp_Dir2d xdir = conic->XAxis().Direction(); + Py::Module module("__FreeCADBase__"); + Py::Callable method(module.getAttr("Vector2d")); + Py::Tuple arg(2); + arg.setItem(0, Py::Float(xdir.X())); + arg.setItem(1, Py::Float(xdir.Y())); + return method.apply(arg); } -Py::Object ArcOfConic2dPy::getCircle(void) const +void ArcOfConic2dPy::setXAxis(Py::Object arg) { - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfCirclePtr()->handle()); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); - return Py::Object(new CirclePy(new GeomCircle(circle)), true); + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); + Base::Vector2d dir = Py::Vector2d(arg.ptr()).getCxxObject()->value(); + gp_Ax2d xaxis = conic->XAxis(); + xaxis.SetDirection(gp_Dir2d(dir.x, dir.y)); + conic->SetXAxis(xaxis); } -#endif + +Py::Object ArcOfConic2dPy::getYAxis(void) const +{ + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); + gp_Dir2d ydir = conic->YAxis().Direction(); + Py::Module module("__FreeCADBase__"); + Py::Callable method(module.getAttr("Vector2d")); + Py::Tuple arg(2); + arg.setItem(0, Py::Float(ydir.X())); + arg.setItem(1, Py::Float(ydir.Y())); + return method.apply(arg); +} + +void ArcOfConic2dPy::setYAxis(Py::Object arg) +{ + Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle()); + Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); + Base::Vector2d dir = Py::Vector2d(arg.ptr()).getCxxObject()->value(); + gp_Ax2d yaxis = conic->YAxis(); + yaxis.SetDirection(gp_Dir2d(dir.x, dir.y)); + conic->SetYAxis(yaxis); +} + PyObject *ArcOfConic2dPy::getCustomAttributes(const char* ) const { return 0; diff --git a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPy.xml index 54ab57055..776ab6312 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPy.xml @@ -27,24 +27,6 @@ - - - The angle between the X axis and the major axis of the ellipse. - - - - - - Center of the ellipse. - - - - - - The axis direction of the ellipse - - - The internal ellipse representation diff --git a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp index d80d1c3cc..d47199f33 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfEllipse2dPyImp.cpp @@ -149,79 +149,6 @@ void ArcOfEllipse2dPy::setMinorRadius(Py::Float arg) getGeomArcOfEllipsePtr()->setMinorRadius((double)arg); } -Py::Float ArcOfEllipse2dPy::getAngleXU(void) const -{ - return Py::Float(getGeomArcOfEllipsePtr()->getAngleXU()); -} - -void ArcOfEllipse2dPy::setAngleXU(Py::Float arg) -{ - getGeomArcOfEllipsePtr()->setAngleXU((double)arg); -} - -Py::Object ArcOfEllipse2dPy::getCenter(void) const -{ - return Py::Vector(getGeomArcOfEllipsePtr()->getCenter()); -} - -void ArcOfEllipse2dPy::setCenter(Py::Object arg) -{ - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - getGeomArcOfEllipsePtr()->setCenter(loc); - } - else if (PyObject_TypeCheck(p, &PyTuple_Type)) { - Base::Vector3d loc = Base::getVectorFromTuple(p); - getGeomArcOfEllipsePtr()->setCenter(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object ArcOfEllipse2dPy::getAxis(void) const -{ - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfEllipsePtr()->handle()); - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve()); - gp_Ax1 axis = ellipse->Axis(); - gp_Dir dir = axis.Direction(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); -} - -void ArcOfEllipse2dPy::setAxis(Py::Object arg) -{ - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfEllipsePtr()->handle()); - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve()); - try { - gp_Ax1 axis; - axis.SetLocation(ellipse->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - ellipse->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } -} - Py::Object ArcOfEllipse2dPy::getEllipse(void) const { Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast diff --git a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPy.xml index 0ee3836cd..bc23ce9c5 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPy.xml @@ -27,24 +27,6 @@ - - - The angle between the X axis and the major axis of the hyperbola. - - - - - - Center of the hyperbola. - - - - - - The axis direction of the hyperbola - - - The internal hyperbola representation diff --git a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp index 30ce6c3ee..ca68d253e 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfHyperbola2dPyImp.cpp @@ -149,79 +149,6 @@ void ArcOfHyperbola2dPy::setMinorRadius(Py::Float arg) getGeomArcOfHyperbolaPtr()->setMinorRadius((double)arg); } -Py::Float ArcOfHyperbola2dPy::getAngleXU(void) const -{ - return Py::Float(getGeomArcOfHyperbolaPtr()->getAngleXU()); -} - -void ArcOfHyperbola2dPy::setAngleXU(Py::Float arg) -{ - getGeomArcOfHyperbolaPtr()->setAngleXU((double)arg); -} - -Py::Object ArcOfHyperbola2dPy::getCenter(void) const -{ - return Py::Vector(getGeomArcOfHyperbolaPtr()->getCenter()); -} - -void ArcOfHyperbola2dPy::setCenter(Py::Object arg) -{ - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - getGeomArcOfHyperbolaPtr()->setCenter(loc); - } - else if (PyObject_TypeCheck(p, &PyTuple_Type)) { - Base::Vector3d loc = Base::getVectorFromTuple(p); - getGeomArcOfHyperbolaPtr()->setCenter(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object ArcOfHyperbola2dPy::getAxis(void) const -{ - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfHyperbolaPtr()->handle()); - Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(trim->BasisCurve()); - gp_Ax1 axis = hyperbola->Axis(); - gp_Dir dir = axis.Direction(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); -} - -void ArcOfHyperbola2dPy::setAxis(Py::Object arg) -{ - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfHyperbolaPtr()->handle()); - Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(trim->BasisCurve()); - try { - gp_Ax1 axis; - axis.SetLocation(hyperbola->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - hyperbola->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } -} - Py::Object ArcOfHyperbola2dPy::getHyperbola(void) const { Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast diff --git a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml index 5ebc34b74..47f8ba1dd 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml +++ b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPy.xml @@ -20,24 +20,6 @@ The focal length of the parabola. - - - - The angle between the X axis and the major axis of the parabola. - - - - - - Center of the parabola. - - - - - - The axis direction of the parabola - - diff --git a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp index be73be224..f182430cf 100644 --- a/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/ArcOfParabola2dPyImp.cpp @@ -137,79 +137,6 @@ void ArcOfParabola2dPy::setFocal(Py::Float arg) getGeomArcOfParabolaPtr()->setFocal((double)arg); } -Py::Float ArcOfParabola2dPy::getAngleXU(void) const -{ - return Py::Float(getGeomArcOfParabolaPtr()->getAngleXU()); -} - -void ArcOfParabola2dPy::setAngleXU(Py::Float arg) -{ - getGeomArcOfParabolaPtr()->setAngleXU((double)arg); -} - -Py::Object ArcOfParabola2dPy::getCenter(void) const -{ - return Py::Vector(getGeomArcOfParabolaPtr()->getCenter()); -} - -void ArcOfParabola2dPy::setCenter(Py::Object arg) -{ - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - getGeomArcOfParabolaPtr()->setCenter(loc); - } - else if (PyObject_TypeCheck(p, &PyTuple_Type)) { - Base::Vector3d loc = Base::getVectorFromTuple(p); - getGeomArcOfParabolaPtr()->setCenter(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object ArcOfParabola2dPy::getAxis(void) const -{ - 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(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); -} - -void ArcOfParabola2dPy::setAxis(Py::Object arg) -{ - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast - (getGeomArcOfParabolaPtr()->handle()); - Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve()); - try { - gp_Ax1 axis; - axis.SetLocation(parabola->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - parabola->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } -} - Py::Object ArcOfParabola2dPy::getParabola(void) const { Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast diff --git a/src/Mod/Part/App/Geom2d/Conic2dPy.xml b/src/Mod/Part/App/Geom2d/Conic2dPy.xml index 3854bdaf8..89262c4ea 100644 --- a/src/Mod/Part/App/Geom2d/Conic2dPy.xml +++ b/src/Mod/Part/App/Geom2d/Conic2dPy.xml @@ -12,8 +12,7 @@ Constructor="true"> - Describes an abstract conic in 2d space - + Describes an abstract conic in 2d space diff --git a/src/Mod/Part/App/Geom2d/Curve2dPy.xml b/src/Mod/Part/App/Geom2d/Curve2dPy.xml index 0311f7d0e..e8a039d6e 100644 --- a/src/Mod/Part/App/Geom2d/Curve2dPy.xml +++ b/src/Mod/Part/App/Geom2d/Curve2dPy.xml @@ -21,13 +21,13 @@ Changes the direction of parametrization of the curve. - diff --git a/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp b/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp index 9ccf7daff..1396ddc78 100644 --- a/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/Ellipse2dPyImp.cpp @@ -154,44 +154,6 @@ void Ellipse2dPy::setMinorRadius(Py::Float arg) ellipse->SetMinorRadius((double)arg); } -Py::Float Ellipse2dPy::getAngleXU(void) const -{ - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - - gp_Pnt center = ellipse->Axis().Location(); - gp_Dir normal = ellipse->Axis().Direction(); - gp_Dir xdir = ellipse->XAxis().Direction(); - - gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method - - return Py::Float(-xdir.AngleWithRef(xdirref.XDirection(),normal)); - -} - -void Ellipse2dPy::setAngleXU(Py::Float arg) -{ - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - - - gp_Pnt center = ellipse->Axis().Location(); - gp_Dir normal = ellipse->Axis().Direction(); - - gp_Ax1 normaxis(center, normal); - - gp_Ax2 xdirref(center, normal); - - xdirref.Rotate(normaxis,arg); - - ellipse->SetPosition(xdirref); - -} - -Py::Float Ellipse2dPy::getEccentricity(void) const -{ - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - return Py::Float(ellipse->Eccentricity()); -} - Py::Float Ellipse2dPy::getFocal(void) const { Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); @@ -211,73 +173,6 @@ Py::Object Ellipse2dPy::getFocus2(void) const gp_Pnt loc = ellipse->Focus2(); return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z())); } - -Py::Object Ellipse2dPy::getCenter(void) const -{ - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - gp_Pnt loc = ellipse->Location(); - return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z())); -} - -void Ellipse2dPy::setCenter(Py::Object arg) -{ - PyObject* p = arg.ptr(); - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - Base::Vector3d loc = static_cast(p)->value(); - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - ellipse->SetLocation(gp_Pnt(loc.x, loc.y, loc.z)); - } - else if (PyTuple_Check(p)) { - Py::Tuple tuple(arg); - gp_Pnt loc; - loc.SetX((double)Py::Float(tuple.getItem(0))); - loc.SetY((double)Py::Float(tuple.getItem(1))); - loc.SetZ((double)Py::Float(tuple.getItem(2))); - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - ellipse->SetLocation(loc); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object Ellipse2dPy::getAxis(void) const -{ - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - gp_Ax1 axis = ellipse->Axis(); - gp_Dir dir = axis.Direction(); - return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); -} - -void Ellipse2dPy::setAxis(Py::Object arg) -{ - PyObject* p = arg.ptr(); - Base::Vector3d val; - if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { - val = static_cast(p)->value(); - } - else if (PyTuple_Check(p)) { - val = Base::getVectorFromTuple(p); - } - else { - std::string error = std::string("type must be 'Vector', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } - - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle()); - try { - gp_Ax1 axis; - axis.SetLocation(ellipse->Location()); - axis.SetDirection(gp_Dir(val.x, val.y, val.z)); - ellipse->SetAxis(axis); - } - catch (Standard_Failure) { - throw Py::Exception("cannot set axis"); - } -} #endif PyObject *Ellipse2dPy::getCustomAttributes(const char* /*attr*/) const { diff --git a/src/Mod/Part/App/Geometry2d.cpp b/src/Mod/Part/App/Geometry2d.cpp index 1454591bc..80718cffe 100644 --- a/src/Mod/Part/App/Geometry2d.cpp +++ b/src/Mod/Part/App/Geometry2d.cpp @@ -666,7 +666,7 @@ Geom2dArcOfConic::~Geom2dArcOfConic() { } -Base::Vector2d Geom2dArcOfConic::getCenter(void) const +Base::Vector2d Geom2dArcOfConic::getLocation(void) const { Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(handle()); Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve()); @@ -674,7 +674,7 @@ Base::Vector2d Geom2dArcOfConic::getCenter(void) const return Base::Vector2d(loc.X(),loc.Y()); } -void Geom2dArcOfConic::setCenter(const Base::Vector2d& Center) +void Geom2dArcOfConic::setLocation(const Base::Vector2d& Center) { gp_Pnt2d p1(Center.x,Center.y); Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(handle()); diff --git a/src/Mod/Part/App/Geometry2d.h b/src/Mod/Part/App/Geometry2d.h index 1ef7ec9a8..78bbcbe5c 100644 --- a/src/Mod/Part/App/Geometry2d.h +++ b/src/Mod/Part/App/Geometry2d.h @@ -224,8 +224,8 @@ public: virtual ~Geom2dArcOfConic(); virtual Geometry2d *clone(void) const = 0; - Base::Vector2d getCenter(void) const; - void setCenter(const Base::Vector2d& Center); + Base::Vector2d getLocation(void) const; + void setLocation(const Base::Vector2d& Center); bool isReversed() const; Base::Vector2d getStartPoint() const;