change node attribute to a id:vector3d dictionary and changes the scripts
This commit is contained in:
parent
35d9459853
commit
97b32d6eb9
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -99,7 +99,7 @@ class _AlignTaskPanel:
|
|||
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
import Mesh
|
||||
# find the eigen axis
|
||||
self.obj.Placement = Mesh.calculateEigenTransform(self.obj.FemMesh.Nodes)
|
||||
self.obj.Placement = Mesh.calculateEigenTransform(self.obj.FemMesh.Nodes.values())
|
||||
|
||||
# make the first alignment persistent
|
||||
m = Fem.FemMesh(self.obj.FemMesh)
|
||||
|
|
|
@ -44,23 +44,23 @@ def getBoundaryCoditions(Mesh):
|
|||
SecondIndex = -1
|
||||
ThirdLength = 10000.0
|
||||
ThirdIndex = -1
|
||||
Index = 0
|
||||
for i in Mesh.Nodes:
|
||||
|
||||
for id,i in Mesh.Nodes.items():
|
||||
l = (i-FreeCAD.Vector(BndBox.XMin,BndBox.YMin,BndBox.ZMin)).Length
|
||||
if FirstLength > l:
|
||||
FirstLength = l
|
||||
FirstIndex = Index
|
||||
FirstIndex = id
|
||||
|
||||
l = (i-FreeCAD.Vector(BndBox.XMax,BndBox.YMin,BndBox.ZMin)).Length
|
||||
if SecondLength > l:
|
||||
SecondLength = l
|
||||
SecondIndex = Index
|
||||
SecondIndex = id
|
||||
|
||||
l = (i-FreeCAD.Vector(BndBox.XMin,BndBox.YMax,BndBox.ZMin)).Length
|
||||
if ThirdLength > l:
|
||||
ThirdLength = l
|
||||
ThirdIndex = Index
|
||||
Index = Index + 1
|
||||
ThirdIndex = id
|
||||
|
||||
|
||||
print FirstIndex,SecondIndex,ThirdIndex
|
||||
return (FirstIndex,SecondIndex,ThirdIndex)
|
||||
|
|
Loading…
Reference in New Issue
Block a user