From cd69467edeb25b60c6419aa0a391e9463dedbaa3 Mon Sep 17 00:00:00 2001 From: jriegel Date: Sun, 9 Feb 2014 17:53:21 +0100 Subject: [PATCH] Finish get nodes by surface --- src/Mod/Fem/App/FemMesh.cpp | 21 +++++++++++++++----- src/Mod/Fem/App/FemMeshPy.xml | 2 +- src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp | 13 ++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index ffd7c5dad..9349067a0 100755 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -29,7 +29,9 @@ # include # include # include -# include +# include +# include +# include # include #endif @@ -408,6 +410,9 @@ std::set FemMesh::getSurfaceNodes(const TopoDS_Face &face)const Bnd_Box box; BRepBndLib::Add(face, box); + // limit where the mesh node belongs to the face: + double limit = box.SquareExtent()/10000.0; + box.Enlarge(limit); // get the actuall transform of the FemMesh const Base::Matrix4D Mtrx(getTransform()); @@ -420,15 +425,21 @@ std::set FemMesh::getSurfaceNodes(const TopoDS_Face &face)const vec = Mtrx * vec; if(!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))){ + // create a Vertex + BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z)); + TopoDS_Shape s = aBuilder.Vertex(); + // measure distance + BRepExtrema_DistShapeShape measure(face,s); + measure.Perform(); + if (!measure.IsDone() || measure.NbSolution() < 1) + continue; - result.insert(aNode->GetID()); + if(measure.Value() < limit) + result.insert(aNode->GetID()); } } - BRepAlgo_NormalProjection algo; - - return result; } diff --git a/src/Mod/Fem/App/FemMeshPy.xml b/src/Mod/Fem/App/FemMeshPy.xml index 8933354f8..d8fd2333a 100755 --- a/src/Mod/Fem/App/FemMeshPy.xml +++ b/src/Mod/Fem/App/FemMeshPy.xml @@ -89,7 +89,7 @@ Get the node position vector by an Node-ID - + Return a list of node IDs which belong to a TopoFace diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp index a24a843af..0481b5b8a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp @@ -218,13 +218,14 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg) { - /* std::set& nodeSet; - for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) { - nodeSet.i (double)Py::Int(*it); - } - setHighlightNodes*/ - throw Py::AttributeError("Not yet implemented"); + std::set res; + for( Py::List::iterator it = arg.begin(); it!= arg.end();++it){ + Py::Int id(*it); + if(id) + res.insert(id); + } + this->getViewProviderFemMeshPtr()->setHighlightNodes(res); } Py::List ViewProviderFemMeshPy::getVisibleElementFaces(void) const