]> OCCT Git - occt.git/commitdiff
0032235: Foundation Classes, Message_MsgFile - force initialization of global mutex
authorkgv <kgv@opencascade.com>
Fri, 19 Mar 2021 21:08:50 +0000 (00:08 +0300)
committerkgv <kgv@opencascade.com>
Mon, 22 Mar 2021 08:34:52 +0000 (11:34 +0300)
Initialization of several global variables has been refactored to a function.

src/BOPTest/BOPTest_MkConnectedCommands.cxx
src/BOPTest/BOPTest_PeriodicityCommands.cxx
src/BRepTest/BRepTest_FeatureCommands.cxx
src/Message/Message_MsgFile.cxx

index 1dbd41ebf51314714091ae3428a5521e59cdd2bc..8e15fd9a73cbb190aec32afc2d20e020b8f22b0d 100644 (file)
@@ -41,7 +41,11 @@ static Standard_Integer ClearRepetitions(Draw_Interpretor&, Standard_Integer, co
 
 namespace
 {
-  static BOPAlgo_MakeConnected TheMakeConnectedTool;
+  static BOPAlgo_MakeConnected& getMakeConnectedTool()
+  {
+    static BOPAlgo_MakeConnected TheMakeConnectedTool;
+    return TheMakeConnectedTool;
+  }
 }
 
 //=======================================================================
@@ -104,7 +108,7 @@ Standard_Integer MakeConnected(Draw_Interpretor& theDI,
     return 1;
   }
 
-  TheMakeConnectedTool.Clear();
+  getMakeConnectedTool().Clear();
 
   for (Standard_Integer i = 2; i < theArgc; ++i)
   {
@@ -114,24 +118,24 @@ Standard_Integer MakeConnected(Draw_Interpretor& theDI,
       theDI << "Error: " << theArgv[i] << " is a null shape. Skip it.\n";
       continue;
     }
-    TheMakeConnectedTool.AddArgument(aS);
+    getMakeConnectedTool().AddArgument(aS);
   }
 
-  TheMakeConnectedTool.SetRunParallel(BOPTest_Objects::RunParallel());
+  getMakeConnectedTool().SetRunParallel(BOPTest_Objects::RunParallel());
 
-  TheMakeConnectedTool.Perform();
+  getMakeConnectedTool().Perform();
 
   // Print Error/Warning messages
-  BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
+  BOPTest::ReportAlerts(getMakeConnectedTool().GetReport());
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
+  BRepTest_Objects::SetHistory(getMakeConnectedTool().History());
 
-  if (TheMakeConnectedTool.HasErrors())
+  if (getMakeConnectedTool().HasErrors())
     return 0;
 
   // Draw the result shape
-  const TopoDS_Shape& aResult = TheMakeConnectedTool.Shape();
+  const TopoDS_Shape& aResult = getMakeConnectedTool().Shape();
   DBRep::Set(theArgv[1], aResult);
 
   return 0;
@@ -151,7 +155,7 @@ Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
     return 1;
   }
 
-  if (TheMakeConnectedTool.Shape().IsNull() || TheMakeConnectedTool.HasErrors())
+  if (getMakeConnectedTool().Shape().IsNull() || getMakeConnectedTool().HasErrors())
   {
     theDI << "Make the shapes connected first.\n";
     return 1;
@@ -210,19 +214,19 @@ Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
     }
   }
 
-  TheMakeConnectedTool.MakePeriodic(aParams);
+  getMakeConnectedTool().MakePeriodic(aParams);
 
   // Print Error/Warning messages
-  BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
+  BOPTest::ReportAlerts(getMakeConnectedTool().GetReport());
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
+  BRepTest_Objects::SetHistory(getMakeConnectedTool().History());
 
-  if (TheMakeConnectedTool.HasErrors())
+  if (getMakeConnectedTool().HasErrors())
     return 0;
 
   // Draw the result shape
-  const TopoDS_Shape& aResult = TheMakeConnectedTool.PeriodicShape();
+  const TopoDS_Shape& aResult = getMakeConnectedTool().PeriodicShape();
   DBRep::Set(theArgv[1], aResult);
 
   return 0;
@@ -242,7 +246,7 @@ Standard_Integer RepeatShape(Draw_Interpretor& theDI,
     return 1;
   }
 
-  if (TheMakeConnectedTool.PeriodicityTool().HasErrors())
+  if (getMakeConnectedTool().PeriodicityTool().HasErrors())
   {
     theDI << "The shapes have not been made periodic yet.\n";
     return 1;
@@ -276,20 +280,20 @@ Standard_Integer RepeatShape(Draw_Interpretor& theDI,
       return 1;
     }
 
-    TheMakeConnectedTool.RepeatShape(aDirID, aTimes);
+    getMakeConnectedTool().RepeatShape(aDirID, aTimes);
   }
 
   // Print Error/Warning messages
-  BOPTest::ReportAlerts(TheMakeConnectedTool.GetReport());
+  BOPTest::ReportAlerts(getMakeConnectedTool().GetReport());
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
+  BRepTest_Objects::SetHistory(getMakeConnectedTool().History());
 
-  if (TheMakeConnectedTool.HasErrors())
+  if (getMakeConnectedTool().HasErrors())
     return 0;
 
   // Draw the result shape
-  const TopoDS_Shape& aResult = TheMakeConnectedTool.PeriodicShape();
+  const TopoDS_Shape& aResult = getMakeConnectedTool().PeriodicShape();
   DBRep::Set(theArgv[1], aResult);
 
   return 0;
@@ -331,8 +335,8 @@ Standard_Integer MaterialsOn(Draw_Interpretor& theDI,
   }
 
   const TopTools_ListOfShape& aLS = bPositive ?
-    TheMakeConnectedTool.MaterialsOnPositiveSide(aShape) :
-    TheMakeConnectedTool.MaterialsOnNegativeSide(aShape);
+    getMakeConnectedTool().MaterialsOnPositiveSide(aShape) :
+    getMakeConnectedTool().MaterialsOnNegativeSide(aShape);
 
   TopoDS_Shape aResult;
   if (aLS.IsEmpty())
@@ -373,7 +377,7 @@ Standard_Integer GetTwins(Draw_Interpretor& theDI,
     return 1;
   }
 
-  const TopTools_ListOfShape& aTwins = TheMakeConnectedTool.PeriodicityTool().GetTwins(aShape);
+  const TopTools_ListOfShape& aTwins = getMakeConnectedTool().PeriodicityTool().GetTwins(aShape);
 
   TopoDS_Shape aCTwins;
   if (aTwins.IsEmpty())
@@ -401,13 +405,15 @@ Standard_Integer ClearRepetitions(Draw_Interpretor&,
                                   const char **theArgv)
 {
   // Clear all previous repetitions
-  TheMakeConnectedTool.ClearRepetitions();
+  getMakeConnectedTool().ClearRepetitions();
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(TheMakeConnectedTool.History());
+  BRepTest_Objects::SetHistory(getMakeConnectedTool().History());
 
   if (theArgc > 1)
-    DBRep::Set(theArgv[1], TheMakeConnectedTool.PeriodicShape());
+  {
+    DBRep::Set(theArgv[1], getMakeConnectedTool().PeriodicShape());
+  }
 
   return 0;
 }
index f29693e1c855ea2dff97c6f76751f15517f0d830..6528491ced1384a4904e2793fe07aad8a3329514 100644 (file)
@@ -37,7 +37,11 @@ static Standard_Integer ClearRepetitions(Draw_Interpretor&, Standard_Integer, co
 
 namespace
 {
-  static BOPAlgo_MakePeriodic ThePeriodicityMaker;
+  static BOPAlgo_MakePeriodic& getPeriodicityMaker()
+  {
+    static BOPAlgo_MakePeriodic ThePeriodicityMaker;
+    return ThePeriodicityMaker;
+  }
 }
 
 //=======================================================================
@@ -99,8 +103,8 @@ Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
     return 1;
   }
 
-  ThePeriodicityMaker.Clear();
-  ThePeriodicityMaker.SetShape(aShape);
+  getPeriodicityMaker().Clear();
+  getPeriodicityMaker().SetShape(aShape);
 
   for (Standard_Integer i = 3; i < theArgc;)
   {
@@ -131,7 +135,7 @@ Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
 
     Standard_Real aPeriod = Draw::Atof(theArgv[++i]);
 
-    ThePeriodicityMaker.MakePeriodic(aDirID, Standard_True, aPeriod);
+    getPeriodicityMaker().MakePeriodic(aDirID, Standard_True, aPeriod);
 
     ++i;
     if (theArgc > i + 1)
@@ -146,28 +150,30 @@ Standard_Integer MakePeriodic(Draw_Interpretor& theDI,
         }
         Standard_Real aFirst = Draw::Atof(theArgv[++i]);
 
-        ThePeriodicityMaker.SetTrimmed(aDirID, Standard_False, aFirst);
+        getPeriodicityMaker().SetTrimmed(aDirID, Standard_False, aFirst);
         ++i;
       }
     }
   }
 
-  ThePeriodicityMaker.SetRunParallel(BOPTest_Objects::RunParallel());
+  getPeriodicityMaker().SetRunParallel(BOPTest_Objects::RunParallel());
 
   // Perform operation
-  ThePeriodicityMaker.Perform();
+  getPeriodicityMaker().Perform();
 
   // Print Error/Warning messages
-  BOPTest::ReportAlerts(ThePeriodicityMaker.GetReport());
+  BOPTest::ReportAlerts(getPeriodicityMaker().GetReport());
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
+  BRepTest_Objects::SetHistory(getPeriodicityMaker().History());
 
-  if (ThePeriodicityMaker.HasErrors())
+  if (getPeriodicityMaker().HasErrors())
+  {
     return 0;
+  }
 
   // Draw the result shape
-  const TopoDS_Shape& aResult = ThePeriodicityMaker.Shape();
+  const TopoDS_Shape& aResult = getPeriodicityMaker().Shape();
   DBRep::Set(theArgv[1], aResult);
 
   return 0;
@@ -195,7 +201,7 @@ Standard_Integer GetTwins(Draw_Interpretor& theDI,
     return 1;
   }
 
-  const TopTools_ListOfShape& aTwins = ThePeriodicityMaker.GetTwins(aShape);
+  const TopTools_ListOfShape& aTwins = getPeriodicityMaker().GetTwins(aShape);
 
   TopoDS_Shape aCTwins;
   if (aTwins.IsEmpty())
@@ -256,20 +262,22 @@ Standard_Integer RepeatShape(Draw_Interpretor& theDI,
       return 1;
     }
 
-    ThePeriodicityMaker.RepeatShape(aDirID, aTimes);
+    getPeriodicityMaker().RepeatShape(aDirID, aTimes);
   }
 
   // Print Error/Warning messages
-  BOPTest::ReportAlerts(ThePeriodicityMaker.GetReport());
+  BOPTest::ReportAlerts(getPeriodicityMaker().GetReport());
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
+  BRepTest_Objects::SetHistory(getPeriodicityMaker().History());
 
-  if (ThePeriodicityMaker.HasErrors())
+  if (getPeriodicityMaker().HasErrors())
+  {
     return 0;
+  }
 
   // Draw the result shape
-  const TopoDS_Shape& aResult = ThePeriodicityMaker.RepeatedShape();
+  const TopoDS_Shape& aResult = getPeriodicityMaker().RepeatedShape();
   DBRep::Set(theArgv[1], aResult);
 
   return 0;
@@ -284,13 +292,15 @@ Standard_Integer ClearRepetitions(Draw_Interpretor&,
                                   const char **theArgv)
 {
   // Clear all previous repetitions
-  ThePeriodicityMaker.ClearRepetitions();
+  getPeriodicityMaker().ClearRepetitions();
 
   // Set the history of the operation in session
-  BRepTest_Objects::SetHistory(ThePeriodicityMaker.History());
+  BRepTest_Objects::SetHistory(getPeriodicityMaker().History());
 
   if (theArgc > 1)
-    DBRep::Set(theArgv[1], ThePeriodicityMaker.Shape());
+  {
+    DBRep::Set(theArgv[1], getPeriodicityMaker().Shape());
+  }
 
   return 0;
 }
index 3ba46a0a5258239b121fc868bb1c7a6e8045c054..a56e27068f003b856474294a7130f60f66c6106c 100644 (file)
 Standard_IMPORT Draw_Viewer dout;
 #endif
 
-static BRepFeat_MakeCylindricalHole theHole;
+static BRepFeat_MakeCylindricalHole& getHole()
+{
+  static BRepFeat_MakeCylindricalHole theHole;
+  return theHole;
+}
 static Standard_Boolean WithControl = Standard_True;
 
 Standard_Boolean DownCastingEnforcing = Standard_False;
 
-static BRepFeat_MakePrism thePrism;
-static BRepFeat_MakeDPrism theDPrism;
-static BRepFeat_MakeRevol theRevol;
-static BRepFeat_MakePipe  thePipe;
-static BRepFeat_MakeLinearForm  theLF;
-static BRepFeat_MakeRevolutionForm  theRF;
+static BRepFeat_MakePrism& getPrism()
+{
+  static BRepFeat_MakePrism thePrism;
+  return thePrism;
+}
+static BRepFeat_MakeDPrism& getDPrism()
+{
+  static BRepFeat_MakeDPrism theDPrism;
+  return theDPrism;
+}
+static BRepFeat_MakeRevol& getRevol()
+{
+  static BRepFeat_MakeRevol theRevol;
+  return theRevol;
+}
+static BRepFeat_MakePipe& getPipe()
+{
+  static BRepFeat_MakePipe thePipe;
+  return thePipe;
+}
+static BRepFeat_MakeLinearForm& getLienarForm()
+{
+  static BRepFeat_MakeLinearForm theLF;
+  return theLF;
+}
+static BRepFeat_MakeRevolutionForm& getRevolutionForm()
+{
+  static BRepFeat_MakeRevolutionForm theRF;
+  return theRF;
+}
 
 //Input shapes for Prism, DPrism, Revol, Pipe
 static TopoDS_Shape theSbase, thePbase;
@@ -231,26 +259,27 @@ static Standard_Integer HOLE1(Draw_Interpretor& theCommands,
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S, gp_Ax1(Or, Di));
+  getHole().Init(S, gp_Ax1(Or, Di));
 
   if (narg <= 10) {
-    theHole.Perform(Radius);
+    getHole().Perform(Radius);
   }
   else {
     Standard_Real pfrom = Draw::Atof(a[10]);
     Standard_Real pto = Draw::Atof(a[11]);
-    theHole.Perform(Radius, pfrom, pto, WithControl);
+    getHole().Perform(Radius, pfrom, pto, WithControl);
   }
 
-  theHole.Build();
-  if (!theHole.HasErrors()) {
+  getHole().Build();
+  if (!getHole().HasErrors())
+  {
     //    dout.Clear();
-    DBRep::Set(a[1], theHole.Shape());
+    DBRep::Set(a[1], getHole().Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands, theHole.Status());
+  Print(theCommands, getHole().Status());
   return 1;
 }
 
@@ -265,18 +294,19 @@ static Standard_Integer HOLE2(Draw_Interpretor& theCommands,
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S, gp_Ax1(Or, Di));
-  theHole.PerformThruNext(Radius, WithControl);
+  getHole().Init(S, gp_Ax1(Or, Di));
+  getHole().PerformThruNext(Radius, WithControl);
 
-  theHole.Build();
-  if (!theHole.HasErrors()) {
+  getHole().Build();
+  if (!getHole().HasErrors())
+  {
     //    dout.Clear();
-    DBRep::Set(a[1], theHole.Shape());
+    DBRep::Set(a[1], getHole().Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands, theHole.Status());
+  Print(theCommands, getHole().Status());
   return 1;
 }
 
@@ -291,17 +321,17 @@ static Standard_Integer HOLE3(Draw_Interpretor& theCommands,
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S, gp_Ax1(Or, Di));
-  theHole.PerformUntilEnd(Radius, WithControl);
-  theHole.Build();
-  if (!theHole.HasErrors()) {
+  getHole().Init(S, gp_Ax1(Or, Di));
+  getHole().PerformUntilEnd(Radius, WithControl);
+  getHole().Build();
+  if (!getHole().HasErrors()) {
     //    dout.Clear();
-    DBRep::Set(a[1], theHole.Shape());
+    DBRep::Set(a[1], getHole().Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands, theHole.Status());
+  Print(theCommands, getHole().Status());
   return 1;
 }
 
@@ -318,17 +348,18 @@ static Standard_Integer HOLE4(Draw_Interpretor& theCommands,
   Standard_Real Radius = Draw::Atof(a[9]);
   Standard_Real Length = Draw::Atof(a[10]);
 
-  theHole.Init(S, gp_Ax1(Or, Di));
-  theHole.PerformBlind(Radius, Length, WithControl);
-  theHole.Build();
-  if (!theHole.HasErrors()) {
+  getHole().Init(S, gp_Ax1(Or, Di));
+  getHole().PerformBlind(Radius, Length, WithControl);
+  getHole().Build();
+  if (!getHole().HasErrors())
+  {
     //    dout.Clear();
-    DBRep::Set(a[1], theHole.Shape());
+    DBRep::Set(a[1], getHole().Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands, theHole.Status());
+  Print(theCommands, getHole().Status());
   return 1;
 }
 
@@ -1630,7 +1661,7 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       theSbase = Sbase;
       thePbase = Pbase;
       theSkface = Skface;
-      thePrism.Init(Sbase, Pbase, Skface, gp_Dir(X, Y, Z), Fuse, Modify);
+      getPrism().Init(Sbase, Pbase, Skface, gp_Dir(X, Y, Z), Fuse, Modify);
     }
     else if (narg == 14) {
       rfdef = Standard_True;
@@ -1641,9 +1672,10 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       Standard_Real H1 = Draw::Atof(a[10]);
       Standard_Real H2 = Draw::Atof(a[11]);
       gp_Ax1 ax1(Or, gp_Dir(X, Y, Z));
-      theRF.Init(Sbase, W, P, ax1, H1, H2, Fuse, Modify);
-      if (!theRF.IsDone()) {
-        se = theRF.CurrentStatusError();
+      getRevolutionForm().Init(Sbase, W, P, ax1, H1, H2, Fuse, Modify);
+      if (!getRevolutionForm().IsDone())
+      {
+        se = getRevolutionForm().CurrentStatusError();
         //BRepFeat::Print(se,std::cout) << std::endl;
         Standard_SStream aSStream;
         BRepFeat::Print(se, aSStream);
@@ -1660,7 +1692,7 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       theSbase = Sbase;
       thePbase = Pbase;
       theSkface = Skface;
-      theRevol.Init(Sbase, Pbase, Skface, gp_Ax1(Or, gp_Dir(X, Y, Z)),
+      getRevol().Init(Sbase, Pbase, Skface, gp_Ax1(Or, gp_Dir(X, Y, Z)),
         Fuse, Modify);
     }
     else {
@@ -1669,9 +1701,10 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       X = Draw::Atof(a[7]);
       Y = Draw::Atof(a[8]);
       Z = Draw::Atof(a[9]);
-      theLF.Init(Sbase, W, P, Direct, gp_Vec(X, Y, Z), Fuse, Modify);
-      if (!theLF.IsDone()) {
-        se = theLF.CurrentStatusError();
+      getLienarForm().Init(Sbase, W, P, Direct, gp_Vec(X, Y, Z), Fuse, Modify);
+      if (!getLienarForm().IsDone())
+      {
+        se = getLienarForm().CurrentStatusError();
         //BRepFeat::Print(se,std::cout) << std::endl;
         Standard_SStream aSStream;
         BRepFeat::Print(se, aSStream);
@@ -1691,7 +1724,7 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       theSbase = Sbase;
       thePbase = Pbase;
       theSkface = Skface;
-      theDPrism.Init(Sbase, TopoDS::Face(Pbase), Skface, Angle, Fuse, Modify);
+      getDPrism().Init(Sbase, TopoDS::Face(Pbase), Skface, Angle, Fuse, Modify);
     }
     else { // FEATPIPE
       TopoDS_Shape aLocalShape(DBRep::Get(a[4], TopAbs_WIRE));
@@ -1711,7 +1744,7 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       theSbase = Sbase;
       thePbase = Pbase;
       theSkface = Skface;
-      thePipe.Init(Sbase, Pbase, Skface, Spine, Fuse, Modify);
+      getPipe().Init(Sbase, Pbase, Skface, Spine, Fuse, Modify);
     }
   }
   return 0;
@@ -1743,7 +1776,7 @@ static Standard_Integer ADD(Draw_Interpretor&,
       if (fac.IsNull()) {
         return 1;
       }
-      thePrism.Add(edg, fac);
+      getPrism().Add(edg, fac);
     }
   }
   else if (!strcasecmp("REVOL", a[1])) {
@@ -1763,7 +1796,7 @@ static Standard_Integer ADD(Draw_Interpretor&,
       if (fac.IsNull()) {
         return 1;
       }
-      theRevol.Add(edg, fac);
+      getRevol().Add(edg, fac);
     }
   }
   else if (!strcasecmp("PIPE", a[1])) {
@@ -1783,7 +1816,7 @@ static Standard_Integer ADD(Draw_Interpretor&,
       if (fac.IsNull()) {
         return 1;
       }
-      thePipe.Add(edg, fac);
+      getPipe().Add(edg, fac);
     }
   }
   else {
@@ -1874,14 +1907,14 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
     if (narg == 4) {
       Standard_Real Val = Draw::Atof(a[3]);
       if (Kas == 1) {
-        thePrism.Perform(Val);
+        getPrism().Perform(Val);
       }
       else if (Kas == 2) {
         Val *= (M_PI / 180.);
-        theRevol.Perform(Val);
+        getRevol().Perform(Val);
       }
       else if (Kas == 4) {
-        theDPrism.Perform(Val);
+        getDPrism().Perform(Val);
       }
       else if (Kas == 5) {
         theCommands << "invalid command for lf";
@@ -1896,14 +1929,14 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       Standard_Real Val = Draw::Atof(a[3]);
       TopoDS_Shape FUntil = DBRep::Get(a[4], TopAbs_SHAPE);
       if (Kas == 1) {
-        thePrism.PerformUntilHeight(FUntil, Val);
+        getPrism().PerformUntilHeight(FUntil, Val);
       }
       else if (Kas == 2) {
         Val *= (M_PI / 180.);
-        theRevol.PerformUntilAngle(FUntil, Val);
+        getRevol().PerformUntilAngle(FUntil, Val);
       }
       else if (Kas == 4) {
-        theDPrism.PerformUntilHeight(FUntil, Val);
+        getDPrism().PerformUntilHeight(FUntil, Val);
       }
       else {
         theCommands << "invalid command for ribs or slots";
@@ -1915,22 +1948,22 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
     if (narg == 3) { // Thru all
       switch (Kas) {
       case 1:
-        thePrism.PerformThruAll();
+        getPrism().PerformThruAll();
         break;
       case 2:
-        theRevol.PerformThruAll();
+        getRevol().PerformThruAll();
         break;
       case 3:
-        thePipe.Perform();
+        getPipe().Perform();
         break;
       case 4:
-        theDPrism.PerformThruAll();
+        getDPrism().PerformThruAll();
         break;
       case 5:
-        theLF.Perform();
+        getLienarForm().Perform();
         break;
       case 6:
-        theRF.Perform();
+        getRevolutionForm().Perform();
         break;
       default:
 
@@ -1943,17 +1976,17 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       case 1:
       {
         if (Funtil.IsNull()) {
-          thePrism.PerformUntilEnd();
+          getPrism().PerformUntilEnd();
         }
         else {
-          thePrism.Perform(Funtil);
+          getPrism().Perform(Funtil);
         }
       }
       break;
       case 2:
       {
         if (!Funtil.IsNull()) {
-          theRevol.Perform(Funtil);
+          getRevol().Perform(Funtil);
         }
         else {
           return 1;
@@ -1962,8 +1995,9 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       break;
       case 3:
       {
-        if (!Funtil.IsNull()) {
-          thePipe.Perform(Funtil);
+        if (!Funtil.IsNull())
+        {
+          getPipe().Perform(Funtil);
         }
         else {
           theCommands << "invalid command for ribs pipe";
@@ -1974,10 +2008,10 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       case 4:
       {
         if (!Funtil.IsNull()) {
-          theDPrism.Perform(Funtil);
+          getDPrism().Perform(Funtil);
         }
         else {
-          theDPrism.PerformUntilEnd();
+          getDPrism().PerformUntilEnd();
         }
       }
       break;
@@ -2006,11 +2040,13 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       switch (Kas) {
       case 1:
       {
-        if (Ffrom.IsNull()) {
-          thePrism.PerformFromEnd(Funtil);
+        if (Ffrom.IsNull())
+        {
+          getPrism().PerformFromEnd(Funtil);
         }
-        else {
-          thePrism.Perform(Ffrom, Funtil);
+        else
+        {
+          getPrism().Perform(Ffrom, Funtil);
         }
       }
       break;
@@ -2019,7 +2055,7 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
         if (Ffrom.IsNull()) {
           return 1;
         }
-        theRevol.Perform(Ffrom, Funtil);
+        getRevol().Perform(Ffrom, Funtil);
       }
       break;
       case 3:
@@ -2027,16 +2063,16 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
         if (Ffrom.IsNull()) {
           return 1;
         }
-        thePipe.Perform(Ffrom, Funtil);
+        getPipe().Perform(Ffrom, Funtil);
       }
       break;
       case 4:
       {
         if (Ffrom.IsNull()) {
-          theDPrism.PerformFromEnd(Funtil);
+          getDPrism().PerformFromEnd(Funtil);
         }
         else {
-          theDPrism.Perform(Ffrom, Funtil);
+          getDPrism().Perform(Ffrom, Funtil);
         }
       }
       break;
@@ -2050,15 +2086,16 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
   BRepFeat_StatusError se;
   switch (Kas) {
   case 1:
-    if (!thePrism.IsDone()) {
-      se = thePrism.CurrentStatusError();
+    if (!getPrism().IsDone())
+    {
+      se = getPrism().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2], thePrism);
+    DBRep::Set(a[2], getPrism());
     dout.Flush();
     //History 
     if (BRepTest_Objects::IsHistoryNeeded())
@@ -2067,12 +2104,13 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       anArgs.Append(theSbase);
       anArgs.Append(thePbase);
       anArgs.Append(theSkface);
-      BRepTest_Objects::SetHistory(anArgs, thePrism);
+      BRepTest_Objects::SetHistory(anArgs, getPrism());
     }
     return 0;
   case 2:
-    if (!theRevol.IsDone()) {
-      se = theRevol.CurrentStatusError();
+    if (!getRevol().IsDone())
+    {
+      se = getRevol().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
@@ -2086,14 +2124,15 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       anArgs.Append(theSbase);
       anArgs.Append(thePbase);
       anArgs.Append(theSkface);
-      BRepTest_Objects::SetHistory(anArgs, theRevol);
+      BRepTest_Objects::SetHistory(anArgs, getRevol());
     }
-    DBRep::Set(a[2], theRevol);
+    DBRep::Set(a[2], getRevol());
     dout.Flush();
     return 0;
   case 3:
-    if (!thePipe.IsDone()) {
-      se = thePipe.CurrentStatusError();
+    if (!getPipe().IsDone())
+    {
+      se = getPipe().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
@@ -2107,14 +2146,15 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       anArgs.Append(theSbase);
       anArgs.Append(thePbase);
       anArgs.Append(theSkface);
-      BRepTest_Objects::SetHistory(anArgs, thePipe);
+      BRepTest_Objects::SetHistory(anArgs, getPipe());
     }
-    DBRep::Set(a[2], thePipe);
+    DBRep::Set(a[2], getPipe());
     dout.Flush();
     return 0;
   case 4:
-    if (!theDPrism.IsDone()) {
-      se = theDPrism.CurrentStatusError();
+    if (!getDPrism().IsDone())
+    {
+      se = getDPrism().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
@@ -2128,33 +2168,35 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       anArgs.Append(theSbase);
       anArgs.Append(thePbase);
       anArgs.Append(theSkface);
-      BRepTest_Objects::SetHistory(anArgs, theDPrism);
+      BRepTest_Objects::SetHistory(anArgs, getDPrism());
     }
-    DBRep::Set(a[2], theDPrism);
+    DBRep::Set(a[2], getDPrism());
     dout.Flush();
     return 0;
   case 5:
-    if (!theLF.IsDone()) {
-      se = theLF.CurrentStatusError();
+    if (!getLienarForm().IsDone())
+    {
+      se = getLienarForm().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2], theLF);
+    DBRep::Set(a[2], getLienarForm());
     dout.Flush();
     return 0;
   case 6:
-    if (!theRF.IsDone()) {
-      se = theRF.CurrentStatusError();
+    if (!getRevolutionForm().IsDone())
+    {
+      se = getRevolutionForm().CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
       BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2], theRF);
+    DBRep::Set(a[2], getRevolutionForm());
     dout.Flush();
     return 0;
   default:
@@ -2207,11 +2249,11 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
       return 1;
     }
 
-    theDPrism.BossEdges(dprsig);
+    getDPrism().BossEdges(dprsig);
 
     TopTools_ListOfShape theTopEdges, theLatEdges;
-    theTopEdges = theDPrism.TopEdges();
-    theLatEdges = theDPrism.LatEdges();
+    theTopEdges = getDPrism().TopEdges();
+    theLatEdges = getDPrism().LatEdges();
 
     TopTools_ListIteratorOfListOfShape it;
     BRep_Builder B;
@@ -2245,7 +2287,7 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
       V = DBRep::Get(a[2], TopAbs_SHAPE);
     }
     else if (Kas == 3) {
-      V = theDPrism;
+      V = getDPrism();
     }
 
     if (V.IsNull()) return 1;
index 31fc76bad76bcadf4c6b2228deaacbe1717561f1..3ac1e541715b62336337980f6b940169a9f9ede3 100644 (file)
@@ -35,7 +35,11 @@ static Message_DataMapOfExtendedString& msgsDataMap ()
 }
 
 // mutex used to prevent concurrent access to message registry
-static Standard_Mutex theMutex;
+static Standard_Mutex& Message_MsgFile_Mutex()
+{
+  static Standard_Mutex theMutex;
+  return theMutex;
+}
 
 typedef enum
 {
@@ -345,13 +349,12 @@ Standard_Boolean Message_MsgFile::LoadFromString (const Standard_CString theCont
 //purpose  : Add one message to the global table. Fails if the same keyword
 //           already exists in the table
 //=======================================================================
-
 Standard_Boolean Message_MsgFile::AddMsg (const TCollection_AsciiString& theKeyword,
                                          const TCollection_ExtendedString&  theMessage)
 {
   Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
 
-  Standard_Mutex::Sentry aSentry (theMutex);
+  Standard_Mutex::Sentry aSentry (Message_MsgFile_Mutex());
   aDataMap.Bind (theKeyword, theMessage);
   return Standard_True;
 }
@@ -360,21 +363,19 @@ Standard_Boolean Message_MsgFile::AddMsg (const TCollection_AsciiString& theKeyw
 //function : getMsg
 //purpose  : retrieve the message previously defined for the given keyword
 //=======================================================================
-
-const TCollection_ExtendedString &Message_MsgFile::Msg (const Standard_CString theKeyword)
+const TCollection_ExtendedString& Message_MsgFile::Msg (const Standard_CString theKeyword)
 {
-  TCollection_AsciiString aKey((char*)theKeyword);
+  TCollection_AsciiString aKey (theKeyword);
   return Msg (aKey);
 } 
 
 //=======================================================================
 //function : HasMsg
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 Standard_Boolean Message_MsgFile::HasMsg (const TCollection_AsciiString& theKeyword)
 {
-  Standard_Mutex::Sentry aSentry (theMutex);
+  Standard_Mutex::Sentry aSentry (Message_MsgFile_Mutex());
   return ::msgsDataMap().IsBound (theKeyword);
 }
 
@@ -382,24 +383,26 @@ Standard_Boolean Message_MsgFile::HasMsg (const TCollection_AsciiString& theKeyw
 //function : Msg
 //purpose  : retrieve the message previously defined for the given keyword
 //=======================================================================
-
-const TCollection_ExtendedString &Message_MsgFile::Msg (const TCollection_AsciiString& theKeyword)
+const TCollection_ExtendedString& Message_MsgFile::Msg (const TCollection_AsciiString& theKeyword)
 {
   // find message in the map
   Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
-  Standard_Mutex::Sentry aSentry (theMutex);
+  Standard_Mutex::Sentry aSentry (Message_MsgFile_Mutex());
 
   // if message is not found, generate error message and add it to the map to minimize overhead
   // on consequent calls with the same key
-  if (! aDataMap.IsBound(theKeyword))
+  const TCollection_ExtendedString* aValPtr = aDataMap.Seek (theKeyword);
+  if (aValPtr == NULL)
   {
     // text of the error message can be itself defined in the map
     static const TCollection_AsciiString aPrefixCode("Message_Msg_BadKeyword");
     static const TCollection_ExtendedString aDefPrefix("Unknown message invoked with the keyword ");
-    TCollection_AsciiString aErrorMessage = (aDataMap.IsBound(aPrefixCode) ? aDataMap(aPrefixCode) : aDefPrefix);
+    const TCollection_ExtendedString* aPrefValPtr = aDataMap.Seek (aPrefixCode);
+    TCollection_AsciiString aErrorMessage = (aPrefValPtr != NULL ? *aPrefValPtr : aDefPrefix);
     aErrorMessage += theKeyword;
     aDataMap.Bind (theKeyword, aErrorMessage); // do not use AddMsg() here to avoid mutex deadlock
+    aValPtr = aDataMap.Seek (theKeyword);
   }
 
-  return aDataMap (theKeyword);
+  return *aValPtr;
 }