0025660: Project command produce wrong 2dcurve
authoraml <aml@opencascade.com>
Thu, 15 Jan 2015 12:33:15 +0000 (15:33 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 15 Jan 2015 12:35:07 +0000 (15:35 +0300)
Changed starting point of Newton optimization.

Test case for issue CR25660

src/ProjLib/ProjLib_CompProjectedCurve.cxx
tests/bugs/moddata_3/bug25660 [new file with mode: 0644]

index e487639..f57433d 100644 (file)
@@ -756,18 +756,24 @@ void ProjLib_CompProjectedCurve::Init()
     t = Triple.X() + Step;
     if (t > LastU) t = LastU;
 
     t = Triple.X() + Step;
     if (t > LastU) t = LastU;
 
+    Standard_Real U0, V0;
+    gp_Pnt2d aLowBorder(mySurface->FirstUParameter(),mySurface->FirstVParameter());
+    gp_Pnt2d aUppBorder(mySurface->LastUParameter(), mySurface->LastVParameter());
+    gp_Pnt2d aTol(myTolU, myTolV);
     //Here we are trying to prolong continuous part
     while (t <= LastU && new_part) 
     {
     //Here we are trying to prolong continuous part
     while (t <= LastU && new_part) 
     {
-      Standard_Real U0, V0;
 
 
-      U0 = Triple.Y();
-      V0 = Triple.Z();
+      U0 = Triple.Y() + (Triple.Y() - prevTriple.Y());
+      V0 = Triple.Z() + (Triple.Z() - prevTriple.Z());
+      // adjust U0 to be in [mySurface->FirstUParameter(),mySurface->LastUParameter()]
+      U0 = Min(Max(U0, aLowBorder.X()), aUppBorder.X()); 
+      // adjust V0 to be in [mySurface->FirstVParameter(),mySurface->LastVParameter()]
+      V0 = Min(Max(V0, aLowBorder.Y()), aUppBorder.Y()); 
 
 
-      aPrjPS.Perform(t, U0, V0, gp_Pnt2d(myTolU, myTolV), 
-        gp_Pnt2d(mySurface->FirstUParameter(),mySurface->FirstVParameter()), 
-        gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), 
-        FuncTol, Standard_True);
+
+      aPrjPS.Perform(t, U0, V0, aTol,
+                     aLowBorder, aUppBorder, FuncTol, Standard_True);
       if(!aPrjPS.IsDone()) 
       {
 
       if(!aPrjPS.IsDone()) 
       {
 
diff --git a/tests/bugs/moddata_3/bug25660 b/tests/bugs/moddata_3/bug25660
new file mode 100644 (file)
index 0000000..78b3184
--- /dev/null
@@ -0,0 +1,49 @@
+puts "================"
+puts "OCC25660"
+puts "================"
+puts ""
+#######################################################################
+# Project command produce wrong 2dcurve
+#######################################################################
+
+restore [locate_data_file bug25660_c3d.draw] c3d
+restore [locate_data_file bug25660_surf.draw] surf
+
+project c2d c3d surf
+
+set log [dump c2d]
+
+regexp {Degree +([-0-9.+eE]+), +([-0-9.+eE]+) Poles, +([-0-9.+eE]+)} ${log} full Degree Poles KnotsPoles
+puts "Degree=${Degree}"
+puts "Poles=${Poles}"
+puts "KnotsPoles=${KnotsPoles}"
+puts ""
+
+set tol_abs 1.e-7
+set tol_rel 0.01
+set V_i 0
+
+for {set i 1} {${i} <= ${Poles}} {incr i} {
+   set V_i_1 ${V_i}
+   set exp_string " +${i} : +(\[-0-9.+eE\]+), +(\[-0-9.+eE\]+)"
+   regexp ${exp_string} ${log} full U_i V_i
+   #puts "i=${i} U_i=${U_i} V_i=${V_i}"
+   if { ${i} == 1 } {
+      # First pole
+      puts "V_first=${V_i}"
+      set expected_V_first 0.0
+      checkreal "V_first" ${V_i} ${expected_V_first} ${tol_abs} ${tol_rel}
+   }
+   if { ${i} == ${Poles} } {
+      # Last pole
+      puts "V_last=${V_i}"
+      set expected_V_last 6.96771797765
+      checkreal "V_last" ${V_i} ${expected_V_last} ${tol_abs} ${tol_rel}
+   }
+   if { ${i} > 1 } {
+      #puts "i=${i} U_i=${U_i} V_i=${V_i} V_i_1=${V_i_1}"
+      if { ${V_i_1} >= ${V_i} } {
+         puts "Error: Bad value of V in string: ${i} :${U_i}, ${V_i}"
+      }
+   }
+}