From: eap Date: Mon, 1 Feb 2010 11:12:17 +0000 (+0000) Subject: 0019296: EDF 681 SMESH - Pre-evaluation of the number of elements before mesh X-Git-Tag: V5_1_4a1~117 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0cadad987c1c57b4f2f04ff1ceab31f81515dfb5;p=modules%2Fsmesh.git 0019296: EDF 681 SMESH - Pre-evaluation of the number of elements before mesh * Evaluate(): ** do not read from out of vector range ** report error if algo->Evaluate() returns negative number --- diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index c644c2087..f5de7bd50 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1686,8 +1686,20 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh, MapShapeNbElemsItr anIt = aResMap.begin(); for(; anIt!=aResMap.end(); anIt++) { const vector& aVec = (*anIt).second; - for(i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) { - nbels[i] += aVec[i]; + for(i = SMESH::Entity_Node; i < aVec.size(); i++) { + int nbElem = aVec[i]; + if ( nbElem < 0 ) // algo failed, check that it has reported a message + { + SMESH_subMesh* sm = anIt->first; + SMESH_ComputeErrorPtr& error = sm->GetComputeError(); + const SMESH_Algo* algo = myGen.GetAlgo( myLocMesh, sm->GetSubShape()); + if ( algo && !error.get() || error->IsOK() ) + error.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED,"Failed to evaluate",algo)); + } + else + { + nbels[i] += aVec[i]; + } } } return nbels._retn();