diff --git a/src/Mod/Part/App/TopoShapeEdgePy.xml b/src/Mod/Part/App/TopoShapeEdgePy.xml
index 83e9d660af..76055215af 100644
--- a/src/Mod/Part/App/TopoShapeEdgePy.xml
+++ b/src/Mod/Part/App/TopoShapeEdgePy.xml
@@ -14,14 +14,19 @@
TopoShapeEdge is the OpenCasCade topological edge wrapper
-
+
+
+ float = getParameterByLength(float) - Return parameter [First,Last]. Input value must be of [0|Length]
+
+
+
- Vector = tangentAt(pos) - Get the tangent at the given parameter [0|Length] if defined
+ Vector = tangentAt(pos) - Get the tangent at the given parameter [First|Last] if defined
- Vector = valueAt(pos) - Get the point at the given parameter [0|Length] if defined
+ Vector = valueAt(pos) - Get the point at the given parameter [First|Last] if defined
@@ -31,32 +36,32 @@
- Vector = normalAt(pos) - Get the normal vector at the given parameter [0|Length] if defined
+ Vector = normalAt(pos) - Get the normal vector at the given parameter [First|Last] if defined
- Vector = d1At(pos) - Get the first derivative at the given parameter [0|Length] if defined
+ Vector = d1At(pos) - Get the first derivative at the given parameter [First|Last] if defined
- Vector = d2At(pos) - Get the second derivative at the given parameter [0|Length] if defined
+ Vector = d2At(pos) - Get the second derivative at the given parameter [First|Last] if defined
- Vector = d3At(pos) - Get the third derivative at the given parameter [0|Length] if defined
+ Vector = d3At(pos) - Get the third derivative at the given parameter [First|Last] if defined
- Float = curvatureAt(pos) - Get the curvature at the given parameter [0|Length] if defined
+ Float = curvatureAt(pos) - Get the curvature at the given parameter [First|Last] if defined
- Vector = centerOfCurvatureAt(float pos) - Get the center of curvature at the given parameter [0|Length] if defined
+ Vector = centerOfCurvatureAt(float pos) - Get the center of curvature at the given parameter [First|Last] if defined
@@ -132,8 +137,6 @@ absolute Cartesian coordinate system.
- private:
- double getNormalizedParameter(double) const;
diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp
index c9d850cc1c..a0dd79abef 100644
--- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp
+++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp
@@ -166,23 +166,31 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
// ====== Methods ======================================================================
-double TopoShapeEdgePy::getNormalizedParameter(double u) const
+PyObject* TopoShapeEdgePy::getParameterByLength(PyObject *args)
{
-#if 0
+ double u;
+ if (!PyArg_ParseTuple(args, "d",&u))
+ return 0;
+
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- // normalizing parameter space to length
+ // transform value of [0,Length] to [First,Last]
double first = BRepLProp_CurveTool::FirstParameter(adapt);
double last = BRepLProp_CurveTool::LastParameter(adapt);
if (!Precision::IsInfinite(first) && !Precision::IsInfinite(last)) {
double length = GCPnts_AbscissaPoint::Length(adapt);
+
+ if (u < 0 || u > length) {
+ PyErr_SetString(PyExc_ValueError, "value out of range");
+ return 0;
+ }
+
double stretch = (last - first) / length;
u = first + u*stretch;
}
-#endif
- return u;
+ return PyFloat_FromDouble(u);
}
PyObject* TopoShapeEdgePy::valueAt(PyObject *args)
@@ -194,8 +202,6 @@ PyObject* TopoShapeEdgePy::valueAt(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
// Check now the orientation of the edge to make
// sure that we get the right wanted point!
BRepLProp_CLProps prop(adapt,u,0,Precision::Confusion());
@@ -241,8 +247,6 @@ PyObject* TopoShapeEdgePy::tangentAt(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
if (prop.IsTangentDefined()) {
gp_Dir dir;
@@ -264,8 +268,6 @@ PyObject* TopoShapeEdgePy::normalAt(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
gp_Dir V ;
@@ -288,8 +290,6 @@ PyObject* TopoShapeEdgePy::curvatureAt(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
double C = prop.Curvature();
@@ -311,8 +311,6 @@ PyObject* TopoShapeEdgePy::centerOfCurvatureAt(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
gp_Pnt V ;
@@ -335,8 +333,6 @@ PyObject* TopoShapeEdgePy::derivative1At(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,1,Precision::Confusion());
const gp_Vec& V = prop.D1();
@@ -358,8 +354,6 @@ PyObject* TopoShapeEdgePy::derivative2At(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,2,Precision::Confusion());
const gp_Vec& V = prop.D2();
@@ -381,8 +375,6 @@ PyObject* TopoShapeEdgePy::derivative3At(PyObject *args)
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->_Shape);
BRepAdaptor_Curve adapt(e);
- u = getNormalizedParameter(u);
-
try {
BRepLProp_CLProps prop(adapt,u,3,Precision::Confusion());
const gp_Vec& V = prop.D3();