diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 5be2fd8d5..797f66b0c 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -158,6 +158,19 @@ This is a more detailed check as done in isValid(). Sew the shape if there is a gap. + + + +childShapes([cumOri=True, cumLoc=True]) -> list +Return a list of sub-shapes that are direct children of this shape. + * If cumOri is true, the function composes all + sub-shapes with the orientation of this shape. + * If cumLoc is true, the function multiplies all + sub-shapes by the location of this shape, i.e. it applies to + each sub-shape the transformation that is associated with this shape. + + + Removes internal wires (also holes) from the shape. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 19bfcdab6..ed5a900f7 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -757,6 +757,70 @@ PyObject* TopoShapePy::sewShape(PyObject *args) } } +PyObject* TopoShapePy::childShapes(PyObject *args) +{ + PyObject* cumOri = Py_True; + PyObject* cumLoc = Py_True; + if (!PyArg_ParseTuple(args, "|O!O!", &(PyBool_Type), &cumOri, + &(PyBool_Type), &cumLoc)) + return NULL; + + try { + TopoDS_Iterator it(getTopoShapePtr()->_Shape, + PyObject_IsTrue(cumOri) ? Standard_True : Standard_False, + PyObject_IsTrue(cumLoc) ? Standard_True : Standard_False); + Py::List list; + for (; it.More(); it.Next()) { + const TopoDS_Shape& aChild = it.Value(); + if (!aChild.IsNull()) { + TopAbs_ShapeEnum type = aChild.ShapeType(); + PyObject* pyChild = 0; + switch (type) + { + case TopAbs_COMPOUND: + pyChild = new TopoShapeCompoundPy(new TopoShape(aChild)); + break; + case TopAbs_COMPSOLID: + pyChild = new TopoShapeCompSolidPy(new TopoShape(aChild)); + break; + case TopAbs_SOLID: + pyChild = new TopoShapeSolidPy(new TopoShape(aChild)); + break; + case TopAbs_SHELL: + pyChild = new TopoShapeShellPy(new TopoShape(aChild)); + break; + case TopAbs_FACE: + pyChild = new TopoShapeFacePy(new TopoShape(aChild)); + break; + case TopAbs_WIRE: + pyChild = new TopoShapeWirePy(new TopoShape(aChild)); + break; + case TopAbs_EDGE: + pyChild = new TopoShapeEdgePy(new TopoShape(aChild)); + break; + case TopAbs_VERTEX: + pyChild = new TopoShapeVertexPy(new TopoShape(aChild)); + break; + case TopAbs_SHAPE: + break; + default: + break; + } + + if (pyChild) { + list.append(Py::Object(pyChild,true)); + } + } + } + return Py::new_reference_to(list); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); + return NULL; + } +} + PyObject* TopoShapePy::removeInternalWires(PyObject *args) { double minArea;