diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 1b7804e58c..8b7cb06f98 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -50,6 +50,7 @@ # include # include # include +# include # include # include # include @@ -444,6 +445,9 @@ public: "makeFace(list_of_shapes_or_compound, maker_class_name) -- Create a face (faces) using facemaker class.\n" "maker_class_name is a string like 'Part::FaceMakerSimple'." ); + add_varargs_method("makeFilledSurface",&Module::makeFilledSurface, + "makeFilledSurface(list of curves, tolerance) -- Create a surface out of a list of curves." + ); add_varargs_method("makeFilledFace",&Module::makeFilledFace, "makeFilledFace(list) -- Create a face out of a list of edges." ); @@ -1012,6 +1016,38 @@ private: throw Py::Exception(); } } + Py::Object makeFilledSurface(const Py::Tuple &args) + { + PyObject *obj; + double tolerance; + if (!PyArg_ParseTuple(args.ptr(), "Od", &obj, &tolerance)) + throw Py::Exception(); + + try { + GeomFill_Generator generator; + Py::Sequence list(obj); + for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { + if (PyObject_TypeCheck((*it).ptr(), &(Part::GeometryCurvePy::Type))) { + Handle(Geom_Curve) hCurve = Handle(Geom_Curve)::DownCast(static_cast((*it).ptr())->getGeomCurvePtr()->handle()); + if (!hCurve.IsNull()) { + generator.AddCurve(hCurve); + } + } + } + + generator.Perform(tolerance); + Handle(Geom_Surface) hSurface = generator.Surface(); + if (!hSurface.IsNull()) { + return Py::asObject(makeFromSurface(hSurface)->getPyObject()); + } + else { + throw Py::Exception(PartExceptionOCCError, "Failed to created surface by filling curves"); + } + } + catch (Standard_Failure& e) { + throw Py::Exception(PartExceptionOCCError, e.GetMessageString()); + } + } Py::Object makeFilledFace(const Py::Tuple& args) { // TODO: BRepFeat_SplitShape