+ fixes #0001544: Python function to retrive direct children of a shape using TopoDS_Iterator
This commit is contained in:
parent
65071e1684
commit
f9ff3b250e
|
@ -158,6 +158,19 @@ This is a more detailed check as done in isValid().</UserDocu>
|
|||
<UserDocu>Sew the shape if there is a gap.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="childShapes" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
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.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeInternalWires">
|
||||
<Documentation>
|
||||
<UserDocu>Removes internal wires (also holes) from the shape.</UserDocu>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user