FEM: add getNodesBySolid()

Conflicts:
	src/Mod/Fem/App/FemMesh.cpp
This commit is contained in:
Bernd Hahnebach
2015-04-21 21:29:39 +02:00
committed by Yorik van Havre
parent 3724748d06
commit accb05c502
4 changed files with 76 additions and 0 deletions

View File

@@ -524,6 +524,45 @@ std::map<int, int> FemMesh::getccxVolumesByFace(const TopoDS_Face &face) const
return result;
}
std::set<int> FemMesh::getNodesBySolid(const TopoDS_Solid &solid) const
{
std::set<int> result;
Bnd_Box box;
BRepBndLib::Add(solid, box);
// limit where the mesh node belongs to the solid:
double limit = box.SquareExtent()/10000.0;
//double limit = BRep_Tool::Tolerance(solid); // does not compile --> no matching function for call to 'BRep_Tool::Tolerance(const TopoDS_Solid&)'
box.Enlarge(limit);
// get the current transform of the FemMesh
const Base::Matrix4D Mtrx(getTransform());
SMDS_NodeIteratorPtr aNodeIter = myMesh->GetMeshDS()->nodesIterator();
while (aNodeIter->more()) {
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))) {
// create a vertex
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z));
TopoDS_Shape s = aBuilder.Vertex();
// measure distance
BRepExtrema_DistShapeShape measure(solid,s);
measure.Perform();
if (!measure.IsDone() || measure.NbSolution() < 1)
continue;
if (measure.Value() < limit)
result.insert(aNode->GetID());
}
}
return result;
}
std::set<int> FemMesh::getNodesByFace(const TopoDS_Face &face) const
{
std::set<int> result;