0022735: Data races in BRepMesh working in parallel mode
authorKGV <>
Wed, 12 Oct 2011 06:50:42 +0000 (06:50 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:30:44 +0000 (19:30 +0400)
src/BRepMesh/BRepMesh_IncrementalMesh.cxx
src/IFSelect/IFSelect_WorkSession.cxx
src/MeshTest/MeshTest_PluginCommands.cxx

index 74cb77c..f28765b 100755 (executable)
@@ -213,22 +213,31 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
   }
 
   // get list of faces
-  TopTools_ListOfShape LF;
-  BRepLib::ReverseSortFaces(S,LF);
-
-  // make array of faces suitable for processing (excluding faces without surface)
   std::vector<TopoDS_Face> aFaces;
-  for (TopTools_ListIteratorOfListOfShape it(LF); it.More(); it.Next()) 
   {
-    TopoDS_Face F = TopoDS::Face(it.Value());
-
-    TopLoc_Location L1;
-    const Handle(Geom_Surface)& Surf = BRep_Tool::Surface(F, L1);
-    if(Surf.IsNull())
-      continue;
-    
-    Update (F);
-    aFaces.push_back (F);
+    TopTools_ListOfShape aFaceList;
+    BRepLib::ReverseSortFaces (S, aFaceList);
+    TopTools_MapOfShape aFaceMap;
+    aFaces.reserve (aFaceList.Extent());
+
+    // make array of faces suitable for processing (excluding faces without surface)
+    TopLoc_Location aDummyLoc;
+    const TopLoc_Location anEmptyLoc;
+    for (TopTools_ListIteratorOfListOfShape aFaceIter (aFaceList); aFaceIter.More(); aFaceIter.Next())
+    {
+      TopoDS_Shape aFaceNoLoc = aFaceIter.Value();
+      aFaceNoLoc.Location (anEmptyLoc);
+      if (!aFaceMap.Add (aFaceNoLoc))
+        continue; // already processed
+
+      TopoDS_Face aFace = TopoDS::Face (aFaceIter.Value());
+      const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aDummyLoc);
+      if (aSurf.IsNull())
+        continue;
+
+      Update (aFace);
+      aFaces.push_back (aFace);
+    }
   }
 
   if (myInParallel)
index c0a7d21..06f5bea 100755 (executable)
@@ -2488,7 +2488,11 @@ IFSelect_ReturnStatus IFSelect_WorkSession::SendAll
     }
   }
   else checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol);
-
+  Handle_Interface_Check aMainFail = checks.CCheck(0);
+  if (!aMainFail.IsNull() && aMainFail->HasFailed ())
+  {
+        return IFSelect_RetStop;
+  }
   if (theloaded.Length() == 0) theloaded.AssignCat(filename);
   thecheckrun = checks;
   if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone;
index a60454c..0bd9cf4 100755 (executable)
@@ -28,6 +28,7 @@
 #include <TColgp_Array1OfPnt2d.hxx>
 #include <Poly_Polygon3D.hxx>
 #include <Poly_Polygon2D.hxx>
+#include <Standard.hxx>
 
 static Standard_Integer mpnames           (Draw_Interpretor& , Standard_Integer , const char** );
 static Standard_Integer mpsetdefaultname  (Draw_Interpretor& , Standard_Integer , const char** );
@@ -422,6 +423,8 @@ static int mpparallel (Draw_Interpretor& di, Standard_Integer argc, const char**
   {
     Standard_Boolean isParallelOn = atoi (argv[1]) == 1;
     BRepMesh_IncrementalMesh::SetParallelDefault (isParallelOn);
+    if (isParallelOn)
+      Standard::SetReentrant(Standard_True);
   }
   std::cout << "Incremental Mesh, multi-threading "
             << (BRepMesh_IncrementalMesh::IsParallelDefault() ? "ON\n" : "OFF\n");