From b8cac92e833f7245f30ac869b66a4f0b494b99b0 Mon Sep 17 00:00:00 2001 From: jriegel Date: Wed, 31 Jul 2013 19:10:45 +0200 Subject: [PATCH] switch MachDistIsostatic to python algorithem --- src/Mod/Fem/App/FemMeshPyImp.cpp | 6 ++++ .../Machining_Distortion/MachDistIsostatic.py | 33 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index ab67ddf2a..795972455 100755 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -466,10 +466,16 @@ Py::Tuple FemMeshPy::getNodes(void) const { int count = getFemMeshPtr()->getSMesh()->GetMeshDS()->NbNodes(); Py::Tuple tup(count); + // get the actuall transform of the FemMesh + Base::Matrix4D Mtrx = getFemMeshPtr()->getTransform(); SMDS_NodeIteratorPtr aNodeIter = getFemMeshPtr()->getSMesh()->GetMeshDS()->nodesIterator(); for (int i=0;aNodeIter->more();i++) { const SMDS_MeshNode* aNode = aNodeIter->next(); + Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z()); + // Apply the matrix to hold the BoundBox in absolute space. + vec = Mtrx * vec; + tup.setItem(i, Py::asObject(new Base::VectorPy(Base::Vector3d(aNode->X(),aNode->Y(),aNode->Z())))); } diff --git a/src/Mod/Machining_Distortion/MachDistIsostatic.py b/src/Mod/Machining_Distortion/MachDistIsostatic.py index fe36a5f2e..2dc029114 100644 --- a/src/Mod/Machining_Distortion/MachDistIsostatic.py +++ b/src/Mod/Machining_Distortion/MachDistIsostatic.py @@ -34,6 +34,35 @@ __author__ = "Juergen Riegel" __url__ = "http://free-cad.sourceforge.net" +def getBoundaryCoditions(Mesh): + BndBox = Mesh.BoundBox + FirstLength = 10000.0 + FirstIndex = -1 + SecondLength = 10000.0 + SecondIndex = -1 + ThirdLength = 10000.0 + ThirdIndex = -1 + Index = 0 + for i in Mesh.Nodes: + l = (i-FreeCAD.Vector(BndBox.XMin,BndBox.YMin,BndBox.ZMin)).Length + if FirstLength > l: + FirstLength = l + FirstIndex = Index + + l = (i-FreeCAD.Vector(BndBox.XMax,BndBox.YMin,BndBox.ZMin)).Length + if SecondLength > l: + SecondLength = l + SecondIndex = Index + + l = (i-FreeCAD.Vector(BndBox.XMin,BndBox.YMax,BndBox.ZMin)).Length + if ThirdLength > l: + ThirdLength = l + ThirdIndex = Index + Index = Index + 1 + + print FirstIndex,SecondIndex,ThirdIndex + return (FirstIndex,SecondIndex,ThirdIndex) + class _CommandIsostatic: "the MachDist Isostatic command definition" @@ -67,7 +96,9 @@ class _CommandIsostatic: obj = FreeCAD.activeDocument().ActiveObject FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [App.activeDocument().ActiveObject]") - node_numbers = Fem.getBoundary_Conditions(FemMeshObj.FemMesh) + #node_numbers = Fem.getBoundary_Conditions(FemMeshObj.FemMesh) + node_numbers = getBoundaryCoditions(FemMeshObj.FemMesh) + nodes = FemMeshObj.FemMesh.Nodes meshObj = None