0022550: Fixing data races
[occt.git] / src / Approx / Approx_CurvlinFunc.cxx
index 55256eb..91e9c1d 100755 (executable)
@@ -12,8 +12,7 @@
  #include <GCPnts_AbscissaPoint.hxx>
 #include <Precision.hxx>
 
-static Standard_Real myPrevS, myPrevU;
-#ifdef DEB
+#ifdef __OCC_DEBUG_CHRONO
 #include <OSD_Timer.hxx>
 static OSD_Chronometer chr_uparam;
 Standard_EXPORT Standard_Integer uparam_count;
@@ -98,7 +97,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor3d_HCurve)& C, const
                     myCase(1), 
                     myFirstS(0), 
                     myLastS(1), 
-                    myTolLen(Tol)
+                    myTolLen(Tol),
+                    myPrevS (0.0),
+                    myPrevU (0.0)
 {
   Init();
 }
@@ -109,7 +110,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_HCurve2d)& C2D, co
                     myCase(2), 
                     myFirstS(0), 
                     myLastS(1), 
-                    myTolLen(Tol)
+                    myTolLen(Tol),
+                    myPrevS (0.0),
+                    myPrevU (0.0)
 {  
   Init();
 }
@@ -122,7 +125,9 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_HCurve2d)& C2D1, c
                     myCase(3), 
                     myFirstS(0), 
                     myLastS(1), 
-                    myTolLen(Tol)
+                    myTolLen(Tol),
+                    myPrevS (0.0),
+                    myPrevU (0.0)
 {  
   Init();
 }
@@ -206,8 +211,9 @@ void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C, Handle(TColStd_HArray1OfReal)&
   for(i = Si->Lower(); i<= Si->Upper(); i++)
     Si->ChangeValue(i) /= Len;
 
-  myPrevS = myFirstS;
-  myPrevU = FirstU;
+  // TODO - fields should be mutable
+  const_cast<Approx_CurvlinFunc*>(this)->myPrevS = myFirstS;
+  const_cast<Approx_CurvlinFunc*>(this)->myPrevU = FirstU;
 }
 
 void  Approx_CurvlinFunc::SetTol(const Standard_Real Tol)
@@ -431,7 +437,7 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
   Standard_Real deltaS, base, U, Length;
   Standard_Integer NbInt, NInterval, i;
   Handle(TColStd_HArray1OfReal) InitUArray, InitSArray;
-#ifdef DEB
+#ifdef __OCC_DEBUG_CHRONO
   InitChron(chr_uparam);
 #endif
   if(S < 0 || S > 1) Standard_ConstructionError::Raise("Approx_CurvlinFunc::GetUParameter");
@@ -477,10 +483,11 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
 
   U = GCPnts_AbscissaPoint(C, deltaS, base, UGuess, myTolLen).Parameter();
 
-  myPrevS = S;
-  myPrevU = U;
+  // TODO - fields should be mutable
+  const_cast<Approx_CurvlinFunc*>(this)->myPrevS = S;
+  const_cast<Approx_CurvlinFunc*>(this)->myPrevU = U;
 
-#ifdef DEB
+#ifdef __OCC_DEBUG_CHRONO
   ResultChron(chr_uparam, t_uparam);
   uparam_count++;
 #endif