add function to retrive femmesh edges by a TopoDS_Edge
This commit is contained in:
@@ -633,6 +633,34 @@ std::list<int> FemMesh::getFacesByFace(const TopoDS_Face &face) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::list<int> FemMesh::getEdgesByEdge(const TopoDS_Edge &edge) const
|
||||
{
|
||||
std::list<int> result;
|
||||
std::set<int> nodes_on_edge = getNodesByEdge(edge);
|
||||
|
||||
SMDS_EdgeIteratorPtr edge_iter = myMesh->GetMeshDS()->edgesIterator();
|
||||
while (edge_iter->more()) {
|
||||
const SMDS_MeshEdge* edge = static_cast<const SMDS_MeshEdge*>(edge_iter->next());
|
||||
int numNodes = edge->NbNodes();
|
||||
|
||||
std::set<int> edge_nodes;
|
||||
for (int i=0; i<numNodes; i++) {
|
||||
edge_nodes.insert(edge->GetNode(i)->GetID());
|
||||
}
|
||||
|
||||
std::vector<int> element_edge_nodes;
|
||||
std::set_intersection(nodes_on_edge.begin(), nodes_on_edge.end(), edge_nodes.begin(), edge_nodes.end(),
|
||||
std::back_insert_iterator<std::vector<int> >(element_edge_nodes));
|
||||
|
||||
if (element_edge_nodes.size() == static_cast<std::size_t>(numNodes)) {
|
||||
result.push_back(edge->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
result.sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*! That function returns map containing volume ID and face number
|
||||
* as per CalculiX definition for tetrahedral elements. See CalculiX
|
||||
* documentation for the details.
|
||||
|
||||
@@ -101,6 +101,8 @@ public:
|
||||
std::list<int> getElementNodes(int id) const;
|
||||
/// retrieving face IDs number by face
|
||||
std::list<int> getFacesByFace(const TopoDS_Face &face) const;
|
||||
/// retrieving edge IDs number by edge
|
||||
std::list<int> getEdgesByEdge(const TopoDS_Edge &edge) const;
|
||||
/// retrieving volume IDs and face IDs number by face
|
||||
std::list<std::pair<int, int> > getVolumesByFace(const TopoDS_Face &face) const;
|
||||
/// retrieving volume IDs and CalculiX face number by face
|
||||
|
||||
@@ -93,6 +93,11 @@
|
||||
<UserDocu>Return a list of face IDs which belong to a TopoFace</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getEdgesByEdge" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Return a list of edge IDs which belong to a TopoEdge</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getVolumesByFace" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Return a dict of volume IDs and face IDs which belong to a TopoFace</UserDocu>
|
||||
|
||||
@@ -711,6 +711,40 @@ PyObject* FemMeshPy::getFacesByFace(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PyObject* FemMeshPy::getEdgesByEdge(PyObject *args)
|
||||
{
|
||||
PyObject *pW;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeEdgePy::Type), &pW))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
const TopoDS_Shape& sh = static_cast<Part::TopoShapeEdgePy*>(pW)->getTopoShapePtr()->getShape();
|
||||
if (sh.IsNull()) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, "Edge is empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TopoDS_Edge& fc = TopoDS::Edge(sh);
|
||||
|
||||
Py::List ret;
|
||||
std::list<int> resultSet = getFemMeshPtr()->getEdgesByEdge(fc);
|
||||
for (std::list<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
ret.append(Py::Long(*it));
|
||||
#else
|
||||
ret.append(Py::Int(*it));
|
||||
#endif
|
||||
}
|
||||
|
||||
return Py::new_reference_to(ret);
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* FemMeshPy::getVolumesByFace(PyObject *args)
|
||||
{
|
||||
PyObject *pW;
|
||||
|
||||
Reference in New Issue
Block a user