+ check for null shape before calling BRep_Tool::IsClosed

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5379 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2012-01-02 14:03:55 +00:00
parent ba343de080
commit 3fd1827084
2 changed files with 5 additions and 1 deletions

View File

@ -123,7 +123,7 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) {
TopoShape* shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
if (shape && shape->_Shape.ShapeType() == TopAbs_EDGE) {
if (shape && !shape->_Shape.IsNull() && shape->_Shape.ShapeType() == TopAbs_EDGE) {
this->getTopoShapePtr()->_Shape = shape->_Shape;
return 0;
}
@ -507,6 +507,8 @@ Py::Object TopoShapeEdgePy::getCenterOfMass(void) const
Py::Boolean TopoShapeEdgePy::getClosed(void) const
{
if (getTopoShapePtr()->_Shape.IsNull())
throw Py::Exception("Cannot determine the 'Closed'' flag of an empty shape");
Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->_Shape);
return Py::Boolean(ok ? true : false);
}

View File

@ -1030,6 +1030,8 @@ PyObject* TopoShapePy::isClosed(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
if (getTopoShapePtr()->_Shape.IsNull())
Standard_Failure::Raise("Cannot determine the 'Closed'' flag of an empty shape");
return Py_BuildValue("O", (getTopoShapePtr()->isClosed() ? Py_True : Py_False));
}
catch (...) {