Part: [skip ci] allow to create empty shapes of each type

This commit is contained in:
wmayer
2020-10-16 17:08:49 +02:00
parent 9fcf2c21cf
commit 1062b6ee0f
8 changed files with 56 additions and 1 deletions

View File

@@ -55,6 +55,13 @@ PyObject *TopoShapeCompSolidPy::PyMake(struct _typeobject *, PyObject *, PyObjec
int TopoShapeCompSolidPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined CompSolid
getTopoShapePtr()->setShape(TopoDS_CompSolid());
return 0;
}
PyErr_Clear();
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O", &pcObj))
return -1;

View File

@@ -59,6 +59,13 @@ PyObject *TopoShapeCompoundPy::PyMake(struct _typeobject *, PyObject *, PyObject
// constructor method
int TopoShapeCompoundPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Compound
getTopoShapePtr()->setShape(TopoDS_Compound());
return 0;
}
PyErr_Clear();
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O", &pcObj))
return -1;
@@ -79,7 +86,6 @@ int TopoShapeCompoundPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return -1;
}

View File

@@ -121,6 +121,13 @@ PyObject *TopoShapeEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
// constructor method
int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Edge
getTopoShapePtr()->setShape(TopoDS_Edge());
return 0;
}
PyErr_Clear();
PyObject *pcObj, *pcObj2;
double first=DBL_MAX, last=DBL_MAX;
if (PyArg_ParseTuple(args, "O!|dd", &(Part::GeometryPy::Type), &pcObj, &first, &last)) {

View File

@@ -117,6 +117,13 @@ PyObject *TopoShapeFacePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
// constructor method
int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Face
getTopoShapePtr()->setShape(TopoDS_Face());
return 0;
}
PyErr_Clear();
PyObject *pW;
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pW)) {
try {

View File

@@ -77,6 +77,13 @@ PyObject *TopoShapeShellPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
// constructor method
int TopoShapeShellPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Shell
getTopoShapePtr()->setShape(TopoDS_Shell());
return 0;
}
PyErr_Clear();
PyObject *obj;
if (!PyArg_ParseTuple(args, "O", &obj))
return -1;

View File

@@ -79,6 +79,13 @@ PyObject *TopoShapeSolidPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
// constructor method
int TopoShapeSolidPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Solid
getTopoShapePtr()->setShape(TopoDS_Solid());
return 0;
}
PyErr_Clear();
PyObject *obj;
if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &obj))
return -1;

View File

@@ -63,6 +63,13 @@ PyObject *TopoShapeVertexPy::PyMake(struct _typeobject *, PyObject *, PyObject *
// constructor method
int TopoShapeVertexPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Vertex
getTopoShapePtr()->setShape(TopoDS_Vertex());
return 0;
}
PyErr_Clear();
double x=0.0,y=0.0,z=0.0;
PyObject *object;
bool success = false;

View File

@@ -85,6 +85,13 @@ PyObject *TopoShapeWirePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
// constructor method
int TopoShapeWirePy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
if (PyArg_ParseTuple(args, "")) {
// Undefined Wire
getTopoShapePtr()->setShape(TopoDS_Wire());
return 0;
}
PyErr_Clear();
PyObject *pcObj;
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) {
BRepBuilderAPI_MakeWire mkWire;