Skip to content

Commit

Permalink
Add parameter at given distance method for curves
Browse files Browse the repository at this point in the history
  • Loading branch information
maito78 authored and wwmayer committed Jul 29, 2016
1 parent a14794b commit 8fe7c94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Mod/Part/App/GeometryCurvePy.xml
Expand Up @@ -63,6 +63,12 @@ Part.show(s)
length([uMin,uMax,Tol]) -> Float</UserDocu>
</Documentation>
</Methode>
<Methode Name="parameterAtDistance">
<Documentation>
<UserDocu>Returns the parameter on the curve of a point at the given distance from a starting parameter.
parameterAtDistance([abscissa, startingParameter]) -> Float the</UserDocu>
</Documentation>
</Methode>
<Methode Name="value">
<Documentation>
<UserDocu>Computes the point of parameter u on this curve</UserDocu>
Expand Down
32 changes: 29 additions & 3 deletions src/Mod/Part/App/GeometryCurvePyImp.cpp
Expand Up @@ -322,6 +322,32 @@ PyObject* GeometryCurvePy::length(PyObject *args)
return 0;
}

PyObject* GeometryCurvePy::parameterAtDistance(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double abscissa;
double u = 0;
if (!PyArg_ParseTuple(args, "d|d", &abscissa,&u))
return 0;
GeomAdaptor_Curve adapt(c);
GCPnts_AbscissaPoint abscissaPoint(adapt,abscissa,u);
double parm = abscissaPoint.Parameter();
return PyFloat_FromDouble(parm);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}

PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}

PyObject* GeometryCurvePy::value(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Expand Down Expand Up @@ -418,12 +444,12 @@ PyObject* GeometryCurvePy::makeRuledSurface(PyObject *args)
}
// check the result surface type
if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
Handle_Geom_RectangularTrimmedSurface aTSurf =
Handle_Geom_RectangularTrimmedSurface aTSurf =
Handle_Geom_RectangularTrimmedSurface::DownCast(aSurf);
return new RectangularTrimmedSurfacePy(new GeomTrimmedSurface(aTSurf));
}
else if (aSurf->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
Handle_Geom_BSplineSurface aBSurf =
Handle_Geom_BSplineSurface aBSurf =
Handle_Geom_BSplineSurface::DownCast(aSurf);
return new BSplineSurfacePy(new GeomBSplineSurface(aBSurf));
}
Expand Down Expand Up @@ -610,7 +636,7 @@ PyObject *GeometryCurvePy::getCustomAttributes(const char* /*attr*/) const

int GeometryCurvePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
return 0;
}

// Specialized intersection functions
Expand Down

0 comments on commit 8fe7c94

Please sign in to comment.