Part.EdgePy : get access to stored Pcurves
This commit is contained in:
@@ -528,6 +528,15 @@ coordinate system.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Continuity" Type="String"/>
|
||||
</Attribute>
|
||||
<Methode Name="curveOnSurface" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>curveOnSurface(idx) -> None or tuple
|
||||
Returns the 2D curve, the surface and the parameter range of index idx.
|
||||
Returns None if index idx is out of range.
|
||||
Returns a 4-items tuple of a curve, a surface, first parameter and last parameter.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<ClassDeclarations>
|
||||
</ClassDeclarations>
|
||||
</PythonExport>
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
# include <Geom_BezierCurve.hxx>
|
||||
# include <Geom_BSplineCurve.hxx>
|
||||
# include <Geom_OffsetCurve.hxx>
|
||||
# include <Geom_Surface.hxx>
|
||||
# include <Geom2d_Curve.hxx>
|
||||
# include <TopLoc_Location.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Elips.hxx>
|
||||
# include <gp_Hypr.hxx>
|
||||
@@ -86,6 +89,7 @@
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.h>
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.cpp>
|
||||
|
||||
#include "Geometry2d.h"
|
||||
#include "Geometry.h"
|
||||
#include <Mod/Part/App/GeometryPy.h>
|
||||
#include <Mod/Part/App/LinePy.h>
|
||||
@@ -1045,6 +1049,42 @@ Py::Boolean TopoShapeEdgePy::getDegenerated(void) const
|
||||
return Py::Boolean(ok ? true : false);
|
||||
}
|
||||
|
||||
PyObject* TopoShapeEdgePy::curveOnSurface(PyObject *args)
|
||||
{
|
||||
int idx;
|
||||
if (!PyArg_ParseTuple(args, "i", &idx))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
TopoDS_Edge edge = TopoDS::Edge(getTopoShapePtr()->getShape());
|
||||
Handle(Geom2d_Curve) curve;
|
||||
Handle(Geom_Surface) surf;
|
||||
TopLoc_Location loc;
|
||||
Standard_Real first, last;
|
||||
|
||||
BRep_Tool::CurveOnSurface(edge, curve, surf, loc, first, last, idx+1);
|
||||
if (curve.IsNull())
|
||||
Py_Return;
|
||||
std::unique_ptr<Part::Geom2dCurve> geo2d = getCurve2dFromGeom2d(curve);
|
||||
if (!geo2d)
|
||||
Py_Return;
|
||||
Part::GeomSurface* geosurf = makeFromSurface(surf);
|
||||
if (!geosurf)
|
||||
Py_Return;
|
||||
|
||||
Py::Tuple tuple(4);
|
||||
tuple.setItem(0, Py::asObject(geo2d->getPyObject()));
|
||||
tuple.setItem(1, Py::asObject(geosurf->getPyObject()));
|
||||
tuple.setItem(2, Py::Float(first));
|
||||
tuple.setItem(3, Py::Float(last));
|
||||
return Py::new_reference_to(tuple);
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *TopoShapeEdgePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user