From 1b823ad4405dcec3c29c1136f4ba4f80f5d0d3c0 Mon Sep 17 00:00:00 2001 From: msv Date: Wed, 16 Sep 2015 15:25:23 +0300 Subject: [PATCH] 0026642: ShapeUpgrade_UnifySameDomain introduces extremely high vertex tolerances 0026099: Wrong result done by 2d intersection algorithm Detection of intersection for almost parallel lines has been improved. Test-case for issue #26099 and adjusting of test-case boolean volumemaker B6 Algorithm of computation of safe shift value along 2D-line (in order to distance between two points was less than tolerance) has been improved. Correction of some test cases in accordance with their new behavior. Test-case for issue #26642 --- src/IntCurve/IntCurve_IntConicConic_1.cxx | 40 ++++++++++++++++----- tests/boolean/volumemaker/D5 | 1 + tests/bugs/heal/bug26642 | 38 ++++++++++++++++++++ tests/bugs/modalg_6/bug26099 | 23 ++++++++++++ tests/de/step_2/N8 | 2 ++ tests/offset/wire_unclosed_outside_0_025/B4 | 6 ++-- 6 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 tests/bugs/heal/bug26642 create mode 100644 tests/bugs/modalg_6/bug26099 diff --git a/src/IntCurve/IntCurve_IntConicConic_1.cxx b/src/IntCurve/IntCurve_IntConicConic_1.cxx index 9f1f999018..b55f5017dd 100644 --- a/src/IntCurve/IntCurve_IntConicConic_1.cxx +++ b/src/IntCurve/IntCurve_IntConicConic_1.cxx @@ -1229,12 +1229,12 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 //-- 2 : Confondues a la tolerance pres Standard_Integer nbsol; IntRes2d_IntersectionPoint PtSeg1,PtSeg2; - Standard_Real SINL1L2; + Standard_Real aHalfSinL1L2; Standard_Real Tol = TolR; if(TolR< 1e-10) Tol = 1e-10; - LineLineGeometricIntersection(L1,L2,Tol,U1,U2,SINL1L2,nbsol); + LineLineGeometricIntersection(L1,L2,Tol,U1,U2,aHalfSinL1L2,nbsol); gp_Vec2d Tan1=L1.Direction(); gp_Vec2d Tan2=L2.Direction(); @@ -1254,7 +1254,7 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 //-- d une distance superieure a Tol. //--------------------------------------------------- IntRes2d_Position Pos1a,Pos2a,Pos1b,Pos2b; - Standard_Real d=Tol/(SINL1L2); + Standard_Real d = 0.5 * Tol / aHalfSinL1L2; Standard_Real U1inf=U1-d; Standard_Real U1sup=U1+d; Standard_Real U1mU2=U1-U2; @@ -1345,7 +1345,7 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 //------------------------------------------------------ - } //--------------- Fin du cas : 1 seul point -------------------- + } //--------------- Fin du cas : 1 seul point -------------------- else { //-- Intersection AND Domain1 --------> Segment --------------------- @@ -1364,7 +1364,7 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 if(Res2sup_m_Res2inf < 0.0) { //-- Pas de solutions On retourne Vide } - else if(((Res2sup-Res2inf) > LongMiniSeg) + else if((Res2sup_m_Res2inf > LongMiniSeg) || ((Pos2a==Pos2b)&&(Pos2a!=IntRes2d_Middle))) { //----------- Calcul des attributs du segment -------------- //-- Attention, les bornes Res1inf(sup) bougent donc il faut @@ -1646,17 +1646,41 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 //-- Attention Res1sup peut etre different de U2 //-- Mais on a Res1sup-Res1inf < Tol - //gka #0022833 + //gka #0022833 IntRes2d_TypeTrans aCurTrans = ( ProdVectTan >= TOLERANCE_ANGULAIRE ? IntRes2d_In : ( ProdVectTan <= -TOLERANCE_ANGULAIRE ? IntRes2d_Out : IntRes2d_Undecided ) ); - IntRes2d_IntersectionPoint NewPoint1; + IntRes2d_IntersectionPoint NewPoint1; if( computeIntPoint(Domain2, Domain1, L2, L1, aCosT1T2, U2, U1, Res2inf, Res2sup, 2, aCurTrans, NewPoint1 ) ) - Append(NewPoint1); + Append(NewPoint1); } } } + +//#ifdef OCCT_DEBUG +// if (NbPoints() || NbSegments()) +// { +// static int cnt = 0; cnt++; +// +// printf("line l1_%03d %.15g %.15g %.15g %.15g\n", cnt, L1.Location().X(), L1.Location().Y(), L1.Direction().X(), L1.Direction().Y()); +// +// if (Domain1.HasFirstPoint() && Domain1.HasLastPoint()) +// printf("trim l1_%03d l1_%03d %.15g %.15g\n", cnt, cnt, Domain1.FirstParameter(), Domain1.LastParameter()); +// +// printf("line l2_%03d %.15g %.15g %.15g %.15g\n", cnt, L2.Location().X(), L2.Location().Y(), L2.Direction().X(), L2.Direction().Y()); +// +// if (Domain2.HasFirstPoint() && Domain2.HasLastPoint()) +// printf("trim l2_%03d l2_%03d %.15g %.15g\n", cnt, cnt, Domain2.FirstParameter(), Domain2.LastParameter()); +// +// for (int i=1; i <= NbPoints(); i++) +// printf("point p%d_%03d %.15g %.15g\n", i, cnt, Point(i).Value().X(), Point(i).Value().Y()); +// +// for (int i=1; i <= NbSegments(); i++) +// printf("point s1_%d_%03d %.15g %.15g; point s2_%d_%03d %.15g %.15g\n", i, cnt, Segment(i).FirstPoint().Value().X(), Segment(i).FirstPoint().Value().Y(), i, cnt, Segment(i).LastPoint().Value().X(), Segment(i).LastPoint().Value().Y()); +// } +//#endif + } else { if(nbsol==2) { //== Droites confondues a la tolerance pres diff --git a/tests/boolean/volumemaker/D5 b/tests/boolean/volumemaker/D5 index b3a6af6f5f..3ae6b873ca 100644 --- a/tests/boolean/volumemaker/D5 +++ b/tests/boolean/volumemaker/D5 @@ -3,6 +3,7 @@ puts "TODO OCC26020 ALL: Error: bopcheck failed" puts "TODO OCC26020 Debian60-64: Error : The area of the resulting shape is" +puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to" # planar face plane pln_f1 0 -1450 -4.4408920985006262e-015 0 1 1.1102230246251565e-016 diff --git a/tests/bugs/heal/bug26642 b/tests/bugs/heal/bug26642 new file mode 100644 index 0000000000..5f5e174c47 --- /dev/null +++ b/tests/bugs/heal/bug26642 @@ -0,0 +1,38 @@ +puts "========" +puts "OCC26642" +puts "========" +puts "" +############################################################################ +# ShapeUpgrade_UnifySameDomain introduces extremely high vertex tolerances +############################################################################ + +restore [locate_data_file OCC26656_unify.input.brep] i + +set bug_info [tolerance i] +set value_1 [lindex $bug_info 1] +set value_1 [string trim [string range $value_1 [expr {[string first "=" $value_1] + 1}] [expr {[string length $value_1] - 1}]]] + +unifysamedom r i + +set bug_info [tolerance i] +set value_2 [lindex $bug_info 1] +set value_2 [string trim [string range $value_2 [expr {[string first "=" $value_2] + 1}] [expr {[string length $value_2] - 1}]]] +set bug_info [tolerance r] +set value_3 [lindex $bug_info 1] +set value_3 [string trim [string range $value_3 [expr {[string first "=" $value_3] + 1}] [expr {[string length $value_3] - 1}]]] + +if {$value_1 > $value_2} { + set diff_12 [expr {$value_1 - $value_2}] +} else { + set diff_12 [expr {$value_2 - $value_1}] +} + +if {$value_1 > $value_3} { + set diff_13 [expr {$value_1 - $value_3}] +} else { + set diff_13 [expr {$value_3 - $value_1}] +} + +if {$diff_12 > 1.e-06 || $diff_13 > 1.e-06} { + puts "ERROR: OCC26642 is reproduced. Command unifysamedom works wrongly." +} diff --git a/tests/bugs/modalg_6/bug26099 b/tests/bugs/modalg_6/bug26099 new file mode 100644 index 0000000000..8fe535c419 --- /dev/null +++ b/tests/bugs/modalg_6/bug26099 @@ -0,0 +1,23 @@ +puts "========" +puts "OCC26099" +puts "========" +puts "" +################################################## +# Wrong result done by 2d intersection algorithm +################################################## + +restore [locate_data_file OCC26099-f.brep] f +explode f e +pcurve c4 f_4 f +pcurve c5 f_5 f +set bug_info [2dintersect c4 c5] + +if {[regexp {fist: ([\-0-9.]*) .*second: ([\-0-9.]*)} $bug_info dummy par1 par2] == 0} { + puts "ERROR: OCC26099 is reproduced. No intersection." +} + +set refpar1 0.98989794855663704 +set refpar2 0 +if {[expr abs($par1-$refpar1)] > 0.0001 || [expr abs($par2-$refpar2)] > 0.0001} { + puts "ERROR: OCC26099 is reproduced. Parameters are $par1 and $par2, expected $refpar1 and $refpar2" +} diff --git a/tests/de/step_2/N8 b/tests/de/step_2/N8 index bfc960e9b2..909867c6b3 100644 --- a/tests/de/step_2/N8 +++ b/tests/de/step_2/N8 @@ -1,3 +1,5 @@ +puts "TODO OCC12345 ALL: TPSTAT : Faulty" + # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: TPSTAT : Faulty" diff --git a/tests/offset/wire_unclosed_outside_0_025/B4 b/tests/offset/wire_unclosed_outside_0_025/B4 index 49cfa136ae..0fbddbf243 100644 --- a/tests/offset/wire_unclosed_outside_0_025/B4 +++ b/tests/offset/wire_unclosed_outside_0_025/B4 @@ -2,8 +2,8 @@ puts "TODO OCC25109 ALL: Faulty shapes in variables" restore [locate_data_file case_3_wire2.brep] s -set length 957.647 -set nbsh_v 86 -set nbsh_e 86 +set length 946.063 +set nbsh_v 79 +set nbsh_e 79 set nbsh_w 2 -- 2.39.5