Salome HOME
PAL7913. Add static ShellPoint()
[modules/smesh.git] / src / SMESH / SMESH_Gen.cxx
index 3a202a347c95489c75473a369f0f0be2b6b92378..18df11ed32c23abcd9b55154360ba55f16e6cbeb 100644 (file)
@@ -166,6 +166,9 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 
   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
 
+  if ( sm->GetComputeState() == SMESH_subMesh::COMPUTE_OK )
+    return true; // already computed
+
   // -----------------------------------------------------------------
   // apply algos that do not require descretized boundaries, starting
   // from the most complex shapes
@@ -208,12 +211,21 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
   // mesh the rest subshapes starting from vertices
   // -----------------------------------------------
 
-  smToCompute = sm->GetFirstToCompute();
-  while (smToCompute)
+  int i, nbSub = smMap.size();
+  map<int, SMESH_subMesh*>::const_iterator itSub = smMap.begin();
+  for ( i = 0; i <= nbSub; ++i ) // loop on the whole map plus <sm>
   {
+    if ( itSub == smMap.end() )
+      smToCompute = sm;
+    else
+      smToCompute = (itSub++)->second;
+    if (smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE) {
+      if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
+        ret = false;
+      continue;
+    }
     TopoDS_Shape subShape = smToCompute->GetSubShape();
-    int dim = GetShapeDim(subShape);
-    if (dim > 0)
+    if ( subShape.ShapeType() != TopAbs_VERTEX )
     {
       if ( !smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE) )
         ret = false;
@@ -229,22 +241,10 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
         smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
       }
     }
-    smToCompute = sm->GetFirstToCompute();
   }
 
-  if (!ret) return false;
-
-  // JFA for PAL6524: if there are failed sub-meshes, return Standard_False
-  const map < int, SMESH_subMesh * >&subMeshes = sm->DependsOn();
-  map < int, SMESH_subMesh * >::const_iterator itsub;
-  for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) {
-    SMESH_subMesh *smi = (*itsub).second;
-    if (smi->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) return false;
-  }
-  if (sm->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) return false;
-
-  MESSAGE( "VSR - SMESH_Gen::Compute() finished" );
-  return true;
+  MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
+  return ret;
 }