From c6529d21febeb9d56f2087148f246364132cc3df Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 1 Dec 2016 00:04:13 +0100 Subject: [PATCH] implement Line class --- src/Mod/Part/App/AppPart.cpp | 96 ++++++++- src/Mod/Part/App/ConePyImp.cpp | 8 +- src/Mod/Part/App/CylinderPyImp.cpp | 8 +- src/Mod/Part/App/GeometrySurfacePyImp.cpp | 16 +- src/Mod/Part/App/LinePy.xml | 32 +-- src/Mod/Part/App/LinePyImp.cpp | 205 +++++-------------- src/Mod/Part/App/PlanePyImp.cpp | 22 +- src/Mod/Part/App/SurfaceOfExtrusionPyImp.cpp | 14 +- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 13 +- src/Mod/Sketcher/App/Sketch.cpp | 4 +- src/Mod/Sketcher/App/SketchPyImp.cpp | 1 - 11 files changed, 191 insertions(+), 228 deletions(-) diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 26b1aa9e7..7fea4de7f 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -133,6 +133,89 @@ PyObject* Part::PartExceptionOCCRangeError; PyObject* Part::PartExceptionOCCConstructionError; PyObject* Part::PartExceptionOCCDimensionError; +// <--- +namespace Part { + +// Compatibility class to keep old code working until removed +class LinePyOld : public LineSegmentPy +{ +public: + static PyTypeObject Type; + virtual PyTypeObject *GetType(void) {return &Type;} + +public: + static PyObject *PyMake(struct _typeobject *, PyObject *, PyObject *) + { + PyErr_SetString(PyExc_DeprecationWarning, "For future usage 'Line' will be an infinite line, use 'LineSegment' instead"); + PyErr_Print(); + return new LinePyOld(new GeomLineSegment); + } + LinePyOld(GeomLineSegment *pcObject, PyTypeObject *T = &Type) + : LineSegmentPy(pcObject, T) + { + } + virtual ~LinePyOld() + { + } +}; + +/// Type structure of LinePyOld +PyTypeObject LinePyOld::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + "Part.GeomLine", /*tp_name*/ + sizeof(LinePyOld), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + PyDestructor, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call */ + 0, /*tp_str */ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + /* --- Functions to access object as input/output buffer ---------*/ + 0, /* tp_as_buffer */ + /* --- Flags to define presence of optional/expanded features */ + Py_TPFLAGS_HAVE_CLASS, /*tp_flags */ + "", + 0, /*tp_traverse */ + 0, /*tp_clear */ + 0, /*tp_richcompare */ + 0, /*tp_weaklistoffset */ + 0, /*tp_iter */ + 0, /*tp_iternext */ + 0, /*tp_methods */ + 0, /*tp_members */ + 0, /*tp_getset */ + &LineSegmentPy::Type, /*tp_base */ + 0, /*tp_dict */ + 0, /*tp_descr_get */ + 0, /*tp_descr_set */ + 0, /*tp_dictoffset */ + __PyInit, /*tp_init */ + 0, /*tp_alloc */ + Part::LinePyOld::PyMake,/*tp_new */ + 0, /*tp_free Low-level free-memory routine */ + 0, /*tp_is_gc For PyObject_IS_GC */ + 0, /*tp_bases */ + 0, /*tp_mro method resolution order */ + 0, /*tp_cache */ + 0, /*tp_subclasses */ + 0, /*tp_weaklist */ + 0, /*tp_del */ + 0 /*tp_version_tag */ +}; + +} +// ---> PyMODINIT_FUNC initPart() { @@ -207,7 +290,18 @@ PyMODINIT_FUNC initPart() Base::Interpreter().addType(&Part::TopoShapeCompSolidPy ::Type,partModule,"CompSolid"); Base::Interpreter().addType(&Part::TopoShapeShellPy ::Type,partModule,"Shell"); - Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"Line"); + Base::Reference hPartGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); + + // General + Base::Reference hGenPGrp = hPartGrp->GetGroup("General"); + if (hGenPGrp->GetBool("LineOld", true)) { + Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"_Line"); + Base::Interpreter().addType(&Part::LinePyOld ::Type,partModule,"Line"); + } + else { + Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"Line"); + } Base::Interpreter().addType(&Part::LineSegmentPy ::Type,partModule,"LineSegment"); Base::Interpreter().addType(&Part::PointPy ::Type,partModule,"Point"); Base::Interpreter().addType(&Part::CirclePy ::Type,partModule,"Circle"); diff --git a/src/Mod/Part/App/ConePyImp.cpp b/src/Mod/Part/App/ConePyImp.cpp index 0e7504e55..5811d85dd 100644 --- a/src/Mod/Part/App/ConePyImp.cpp +++ b/src/Mod/Part/App/ConePyImp.cpp @@ -181,12 +181,10 @@ PyObject* ConePy::uIso(PyObject * args) Handle_Geom_ConicalSurface cone = Handle_Geom_ConicalSurface::DownCast (getGeomConePtr()->handle()); Handle_Geom_Line c = Handle_Geom_Line::DownCast(cone->UIso(u)); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(c->Lin()); + this_curv->SetLin(c->Lin()); return new LinePy(line); } catch (Standard_Failure) { diff --git a/src/Mod/Part/App/CylinderPyImp.cpp b/src/Mod/Part/App/CylinderPyImp.cpp index 72471dac6..786503511 100644 --- a/src/Mod/Part/App/CylinderPyImp.cpp +++ b/src/Mod/Part/App/CylinderPyImp.cpp @@ -168,12 +168,10 @@ PyObject* CylinderPy::uIso(PyObject * args) (getGeomCylinderPtr()->handle()); Handle_Geom_Curve c = cyl->UIso(v); if (!Handle_Geom_Line::DownCast(c).IsNull()) { - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(Handle_Geom_Line::DownCast(c)->Lin()); + this_curv->SetLin(Handle_Geom_Line::DownCast(c)->Lin()); return new LinePy(line); } diff --git a/src/Mod/Part/App/GeometrySurfacePyImp.cpp b/src/Mod/Part/App/GeometrySurfacePyImp.cpp index f212ff41d..e916db465 100644 --- a/src/Mod/Part/App/GeometrySurfacePyImp.cpp +++ b/src/Mod/Part/App/GeometrySurfacePyImp.cpp @@ -281,12 +281,10 @@ PyObject* GeometrySurfacePy::uIso(PyObject * args) Handle_Geom_Curve c = surf->UIso(v); if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(aLine->Lin()); + this_curv->SetLin(aLine->Lin()); return new LinePy(line); } else { @@ -312,12 +310,10 @@ PyObject* GeometrySurfacePy::vIso(PyObject * args) Handle_Geom_Curve c = surf->VIso(v); if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(aLine->Lin()); + this_curv->SetLin(aLine->Lin()); return new LinePy(line); } else { diff --git a/src/Mod/Part/App/LinePy.xml b/src/Mod/Part/App/LinePy.xml index 834040782..9239a16e5 100644 --- a/src/Mod/Part/App/LinePy.xml +++ b/src/Mod/Part/App/LinePy.xml @@ -3,8 +3,8 @@ - + - Set the parameter range of the underlying line geometry + Returns the location of this line. - - - - Returns the start point of this line. - - + - + - Returns the end point point of this line. + Returns the direction of this line. - + - - - Defines the line as infinite. The StartPoint and EndPoint will be ignored as boundaries. - - - - - public: - bool Infinite; - - diff --git a/src/Mod/Part/App/LinePyImp.cpp b/src/Mod/Part/App/LinePyImp.cpp index ee714a6f3..d67dcab3f 100644 --- a/src/Mod/Part/App/LinePyImp.cpp +++ b/src/Mod/Part/App/LinePyImp.cpp @@ -26,9 +26,7 @@ # include # include # include -# include # include -# include # include #endif @@ -37,8 +35,8 @@ #include "OCCError.h" #include "Geometry.h" -#include "LinePy.h" -#include "LinePy.cpp" +#include +#include using namespace Part; @@ -47,24 +45,13 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et); // returns a string which represents the object e.g. when printed in python std::string LinePy::representation(void) const { - std::stringstream str; - //if(Infinite) - // str << ""; - //else { - Base::Vector3d start = getGeomLineSegmentPtr()->getStartPoint(); - Base::Vector3d end = getGeomLineSegmentPtr()->getEndPoint(); - str << ""; - //} - - return str.str(); + return ""; } PyObject *LinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper { // create a new instance of LinePy and the Twin object - return new LinePy(new GeomLineSegment); + return new LinePy(new GeomLine); } // constructor method @@ -73,7 +60,6 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "")) { // default line - Infinite=false; return 0; } @@ -82,46 +68,15 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "O!", &(LinePy::Type), &pLine)) { // Copy line LinePy* pcLine = static_cast(pLine); - // get Geom_Line of line segment - Handle_Geom_TrimmedCurve that_curv = Handle_Geom_TrimmedCurve::DownCast - (pcLine->getGeomLineSegmentPtr()->handle()); + // get Geom_Line of line Handle_Geom_Line that_line = Handle_Geom_Line::DownCast - (that_curv->BasisCurve()); - // get Geom_Line of line segment - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); + (pcLine->getGeomLinePtr()->handle()); + // get Geom_Line of line Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - - Infinite = pcLine->Infinite; + (this->getGeomLinePtr()->handle()); // Assign the lines this_line->SetLin(that_line->Lin()); - this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter()); - return 0; - } - - PyErr_Clear(); - double first, last; - if (PyArg_ParseTuple(args, "O!dd", &(LinePy::Type), &pLine, &first, &last)) { - // Copy line - LinePy* pcLine = static_cast(pLine); - // get Geom_Line of line segment - Handle_Geom_TrimmedCurve that_curv = Handle_Geom_TrimmedCurve::DownCast - (pcLine->getGeomLineSegmentPtr()->handle()); - Handle_Geom_Line that_line = Handle_Geom_Line::DownCast - (that_curv->BasisCurve()); - // get Geom_Line of line segment - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - - Infinite = pcLine->Infinite; - - // Assign the lines - this_line->SetLin(that_line->Lin()); - this_curv->SetTrim(first, last); return 0; } @@ -136,24 +91,18 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/) double distance = Base::Distance(v1, v2); if (distance < gp::Resolution()) Standard_Failure::Raise("Both points are equal"); - GC_MakeSegment ms(gp_Pnt(v1.x,v1.y,v1.z), - gp_Pnt(v2.x,v2.y,v2.z)); + GC_MakeLine ms(gp_Pnt(v1.x,v1.y,v1.z), + gp_Pnt(v2.x,v2.y,v2.z)); if (!ms.IsDone()) { PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(ms.Status())); return -1; } - // get Geom_Line of line segment - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - Handle_Geom_TrimmedCurve that_curv = ms.Value(); - Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve()); - this_line->SetLin(that_line->Lin()); - this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter()); - - Infinite = false; + // get Geom_Line of line + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast + (this->getGeomLinePtr()->handle()); + Handle_Geom_Line that_curv = ms.Value(); + this_curv->SetLin(that_curv->Lin()); return 0; } catch (Standard_Failure) { @@ -174,53 +123,34 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/) return -1; } -PyObject* LinePy::setParameterRange(PyObject *args) +Py::Object LinePy::getLocation(void) const { - double first, last; - if (!PyArg_ParseTuple(args, "dd", &first, &last)) - return NULL; - - try { - Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - this_curve->SetTrim(first, last); - } - catch (Standard_Failure) { - Handle_Standard_Failure e = Standard_Failure::Caught(); - PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); - return NULL; - } - - Py_Return; -} - -Py::Object LinePy::getStartPoint(void) const -{ - Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - gp_Pnt pnt = this_curve->StartPoint(); + Handle_Geom_Line this_curve = Handle_Geom_Line::DownCast + (this->getGeomLinePtr()->handle()); + gp_Pnt pnt = this_curve->Position().Location(); return Py::Vector(Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z())); } -void LinePy::setStartPoint(Py::Object arg) +void LinePy::setLocation(Py::Object arg) { - gp_Pnt p1, p2; - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - p2 = this_curv->EndPoint(); + gp_Pnt pnt; + gp_Dir dir; + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast + (this->getGeomLinePtr()->handle()); + dir = this_curv->Position().Direction(); PyObject *p = arg.ptr(); if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { Base::Vector3d v = static_cast(p)->value(); - p1.SetX(v.x); - p1.SetY(v.y); - p1.SetZ(v.z); + pnt.SetX(v.x); + pnt.SetY(v.y); + pnt.SetZ(v.z); } else if (PyTuple_Check(p)) { Py::Tuple tuple(arg); - p1.SetX((double)Py::Float(tuple.getItem(0))); - p1.SetY((double)Py::Float(tuple.getItem(1))); - p1.SetZ((double)Py::Float(tuple.getItem(2))); + pnt.SetX((double)Py::Float(tuple.getItem(0))); + pnt.SetY((double)Py::Float(tuple.getItem(1))); + pnt.SetZ((double)Py::Float(tuple.getItem(2))); } else { std::string error = std::string("type must be 'Vector' or tuple, not "); @@ -229,21 +159,14 @@ void LinePy::setStartPoint(Py::Object arg) } try { - // Create line out of two points - if (p1.Distance(p2) < gp::Resolution()) - Standard_Failure::Raise("Both points are equal"); - GC_MakeSegment ms(p1, p2); + GC_MakeLine ms(pnt, dir); if (!ms.IsDone()) { throw Py::Exception(gce_ErrorStatusText(ms.Status())); } - // get Geom_Line of line segment - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - Handle_Geom_TrimmedCurve that_curv = ms.Value(); - Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve()); - this_line->SetLin(that_line->Lin()); - this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter()); + // get Geom_Line of line + Handle_Geom_Line that_curv = ms.Value(); + this_curv->SetLin(that_curv->Lin()); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); @@ -251,33 +174,33 @@ void LinePy::setStartPoint(Py::Object arg) } } -Py::Object LinePy::getEndPoint(void) const +Py::Object LinePy::getDirection(void) const { - Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - gp_Pnt pnt = this_curve->EndPoint(); - return Py::Vector(Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z())); + Handle_Geom_Line this_curve = Handle_Geom_Line::DownCast + (this->getGeomLinePtr()->handle()); + gp_Dir dir = this_curve->Position().Direction(); + return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z())); } -void LinePy::setEndPoint(Py::Object arg) +void LinePy::setDirection(Py::Object arg) { - gp_Pnt p1, p2; - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (this->getGeomLineSegmentPtr()->handle()); - p1 = this_curv->StartPoint(); + gp_Pnt pnt; + gp_Dir dir; + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast + (this->getGeomLinePtr()->handle()); + pnt = this_curv->Position().Location(); PyObject *p = arg.ptr(); if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { Base::Vector3d v = static_cast(p)->value(); - p2.SetX(v.x); - p2.SetY(v.y); - p2.SetZ(v.z); + dir = gp_Dir(v.x,v.y,v.z); } else if (PyTuple_Check(p)) { Py::Tuple tuple(arg); - p2.SetX((double)Py::Float(tuple.getItem(0))); - p2.SetY((double)Py::Float(tuple.getItem(1))); - p2.SetZ((double)Py::Float(tuple.getItem(2))); + double x = (double)Py::Float(tuple.getItem(0)); + double y = (double)Py::Float(tuple.getItem(1)); + double z = (double)Py::Float(tuple.getItem(2)); + dir = gp_Dir(x,y,z); } else { std::string error = std::string("type must be 'Vector' or tuple, not "); @@ -286,21 +209,14 @@ void LinePy::setEndPoint(Py::Object arg) } try { - // Create line out of two points - if (p1.Distance(p2) < gp::Resolution()) - Standard_Failure::Raise("Both points are equal"); - GC_MakeSegment ms(p1, p2); + GC_MakeLine ms(pnt, dir); if (!ms.IsDone()) { throw Py::Exception(gce_ErrorStatusText(ms.Status())); } - // get Geom_Line of line segment - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - Handle_Geom_TrimmedCurve that_curv = ms.Value(); - Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve()); - this_line->SetLin(that_line->Lin()); - this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter()); + // get Geom_Line of line + Handle_Geom_Line that_curv = ms.Value(); + this_curv->SetLin(that_curv->Lin()); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); @@ -308,17 +224,6 @@ void LinePy::setEndPoint(Py::Object arg) } } -Py::Boolean LinePy::getInfinite(void) const -{ - return Py::Boolean(Infinite); -} - -void LinePy::setInfinite(Py::Boolean arg) -{ - Infinite = arg; -} - - PyObject *LinePy::getCustomAttributes(const char* /*attr*/) const { return 0; diff --git a/src/Mod/Part/App/PlanePyImp.cpp b/src/Mod/Part/App/PlanePyImp.cpp index 7030ad57e..c8580ce92 100644 --- a/src/Mod/Part/App/PlanePyImp.cpp +++ b/src/Mod/Part/App/PlanePyImp.cpp @@ -40,9 +40,9 @@ #include "OCCError.h" #include "Geometry.h" -#include "LinePy.h" -#include "PlanePy.h" -#include "PlanePy.cpp" +#include +#include +#include using namespace Part; @@ -266,12 +266,10 @@ PyObject* PlanePy::uIso(PyObject * args) Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast (getGeomPlanePtr()->handle()); Handle_Geom_Line c = Handle_Geom_Line::DownCast(plane->UIso(u)); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(c->Lin()); + this_curv->SetLin(c->Lin()); return new LinePy(line); } catch (Standard_Failure) { @@ -291,12 +289,10 @@ PyObject* PlanePy::vIso(PyObject * args) Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast (getGeomPlanePtr()->handle()); Handle_Geom_Line c = Handle_Geom_Line::DownCast(plane->VIso(v)); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(c->Lin()); + this_curv->SetLin(c->Lin()); return new LinePy(line); } catch (Standard_Failure) { diff --git a/src/Mod/Part/App/SurfaceOfExtrusionPyImp.cpp b/src/Mod/Part/App/SurfaceOfExtrusionPyImp.cpp index 99f78b103..68d4ab97e 100644 --- a/src/Mod/Part/App/SurfaceOfExtrusionPyImp.cpp +++ b/src/Mod/Part/App/SurfaceOfExtrusionPyImp.cpp @@ -169,11 +169,9 @@ PyObject* SurfaceOfExtrusionPy::uIso(PyObject * args) } if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast - (line->handle()); + GeomLine* line = new GeomLine(); Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); + (line->handle()); this_line->SetLin(aLine->Lin()); return new LinePy(line); } @@ -212,12 +210,10 @@ PyObject* SurfaceOfExtrusionPy::vIso(PyObject * args) } if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(aLine->Lin()); + this_curv->SetLin(aLine->Lin()); return new LinePy(line); } PyErr_Format(PyExc_NotImplementedError, "Iso curve is of type '%s'", diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index ef6221123..da1266c05 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -104,7 +104,7 @@ std::string TopoShapeEdgePy::representation(void) const PyObject *TopoShapeEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper { - // create a new instance of TopoShapeEdgePy and the Twin object + // create a new instance of TopoShapeEdgePy and the Twin object return new TopoShapeEdgePy(new TopoShape); } @@ -691,13 +691,10 @@ Py::Object TopoShapeEdgePy::getCurve() const { case GeomAbs_Line: { - GeomLineSegment* line = new GeomLineSegment(); - Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + GeomLine* line = new GeomLine(); + Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast (line->handle()); - Handle_Geom_Line this_line = Handle_Geom_Line::DownCast - (this_curv->BasisCurve()); - this_line->SetLin(adapt.Line()); - this_curv->SetTrim(adapt.FirstParameter(), adapt.LastParameter()); + this_curv->SetLin(adapt.Line()); return Py::Object(new LinePy(line),true); } case GeomAbs_Circle: @@ -892,5 +889,5 @@ PyObject *TopoShapeEdgePy::getCustomAttributes(const char* /*attr*/) const int TopoShapeEdgePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { - return 0; + return 0; } diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index ab9777d94..4415f2379 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -684,7 +684,7 @@ Py::Tuple Sketch::getPyGeometry(void) const tuple[i] = Py::asObject(new VectorPy(temp)); } else if (it->type == Line) { GeomLineSegment *lineSeg = static_cast(it->geo->clone()); - tuple[i] = Py::asObject(new LinePy(lineSeg)); + tuple[i] = Py::asObject(new LineSegmentPy(lineSeg)); } else if (it->type == Arc) { GeomArcOfCircle *aoc = static_cast(it->geo->clone()); tuple[i] = Py::asObject(new ArcOfCirclePy(aoc)); diff --git a/src/Mod/Sketcher/App/SketchPyImp.cpp b/src/Mod/Sketcher/App/SketchPyImp.cpp index e1bfbab03..07b4b1bf7 100644 --- a/src/Mod/Sketcher/App/SketchPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchPyImp.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include