Part: implement BSplineSurface.buildFromNSections based on GeomFill_NSections

This commit is contained in:
wmayer
2020-09-25 15:07:47 +02:00
parent 77f84ce743
commit e22e215d16
2 changed files with 69 additions and 1 deletions

View File

@@ -721,6 +721,13 @@
arguments: poles (sequence of sequence of Base.Vector), umults, vmults, [uknots, vknots, uperiodic, vperiodic, udegree, vdegree, weights (sequence of sequence of float)]
</UserDocu>
</Documentation>
</Methode>
</Methode>
<Methode Name="buildFromNSections">
<Documentation>
<UserDocu>
Builds a B-Spline from a list of control curves
</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -35,6 +35,7 @@
# include <GeomAPI_PointsToBSplineSurface.hxx>
# include <GeomAbs_Shape.hxx>
#endif
# include <GeomFill_NSections.hxx>
#include <Base/GeometryPyCXX.h>
#include <Base/VectorPy.h>
@@ -1511,6 +1512,66 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k
}
}
/*!
* \code
c = Part.Circle()
c.Radius=50
c = c.trim(0, math.pi)
e1 = Part.Ellipse()
e1.Center = (0, 0, 75)
e1.MajorRadius = 30
e1.MinorRadius = 5
e1 = e1.trim(0, math.pi)
e2 = Part.Ellipse()
e2.Center = (0, 0, 100)
e2.MajorRadius = 20
e2.MinorRadius = 5
e2 = e2.trim(0, math.pi)
bs = Part.BSplineSurface()
bs.buildFromNSections([c, e1, e2])
* \endcode
*/
PyObject* BSplineSurfacePy::buildFromNSections(PyObject *args)
{
PyObject* list;
PyObject* refSurf = Py_False;
if (!PyArg_ParseTuple(args, "O|O!", &list, &PyBool_Type, &refSurf))
return nullptr;
try {
TColGeom_SequenceOfCurve curveSeq;
Py::Sequence curves(list);
for (Py::Sequence::iterator it = curves.begin(); it != curves.end(); ++it) {
Py::Object obj(*it);
if (PyObject_TypeCheck(obj.ptr(), &GeometryCurvePy::Type)) {
GeomCurve* geom = static_cast<GeometryCurvePy*>(obj.ptr())->getGeomCurvePtr();
curveSeq.Append(Handle(Geom_Curve)::DownCast(geom->handle()));
}
}
GeomFill_NSections fillOp(curveSeq);
if (PyObject_IsTrue(refSurf)) {
Handle(Geom_BSplineSurface) ref = Handle(Geom_BSplineSurface)::DownCast
(getGeometryPtr()->handle());
fillOp.SetSurface(ref);
}
fillOp.ComputeSurface();
Handle(Geom_BSplineSurface) aSurf = fillOp.BSplineSurface();
this->getGeomBSplineSurfacePtr()->setHandle(aSurf);
Py_Return;
}
catch (const Standard_Failure& e) {
Standard_CString msg = e.GetMessageString();
PyErr_SetString(PartExceptionOCCError, msg ? msg : "");
return nullptr;
}
}
Py::Long BSplineSurfacePy::getUDegree(void) const
{
Handle(Geom_BSplineSurface) surf = Handle(Geom_BSplineSurface)::DownCast