add TopoShape::multiFuse method

to fuse multiple shapes at once.
This commit is contained in:
Sebastian Hoogen
2015-02-19 13:14:18 +01:00
committed by wmayer
parent bc6f86ea90
commit 9a758221ee
4 changed files with 86 additions and 0 deletions

View File

@@ -645,6 +645,39 @@ PyObject* TopoShapePy::fuse(PyObject *args)
}
}
PyObject* TopoShapePy::multiFuse(PyObject *args)
{
double tolerance = 0.0;
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O|d", &pcObj, &tolerance))
return NULL;
std::vector<TopoDS_Shape> shapeVec;
Py::Sequence shapeSeq(pcObj);
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(Part::TopoShapePy::Type))) {
shapeVec.push_back(static_cast<Part::TopoShapePy*>(item)->getTopoShapePtr()->_Shape);
}
else {
PyErr_SetString(PyExc_TypeError, "non-shape object in sequence");
return 0;
}
}
try {
TopoDS_Shape multiFusedShape = this->getTopoShapePtr()->multiFuse(shapeVec,tolerance);
return new TopoShapePy(new TopoShape(multiFusedShape));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return NULL;
}
catch (const std::exception& e) {
PyErr_SetString(PartExceptionOCCError, e.what());
return NULL;
}
}
PyObject* TopoShapePy::oldFuse(PyObject *args)
{
PyObject *pcObj;