Part: add Part.makeFilledSurface() that internally uses GeomFill_Generator
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
# include <Geom_Circle.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <GeomFill_AppSurf.hxx>
|
||||
# include <GeomFill_Generator.hxx>
|
||||
# include <GeomFill_Line.hxx>
|
||||
# include <GeomFill_SectionGenerator.hxx>
|
||||
# include <Interface_Static.hxx>
|
||||
@@ -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<Part::GeometryCurvePy*>((*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
|
||||
|
||||
Reference in New Issue
Block a user