+ FEM: get nodes by vertex
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
# include <memory>
|
||||
# include <strstream>
|
||||
# include <Bnd_Box.hxx>
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRepExtrema_DistShapeShape.hxx>
|
||||
# include <TopoDS_Vertex.hxx>
|
||||
@@ -479,6 +480,32 @@ std::set<long> FemMesh::getNodesByEdge(const TopoDS_Edge &edge) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::set<long> FemMesh::getNodesByVertex(const TopoDS_Vertex &vertex) const
|
||||
{
|
||||
std::set<long> result;
|
||||
|
||||
double limit = BRep_Tool::Tolerance(vertex);
|
||||
limit *= limit; // use square to improve speed
|
||||
gp_Pnt pnt = BRep_Tool::Pnt(vertex);
|
||||
Base::Vector3d node(pnt.X(), pnt.Y(), pnt.Z());
|
||||
|
||||
// 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());
|
||||
vec = Mtrx * vec;
|
||||
|
||||
if (Base::DistanceP2(node, vec) <= limit) {
|
||||
result.insert(aNode->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void FemMesh::readNastran(const std::string &Filename)
|
||||
{
|
||||
Base::TimeInfo Start;
|
||||
|
||||
@@ -38,6 +38,7 @@ class SMESH_Hypothesis;
|
||||
class TopoDS_Shape;
|
||||
class TopoDS_Face;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Vertex;
|
||||
|
||||
namespace Fem
|
||||
{
|
||||
@@ -87,9 +88,11 @@ public:
|
||||
/// retrieving by region growing
|
||||
std::set<long> getSurfaceNodes(long ElemId, short FaceId, float Angle=360)const;
|
||||
/// retrieving by face
|
||||
std::set<long> getNodesByFace(const TopoDS_Face &face)const;
|
||||
std::set<long> getNodesByFace(const TopoDS_Face &face) const;
|
||||
/// retrieving by edge
|
||||
std::set<long> getNodesByEdge(const TopoDS_Edge &edge)const;
|
||||
std::set<long> getNodesByEdge(const TopoDS_Edge &edge) const;
|
||||
/// retrieving by vertex
|
||||
std::set<long> getNodesByVertex(const TopoDS_Vertex &vertex) const;
|
||||
//@}
|
||||
|
||||
/** @name Placement control */
|
||||
|
||||
@@ -99,6 +99,11 @@
|
||||
<UserDocu>Return a list of node IDs which belong to a TopoEdge</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getNodesByVertex" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Return a list of node IDs which belong to a TopoVertex</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Nodes" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Dictionary of Nodes by ID (int ID:Vector())</UserDocu>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include <Mod/Part/App/TopoShapeFacePy.h>
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.h>
|
||||
#include <Mod/Part/App/TopoShapeVertexPy.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "Mod/Fem/App/FemMesh.h"
|
||||
@@ -558,7 +559,6 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args)
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyObject* FemMeshPy::getNodesByEdge(PyObject *args)
|
||||
@@ -587,7 +587,34 @@ PyObject* FemMeshPy::getNodesByEdge(PyObject *args)
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyObject* FemMeshPy::getNodesByVertex(PyObject *args)
|
||||
{
|
||||
PyObject *pW;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeVertexPy::Type), &pW))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
const TopoDS_Shape& sh = static_cast<Part::TopoShapeVertexPy*>(pW)->getTopoShapePtr()->_Shape;
|
||||
const TopoDS_Vertex& fc = TopoDS::Vertex(sh);
|
||||
if (sh.IsNull()) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Vertex is empty");
|
||||
return 0;
|
||||
}
|
||||
Py::List ret;
|
||||
std::set<long> resultSet = getFemMeshPtr()->getNodesByVertex(fc);
|
||||
for (std::set<long>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
|
||||
ret.append(Py::Int(*it));
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -414,8 +414,8 @@ class _JobControlTaskPanel:
|
||||
print ' Line Support (fixed edge) on: ', f
|
||||
n = MeshObject.FemMesh.getNodesByEdge(fo)
|
||||
elif fo.ShapeType == 'Vertex':
|
||||
print ' Point Support (fixed vertex) on: ', f, ' --> not supported yet'
|
||||
#n = MeshObject.FemMesh.getNodesByVertex(fo) # ToDo
|
||||
print ' Point Support (fixed vertex) on: ', f
|
||||
n = MeshObject.FemMesh.getNodesByVertex(fo)
|
||||
for i in n:
|
||||
inpfile.write( str(i)+',\n')
|
||||
inpfile.write('\n\n')
|
||||
@@ -437,8 +437,8 @@ class _JobControlTaskPanel:
|
||||
print ' Line Load (edge load) on: ', f
|
||||
n = MeshObject.FemMesh.getNodesByEdge(fo)
|
||||
elif fo.ShapeType == 'Vertex':
|
||||
print ' Point Load (vertex load) on: ', f, ' --> not supported yet'
|
||||
#n = MeshObject.FemMesh.getNodesByVertex(fo) # ToDo
|
||||
print ' Point Load (vertex load) on: ', f
|
||||
n = MeshObject.FemMesh.getNodesByVertex(fo)
|
||||
for i in n:
|
||||
inpfile.write( str(i)+',\n')
|
||||
NbrForceNodes = NbrForceNodes + 1 # NodeSum of mesh-nodes of ALL reference shapes from ForceObject
|
||||
|
||||
Reference in New Issue
Block a user