+ implement FemMesh::getVolumesByFace, replace inner list by tuple

This commit is contained in:
wmayer
2015-05-08 21:45:13 +02:00
parent 29205f7f4d
commit d3029657f0
4 changed files with 87 additions and 10 deletions

View File

@@ -514,6 +514,39 @@ PyObject* FemMeshPy::setTransform(PyObject *args)
Py_Return;
}
PyObject* FemMeshPy::getVolumesByFace(PyObject *args)
{
PyObject *pW;
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &pW))
return 0;
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->_Shape;
if (sh.IsNull()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty");
return 0;
}
const TopoDS_Face& fc = TopoDS::Face(sh);
Py::List ret;
std::map<int, int> resultSet = getFemMeshPtr()->getVolumesByFace(fc);
for (std::map<int, int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
Py::Tuple vol_face(2);
vol_face.setItem(0, Py::Int(it->first));
vol_face.setItem(1, Py::Int(it->second));
ret.append(vol_face);
}
return Py::new_reference_to(ret);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
return 0;
}
}
PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args)
{
PyObject *pW;
@@ -522,22 +555,23 @@ PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args)
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->_Shape;
const TopoDS_Face& fc = TopoDS::Face(sh);
if (sh.IsNull()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty");
return 0;
}
const TopoDS_Face& fc = TopoDS::Face(sh);
Py::List ret;
std::map<int, int> resultSet = getFemMeshPtr()->getccxVolumesByFace(fc);
for (std::map<int, int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
Py::List vol_face;
vol_face.append(Py::Int(it->first));
vol_face.append(Py::Int(it->second));
ret.append(vol_face);
}
Py::Tuple vol_face(2);
vol_face.setItem(0, Py::Int(it->first));
vol_face.setItem(1, Py::Int(it->second));
ret.append(vol_face);
}
return Py::new_reference_to(ret);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();