0032470: Modeling Algorithms - BOP wrong result on sphere and box
authorjgv <jgv@opencascade.com>
Fri, 30 Jul 2021 00:09:09 +0000 (03:09 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 4 Aug 2021 17:08:52 +0000 (20:08 +0300)
Correct adjusting pcurves on periodic surfaces: take the middle point as a reference point.

src/ProjLib/ProjLib_ComputeApprox.cxx
tests/bugs/modalg_7/bug32470 [new file with mode: 0644]
tests/bugs/moddata_3/bug5145
tests/draft/angle/K8

index 4d82699..e474511 100644 (file)
@@ -1246,7 +1246,9 @@ void ProjLib_ComputeApprox::Perform
 
     //Return curve home
     Standard_Real UFirst = F.FirstParameter();
-    gp_Pnt P3d = C->Value( UFirst );
+    Standard_Real ULast = F.LastParameter();
+    Standard_Real Umid = (UFirst + ULast)/2;
+    gp_Pnt P3d = C->Value (Umid);
     Standard_Real u = 0., v = 0.;
     switch (SType)
     {
@@ -1301,7 +1303,7 @@ void ProjLib_ComputeApprox::Perform
     if (F.UCouture || (F.VCouture && SType == GeomAbs_Sphere))
     {
       Standard_Real aNbPer;
-      gp_Pnt2d P2d = F.Value(UFirst);
+      gp_Pnt2d P2d = F.Value (Umid);
       du = u - P2d.X();
       du = (du < 0) ? (du - Precision::PConfusion()) : 
         (du + Precision::PConfusion());
diff --git a/tests/bugs/modalg_7/bug32470 b/tests/bugs/modalg_7/bug32470
new file mode 100644 (file)
index 0000000..99c842b
--- /dev/null
@@ -0,0 +1,22 @@
+puts "============================================"
+puts "OCC32470: BOP wrong result on sphere and box"
+puts "============================================"
+puts ""
+
+psphere sph 10
+box b 20 100 100
+ttranslate b 0 -50 -50
+trotate b 0 0 10 0 -1 0 45
+bcut result sph b
+
+checkshape result
+
+checknbshapes result -t -vertex 3 -edge 5 -wire 2 -face 2 -shell 1 -solid 1
+
+set tolres [checkmaxtol result]
+
+if { ${tolres} > 1.e-5} {
+   puts "Error: bad tolerance of result"
+}
+
+checkprops result -s 1229.69 -v 3945.6
index a186a3d..b66dbe3 100644 (file)
@@ -17,6 +17,38 @@ trim c2 c pi 2.*pi
 project c2d1 c1 s
 project c2d2 c2 s
 
+2dcvalue c2d1 0    x1 y1
+2dcvalue c2d1 pi   x2 y2
+2dcvalue c2d2 pi   x3 y3
+2dcvalue c2d2 2*pi x4 y4
+
+set tol 1.e-9
+
+if {[expr abs([dval x1]) - 4.7123885383825099] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs([dval y1]) - 1.5707963267948966] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs([dval x2]) - 6.2831853071795862] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs(-1.2217304763960311 - [dval y2])] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs([dval x3])] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs(-1.2217304763960311 - [dval y3])] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs([dval x4]) - 1.5707967687970734] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+if {[expr abs([dval y4]) - 1.5707963267948948] > $tol} {
+   puts "Error: Wrong projection in 2D"
+}
+
 checklength c2d1 -l 3.68009
 checklength c2d2 -l 3.68009
 
index 050389a..f0211db 100644 (file)
@@ -10,4 +10,4 @@ bfuse f pt pr
 nexplode f f
 depouille result f 0 0 1 f_4 5 0 0 40 0 0 1
 
-checkprops result -s 10112.2
+checkprops result -s 9447.73