+ support to create faces from vertices with shape builder

This commit is contained in:
wmayer
2014-07-25 13:35:10 +02:00
parent f0eb27f710
commit 4dee80f4e1
4 changed files with 176 additions and 56 deletions

View File

@@ -1022,7 +1022,8 @@ static PyObject * makeLine(PyObject *self, PyObject *args)
static PyObject * makePolygon(PyObject *self, PyObject *args)
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O", &pcObj)) // convert args: Python->C
PyObject *pclosed=Py_False;
if (!PyArg_ParseTuple(args, "O|O!", &pcObj, &(PyBool_Type), &pclosed)) // convert args: Python->C
return NULL; // NULL triggers exception
PY_TRY {
@@ -1048,6 +1049,13 @@ static PyObject * makePolygon(PyObject *self, PyObject *args)
if (!mkPoly.IsDone())
Standard_Failure::Raise("Cannot create polygon because less than two vertices are given");
// if the polygon should be closed
if (PyObject_IsTrue(pclosed)) {
if (!mkPoly.FirstVertex().IsSame(mkPoly.LastVertex())) {
mkPoly.Add(mkPoly.FirstVertex());
}
}
return new TopoShapeWirePy(new TopoShape(mkPoly.Wire()));
}
catch (Standard_Failure) {