change node attribute to a id:vector3d dictionary and changes the scripts

This commit is contained in:
jriegel
2013-08-29 22:15:14 +02:00
parent c68f354761
commit 6d04316fa1
4 changed files with 49 additions and 21 deletions

View File

@@ -78,17 +78,22 @@
<Documentation>
<UserDocu>Use a Placement object to perform a translation or rotation</UserDocu>
</Documentation>
</Methode>
<Methode Name="copy">
<Documentation>
<UserDocu>Make a copy of this FEM mesh.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Nodes" ReadOnly="true">
</Methode>
<Methode Name="copy">
<Documentation>
<UserDocu>Make a copy of this FEM mesh.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getNodeById">
<Documentation>
<UserDocu>Get the node position vector by an Node-ID</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Nodes" ReadOnly="true">
<Documentation>
<UserDocu>Tuple of node points.</UserDocu>
<UserDocu>Dictionary of Nodes by ID (int ID:Vector())</UserDocu>
</Documentation>
<Parameter Name="Nodes" Type="Tuple"/>
<Parameter Name="Nodes" Type="Dict"/>
</Attribute>
<Attribute Name="NodeCount" ReadOnly="true">
<Documentation>

View File

@@ -460,12 +460,34 @@ PyObject* FemMeshPy::setTransform(PyObject *args)
Py_Return;
}
PyObject* FemMeshPy::getNodeById(PyObject *args)
{
int id;
if (!PyArg_ParseTuple(args, "i", &id))
return 0;
Base::Matrix4D Mtrx = getFemMeshPtr()->getTransform();
const SMDS_MeshNode* aNode = getFemMeshPtr()->getSMesh()->GetMeshDS()->FindNode(id);
if(aNode){
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
vec = Mtrx * vec;
return new Base::VectorPy( vec );
}else{
PyErr_SetString(PyExc_Exception, "No valid ID");
return 0;
}
}
// ===== Atributes ============================================================
Py::Tuple FemMeshPy::getNodes(void) const
Py::Dict FemMeshPy::getNodes(void) const
{
int count = getFemMeshPtr()->getSMesh()->GetMeshDS()->NbNodes();
Py::Tuple tup(count);
//int count = getFemMeshPtr()->getSMesh()->GetMeshDS()->NbNodes();
//Py::Tuple tup(count);
Py::Dict dict;
// get the actuall transform of the FemMesh
Base::Matrix4D Mtrx = getFemMeshPtr()->getTransform();
@@ -475,11 +497,12 @@ Py::Tuple FemMeshPy::getNodes(void) const
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
int id = aNode->GetID();
tup.setItem(i, Py::asObject(new Base::VectorPy( vec )));
dict[Py::Int(id)] = Py::asObject(new Base::VectorPy( vec ));
}
return tup;
return dict;
}
Py::Int FemMeshPy::getNodeCount(void) const