diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx index 8c6728367c..7a54be1ebf 100644 --- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -68,6 +68,46 @@ static void AddWLine(IntPatch_SequenceOfLine &theLines, const Handle(IntPatch_WLine) &theWLine, const Standard_Real Deflection); +//======================================================================= +//function : DublicateOfLinesProcessing +//purpose : Decides, if rejecting current line is necessary +//======================================================================= +static void DublicateOfLinesProcessing( const IntWalk_PWalking& thePW, + const Standard_Integer theWLID, + IntPatch_SequenceOfLine& theLines, + Standard_Boolean& theIsRejectReq) +{ + const Handle(IntPatch_WLine)& anExistWL = + *((Handle(IntPatch_WLine)*)&theLines.Value(theWLID)); + const Standard_Integer aNbPrevPoints = anExistWL->NbPnts(); + const Standard_Integer aNbCurrPoints = thePW.NbPoints(); + + if(aNbPrevPoints < aNbCurrPoints) + {//Remove preview line + theLines.Remove(theWLID); + theIsRejectReq = Standard_False; + } + else if(aNbPrevPoints == aNbCurrPoints) + { + Standard_Real aLPrev = 0.0, aLCurr = 0.0; + for(Standard_Integer aNbPP = 1; aNbPP < aNbPrevPoints; aNbPP++) + { + const gp_Pnt aP1prev(anExistWL->Point(aNbPP).Value()), + aP2prev(anExistWL->Point(aNbPP+1).Value()); + const gp_Pnt aP1curr(thePW.Value(aNbPP).Value()), + aP2curr(thePW.Value(aNbPP+1).Value()); + + aLPrev += aP1prev.Distance(aP2prev); + aLCurr += aP1curr.Distance(aP2curr); + } + + if(aLPrev < aLCurr) + {//Remove preview line + theLines.Remove(theWLID); + theIsRejectReq = Standard_False; + } + } +} //================================================================================== // function : @@ -331,6 +371,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { // Calculation transition IntSurf_TypeTrans trans1,trans2; @@ -471,6 +516,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { IntSurf_TypeTrans trans1,trans2; Standard_Real locu,locv; @@ -688,6 +738,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { IntSurf_TypeTrans trans1,trans2; Standard_Real locu,locv; @@ -856,6 +911,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { IntSurf_TypeTrans trans1,trans2; Standard_Real locu,locv; @@ -1491,6 +1551,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { IntSurf_TypeTrans trans1,trans2; Standard_Real locu,locv; @@ -2298,6 +2363,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur }// for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { // + if(RejectLine) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejectLine); + } + if(!RejectLine) { IntSurf_TypeTrans trans1,trans2; @@ -2856,6 +2926,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur } } + if(RejetLigne) + { + DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); + } + if(!RejetLigne) { IntSurf_TypeTrans trans1,trans2; diff --git a/tests/boolean/bsection/R9 b/tests/boolean/bsection/R9 index 3d3a76a18f..89d3d79940 100644 --- a/tests/boolean/bsection/R9 +++ b/tests/boolean/bsection/R9 @@ -7,4 +7,4 @@ restore [locate_data_file buc60462b.brep] b bsection result a b -set length 261.262 +set length 264.314 diff --git a/tests/bugs/modalg_5/bug25828_1 b/tests/bugs/modalg_5/bug25828_1 new file mode 100755 index 0000000000..c35b9cdc5c --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_1 @@ -0,0 +1,29 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] t +explode t + +bop t_1 t_2 +bopsection result + +set expl [explode result] + +set ll [llength $expl] + +if {${ll} == 2} { + puts "Result is ${ll} section edges" + puts "${BugNumber} OK" +} else { + puts "Result is ${ll} section edge" + puts "Error ${BugNumber}" +} + +set 2dviewer 0 diff --git a/tests/bugs/modalg_5/bug25828_2 b/tests/bugs/modalg_5/bug25828_2 new file mode 100755 index 0000000000..5e1aae85eb --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_2 @@ -0,0 +1,29 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] t +explode t + +bop t_2 t_1 +bopsection result + +set expl [explode result] + +set ll [llength $expl] + +if {${ll} == 2} { + puts "Result is ${ll} section edges" + puts "${BugNumber} OK" +} else { + puts "Result is ${ll} section edge" + puts "Error ${BugNumber}" +} + +set 2dviewer 0 diff --git a/tests/bugs/modalg_5/bug25828_3 b/tests/bugs/modalg_5/bug25828_3 new file mode 100755 index 0000000000..847d95874b --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_3 @@ -0,0 +1,37 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] b + +explode b +copy b_1 b1 +copy b_2 b2 + +explode b1 f; copy b1_1 b1 +explode b2 f; copy b2_6 b2 + +set log [bopcurves b1 b2 -2d] + +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv + +set MaxTol 5.5e-6 +if {${Toler} > ${MaxTol}} { + puts "Error: Tolerance is too big!" +} + +if {${NbCurv} != 1} { + puts "Error: NbCurv is bad!" +} + +smallview +donly b1 b2 +fit + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug25828_4 b/tests/bugs/modalg_5/bug25828_4 new file mode 100755 index 0000000000..4010990a62 --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_4 @@ -0,0 +1,37 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] b + +explode b +copy b_1 b1 +copy b_2 b2 + +explode b1 f; copy b1_1 b1 +explode b2 f; copy b2_6 b2 + +set log [bopcurves b2 b1 -2d] + +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv + +set MaxTol 5.5e-6 +if {${Toler} > ${MaxTol}} { + puts "Error: Tolerance is too big!" +} + +if {${NbCurv} != 1} { + puts "Error: NbCurv is bad!" +} + +smallview +donly b1 b2 +fit + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug25828_5 b/tests/bugs/modalg_5/bug25828_5 new file mode 100755 index 0000000000..cddef0e1e1 --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_5 @@ -0,0 +1,41 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] b + +explode b +copy b_1 b1 +copy b_2 b2 + +explode b1 f +copy b1_1 b1 +explode b2 f +copy b2_6 b2 + +mksurface s1 b1 +mksurface s2 b2 + +trim s2 s2 -31.464272161690925 31.464272161690968 -21.228551512037676 26.343858939611884 + +set log [intersect rr s1 s2 2.0e-7] + +set ll [llength ${log}] + +if {${ll} == 1} { + puts "${BugNumber} OK" +} else { + puts "Error ${BugNumber}" +} + +smallview +donly rr +fit + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug25828_6 b/tests/bugs/modalg_5/bug25828_6 new file mode 100755 index 0000000000..3257c70dcb --- /dev/null +++ b/tests/bugs/modalg_5/bug25828_6 @@ -0,0 +1,41 @@ +puts "========" +puts "OCC25828" +puts "========" +puts "" +########################################## +## BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments +########################################## + +set BugNumber OCC25828 + +restore [locate_data_file bug25828_intersectionproblem.brep] b + +explode b +copy b_1 b1 +copy b_2 b2 + +explode b1 f +copy b1_1 b1 +explode b2 f +copy b2_6 b2 + +mksurface s1 b1 +mksurface s2 b2 + +trim s2 s2 -31.464272161690925 31.464272161690968 -21.228551512037676 26.343858939611884 + +set log [intersect rr s2 s1 2.0e-7] + +set ll [llength ${log}] + +if {${ll} == 1} { + puts "${BugNumber} OK" +} else { + puts "Error ${BugNumber}" +} + +smallview +donly rr +fit + +set only_screen_axo 1 diff --git a/tests/bugs/moddata_1/bug13 b/tests/bugs/moddata_1/bug13 index 2fc3254fdf..2f58908458 100755 --- a/tests/bugs/moddata_1/bug13 +++ b/tests/bugs/moddata_1/bug13 @@ -26,27 +26,16 @@ set nom 0 break } else { set nom [expr $nom + 1] - if { $j == 1 } { - set info [length res_$j] - regexp {The length res_1 is+ +([-0-9.+eE]+)} $info full ll - set lcheck_1 2.310700219185881e-005 - if { [expr 1.*abs($lcheck_1 - $ll)/$lcheck_1] > 0.01 } { - puts "Error : The lenght of result shape is $ll" - } else { - puts "OK : The length of result shape is ok" - } + + #Check, if curve has non-zero length + set info [length res_$j] + regexp {The length res_1 is+ +([-0-9.+eE]+)} $info full ll + if {${ll} < 1.0e-7} { + puts "Error : res_$j has null-length" } - if { $j == 2 } { - set info [length res_$j] - regexp {The length res_2 is+ +([-0-9.+eE]+)} $info full ll - set lcheck_2 2.2948490793846324e-005 - if { [expr 1.*abs($lcheck_2 - $ll)/$lcheck_2] > 0.01 } { - puts "Error : The lenght of result shape is $ll" - } else { - puts "OK : The length of result shape is ok" - } - } - incr j } + + incr j + } } if { $nom == 0} { puts "Error : Intersection was made WRONGLY"