diff --git a/src/IntCurve/IntCurve_IntConicConic_1.cxx b/src/IntCurve/IntCurve_IntConicConic_1.cxx index 1866e68418..ddb81dc5dc 100644 --- a/src/IntCurve/IntCurve_IntConicConic_1.cxx +++ b/src/IntCurve/IntCurve_IntConicConic_1.cxx @@ -552,12 +552,12 @@ void DomainIntersection(const IntRes2d_Domain& Domain if(Domain.HasFirstPoint()) { if(U1sup < (Domain.FirstParameter()-Domain.FirstTolerance())) { - Res1inf=1; Res1sup=-1; - return; - } + Res1inf=1; Res1sup=-1; + return; + } if(U1inf>(Domain.FirstParameter()+Domain.FirstTolerance())) { - Res1inf=U1inf; - PosInf=IntRes2d_Middle; + Res1inf=U1inf; + PosInf=IntRes2d_Middle; } else { Res1inf=Domain.FirstParameter(); @@ -575,8 +575,8 @@ void DomainIntersection(const IntRes2d_Domain& Domain return; } if(U1sup<(Domain.LastParameter()-Domain.LastTolerance())) { - Res1sup=U1sup; - PosSup=IntRes2d_Middle; + Res1sup=U1sup; + PosSup=IntRes2d_Middle; } else { Res1sup=Domain.LastParameter(); @@ -602,9 +602,9 @@ void DomainIntersection(const IntRes2d_Domain& Domain /*if(PosInf==IntRes2d_Head) { if(Res1sup <= (Res1inf+Domain.FirstTolerance())) { Res1sup=Res1inf; - PosSup=IntRes2d_Head; - } + PosSup=IntRes2d_Head; } +} if(PosSup==IntRes2d_End) { if(Res1inf >= (Res1sup-Domain.LastTolerance())) { Res1inf=Res1sup; @@ -1193,6 +1193,30 @@ static Standard_Boolean computeIntPoint(const IntRes2d_Domain& theCurDomain, return Standard_True; } +//======================================================================= +//function : CheckLLCoincidence +//purpose : Returns true if input are trimmed curves and they coincide +// within tolerance +//======================================================================= +static Standard_Boolean CheckLLCoincidence(const gp_Lin2d& L1, + const gp_Lin2d& L2, + const IntRes2d_Domain& Domain1, + const IntRes2d_Domain& Domain2, + const Standard_Real theTol) +{ + Standard_Boolean isFirst1 = (Domain1.HasFirstPoint() && + L2.Distance(Domain1.FirstPoint()) < theTol); + Standard_Boolean isLast1 = (Domain1.HasLastPoint() && + L2.Distance(Domain1.LastPoint()) < theTol); + if (isFirst1 && isLast1) + return Standard_True; + Standard_Boolean isFirst2 = (Domain2.HasFirstPoint() && + L1.Distance(Domain2.FirstPoint()) < theTol); + Standard_Boolean isLast2 = (Domain2.HasLastPoint() && + L1.Distance(Domain2.LastPoint()) < theTol); + return isFirst2 && isLast2; +} + //---------------------------------------------------------------------- void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 ,const IntRes2d_Domain& Domain1 @@ -1223,6 +1247,9 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1 done=Standard_True; + if(nbsol==1 && CheckLLCoincidence(L1, L2, Domain1, Domain2, Tol)) + nbsol = 2; + if(nbsol==1) { //--------------------------------------------------- //-- d: distance du point I a partir de laquelle les @@ -1321,7 +1348,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 --------------------- @@ -1622,13 +1649,13 @@ 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); } } diff --git a/tests/boolean/volumemaker/B6 b/tests/boolean/volumemaker/B6 index b8d4779af2..3e3fd7d58f 100644 --- a/tests/boolean/volumemaker/B6 +++ b/tests/boolean/volumemaker/B6 @@ -3,7 +3,7 @@ puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_" puts "TODO OCC26020 ALL: Error: bopcheck failed" -puts "TODO OCC26020 Linux: Error : The area of the resulting shape is" +puts "TODO OCC26020 ALL: Error : The area of the resulting shape is" # planar face plane pln_f1 35.877464033656999 5.9462928582193458e-016 -25.973690230789806 -0.64944804833018333 -3.0834627769631957e-016 -0.76040596560003137 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" +}