Edge.getParameterByLength fix
This commit is contained in:
@@ -16,18 +16,21 @@
|
||||
</Documentation>
|
||||
<Methode Name="getParameterByLength" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>paramval = getParameterByLength(pos)
|
||||
<UserDocu>paramval = getParameterByLength(pos, [tolerance = 1e-7])
|
||||
Get the value of the primary parameter at the given distance along the cartesian
|
||||
length of the curve.
|
||||
length of the edge.
|
||||
|
||||
Args:
|
||||
pos (float or int): The distance along the length of the curve at which to
|
||||
pos (float or int): The distance along the length of the edge at which to
|
||||
determine the primary parameter value. See help for the FirstParameter or
|
||||
LastParameter properties for more information on the primary parameter.
|
||||
If the given value is positive, the distance from edge start is used.
|
||||
If the given value is negative, the distance from edge end is used.
|
||||
tol (float): Computing tolerance. Optional, defaults to 1e-7.
|
||||
|
||||
Returns:
|
||||
|
||||
paramval (float): the value of the primary parameter defining the curve at the
|
||||
paramval (float): the value of the primary parameter defining the edge at the
|
||||
given position along its cartesian length.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -187,7 +187,8 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyObject* TopoShapeEdgePy::getParameterByLength(PyObject *args)
|
||||
{
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d",&u))
|
||||
double t=Precision::Confusion();
|
||||
if (!PyArg_ParseTuple(args, "d|d",&u,&t))
|
||||
return 0;
|
||||
|
||||
const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
@@ -197,15 +198,17 @@ PyObject* TopoShapeEdgePy::getParameterByLength(PyObject *args)
|
||||
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);
|
||||
double length = GCPnts_AbscissaPoint::Length(adapt,t);
|
||||
|
||||
if (u < 0 || u > length) {
|
||||
if (u < -length || u > length) {
|
||||
PyErr_SetString(PyExc_ValueError, "value out of range");
|
||||
return 0;
|
||||
}
|
||||
|
||||
double stretch = (last - first) / length;
|
||||
u = first + u*stretch;
|
||||
if (u < 0)
|
||||
u = length+u;
|
||||
GCPnts_AbscissaPoint abscissaPoint(t,adapt,u,first);
|
||||
double parm = abscissaPoint.Parameter();
|
||||
return PyFloat_FromDouble(parm);
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(u);
|
||||
|
||||
Reference in New Issue
Block a user