add Approximation option to TopoShape section

This commit is contained in:
tomate44
2018-06-10 17:51:12 +02:00
committed by wmayer
parent be96fcc62d
commit f3ac51d9b7
4 changed files with 23 additions and 13 deletions

View File

@@ -911,11 +911,12 @@ PyObject* TopoShapePy::common(PyObject *args)
PyObject* TopoShapePy::section(PyObject *args)
{
PyObject *pcObj;
if (PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj)) {
PyObject *approx = Py_False;
if (PyArg_ParseTuple(args, "O!|O!", &(TopoShapePy::Type), &pcObj, &(PyBool_Type), &approx)) {
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
try {
// Let's call algorithm computing a section operation:
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape);
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape,PyObject_IsTrue(approx) ? true : false);
return new TopoShapePy(new TopoShape(secShape));
}
catch (Standard_Failure& e) {
@@ -931,11 +932,11 @@ PyObject* TopoShapePy::section(PyObject *args)
PyErr_Clear();
double tolerance = 0.0;
if (PyArg_ParseTuple(args, "O!d", &(TopoShapePy::Type), &pcObj, &tolerance)) {
if (PyArg_ParseTuple(args, "O!d|O!", &(TopoShapePy::Type), &pcObj, &tolerance, &(PyBool_Type), &approx)) {
std::vector<TopoDS_Shape> shapeVec;
shapeVec.push_back(static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape());
try {
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance);
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
return new TopoShapePy(new TopoShape(sectionShape));
}
catch (Standard_Failure& e) {
@@ -949,7 +950,7 @@ PyObject* TopoShapePy::section(PyObject *args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O|d", &pcObj, &tolerance)) {
if (PyArg_ParseTuple(args, "O|dO!", &pcObj, &tolerance, &(PyBool_Type), &approx)) {
std::vector<TopoDS_Shape> shapeVec;
Py::Sequence shapeSeq(pcObj);
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
@@ -963,7 +964,7 @@ PyObject* TopoShapePy::section(PyObject *args)
}
}
try {
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance);
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
return new TopoShapePy(new TopoShape(multiSectionShape));
}
catch (Standard_Failure& e) {