From 1341c43e5f801c6d957472c36672103ba73e4f85 Mon Sep 17 00:00:00 2001 From: jriegel Date: Sat, 8 Feb 2014 14:09:45 +0100 Subject: [PATCH] Get node of face implementation --- src/Mod/Fem/App/FemMesh.cpp | 22 ++++++++++++++++++++++ src/Mod/Fem/App/FemMeshPyImp.cpp | 9 +++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index 02eebd515..ffd7c5dad 100755 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -30,6 +30,7 @@ # include # include # include +# include #endif #include @@ -326,6 +327,7 @@ SMESH_Mesh* FemMesh::getSMesh() return myMesh; } + SMESH_Gen * FemMesh::getGenerator() { return myGen; @@ -404,6 +406,26 @@ std::set FemMesh::getSurfaceNodes(const TopoDS_Face &face)const std::set result; const SMESHDS_Mesh* data = myMesh->GetMeshDS(); + Bnd_Box box; + BRepBndLib::Add(face, box); + + // get the actuall transform of the FemMesh + const Base::Matrix4D Mtrx(getTransform()); + + SMDS_NodeIteratorPtr aNodeIter = myMesh->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; + + if(!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))){ + + result.insert(aNode->GetID()); + + } + } + BRepAlgo_NormalProjection algo; diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index 124173274..418af9788 100755 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -534,13 +535,17 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args) try { const TopoDS_Shape& sh = static_cast(pW)->getTopoShapePtr()->_Shape; + const TopoDS_Face& fc = TopoDS::Face(sh); if (sh.IsNull()) { PyErr_SetString(PyExc_Exception, "Face is empty"); return 0; } Py::List ret; - throw Py::Exception("Not yet implemented"); - + std::set resultSet = getFemMeshPtr()->getSurfaceNodes(fc); + for( std::set::const_iterator it = resultSet.begin();it!=resultSet.end();++it) + ret.append(Py::Int(*it)); + + return Py::new_reference_to(ret); } catch (Standard_Failure) {