0025892: Wrong result obtained by projection algorithm.
authoraml <aml@opencascade.com>
Thu, 19 Mar 2015 13:33:43 +0000 (16:33 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 19 Mar 2015 14:08:25 +0000 (17:08 +0300)
1) Treatment of case when projection algorithm to BSpline surface return null 2d curve.
2) Changed approximation of next step in default projection algorithm.
3) Special handling of surface of revolution added.

"Period jump" handling evaded in case when curve not computed.

Test cases for issue CR25892

Small correction of test cases fot CR25892

18 files changed:
src/ProjLib/ProjLib_CompProjectedCurve.cxx
src/ProjLib/ProjLib_ProjectedCurve.cxx
src/ProjLib/ProjLib_Projector.cxx
tests/bugs/moddata_2/bug469
tests/bugs/moddata_3/bug25892_01 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_02 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_03 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_04 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_05 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_06 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_07 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_08 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_09 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_10 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_11 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_12 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_13 [new file with mode: 0644]
tests/bugs/moddata_3/bug25892_14 [new file with mode: 0644]

index c1b7a9c..37083ed 100644 (file)
@@ -767,7 +767,7 @@ void ProjLib_CompProjectedCurve::Init()
 
     t = Triple.X() + Step;
     if (t > LastU) t = LastU;
-
+    Standard_Real prevStep = Step;
     Standard_Real U0, V0;
     gp_Pnt2d aLowBorder(mySurface->FirstUParameter(),mySurface->FirstVParameter());
     gp_Pnt2d aUppBorder(mySurface->LastUParameter(), mySurface->LastVParameter());
@@ -776,8 +776,8 @@ void ProjLib_CompProjectedCurve::Init()
     while (t <= LastU && new_part) 
     {
 
-      U0 = Triple.Y() + (Triple.Y() - prevTriple.Y());
-      V0 = Triple.Z() + (Triple.Z() - prevTriple.Z());
+      U0 = Triple.Y() + (Step / prevStep) * (Triple.Y() - prevTriple.Y());
+      V0 = Triple.Z() + (Step / prevStep) * (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()]
@@ -837,9 +837,27 @@ void ProjLib_CompProjectedCurve::Init()
       // Go further
       else 
       {
-        prevTriple = Triple; 
+        prevTriple = Triple;
+        prevStep = Step;
         Triple = gp_Pnt(t, aPrjPS.Solution().X(), aPrjPS.Solution().Y());
 
+        if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution &&
+           (Abs (Triple.Z() - mySurface->FirstVParameter()) < Precision::Confusion() ||
+            Abs (Triple.Z() - mySurface->LastVParameter() ) < Precision::Confusion() ))
+        {
+          // Go out from possible attraktor.
+
+          Standard_Real U,V;
+          InitialPoint(myCurve->Value(t), t, myCurve, mySurface, myTolU, myTolV, U, V);
+          if (Abs (Abs(U - Triple.Y()) - mySurface->UPeriod()) < Precision::Confusion())
+          {
+            // Handle period jump.
+            U = Triple.Y();
+          }
+          Triple.SetY(U);
+          Triple.SetZ(V);
+        }
+
         if((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10)
           mySequence->Value(myNbCurves)->Append(Triple);
         if (t == LastU) {t = LastU + 1; break;}//return;
@@ -854,7 +872,7 @@ void ProjLib_CompProjectedCurve::Init()
         Step = WalkStep;
         t += Step;
         if (t > (LastU-MinStep/2) ) 
-        { 
+        {
           Step =Step+LastU-t;
           t = LastU;
         }      
index f1cfe27..934ca7a 100644 (file)
@@ -332,6 +332,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
   Standard_Real LastPar  = C->LastParameter();
   GeomAbs_SurfaceType SType = mySurface->GetType();
   GeomAbs_CurveType   CType = myCurve->GetType();
+  Standard_Boolean isAnalyticalSurf = Standard_True;
 
   switch (SType)
   {
@@ -384,6 +385,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
     case GeomAbs_BezierSurface:
     case GeomAbs_BSplineSurface:
       {
+        isAnalyticalSurf = Standard_False;
         Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
         Standard_Integer SingularCase[2];
         Standard_Real f, l, dt;
@@ -431,34 +433,38 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
 
         Handle(Geom2d_BSplineCurve) aRes = polar.BSpline();
 
-        if(IsTrimmed[0] || IsTrimmed[1])
+        if (!aRes.IsNull())
         {
-          if(IsTrimmed[0])
+          if( (IsTrimmed[0] || IsTrimmed[1]))
           {
-            //Add segment before start of curve
-            f = myCurve->FirstParameter();
-            ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]);
-          }
-          if(IsTrimmed[1])
-          {
-            //Add segment after end of curve
-            l = myCurve->LastParameter();
-            ExtendC2d(aRes, l,  dt, U1, U2, V1, V2, 1, SingularCase[1]);
+            if(IsTrimmed[0])
+            {
+              //Add segment before start of curve
+              f = myCurve->FirstParameter();
+              ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]);
+            }
+            if(IsTrimmed[1])
+            {
+              //Add segment after end of curve
+              l = myCurve->LastParameter();
+              ExtendC2d(aRes, l,  dt, U1, U2, V1, V2, 1, SingularCase[1]);
+            }
+            Handle(Geom2d_Curve) NewCurve2d;
+            GeomLib::SameRange(Precision::PConfusion(), aRes,
+              aRes->FirstParameter(), aRes->LastParameter(),
+              FirstPar, LastPar, NewCurve2d);
+            aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
           }
-          Handle(Geom2d_Curve) NewCurve2d;
-          GeomLib::SameRange(Precision::PConfusion(), aRes,
-                             aRes->FirstParameter(), aRes->LastParameter(),
-                             FirstPar, LastPar, NewCurve2d);
-          aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
+          myResult.SetBSpline(aRes);
+          myResult.Done();
+          myResult.SetType(GeomAbs_BSplineCurve);
         }
-        myResult.SetBSpline(aRes);
-        myResult.Done();
-        myResult.SetType(GeomAbs_BSplineCurve);
       }
       break;
 
     default:
       {
+        isAnalyticalSurf = Standard_False;
         Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
         Standard_Real Vsingular[2] = {0.0 , 0.0}; //for surfaces of revolution
         Standard_Real f = 0.0, l = 0.0, dt = 0.0;
@@ -546,39 +552,44 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
 
         Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d();
 
-        if(IsTrimmed[0] || IsTrimmed[1])
+        if (!aRes.IsNull())
         {
-          // Treatment only for surface of revolution
-          Standard_Real u1, u2, v1, v2;
-          u1 = mySurface->FirstUParameter();
-          u2 = mySurface->LastUParameter();
-          v1 = mySurface->FirstVParameter();
-          v2 = mySurface->LastVParameter();
-
-          if(IsTrimmed[0])
-          {
-            //Add segment before start of curve
-            ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3);
-          }
-          if(IsTrimmed[1])
+          if(IsTrimmed[0] || IsTrimmed[1])
           {
-            //Add segment after end of curve
-            ExtendC2d(aRes, l,  dt, u1, u2, v1, Vsingular[1], 1, 4);
+            // Treatment only for surface of revolution
+            Standard_Real u1, u2, v1, v2;
+            u1 = mySurface->FirstUParameter();
+            u2 = mySurface->LastUParameter();
+            v1 = mySurface->FirstVParameter();
+            v2 = mySurface->LastVParameter();
+
+            if(IsTrimmed[0])
+            {
+              //Add segment before start of curve
+              ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3);
+            }
+            if(IsTrimmed[1])
+            {
+              //Add segment after end of curve
+              ExtendC2d(aRes, l,  dt, u1, u2, v1, Vsingular[1], 1, 4);
+            }
+            Handle(Geom2d_Curve) NewCurve2d;
+            GeomLib::SameRange(Precision::PConfusion(), aRes,
+              aRes->FirstParameter(), aRes->LastParameter(),
+              FirstPar, LastPar, NewCurve2d);
+            aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
           }
-          Handle(Geom2d_Curve) NewCurve2d;
-          GeomLib::SameRange(Precision::PConfusion(), aRes,
-                             aRes->FirstParameter(), aRes->LastParameter(),
-                             FirstPar, LastPar, NewCurve2d);
-          aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d);
-        }
 
-        myResult.SetBSpline(aRes);
-        myResult.Done();
-        myResult.SetType(GeomAbs_BSplineCurve);
+          myResult.SetBSpline(aRes);
+          myResult.Done();
+          myResult.SetType(GeomAbs_BSplineCurve);
+        }
       }
   }
-  if ( !myResult.IsDone()) 
+
+  if ( !myResult.IsDone() && isAnalyticalSurf)
   {
+    // Use advanced analytical projector if base analytical projection failed.
     ProjLib_ComputeApprox Comp( myCurve, mySurface, myTolerance);
     myResult.Done();
 
@@ -602,8 +613,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
     }
     myTolerance = Comp.Tolerance();
   }
-
-  else
+  else if (myResult.IsDone())
   {
     // On remet arbitrairement la tol atteinte a une valeur
     // petite en attendant mieux. dub lbo 11/03/97
index 11c1a68..1c9556e 100644 (file)
@@ -29,6 +29,8 @@
 
 ProjLib_Projector::ProjLib_Projector()
 {
+  isDone = Standard_False;
+  myType = GeomAbs_BSplineCurve;
 }
 
 
index dd00b42..5e44d4e 100755 (executable)
@@ -1,7 +1,9 @@
 #puts "TODO OCC12345 ALL: An exception was caught"
 #puts "TODO OCC12345 ALL: \\*\\* Exception \\*\\*.*"
-puts "TODO OCC12345 ALL: TEST INCOMPLETE"
-puts "TODO OCC12345 ALL: xception"
+#puts "TODO OCC12345 ALL: TEST INCOMPLETE"
+#puts "TODO OCC12345 ALL: xception"
+puts "TODO OCC25892 ALL: Faulty shapes in variables"
+puts "TODO OCC25892 ALL: The square of result shape is"
 
 puts "========================"
 puts " OCC469 "
diff --git a/tests/bugs/moddata_3/bug25892_01 b/tests/bugs/moddata_3/bug25892_01
new file mode 100644 (file)
index 0000000..08af3bc
--- /dev/null
@@ -0,0 +1,20 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c001] c
+restore [locate_data_file bug25892_f001] f
+
+mksurface s f
+
+catch {project cx c s}
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_02 b/tests/bugs/moddata_3/bug25892_02
new file mode 100644 (file)
index 0000000..707f876
--- /dev/null
@@ -0,0 +1,20 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c002] c
+restore [locate_data_file bug25892_f002] f
+
+mksurface s f
+
+catch {project cx c s}
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_03 b/tests/bugs/moddata_3/bug25892_03
new file mode 100644 (file)
index 0000000..3de819b
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c003] c
+restore [locate_data_file bug25892_s003] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_04 b/tests/bugs/moddata_3/bug25892_04
new file mode 100644 (file)
index 0000000..fe863c4
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c004] c
+restore [locate_data_file bug25892_s004] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_05 b/tests/bugs/moddata_3/bug25892_05
new file mode 100644 (file)
index 0000000..f721d2d
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c005] c
+restore [locate_data_file bug25892_s005] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_06 b/tests/bugs/moddata_3/bug25892_06
new file mode 100644 (file)
index 0000000..442d6ed
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c006] c
+restore [locate_data_file bug25892_s006] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_07 b/tests/bugs/moddata_3/bug25892_07
new file mode 100644 (file)
index 0000000..84e8afb
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c007] c
+restore [locate_data_file bug25892_s007] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_08 b/tests/bugs/moddata_3/bug25892_08
new file mode 100644 (file)
index 0000000..8780644
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c008] c
+restore [locate_data_file bug25892_s008] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_09 b/tests/bugs/moddata_3/bug25892_09
new file mode 100644 (file)
index 0000000..e44f294
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c009] c
+restore [locate_data_file bug25892_s009] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_10 b/tests/bugs/moddata_3/bug25892_10
new file mode 100644 (file)
index 0000000..50a2855
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c010] c
+restore [locate_data_file bug25892_s010] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_11 b/tests/bugs/moddata_3/bug25892_11
new file mode 100644 (file)
index 0000000..6354735
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c011] c
+restore [locate_data_file bug25892_s011] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_12 b/tests/bugs/moddata_3/bug25892_12
new file mode 100644 (file)
index 0000000..6edf2f3
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c012] c
+restore [locate_data_file bug25892_s012] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_13 b/tests/bugs/moddata_3/bug25892_13
new file mode 100644 (file)
index 0000000..09ad7c7
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c013] c
+restore [locate_data_file bug25892_s013] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug25892_14 b/tests/bugs/moddata_3/bug25892_14
new file mode 100644 (file)
index 0000000..8f4d3d5
--- /dev/null
@@ -0,0 +1,18 @@
+puts "============"
+puts "OCC25892"
+puts "============"
+puts ""
+#######################################################################
+# Wrong result obtained by projection algorithm.
+#######################################################################
+
+restore [locate_data_file bug25892_c014] c
+restore [locate_data_file bug25892_s014] s
+
+project cx c s
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1