0024633: Incorrect projection of a curve on a surface
authorjgv <jgv@opencascade.com>
Thu, 27 Mar 2014 12:51:39 +0000 (16:51 +0400)
committerbugmaster <bugmaster@opencascade.com>
Fri, 28 Mar 2014 11:55:16 +0000 (15:55 +0400)
Test cases for issue CR24633

src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
tests/bugs/moddata_3/bug24633_1 [new file with mode: 0644]
tests/bugs/moddata_3/bug24633_2 [new file with mode: 0644]

index 013fe7b..347fd4a 100644 (file)
@@ -1057,14 +1057,59 @@ Handle(Adaptor2d_HCurve2d)
            (pntproj, Surf->Surface(), U0, V0, TolU, TolV) ;
          
          if (aLocateExtPS.IsDone())
-           if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d) {  //OCC217
-           //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
+          {
+           if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d)
+            {  //OCC217
+              //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
              (aLocateExtPS.Point()).Parameter(U0,V0);
              U1 = U0 + usens*uperiod;
              V1 = V0 + vsens*vperiod;
              Pts2d(i).SetCoord(U1,V1);
              myProjIsDone = Standard_True;
            }
+            else
+            {
+              Extrema_ExtPS aGlobalExtr(pntproj, Surf->Surface(), TolU, TolV);
+              if (aGlobalExtr.IsDone())
+              {
+                Standard_Real LocalMinSqDist = RealLast();
+                Standard_Integer imin = 0;
+                for (Standard_Integer isol = 1; isol <= aGlobalExtr.NbExt(); isol++)
+                {
+                  Standard_Real aSqDist = aGlobalExtr.SquareDistance(isol);
+                  if (aSqDist < LocalMinSqDist)
+                  {
+                    LocalMinSqDist = aSqDist;
+                    imin = isol;
+                  }
+                }
+                if (LocalMinSqDist < DistTol3d * DistTol3d)
+                {
+                  Standard_Real LocalU, LocalV;
+                  aGlobalExtr.Point(imin).Parameter(LocalU, LocalV);
+                  if (uperiod > 0. && Abs(U0 - LocalU) >= uperiod/2.)
+                  {
+                    if (LocalU > U0)
+                      usens = -1;
+                    else
+                      usens = 1;
+                  }
+                  if (vperiod > 0. && Abs(V0 - LocalV) >= vperiod/2.)
+                  {
+                    if (LocalV > V0)
+                      vsens = -1;
+                    else
+                      vsens = 1;
+                  }
+                  U0 = LocalU; V0 = LocalV;
+                  U1 = U0 + usens*uperiod;
+                  V1 = V0 + vsens*vperiod;
+                  Pts2d(i).SetCoord(U1,V1);
+                  myProjIsDone = Standard_True;
+                }
+              }
+            }
+          }
          if(!myProjIsDone && uperiod) {
            Standard_Real Uinf, Usup, Uaux;
            Uinf = Surf->Surface().FirstUParameter();
diff --git a/tests/bugs/moddata_3/bug24633_1 b/tests/bugs/moddata_3/bug24633_1
new file mode 100644 (file)
index 0000000..9510b56
--- /dev/null
@@ -0,0 +1,27 @@
+puts "============"
+puts "OCC24633"
+puts "============"
+puts ""
+#######################################################################
+# Incorrect projection of a curve on a surface
+#######################################################################
+
+restore [locate_data_file bug24633_comp_49.brep] a
+
+explode a
+mkcurve c a_1
+mksurface s a_2
+pcurve a_2
+
+project prj c s
+
+set prj_length [lindex [length prj] end]
+
+set good_length 7.2662499016218058
+checkreal "prj_length" ${prj_length} ${good_length} 0.01 0.01
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1
diff --git a/tests/bugs/moddata_3/bug24633_2 b/tests/bugs/moddata_3/bug24633_2
new file mode 100644 (file)
index 0000000..4d2c6bc
--- /dev/null
@@ -0,0 +1,27 @@
+puts "============"
+puts "OCC24633"
+puts "============"
+puts ""
+#######################################################################
+# Incorrect projection of a curve on a surface
+#######################################################################
+
+restore [locate_data_file bug24633_comp_50.brep] a
+
+explode a
+mkcurve c a_1
+mksurface s a_2
+pcurve a_2
+
+project prj c s
+
+set prj_length [lindex [length prj] end]
+
+set good_length 7.2662499016218058
+checkreal "prj_length" ${prj_length} ${good_length} 0.01 0.01
+
+#v2d2
+view 1 -2D-  728 20 400 400
+
+2dfit
+set only_screen_axo 1