0023839: Projection algorithm produces wrong results for set of data
authorjgv <jgv@opencascade.com>
Thu, 18 Jul 2013 08:54:38 +0000 (12:54 +0400)
committerjgv <jgv@opencascade.com>
Thu, 18 Jul 2013 08:54:38 +0000 (12:54 +0400)
Added test cases bugs/modalg_5/bug23839_1 bug23839_2 bug23839_3 bug23839_4 bug23839_5 bug23839_6 bug23839_7

src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
tests/bugs/modalg_5/bug23839_1 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_2 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_3 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_4 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_5 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_6 [new file with mode: 0644]
tests/bugs/modalg_5/bug23839_7 [new file with mode: 0644]

index 5e005f8..8fde532 100755 (executable)
@@ -707,6 +707,14 @@ Handle(Adaptor2d_HCurve2d)
   Standard_Real TolU = Surf->UResolution(Tol3d), TolV = Surf->VResolution(Tol3d);
   Standard_Real DistTol3d = 100.0*Tol3d;
 
   Standard_Real TolU = Surf->UResolution(Tol3d), TolV = Surf->VResolution(Tol3d);
   Standard_Real DistTol3d = 100.0*Tol3d;
 
+  Standard_Real uperiod = 0., vperiod = 0.;
+  if(Surf->IsUPeriodic() || Surf->IsUClosed())
+    uperiod = Surf->LastUParameter() - Surf->FirstUParameter(); 
+  
+  if(Surf->IsVPeriodic() || Surf->IsVClosed())
+    vperiod = Surf->LastVParameter() - Surf->FirstVParameter(); 
+
+  
   // NO myTol is Tol2d !!!!
   //Standard_Real TolU = myTolerance, TolV = myTolerance;
   //Standard_Real Tol3d = 100*myTolerance; // At random Balthazar.
   // NO myTol is Tol2d !!!!
   //Standard_Real TolU = myTolerance, TolV = myTolerance;
   //Standard_Real Tol3d = 100*myTolerance; // At random Balthazar.
@@ -726,7 +734,9 @@ Handle(Adaptor2d_HCurve2d)
   Mult.Init(1);
   Mult(1) = Mult(NbOfPnts) = 2;
   
   Mult.Init(1);
   Mult(1) = Mult(NbOfPnts) = 2;
   
-  Standard_Real Vinf, Vsup;
+  Standard_Real Uinf, Usup, Vinf, Vsup;
+  Uinf = Surf->Surface().FirstUParameter();
+  Usup = Surf->Surface().LastUParameter();
   Vinf = Surf->Surface().FirstVParameter();
   Vsup = Surf->Surface().LastVParameter();
   GeomAbs_SurfaceType Type = Surf->GetType();
   Vinf = Surf->Surface().FirstVParameter();
   Vsup = Surf->Surface().LastVParameter();
   GeomAbs_SurfaceType Type = Surf->GetType();
@@ -856,9 +866,6 @@ Handle(Adaptor2d_HCurve2d)
     }
   }
   else {
     }
   }
   else {
-    Standard_Real Uinf = Surf->Surface().FirstUParameter();
-    Standard_Real Usup = Surf->Surface().LastUParameter();
-    
     myProjIsDone = Standard_False;
     Standard_Real Dist2Min = 1.e+200, u = 0., v = 0.;
     gp_Pnt pntproj;
     myProjIsDone = Standard_False;
     Standard_Real Dist2Min = 1.e+200, u = 0., v = 0.;
     gp_Pnt pntproj;
@@ -1033,20 +1040,11 @@ Handle(Adaptor2d_HCurve2d)
       // (and store the result and each parameter in a sequence)
       Standard_Integer usens = 0, vsens = 0; 
       // to know the position relatively to the period
       // (and store the result and each parameter in a sequence)
       Standard_Integer usens = 0, vsens = 0; 
       // to know the position relatively to the period
-      Standard_Real U0 = u, V0 = v, U1 = u, V1 = v, uperiod =0, vperiod = 0;
+      Standard_Real U0 = u, V0 = v, U1 = u, V1 = v;
       // U0 and V0 are the points in the initialized period 
       // (period with u and v),
       // U1 and V1 are the points for construction of poles
 
       // U0 and V0 are the points in the initialized period 
       // (period with u and v),
       // U1 and V1 are the points for construction of poles
 
-
-      if(Surf->IsUPeriodic() || Surf->IsUClosed()) {
-       uperiod = Surf->LastUParameter() - Surf->FirstUParameter(); 
-      }
-
-      if(Surf->IsVPeriodic() || Surf->IsVClosed()) {
-       vperiod = Surf->LastVParameter() - Surf->FirstVParameter(); 
-      } 
-      
       for ( i = 2 ; i <= NbOfPnts ; i++) 
        if(myProjIsDone) {
          myProjIsDone = Standard_False;
       for ( i = 2 ; i <= NbOfPnts ; i++) 
        if(myProjIsDone) {
          myProjIsDone = Standard_False;
@@ -1192,6 +1190,34 @@ Handle(Adaptor2d_HCurve2d)
   // -- Pnts2d is transformed into Geom2d_BSplineCurve, with the help of Param and Mult
   if(myProjIsDone) {
     myBSpline = new Geom2d_BSplineCurve(Pts2d,Param,Mult,1);
   // -- Pnts2d is transformed into Geom2d_BSplineCurve, with the help of Param and Mult
   if(myProjIsDone) {
     myBSpline = new Geom2d_BSplineCurve(Pts2d,Param,Mult,1);
+    //jgv: put the curve into parametric range
+    gp_Pnt2d MidPoint = myBSpline->Value(0.5*(myBSpline->FirstParameter() + myBSpline->LastParameter()));
+    Standard_Real TestU = MidPoint.X(), TestV = MidPoint.Y();
+    Standard_Real sense = 0.;
+    if (uperiod)
+    {
+      if (TestU < Uinf - TolU)
+        sense = 1.;
+      else if (TestU > Usup + TolU)
+        sense = -1;
+      while (TestU < Uinf - TolU || TestU > Usup + TolU)
+        TestU += sense * uperiod;
+    }
+    if (vperiod)
+    {
+      sense = 0.;
+      if (TestV < Vinf - TolV)
+        sense = 1.;
+      else if (TestV > Vsup + TolV)
+        sense = -1.;
+      while (TestV < Vinf - TolV || TestV > Vsup + TolV)
+        TestV += sense * vperiod;
+    }
+    gp_Vec2d Offset(TestU - MidPoint.X(), TestV - MidPoint.Y());
+    if (Abs(Offset.X()) > gp::Resolution() ||
+        Abs(Offset.Y()) > gp::Resolution())
+      myBSpline->Translate(Offset);
+    //////////////////////////////////////////
     Geom2dAdaptor_Curve GAC(myBSpline);
     Handle(Adaptor2d_HCurve2d) IC2d = new Geom2dAdaptor_HCurve(GAC);
 #ifdef DEB
     Geom2dAdaptor_Curve GAC(myBSpline);
     Handle(Adaptor2d_HCurve2d) IC2d = new Geom2dAdaptor_HCurve(GAC);
 #ifdef DEB
diff --git a/tests/bugs/modalg_5/bug23839_1 b/tests/bugs/modalg_5/bug23839_1
new file mode 100644 (file)
index 0000000..3df8582
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f1] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_2 b/tests/bugs/modalg_5/bug23839_2
new file mode 100644 (file)
index 0000000..0d49e75
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f4] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_3 b/tests/bugs/modalg_5/bug23839_3
new file mode 100644 (file)
index 0000000..2218abe
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f6] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_4 b/tests/bugs/modalg_5/bug23839_4
new file mode 100644 (file)
index 0000000..8e17450
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f8] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_5 b/tests/bugs/modalg_5/bug23839_5
new file mode 100644 (file)
index 0000000..f1245b4
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f10] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_6 b/tests/bugs/modalg_5/bug23839_6
new file mode 100644 (file)
index 0000000..cf94dd5
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f12] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+
diff --git a/tests/bugs/modalg_5/bug23839_7 b/tests/bugs/modalg_5/bug23839_7
new file mode 100644 (file)
index 0000000..69b4413
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC23839"
+puts "========"
+puts ""
+#######################################################################
+# Projection algorithm produces wrong results for set of data
+#######################################################################
+
+restore [locate_data_file bug23839_f14] f
+mksurface s f
+mkface ff s
+pcurve ff
+explode f e
+mkcurve c f_3
+
+project cx c s
+
+v2d
+2dfit
+set only_screen_axo 1
+