fixes 0003618: FEM, GUI, mesh view provider, highlighted node show wrong node number on selection
This commit is contained in:
@@ -424,8 +424,13 @@ std::string ViewProviderFemMesh::getElement(const SoDetail* detail) const
|
||||
else if (detail->getTypeId() == SoPointDetail::getClassTypeId()) {
|
||||
const SoPointDetail* point_detail = static_cast<const SoPointDetail*>(detail);
|
||||
int idx = point_detail->getCoordinateIndex();
|
||||
if (idx < static_cast<int>(vNodeElementIdx.size())) {
|
||||
int vertex = vNodeElementIdx[point_detail->getCoordinateIndex()];
|
||||
// first check if the index is part of the highlighted nodes (#0003618)
|
||||
if (idx < static_cast<int>(vHighlightedIdx.size())) {
|
||||
int vertex = vHighlightedIdx[idx];
|
||||
str << "Node" << vertex;
|
||||
}
|
||||
else if (idx < static_cast<int>(vNodeElementIdx.size())) {
|
||||
int vertex = vNodeElementIdx[idx];
|
||||
str << "Node" << vertex;
|
||||
}
|
||||
else {
|
||||
@@ -471,15 +476,22 @@ std::vector<Base::Vector3d> ViewProviderFemMesh::getSelectionShape(const char* /
|
||||
return std::vector<Base::Vector3d>();
|
||||
}
|
||||
|
||||
std::set<long> ViewProviderFemMesh::getHighlightNodes() const
|
||||
{
|
||||
std::set<long> nodes;
|
||||
nodes.insert(vHighlightedIdx.begin(), vHighlightedIdx.end());
|
||||
return nodes;
|
||||
}
|
||||
|
||||
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
|
||||
{
|
||||
if(!HighlightedNodes.empty()){
|
||||
if (!HighlightedNodes.empty()) {
|
||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh).getValue().getSMesh())->GetMeshDS();
|
||||
|
||||
pcAnoCoords->point.setNum(HighlightedNodes.size());
|
||||
SbVec3f* verts = pcAnoCoords->point.startEditing();
|
||||
int i=0;
|
||||
for(std::set<long>::const_iterator it=HighlightedNodes.begin();it!=HighlightedNodes.end();++it,i++){
|
||||
for (std::set<long>::const_iterator it=HighlightedNodes.begin();it!=HighlightedNodes.end();++it,i++){
|
||||
const SMDS_MeshNode *Node = data->FindNode(*it);
|
||||
if (Node)
|
||||
verts[i].setValue((float)Node->X(),(float)Node->Y(),(float)Node->Z());
|
||||
@@ -487,13 +499,22 @@ void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNod
|
||||
verts[i].setValue(0,0,0);
|
||||
}
|
||||
pcAnoCoords->point.finishEditing();
|
||||
}else{
|
||||
|
||||
// save the node ids
|
||||
vHighlightedIdx.clear();
|
||||
vHighlightedIdx.insert(vHighlightedIdx.end(),
|
||||
HighlightedNodes.begin(), HighlightedNodes.end());
|
||||
}
|
||||
else {
|
||||
pcAnoCoords->point.setNum(0);
|
||||
vHighlightedIdx.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFemMesh::resetHighlightNodes(void)
|
||||
{
|
||||
pcAnoCoords->point.setNum(0);
|
||||
vHighlightedIdx.clear();
|
||||
}
|
||||
|
||||
PyObject * ViewProviderFemMesh::getPyObject()
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
|
||||
// interface methods
|
||||
void setHighlightNodes(const std::set<long>&);
|
||||
std::set<long> getHighlightNodes() const;
|
||||
void resetHighlightNodes(void);
|
||||
|
||||
/** @name Postprocessing
|
||||
@@ -145,6 +146,7 @@ protected:
|
||||
/// index of elements to their triangles
|
||||
std::vector<unsigned long> vFaceElementIdx;
|
||||
std::vector<unsigned long> vNodeElementIdx;
|
||||
std::vector<unsigned long> vHighlightedIdx;
|
||||
|
||||
std::vector<Base::Vector3d> DisplacementVector;
|
||||
double DisplacementFactor;
|
||||
|
||||
@@ -219,21 +219,26 @@ void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg)
|
||||
|
||||
Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
|
||||
{
|
||||
//return Py::List();
|
||||
throw Py::AttributeError("Not yet implemented");
|
||||
Py::List list;
|
||||
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
|
||||
std::set<long> nodeIds = vp->getHighlightNodes();
|
||||
for (auto it : nodeIds) {
|
||||
list.append(Py::Long(it));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
||||
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
|
||||
{
|
||||
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
|
||||
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>
|
||||
(vp->getObject())->FemMesh).getValue().getSMesh())->GetMeshDS();
|
||||
|
||||
std::set<long> res;
|
||||
for(Py::List::iterator it = arg.begin(); it!= arg.end();++it){
|
||||
for (Py::List::iterator it = arg.begin(); it!= arg.end();++it) {
|
||||
long id = static_cast<long>(Py::Long(*it));
|
||||
const SMDS_MeshNode *node = data->FindNode(id);
|
||||
if(node)
|
||||
if (node)
|
||||
res.insert(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user