Skip to content

Commit

Permalink
add keyword support to MakePipeShell.add, support overloaded method
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 13, 2017
1 parent 9b28b56 commit e97d9c3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.xml
Expand Up @@ -74,10 +74,11 @@
</UserDocu>
</Documentation>
</Methode>
<Methode Name="add">
<Methode Name="add" Keyword="true">
<Documentation>
<UserDocu>
add(shape Profile, bool WithContact, bool WithCorrection)
add(shape Profile, bool WithContact=False, bool WithCorrection=False)
add(shape Profile, vertex Location, bool WithContact=False, bool WithCorrection=False)
Adds the section Profile to this framework.
First and last sections may be punctual, so the shape Profile may be both wire and vertex.
If WithContact is true, the section is translated to be in contact with the spine.
Expand Down
63 changes: 47 additions & 16 deletions src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp
Expand Up @@ -34,6 +34,7 @@
#endif

#include "TopoShapePy.h"
#include "TopoShapeVertexPy.h"
#include "BRepOffsetAPI_MakePipeShellPy.h"
#include "BRepOffsetAPI_MakePipeShellPy.cpp"
#include "Tools.h"
Expand Down Expand Up @@ -210,26 +211,56 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
#endif
}

PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args)
PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args, PyObject *kwds)
{
PyObject *prof, *curv=Py_False, *keep=Py_False;
if (!PyArg_ParseTuple(args, "O!|O!O!",&Part::TopoShapePy::Type,&prof
,&PyBool_Type,&curv
,&PyBool_Type,&keep))
return 0;

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;
static char* keywords_pro[] = {"Profile","WithContact","WithCorrection",NULL};
if (PyArg_ParseTupleAndKeywords(args,kwds, "O!|O!O!", keywords_pro
,&Part::TopoShapePy::Type,&prof
,&PyBool_Type,&curv
,&PyBool_Type,&keep)) {
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;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;

PyErr_Clear();
PyObject *loc;
static char* keywords_loc[] = {"Profile","Location","WithContact","WithCorrection",NULL};
if (PyArg_ParseTupleAndKeywords(args,kwds, "O!O!|O!O!", keywords_loc
,&Part::TopoShapePy::Type,&prof
,&Part::TopoShapeVertexPy::Type,&loc
,&PyBool_Type,&curv
,&PyBool_Type,&keep)) {
try {
const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(prof)->getTopoShapePtr()->getShape();
const TopoDS_Vertex& v = TopoDS::Vertex(static_cast<Part::TopoShapePy*>(loc)->getTopoShapePtr()->getShape());
this->getBRepOffsetAPI_MakePipeShellPtr()->Add(s, v,
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;
}
}

PyErr_SetString(PyExc_TypeError, "Wrong arguments:\n"
"add(Profile, WithContact=False, WithCorrection=False)\n"
"add(Profile, Location, WithContact=False, WithCorrection=False)"
);
return 0;
}

PyObject* BRepOffsetAPI_MakePipeShellPy::remove(PyObject *args)
Expand Down

0 comments on commit e97d9c3

Please sign in to comment.