+ fix crash in ViewProviderFemMesh::setHighlightNodes when values out of range
This commit is contained in:
parent
2f25170763
commit
18f0ec61eb
|
@ -467,8 +467,7 @@ std::vector<Base::Vector3d> ViewProviderFemMesh::getSelectionShape(const char* E
|
|||
|
||||
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
|
||||
{
|
||||
|
||||
if(HighlightedNodes.size()){
|
||||
if(!HighlightedNodes.empty()){
|
||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((dynamic_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh).getValue().getSMesh())->GetMeshDS();
|
||||
|
||||
pcAnoCoords->point.setNum(HighlightedNodes.size());
|
||||
|
@ -476,14 +475,15 @@ void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNod
|
|||
int i=0;
|
||||
for(std::set<long>::const_iterator it=HighlightedNodes.begin();it!=HighlightedNodes.end();++it,i++){
|
||||
const SMDS_MeshNode *Node = data->FindNode(*it);
|
||||
verts[i].setValue((float)Node->X(),(float)Node->Y(),(float)Node->Z());
|
||||
if (Node)
|
||||
verts[i].setValue((float)Node->X(),(float)Node->Y(),(float)Node->Z());
|
||||
else
|
||||
verts[i].setValue(0,0,0);
|
||||
}
|
||||
pcAnoCoords->point.finishEditing();
|
||||
|
||||
}else{
|
||||
pcAnoCoords->point.setNum(0);
|
||||
}
|
||||
|
||||
}
|
||||
void ViewProviderFemMesh::resetHighlightNodes(void)
|
||||
{
|
||||
|
|
|
@ -6,8 +6,13 @@
|
|||
|
||||
#include <App/DocumentObjectPy.h>
|
||||
|
||||
#include "Mod/Fem/Gui/ViewProviderFemMesh.h"
|
||||
#include "Mod/Fem/App/FemResultObject.h"
|
||||
#include <Mod/Fem/Gui/ViewProviderFemMesh.h>
|
||||
#include <Mod/Fem/App/FemResultObject.h>
|
||||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
#include <Mod/Fem/App/FemMesh.h>
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
#include <SMDSAbs_ElementType.hxx>
|
||||
|
||||
// inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml)
|
||||
#include "ViewProviderFemMeshPy.h"
|
||||
|
@ -218,13 +223,18 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
|
|||
|
||||
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
||||
{
|
||||
std::set<long> res;
|
||||
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
|
||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((dynamic_cast<Fem::FemMeshObject*>
|
||||
(vp->getObject())->FemMesh).getValue().getSMesh())->GetMeshDS();
|
||||
|
||||
for( Py::List::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
Py::Int id(*it);
|
||||
if(id)
|
||||
std::set<long> res;
|
||||
for(Py::List::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
long id = static_cast<long>(Py::Int(*it));
|
||||
const SMDS_MeshNode *node = data->FindNode(id);
|
||||
if(node)
|
||||
res.insert(id);
|
||||
}
|
||||
|
||||
this->getViewProviderFemMeshPtr()->setHighlightNodes(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user