- myBusy = false;
-
- QStringList aListId = QStringList::split("-", theNewText, false);
- if (aListId.count() != 2)
- return;
-
- int i;
- bool allOk = true;
- const SMDS_MeshNode* a2Nodes[2];
- for (i = 0; i < aListId.count(); i++) {
- if(const SMDS_MeshNode *aNode = aMesh->FindNode(aListId[ i ].toInt()))
- a2Nodes[ i ] = aNode;
- else
- allOk = false;
- }
-
- // find a triangle and an edge nb
- const SMDS_MeshElement* tria[2];
- allOk &= a2Nodes[0] != a2Nodes[1] && findTriangles(a2Nodes[0],a2Nodes[1],tria[0],tria[1]);
- if(allOk){
- myBusy = true; // block onSelectionDone()
- newIndices.Add(tria[0]->GetID());
- mySelector->AddOrRemoveIndex(anIO,newIndices, true);
-
- const SMDS_MeshNode* a3Nodes [3];
- SMDS_ElemIteratorPtr it;
- int edgeInd = 2;
- for (i = 0, it = tria[0]->nodesIterator(); it->more(); i++) {
- a3Nodes[ i ] = static_cast<const SMDS_MeshNode*>(it->next());
- if (i > 0) {
- allOk = (a3Nodes[ i ] == a2Nodes[ 0 ] && a3Nodes[ i - 1] == a2Nodes[ 1 ]) ||
- (a3Nodes[ i ] == a2Nodes[ 1 ] && a3Nodes[ i - 1] == a2Nodes[ 0 ]);
- if (allOk) {
- edgeInd = i - 1;
- break;
- }
- }
- }
-
- newIndices.Clear();
- newIndices.Add(-edgeInd-1);
- mySelector->AddOrRemoveIndex(anIO,newIndices,true);
- myBusy = false;
-
- myOkBtn->setEnabled(true);
- myApplyBtn->setEnabled(true);
+
+ int id1, id2;
+ if ( !getNodeIds(myEdge->text(), id1, id2) )
+ return;
+
+ const SMDS_MeshNode* aNode1 = aMesh->FindNode( id1 );
+ const SMDS_MeshNode* aNode2 = aMesh->FindNode( id2 );
+
+ if ( !aNode1 || !aNode2 || aNode1 == aNode2 )
+ return;
+
+ // find a triangle and an edge index
+ const SMDS_MeshElement* tria1;
+ const SMDS_MeshElement* tria2;
+
+ if ( findTriangles(aNode1,aNode2,tria1,tria2) )
+ {
+ newIndices.Add(tria1->GetID());
+
+ const SMDS_MeshNode* a3Nodes[3];
+ SMDS_ElemIteratorPtr it;
+ int edgeInd = 2, i;
+ for (i = 0, it = tria1->nodesIterator(); it->more(); i++) {
+ a3Nodes[ i ] = static_cast<const SMDS_MeshNode*>(it->next());
+ if (i > 0 && ( (a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2) ||
+ (a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1) ) ) {
+ edgeInd = i - 1;
+ break;
+ }
+ }
+ newIndices.Add(-edgeInd-1);
+
+ myOkBtn->setEnabled(true);
+ myApplyBtn->setEnabled(true);