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
This commit is contained in:
eap 2010-02-01 11:12:17 +00:00
parent 8d99b0dffe
commit 0cadad987c

View File

@ -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<int>& 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();