From 59682f31a74044ea2c4f8e1d97ae4416b23f64d7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 4 Apr 2017 10:05:46 +0200 Subject: [PATCH] add methods firstVertex and lastVertex to TopoEdge --- src/Mod/Part/App/TopoShapeEdgePy.xml | 20 +++++++++++++++++++- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/TopoShapeEdgePy.xml b/src/Mod/Part/App/TopoShapeEdgePy.xml index bc37223f06..ea149baa5c 100644 --- a/src/Mod/Part/App/TopoShapeEdgePy.xml +++ b/src/Mod/Part/App/TopoShapeEdgePy.xml @@ -69,7 +69,25 @@ Set the tolerance for the edge. - + + + Vertex = firstVertex(Orientation=False) +Returns the Vertex of orientation FORWARD in this edge. +If there is none a Null shape is returned. +Orientation = True : taking into account the edge orientation + + + + + + Vertex = lastVertex(Orientation=False) +Returns the Vertex of orientation REVERSED in this edge. +If there is none a Null shape is returned. +Orientation = True : taking into account the edge orientation + + + + Discretizes the edge and returns a list of points. The function accepts keywords as argument: diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index 03f764f610..0b04263d56 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -49,6 +49,7 @@ # include # include # include +# include # include # include # include @@ -668,6 +669,26 @@ PyObject* TopoShapeEdgePy::setTolerance(PyObject *args) Py_Return; } +PyObject* TopoShapeEdgePy::firstVertex(PyObject *args) +{ + PyObject* orient = Py_False; + if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &orient)) + return 0; + const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape()); + TopoDS_Vertex v = TopExp::FirstVertex(e, PyObject_IsTrue(orient) ? Standard_True : Standard_False); + return new TopoShapeVertexPy(new TopoShape(v)); +} + +PyObject* TopoShapeEdgePy::lastVertex(PyObject *args) +{ + PyObject* orient = Py_False; + if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &orient)) + return 0; + const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape()); + TopoDS_Vertex v = TopExp::LastVertex(e, PyObject_IsTrue(orient) ? Standard_True : Standard_False); + return new TopoShapeVertexPy(new TopoShape(v)); +} + // ====== Attributes ====================================================================== Py::Float TopoShapeEdgePy::getTolerance(void) const