diff --git a/src/IntPatch/IntPatch_ImpImpIntersection_5.gxx b/src/IntPatch/IntPatch_ImpImpIntersection_5.gxx index 5b54378f8c..df59aea0fd 100644 --- a/src/IntPatch/IntPatch_ImpImpIntersection_5.gxx +++ b/src/IntPatch/IntPatch_ImpImpIntersection_5.gxx @@ -601,26 +601,47 @@ Standard_Boolean IntCoSp(const IntSurf_Quadric& Quad1, gp_Circ cirsol = inter.Circle(1); param = ElCLib::LineParameter(Co.Axis(), - cirsol.Location()); - if (param >= paramapex) { - - ElCLib::D1(0.,cirsol,ptref,Tgt); - Standard_Real qwe = Tgt.DotCross(Quad2.Normale(ptref), - Quad1.Normale(ptref)); - if(qwe> 0.000000001) { - trans1 = IntSurf_Out; - trans2 = IntSurf_In; - } - else if(qwe< -0.000000001){ - trans1 = IntSurf_In; - trans2 = IntSurf_Out; - } - else { - trans1=trans2=IntSurf_Undecided; - } - Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2); - slin.Append(glig); + cirsol.Location()); + ElCLib::D1(0., cirsol, ptref, Tgt); + Standard_Real qwe = Tgt.DotCross(Quad2.Normale(ptref), + Quad1.Normale(ptref)); + + if (param >= paramapex) + { + if (qwe > Precision::PConfusion()) + { + trans1 = IntSurf_Out; + trans2 = IntSurf_In; + } + else if (qwe < -Precision::PConfusion()) + { + trans1 = IntSurf_In; + trans2 = IntSurf_Out; + } + else + { + trans1 = trans2 = IntSurf_Undecided; + } } + else + { + if (qwe < -Precision::PConfusion()) + { + trans1 = IntSurf_Out; + trans2 = IntSurf_In; + } + else if (qwe > Precision::PConfusion()) + { + trans1 = IntSurf_In; + trans2 = IntSurf_Out; + } + else + { + trans1 = trans2 = IntSurf_Undecided; + } + } + Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol, Standard_False, trans1, trans2); + slin.Append(glig); } break; diff --git a/tests/lowalgos/intss/begin b/tests/lowalgos/intss/begin index b9d05984d3..b6734b105d 100644 --- a/tests/lowalgos/intss/begin +++ b/tests/lowalgos/intss/begin @@ -28,3 +28,23 @@ proc CheckLoops {theCurve theCosMaxAngle {theNbPoints 1000.0}} { dset dz1 dz2 } } + +# General check of the result of geometrical intersection +help CheckIntersectionResult { surf1 surf2 ListOfCurves NbPoints TolerS1 TolerS2 } +proc CheckIntersectionResult {theSurf1 theSurf2 theListOfCurves theNbPoints theTolerS1 theTolerS2} { + upvar #0 $theSurf1 s1 + upvar #0 $theSurf2 s2 + + foreach a $theListOfCurves { + puts "** Check of $a **" + upvar #0 $a aCurve + bounds aCurve U1 U2 + + if {[dval U2-U1] < 1.0e-9} { + puts "Error: Wrong range of $a" + } + + xdistcs aCurve s1 U1 U2 $theNbPoints $theTolerS1 + xdistcs aCurve s2 U1 U2 $theNbPoints $theTolerS2 + } +} \ No newline at end of file diff --git a/tests/lowalgos/intss/bug21494 b/tests/lowalgos/intss/bug21494 deleted file mode 100644 index f91ce163eb..0000000000 --- a/tests/lowalgos/intss/bug21494 +++ /dev/null @@ -1,22 +0,0 @@ -puts "TODO OCC21494 ALL: Error: Intersection between cone and sphere fails" - -puts "========" -puts "OCC21494" -puts "========" -puts "" -############################################ -# Intersection between cone and sphere fails -############################################ - -pcone c 15 0 10 -psphere s 10 -explode c f -explode s f -mksurface sc c_1 -mksurface ss s_1 - -intersect i sc ss - -if { [info exist i_1] == 0 } { - puts "Error: Intersection between cone and sphere fails" -} diff --git a/tests/lowalgos/intss/bug21494_1 b/tests/lowalgos/intss/bug21494_1 new file mode 100644 index 0000000000..81f80ad557 --- /dev/null +++ b/tests/lowalgos/intss/bug21494_1 @@ -0,0 +1,32 @@ +puts "========" +puts "OCC21494: Intersection between cone and sphere fails" +puts "========" +puts "" + +pcone bc 15 0 10 +psphere bs 10 +explode bc f +explode bs f + +set log [bopcurves bc_1 bs_1 -2d] + +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} $log full Toler NbCurv + +if { ![regexp {1 point\(s\) found} $log full] } { + puts "Error: Cone apex and Pole of sphere are excluded from the intersection result" +} + +if {$NbCurv != 1} { + puts "Error: Please check NbCurves for intersector" +} + +if { $Toler > 2.0e-7} { + puts "Error: Big tolerance value" +} + +smallview +don c_* p_* +fit +disp bc bs + +checkview -screenshot -2d -path ${imagedir}/${test_image}_3d.png diff --git a/tests/lowalgos/intss/bug21494_2 b/tests/lowalgos/intss/bug21494_2 new file mode 100644 index 0000000000..d13d7126c5 --- /dev/null +++ b/tests/lowalgos/intss/bug21494_2 @@ -0,0 +1,78 @@ +puts "========" +puts "OCC21494" +puts "========" +puts "" +############################################ +# Intersection between cone and sphere fails +############################################ + +foreach a [directory res*] {unset $a} + +set aGoodNbCurves 1 + +pcone c 15 0 10 +psphere s 10 +explode c f +explode s f +mksurface sc c_1 +mksurface ss s_1 + +intersect res sc ss + +if { ![info exist res_p_1] } { + puts "Error: Cone apex and Pole of sphere are excluded from the intersection result" +} + +set che [whatis res] +set ind [string first "3d curve" $che] +if {${ind} >= 0} { + #Only variable "res" exists + renamevar res res_1 +} + +bclearobjects +bcleartools + +set CurvesList {} + +set ic 1 +set AllowRepeat 1 +while { $AllowRepeat != 0 } { + set che [whatis res_$ic] + set ind [string first "3d curve" $che] + if {${ind} < 0} { + set AllowRepeat 0 + } else { + lappend CurvesList res_$ic + mkedge ee res_$ic + baddobjects ee + incr ic + } +} + +set ic [expr $ic - 1] + +if { $ic != $aGoodNbCurves } { + puts "Error: $aGoodNbCurves curves is expected but $ic ones are found" +} else { + CheckIntersectionResult sc ss $CurvesList 100 2.0e-7 2.0e-7 + + if {$ic > 1} { + bfillds + bbuild result + } elseif {$ic > 0} { + mkedge result res_1 + } + + # Check gaps between intersection curves + checksection result -r 0 + checkmaxtol result -min_tol 2.0e-7 + + checknbshapes result -edge 1 -vertex 1 +} + +smallview +don result* +fit + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png