py3: FEM, PyMods, preprocessor conditions, Py::Long vs Py::Int
This commit is contained in:
parent
3fab41f567
commit
5c0bcf611f
|
@ -74,7 +74,7 @@ extern PyObject* initModule();
|
|||
}
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFem()
|
||||
PyMOD_INIT_FUNC(Fem)
|
||||
{
|
||||
// load dependend module
|
||||
try {
|
||||
|
@ -83,7 +83,7 @@ PyMODINIT_FUNC initFem()
|
|||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
PyMOD_Return(0);
|
||||
}
|
||||
PyObject* femModule = Fem::initModule();
|
||||
Base::Console().Log("Loading Fem module... done\n");
|
||||
|
@ -183,4 +183,6 @@ PyMODINIT_FUNC initFem()
|
|||
Fem::FemPostSphereFunction ::init();
|
||||
Fem::PropertyPostDataObject ::init();
|
||||
#endif
|
||||
|
||||
PyMOD_Return(femModule);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
<Documentation>
|
||||
<UserDocu>Number of nodes in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="NodeCount" Type="Int"/>
|
||||
<Parameter Name="NodeCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Edges" ReadOnly="true">
|
||||
<Documentation>
|
||||
|
@ -166,7 +166,7 @@
|
|||
<Documentation>
|
||||
<UserDocu>Number of edges in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="EdgeCount" Type="Int"/>
|
||||
<Parameter Name="EdgeCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Faces" ReadOnly="true">
|
||||
<Documentation>
|
||||
|
@ -178,25 +178,25 @@
|
|||
<Documentation>
|
||||
<UserDocu>Number of Faces in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="FaceCount" Type="Int"/>
|
||||
<Parameter Name="FaceCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="TriangleCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Triangles in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="TriangleCount" Type="Int"/>
|
||||
<Parameter Name="TriangleCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="QuadrangleCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Quadrangles in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="QuadrangleCount" Type="Int"/>
|
||||
<Parameter Name="QuadrangleCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="PolygonCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Quadrangles in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="PolygonCount" Type="Int"/>
|
||||
<Parameter Name="PolygonCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Volumes" ReadOnly="true">
|
||||
<Documentation>
|
||||
|
@ -208,49 +208,49 @@
|
|||
<Documentation>
|
||||
<UserDocu>Number of Volumes in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="VolumeCount" Type="Int"/>
|
||||
<Parameter Name="VolumeCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="TetraCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Tetras in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="TetraCount" Type="Int"/>
|
||||
<Parameter Name="TetraCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="HexaCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Hexas in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="HexaCount" Type="Int"/>
|
||||
<Parameter Name="HexaCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="PyramidCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Pyramids in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="PyramidCount" Type="Int"/>
|
||||
<Parameter Name="PyramidCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="PrismCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Prisms in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="PrismCount" Type="Int"/>
|
||||
<Parameter Name="PrismCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="PolyhedronCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Polyhedrons in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="PolyhedronCount" Type="Int"/>
|
||||
<Parameter Name="PolyhedronCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="SubMeshCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of SubMeshs in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="SubMeshCount" Type="Int"/>
|
||||
<Parameter Name="SubMeshCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="GroupCount" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Number of Groups in the Mesh.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="GroupCount" Type="Int"/>
|
||||
<Parameter Name="GroupCount" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Groups" ReadOnly="true">
|
||||
<Documentation>
|
||||
|
|
|
@ -197,7 +197,7 @@ PyObject* FemMeshPy::addNode(PyObject *args)
|
|||
SMDS_MeshNode* node = meshDS->AddNode(x,y,z);
|
||||
if (!node)
|
||||
throw std::runtime_error("Failed to add node");
|
||||
return Py::new_reference_to(Py::Int(node->GetID()));
|
||||
return Py::new_reference_to(Py::Long(node->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -213,7 +213,7 @@ PyObject* FemMeshPy::addNode(PyObject *args)
|
|||
SMDS_MeshNode* node = meshDS->AddNodeWithID(x,y,z,i);
|
||||
if (!node)
|
||||
throw std::runtime_error("Failed to add node");
|
||||
return Py::new_reference_to(Py::Int(node->GetID()));
|
||||
return Py::new_reference_to(Py::Long(node->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -241,7 +241,7 @@ PyObject* FemMeshPy::addEdge(PyObject *args)
|
|||
SMDS_MeshEdge* edge = meshDS->AddEdge(node1, node2);
|
||||
if (!edge)
|
||||
throw std::runtime_error("Failed to add edge");
|
||||
return Py::new_reference_to(Py::Int(edge->GetID()));
|
||||
return Py::new_reference_to(Py::Long(edge->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -257,7 +257,11 @@ PyObject* FemMeshPy::addEdge(PyObject *args)
|
|||
Py::List list(obj);
|
||||
std::vector<const SMDS_MeshNode*> Nodes;
|
||||
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long NoNr(*it);
|
||||
#else
|
||||
Py::Int NoNr(*it);
|
||||
#endif
|
||||
const SMDS_MeshNode* node = meshDS->FindNode(NoNr);
|
||||
if (!node)
|
||||
throw std::runtime_error("Failed to get node of the given indices");
|
||||
|
@ -297,7 +301,11 @@ PyObject* FemMeshPy::addEdge(PyObject *args)
|
|||
throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type
|
||||
}
|
||||
}
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return Py::new_reference_to(Py::Long(edge->GetID()));
|
||||
#else
|
||||
return Py::new_reference_to(Py::Int(edge->GetID()));
|
||||
#endif
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError, "addEdge accepts:\n"
|
||||
"-- int,int\n"
|
||||
|
@ -323,7 +331,7 @@ PyObject* FemMeshPy::addFace(PyObject *args)
|
|||
SMDS_MeshFace* face = meshDS->AddFace(node1, node2, node3);
|
||||
if (!face)
|
||||
throw std::runtime_error("Failed to add face");
|
||||
return Py::new_reference_to(Py::Int(face->GetID()));
|
||||
return Py::new_reference_to(Py::Long(face->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -339,7 +347,11 @@ PyObject* FemMeshPy::addFace(PyObject *args)
|
|||
Py::List list(obj);
|
||||
std::vector<const SMDS_MeshNode*> Nodes;
|
||||
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long NoNr(*it);
|
||||
#else
|
||||
Py::Int NoNr(*it);
|
||||
#endif
|
||||
const SMDS_MeshNode* node = meshDS->FindNode(NoNr);
|
||||
if (!node)
|
||||
throw std::runtime_error("Failed to get node of the given indices");
|
||||
|
@ -398,7 +410,9 @@ PyObject* FemMeshPy::addFace(PyObject *args)
|
|||
throw std::runtime_error("Unknown node count, [4|5|6|8] are allowed"); //unknown face type
|
||||
}
|
||||
}
|
||||
return Py::new_reference_to(Py::Int(face->GetID()));
|
||||
|
||||
return Py::new_reference_to(Py::Long(face->GetID()));
|
||||
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError, "addFace accepts:\n"
|
||||
"-- int,int,int\n"
|
||||
|
@ -424,7 +438,7 @@ PyObject* FemMeshPy::addQuad(PyObject *args)
|
|||
SMDS_MeshFace* face = meshDS->AddFace(node1, node2, node3, node4);
|
||||
if (!face)
|
||||
throw std::runtime_error("Failed to add quad");
|
||||
return Py::new_reference_to(Py::Int(face->GetID()));
|
||||
return Py::new_reference_to(Py::Long(face->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -450,7 +464,7 @@ PyObject* FemMeshPy::addVolume(PyObject *args)
|
|||
SMDS_MeshVolume* vol = meshDS->AddVolume(node1, node2, node3, node4);
|
||||
if (!vol)
|
||||
throw std::runtime_error("Failed to add volume");
|
||||
return Py::new_reference_to(Py::Int(vol->GetID()));
|
||||
return Py::new_reference_to(Py::Long(vol->GetID()));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.what());
|
||||
|
@ -466,7 +480,11 @@ PyObject* FemMeshPy::addVolume(PyObject *args)
|
|||
Py::List list(obj);
|
||||
std::vector<const SMDS_MeshNode*> Nodes;
|
||||
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Py::Long NoNr(*it);
|
||||
#else
|
||||
Py::Int NoNr(*it);
|
||||
#endif
|
||||
const SMDS_MeshNode* node = meshDS->FindNode(NoNr);
|
||||
if (!node)
|
||||
throw std::runtime_error("Failed to get node of the given indices");
|
||||
|
@ -563,7 +581,9 @@ PyObject* FemMeshPy::addVolume(PyObject *args)
|
|||
default: throw std::runtime_error("Unknown node count, [4|5|6|8|10|13|15|20] are allowed"); //unknown volume type
|
||||
}
|
||||
}
|
||||
return Py::new_reference_to(Py::Int(vol->GetID()));
|
||||
|
||||
return Py::new_reference_to(Py::Long(vol->GetID()));
|
||||
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError, "addVolume accepts:\n"
|
||||
"-- int,int,int,int\n"
|
||||
|
@ -671,7 +691,11 @@ PyObject* FemMeshPy::getFacesByFace(PyObject *args)
|
|||
Py::List ret;
|
||||
std::list<int> resultSet = getFemMeshPtr()->getFacesByFace(fc);
|
||||
for (std::list<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
ret.append(Py::Long(*it));
|
||||
#else
|
||||
ret.append(Py::Int(*it));
|
||||
#endif
|
||||
}
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
@ -702,8 +726,8 @@ PyObject* FemMeshPy::getVolumesByFace(PyObject *args)
|
|||
std::list<std::pair<int, int> > resultSet = getFemMeshPtr()->getVolumesByFace(fc);
|
||||
for (std::list<std::pair<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));
|
||||
vol_face.setItem(0, Py::Long(it->first));
|
||||
vol_face.setItem(1, Py::Long(it->second));
|
||||
ret.append(vol_face);
|
||||
}
|
||||
|
||||
|
@ -735,8 +759,8 @@ PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args)
|
|||
std::map<int, int> resultSet = getFemMeshPtr()->getccxVolumesByFace(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));
|
||||
vol_face.setItem(0, Py::Long(it->first));
|
||||
vol_face.setItem(1, Py::Long(it->second));
|
||||
ret.append(vol_face);
|
||||
}
|
||||
|
||||
|
@ -784,7 +808,7 @@ PyObject* FemMeshPy::getNodesBySolid(PyObject *args)
|
|||
Py::List ret;
|
||||
std::set<int> resultSet = getFemMeshPtr()->getNodesBySolid(fc);
|
||||
for (std::set<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.append(Py::Int(*it));
|
||||
ret.append(Py::Long(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
||||
|
@ -812,7 +836,7 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args)
|
|||
Py::List ret;
|
||||
std::set<int> resultSet = getFemMeshPtr()->getNodesByFace(fc);
|
||||
for (std::set<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.append(Py::Int(*it));
|
||||
ret.append(Py::Long(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
||||
|
@ -840,7 +864,7 @@ PyObject* FemMeshPy::getNodesByEdge(PyObject *args)
|
|||
Py::List ret;
|
||||
std::set<int> resultSet = getFemMeshPtr()->getNodesByEdge(fc);
|
||||
for (std::set<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.append(Py::Int(*it));
|
||||
ret.append(Py::Long(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
||||
|
@ -868,7 +892,7 @@ PyObject* FemMeshPy::getNodesByVertex(PyObject *args)
|
|||
Py::List ret;
|
||||
std::set<int> resultSet = getFemMeshPtr()->getNodesByVertex(fc);
|
||||
for (std::set<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.append(Py::Int(*it));
|
||||
ret.append(Py::Long(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
||||
|
@ -891,7 +915,7 @@ PyObject* FemMeshPy::getElementNodes(PyObject *args)
|
|||
Py::Tuple ret(resultSet.size());
|
||||
int index = 0;
|
||||
for (std::list<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.setItem(index++, Py::Int(*it));
|
||||
ret.setItem(index++, Py::Long(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
}
|
||||
|
@ -907,8 +931,11 @@ PyObject* FemMeshPy::getGroupName(PyObject *args)
|
|||
int id;
|
||||
if (!PyArg_ParseTuple(args, "i", &id))
|
||||
return 0;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyBytes_FromString(getFemMeshPtr()->getSMesh()->GetGroup(id)->GetName());
|
||||
#else
|
||||
return PyString_FromString(getFemMeshPtr()->getSMesh()->GetGroup(id)->GetName());
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject* FemMeshPy::getGroupElementType(PyObject *args)
|
||||
|
@ -929,7 +956,11 @@ PyObject* FemMeshPy::getGroupElementType(PyObject *args)
|
|||
case SMDSAbs_Ball : typeString = "Ball"; break;
|
||||
default : typeString = "Unknown"; break;
|
||||
}
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyBytes_FromString(typeString);
|
||||
#else
|
||||
return PyString_FromString(typeString);
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject* FemMeshPy::getGroupElements(PyObject *args)
|
||||
|
@ -948,7 +979,11 @@ PyObject* FemMeshPy::getGroupElements(PyObject *args)
|
|||
Py::Tuple tuple(ids.size());
|
||||
int index = 0;
|
||||
for (std::set<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
tuple.setItem(index++, Py::Long(*it));
|
||||
#else
|
||||
tuple.setItem(index++, Py::Int(*it));
|
||||
#endif
|
||||
}
|
||||
|
||||
return Py::new_reference_to(tuple);
|
||||
|
@ -973,15 +1008,15 @@ Py::Dict FemMeshPy::getNodes(void) const
|
|||
vec = Mtrx * vec;
|
||||
int id = aNode->GetID();
|
||||
|
||||
dict[Py::Int(id)] = Py::asObject(new Base::VectorPy( vec ));
|
||||
dict[Py::Long(id)] = Py::asObject(new Base::VectorPy( vec ));
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getNodeCount(void) const
|
||||
Py::Long FemMeshPy::getNodeCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbNodes());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbNodes());
|
||||
}
|
||||
|
||||
Py::Tuple FemMeshPy::getEdges(void) const
|
||||
|
@ -996,15 +1031,15 @@ Py::Tuple FemMeshPy::getEdges(void) const
|
|||
Py::Tuple tuple(ids.size());
|
||||
int index = 0;
|
||||
for (std::set<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
tuple.setItem(index++, Py::Int(*it));
|
||||
tuple.setItem(index++, Py::Long(*it));
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getEdgeCount(void) const
|
||||
Py::Long FemMeshPy::getEdgeCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbEdges());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbEdges());
|
||||
}
|
||||
|
||||
Py::Tuple FemMeshPy::getFaces(void) const
|
||||
|
@ -1019,30 +1054,30 @@ Py::Tuple FemMeshPy::getFaces(void) const
|
|||
Py::Tuple tuple(ids.size());
|
||||
int index = 0;
|
||||
for (std::set<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
tuple.setItem(index++, Py::Int(*it));
|
||||
tuple.setItem(index++, Py::Long(*it));
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getFaceCount(void) const
|
||||
Py::Long FemMeshPy::getFaceCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbFaces());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbFaces());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getTriangleCount(void) const
|
||||
Py::Long FemMeshPy::getTriangleCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbTriangles());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbTriangles());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getQuadrangleCount(void) const
|
||||
Py::Long FemMeshPy::getQuadrangleCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbQuadrangles());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbQuadrangles());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getPolygonCount(void) const
|
||||
Py::Long FemMeshPy::getPolygonCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbPolygons());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbPolygons());
|
||||
}
|
||||
|
||||
Py::Tuple FemMeshPy::getVolumes(void) const
|
||||
|
@ -1057,50 +1092,50 @@ Py::Tuple FemMeshPy::getVolumes(void) const
|
|||
Py::Tuple tuple(ids.size());
|
||||
int index = 0;
|
||||
for (std::set<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
tuple.setItem(index++, Py::Int(*it));
|
||||
tuple.setItem(index++, Py::Long(*it));
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getVolumeCount(void) const
|
||||
Py::Long FemMeshPy::getVolumeCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbVolumes());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbVolumes());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getTetraCount(void) const
|
||||
Py::Long FemMeshPy::getTetraCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbTetras());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbTetras());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getHexaCount(void) const
|
||||
Py::Long FemMeshPy::getHexaCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbHexas());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbHexas());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getPyramidCount(void) const
|
||||
Py::Long FemMeshPy::getPyramidCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbPyramids());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbPyramids());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getPrismCount(void) const
|
||||
Py::Long FemMeshPy::getPrismCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbPrisms());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbPrisms());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getPolyhedronCount(void) const
|
||||
Py::Long FemMeshPy::getPolyhedronCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbPolyhedrons());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbPolyhedrons());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getSubMeshCount(void) const
|
||||
Py::Long FemMeshPy::getSubMeshCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbSubMesh());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbSubMesh());
|
||||
}
|
||||
|
||||
Py::Int FemMeshPy::getGroupCount(void) const
|
||||
Py::Long FemMeshPy::getGroupCount(void) const
|
||||
{
|
||||
return Py::Int(getFemMeshPtr()->getSMesh()->NbGroup());
|
||||
return Py::Long(getFemMeshPtr()->getSMesh()->NbGroup());
|
||||
}
|
||||
|
||||
Py::Tuple FemMeshPy::getGroups(void) const
|
||||
|
@ -1110,7 +1145,11 @@ Py::Tuple FemMeshPy::getGroups(void) const
|
|||
Py::Tuple tuple(groupIDs.size());
|
||||
int index = 0;
|
||||
for (std::list<int>::iterator it = groupIDs.begin(); it != groupIDs.end(); ++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
tuple.setItem(index++, Py::Long(*it));
|
||||
#else
|
||||
tuple.setItem(index++, Py::Int(*it));
|
||||
#endif
|
||||
}
|
||||
|
||||
return tuple;
|
||||
|
@ -1121,6 +1160,7 @@ Py::Object FemMeshPy::getVolume(void) const
|
|||
return Py::Object(new Base::QuantityPy(new Base::Quantity(getFemMeshPtr()->getVolume())));
|
||||
|
||||
}
|
||||
|
||||
// ===== custom attributes ============================================================
|
||||
|
||||
PyObject *FemMeshPy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
|
|
@ -928,7 +928,11 @@ StdMeshers_NumberOfSegmentsPy::~StdMeshers_NumberOfSegmentsPy()
|
|||
|
||||
Py::Object StdMeshers_NumberOfSegmentsPy::setNumSegm(const Py::Tuple& args)
|
||||
{
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
hypothesis<StdMeshers_NumberOfSegments>()->SetNumberOfSegments((int)Py::Long(args[0]));
|
||||
#else
|
||||
hypothesis<StdMeshers_NumberOfSegments>()->SetNumberOfSegments((int)Py::Int(args[0]));
|
||||
#endif
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
|
@ -936,7 +940,7 @@ Py::Object StdMeshers_NumberOfSegmentsPy::getNumSegm(const Py::Tuple& args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
return Py::Int(hypothesis<StdMeshers_NumberOfSegments>()->GetNumberOfSegments());
|
||||
return Py::Long(hypothesis<StdMeshers_NumberOfSegments>()->GetNumberOfSegments());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -961,7 +965,11 @@ StdMeshers_NumberOfLayersPy::~StdMeshers_NumberOfLayersPy()
|
|||
|
||||
Py::Object StdMeshers_NumberOfLayersPy::setNumLayers(const Py::Tuple& args)
|
||||
{
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
hypothesis<StdMeshers_NumberOfLayers>()->SetNumberOfLayers((int)Py::Long(args[0]));
|
||||
#else
|
||||
hypothesis<StdMeshers_NumberOfLayers>()->SetNumberOfLayers((int)Py::Int(args[0]));
|
||||
#endif
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
|
@ -969,7 +977,7 @@ Py::Object StdMeshers_NumberOfLayersPy::getNumLayers(const Py::Tuple& args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
return Py::Int(hypothesis<StdMeshers_NumberOfLayers>()->GetNumberOfLayers());
|
||||
return Py::Long(hypothesis<StdMeshers_NumberOfLayers>()->GetNumberOfLayers());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1045,7 +1053,11 @@ StdMeshers_LengthFromEdgesPy::~StdMeshers_LengthFromEdgesPy()
|
|||
|
||||
Py::Object StdMeshers_LengthFromEdgesPy::setMode(const Py::Tuple& args)
|
||||
{
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
hypothesis<StdMeshers_LengthFromEdges>()->SetMode((int)Py::Long(args[0]));
|
||||
#else
|
||||
hypothesis<StdMeshers_LengthFromEdges>()->SetMode((int)Py::Int(args[0]));
|
||||
#endif
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1065,7 @@ Py::Object StdMeshers_LengthFromEdgesPy::getMode(const Py::Tuple& args)
|
|||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
return Py::Int(hypothesis<StdMeshers_LengthFromEdges>()->GetMode());
|
||||
return Py::Long(hypothesis<StdMeshers_LengthFromEdges>()->GetMode());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -92,14 +92,14 @@ extern PyObject* initModule();
|
|||
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFemGui()
|
||||
PyMOD_INIT_FUNC(FemGui)
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
return;
|
||||
PyMOD_Return(0);
|
||||
}
|
||||
|
||||
(void) FemGui::initModule();
|
||||
PyObject* mod = FemGui::initModule();
|
||||
Base::Console().Log("Loading GUI of Fem module... done\n");
|
||||
|
||||
// instantiating the commands
|
||||
|
@ -161,4 +161,6 @@ PyMODINIT_FUNC initFemGui()
|
|||
|
||||
// add resources and reloads the translators
|
||||
loadFemResource();
|
||||
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg)
|
|||
//std::map<long,App::Color> NodeColorMap;
|
||||
|
||||
//for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
// Py::Int id((*it).first);
|
||||
// Py::Long id((*it).first);
|
||||
// Py::Tuple color((*it).second);
|
||||
// NodeColorMap[id] = App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0);
|
||||
//}
|
||||
|
@ -154,7 +154,7 @@ void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg)
|
|||
|
||||
long i = 0;
|
||||
for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it,i++){
|
||||
Py::Int id((*it).first);
|
||||
Py::Long id((*it).first);
|
||||
Py::Tuple color((*it).second);
|
||||
NodeIds[i] = id;
|
||||
NodeColors[i] = App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0);
|
||||
|
@ -181,7 +181,7 @@ void ViewProviderFemMeshPy::setElementColor(Py::Dict arg)
|
|||
std::map<long,App::Color> NodeColorMap;
|
||||
|
||||
for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
Py::Int id((*it).first);
|
||||
Py::Long id((*it).first);
|
||||
Py::Tuple color((*it).second);
|
||||
NodeColorMap[id] = App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg)
|
|||
Py::Type vType(pyType.o);
|
||||
|
||||
for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
Py::Int id((*it).first);
|
||||
Py::Long id((*it).first);
|
||||
if ((*it).second.isType(vType)) {
|
||||
Py::Vector p((*it).second);
|
||||
NodeDispMap[id] = p.toVector();
|
||||
|
@ -229,7 +229,7 @@ void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
|||
|
||||
std::set<long> res;
|
||||
for(Py::List::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
long id = static_cast<long>(Py::Int(*it));
|
||||
long id = static_cast<long>(Py::Long(*it));
|
||||
const SMDS_MeshNode *node = data->FindNode(id);
|
||||
if(node)
|
||||
res.insert(id);
|
||||
|
@ -265,8 +265,8 @@ Py::List ViewProviderFemMeshPy::getVisibleElementFaces(void) const
|
|||
Py::Tuple tup(2);
|
||||
long element = *it>>3;
|
||||
long face = (*it&7)+1;
|
||||
tup.setItem( 0,Py::Int( element ) );
|
||||
tup.setItem( 1,Py::Int( face ) );
|
||||
tup.setItem( 0,Py::Long( element ) );
|
||||
tup.setItem( 1,Py::Long( face ) );
|
||||
result.setItem(i,tup);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user