exception handling in BRepOffsetAPI_MakePipeShellPy

This commit is contained in:
wmayer
2017-05-13 13:28:31 +02:00
parent 36c60d3f8d
commit 9b28b563ce

View File

@@ -75,8 +75,16 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args)
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
Py_Return;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setTrihedronMode(PyObject *args)
@@ -85,10 +93,18 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setTrihedronMode(PyObject *args)
if (!PyArg_ParseTuple(args, "O!O!",&Base::VectorPy::Type,&pnt
,&Base::VectorPy::Type,&dir))
return 0;
gp_Pnt p = Base::convertTo<gp_Pnt>(Py::Vector(pnt,false).toVector());
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(gp_Ax2(p,d));
Py_Return;
try {
gp_Pnt p = Base::convertTo<gp_Pnt>(Py::Vector(pnt,false).toVector());
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(gp_Ax2(p,d));
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setBiNormalMode(PyObject *args)
@@ -96,9 +112,17 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setBiNormalMode(PyObject *args)
PyObject *dir;
if (!PyArg_ParseTuple(args, "O!",&Base::VectorPy::Type,&dir))
return 0;
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(d);
Py_Return;
try {
gp_Dir d = Base::convertTo<gp_Dir>(Py::Vector(dir,false).toVector());
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(d);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setSpineSupport(PyObject *args)
@@ -106,9 +130,17 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setSpineSupport(PyObject *args)
PyObject *shape;
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(s);
return Py::new_reference_to(Py::Boolean(ok ? true : false));
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(s);
return Py::new_reference_to(Py::Boolean(ok ? true : false));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
@@ -119,46 +151,62 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
,&PyBool_Type,&curv
,&PyLong_Type,&keep))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(spine)->getTopoShapePtr()->getShape();
if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) {
PyErr_SetString(PyExc_TypeError, "spine is not a wire");
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(spine)->getTopoShapePtr()->getShape();
if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) {
PyErr_SetString(PyExc_TypeError, "spine is not a wire");
return 0;
}
BRepFill_TypeOfContact typeOfCantact;
switch (PyLong_AsLong(keep)) {
case 1:
typeOfCantact = BRepFill_Contact;
break;
case 2:
typeOfCantact = BRepFill_ContactOnBorder;
break;
default:
typeOfCantact = BRepFill_NoContact;
break;
}
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
TopoDS::Wire(s),
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
typeOfCantact);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
BRepFill_TypeOfContact typeOfCantact;
switch (PyLong_AsLong(keep)) {
case 1:
typeOfCantact = BRepFill_Contact;
break;
case 2:
typeOfCantact = BRepFill_ContactOnBorder;
break;
default:
typeOfCantact = BRepFill_NoContact;
break;
}
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
TopoDS::Wire(s),
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
typeOfCantact);
Py_Return;
#else
PyObject *spine, *curv, *keep;
if (!PyArg_ParseTuple(args, "O!O!O!",&Part::TopoShapePy::Type,&spine
,&PyBool_Type,&curv
,&PyBool_Type,&keep))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(spine)->getTopoShapePtr()->getShape();
if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) {
PyErr_SetString(PyExc_TypeError, "spine is not a wire");
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(spine)->getTopoShapePtr()->getShape();
if (s.IsNull() || s.ShapeType() != TopAbs_WIRE) {
PyErr_SetString(PyExc_TypeError, "spine is not a wire");
return 0;
}
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
TopoDS::Wire(s),
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMode(
TopoDS::Wire(s),
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
Py_Return;
#endif
}
@@ -169,11 +217,19 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args)
,&PyBool_Type,&curv
,&PyBool_Type,&keep))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s,
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
Py_Return;
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s,
PyObject_IsTrue(curv) ? Standard_True : Standard_False,
PyObject_IsTrue(keep) ? Standard_True : Standard_False);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::remove(PyObject *args)
@@ -181,65 +237,129 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::remove(PyObject *args)
PyObject *prof;
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&prof))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
this->getBRepOffsetAPI_MakePipeShellPtr()->Delete(s);
Py_Return;
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
this->getBRepOffsetAPI_MakePipeShellPtr()->Delete(s);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::isReady(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->IsReady();
return Py::new_reference_to(Py::Boolean(ok ? true : false));
try {
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->IsReady();
return Py::new_reference_to(Py::Boolean(ok ? true : false));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::getStatus(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
Standard_Integer val = this->getBRepOffsetAPI_MakePipeShellPtr()->GetStatus();
return Py::new_reference_to(Py::Long(val));
try {
Standard_Integer val = this->getBRepOffsetAPI_MakePipeShellPtr()->GetStatus();
return Py::new_reference_to(Py::Long(val));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::makeSolid(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->MakeSolid();
return Py::new_reference_to(Py::Boolean(ok ? true : false));
try {
Standard_Boolean ok = this->getBRepOffsetAPI_MakePipeShellPtr()->MakeSolid();
return Py::new_reference_to(Py::Boolean(ok ? true : false));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::build(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->Build();
Py_Return;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->Build();
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::shape(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
const TopoDS_Shape& shape = this->getBRepOffsetAPI_MakePipeShellPtr()->Shape();
return new TopoShapePy(new TopoShape(shape));
try {
const TopoDS_Shape& shape = this->getBRepOffsetAPI_MakePipeShellPtr()->Shape();
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::firstShape(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->FirstShape();
return new TopoShapePy(new TopoShape(shape));
try {
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->FirstShape();
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::lastShape(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->LastShape();
return new TopoShapePy(new TopoShape(shape));
try {
TopoDS_Shape shape = this->getBRepOffsetAPI_MakePipeShellPtr()->LastShape();
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::generated(PyObject *args)
@@ -247,16 +367,24 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::generated(PyObject *args)
PyObject *shape;
if (!PyArg_ParseTuple(args, "O!",&Part::TopoShapePy::Type,&shape))
return 0;
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
const TopTools_ListOfShape& list = this->getBRepOffsetAPI_MakePipeShellPtr()->Generated(s);
Py::List shapes;
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(list); it.More(); it.Next()) {
const TopoDS_Shape& s = it.Value();
shapes.append(Py::asObject(new TopoShapePy(new TopoShape(s))));
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape();
const TopTools_ListOfShape& list = this->getBRepOffsetAPI_MakePipeShellPtr()->Generated(s);
Py::List shapes;
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(list); it.More(); it.Next()) {
const TopoDS_Shape& s = it.Value();
shapes.append(Py::asObject(new TopoShapePy(new TopoShape(s))));
}
return Py::new_reference_to(shapes);
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
return Py::new_reference_to(shapes);
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setTolerance(PyObject *args)
@@ -264,8 +392,16 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setTolerance(PyObject *args)
double tol3d, boundTol, tolAngular;
if (!PyArg_ParseTuple(args, "ddd",&tol3d,&boundTol,&tolAngular))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTolerance(tol3d, boundTol, tolAngular);
Py_Return;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTolerance(tol3d, boundTol, tolAngular);
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setTransitionMode(PyObject *args)
@@ -273,52 +409,84 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setTransitionMode(PyObject *args)
int mode;
if (!PyArg_ParseTuple(args, "i",&mode))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTransitionMode(BRepBuilderAPI_TransitionMode(mode));
Py_Return;
try {
this->getBRepOffsetAPI_MakePipeShellPtr()->SetTransitionMode(BRepBuilderAPI_TransitionMode(mode));
Py_Return;
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setMaxDegree(PyObject *args)
{
#if OCC_VERSION_HEX >= 0x060800
int degree;
if (!PyArg_ParseTuple(args, "i",&degree))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxDegree(degree);
Py_Return;
try {
#if OCC_VERSION_HEX >= 0x060800
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxDegree(degree);
Py_Return;
#else
(void)args;
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.8");
return 0;
(void)args;
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.8");
return 0;
#endif
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setMaxSegments(PyObject *args)
{
#if OCC_VERSION_HEX >= 0x060800
int nbseg;
if (!PyArg_ParseTuple(args, "i",&nbseg))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxSegments(nbseg);
Py_Return;
try {
#if OCC_VERSION_HEX >= 0x060800
this->getBRepOffsetAPI_MakePipeShellPtr()->SetMaxSegments(nbseg);
Py_Return;
#else
(void)args;
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.8");
return 0;
(void)args;
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.8");
return 0;
#endif
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
PyObject* BRepOffsetAPI_MakePipeShellPy::setForceApproxC1(PyObject *args)
{
#if OCC_VERSION_HEX >= 0x060700
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!",&PyBool_Type,&obj))
return 0;
this->getBRepOffsetAPI_MakePipeShellPtr()->SetForceApproxC1(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
Py_Return;
try {
#if OCC_VERSION_HEX >= 0x060700
this->getBRepOffsetAPI_MakePipeShellPtr()->SetForceApproxC1(PyObject_IsTrue(obj) ? Standard_True : Standard_False);
Py_Return;
#else
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.7");
return 0;
PyErr_SetString(PyExc_RuntimeError, "requires OCC >= 6.7");
return 0;
#endif
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}