diff --git a/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx b/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx index 93fd1b1a1b..398a33e6c7 100644 --- a/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx +++ b/src/IntPatch/IntPatch_ImpImpIntersection_4.gxx @@ -2600,6 +2600,29 @@ Standard_Boolean IntCyCyTrim( const IntSurf_Quadric& theQuad1, if(( aWLFindStatus[i] != WLFStatus_Broken) || (aWLine[i]->NbPnts() >= 1) || IsEqual(anU1, anUl)) { + if(aWLine[i]->NbPnts() > 0) + { + Standard_Real aU2p = 0.0, aV2p = 0.0; + if(isTheReverse) + aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS1(aU2p, aV2p); + else + aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS2(aU2p, aV2p); + + const Standard_Real aDelta = aU2[i] - aU2p; + + if(2*Abs(aDelta) > aPeriod) + { + if(aDelta > 0.0) + { + aU2[i] -= aPeriod; + } + else + { + aU2[i] += aPeriod; + } + } + } + if(AddPointIntoWL(theQuad1, theQuad2, anEquationCoeffs, isTheReverse, Standard_True, gp_Pnt2d(anU1, aV1[i]), gp_Pnt2d(aU2[i], aV2[i]), aUSurf1f, aUSurf1l, aUSurf2f, aUSurf2l, @@ -2611,6 +2634,20 @@ Standard_Boolean IntCyCyTrim( const IntSurf_Quadric& theQuad1, aWLFindStatus[i] = WLFStatus_Exist; } } + else if(!isFound1 && !isFound2) + {//We do not add any point while doing this iteration + if(aWLFindStatus[i] == WLFStatus_Exist) + { + aWLFindStatus[i] = WLFStatus_Broken; + } + } + } + } + else + {//We do not add any point while doing this iteration + if(aWLFindStatus[i] == WLFStatus_Exist) + { + aWLFindStatus[i] = WLFStatus_Broken; } } @@ -2625,62 +2662,94 @@ Standard_Boolean IntCyCyTrim( const IntSurf_Quadric& theQuad1, {//current lines are filled. Go to the next lines anUf = anU1; - Standard_Real anULastAdded = RealFirst(); + Standard_Boolean isAdded = Standard_True; + for(Standard_Integer i = 0; i < aNbWLines; i++) { - if((aWLFindStatus[i] != WLFStatus_Broken) || aWLine[i]->NbPnts() < 2) + if(isAddingWLEnabled[i]) + { continue; + } - Standard_Real aU1c = 0.0, aV1c = 0.0; + isAdded = Standard_False; - if(isTheReverse) - aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS2(aU1c, aV1c); - else - aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS1(aU1c, aV1c); + Standard_Boolean isFound1 = Standard_False, isFound2 = Standard_False; - anULastAdded = Max(anULastAdded, aU1c); + AddBoundaryPoint( theQuad1, theQuad2, aWLine[i], anEquationCoeffs, + theUVSurf1, theUVSurf2, theTol3D, theTol2D, aPeriod, + anU1, aU2[i], aV1[i], aV1Prev[i], + aV2[i], aV2Prev[i], i, isTheReverse, + Standard_False, isFound1, isFound2); + + if(isFound1 || isFound2) + { + isAdded = Standard_True; + } + + if(aWLine[i]->NbPnts() > 0) + { + Standard_Real aU2p = 0.0, aV2p = 0.0; + if(isTheReverse) + aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS1(aU2p, aV2p); + else + aWLine[i]->Point(aWLine[i]->NbPnts()).ParametersOnS2(aU2p, aV2p); + + const Standard_Real aDelta = aU2[i] - aU2p; + + if(2*Abs(aDelta) > aPeriod) + { + if(aDelta > 0.0) + { + aU2[i] -= aPeriod; + } + else + { + aU2[i] += aPeriod; + } + } + } + + if(AddPointIntoWL(theQuad1, theQuad2, anEquationCoeffs, isTheReverse, + Standard_True, gp_Pnt2d(anU1, aV1[i]), + gp_Pnt2d(aU2[i], aV2[i]), aUSurf1f, aUSurf1l, + aUSurf2f, aUSurf2l, aVSurf1f, aVSurf1l, + aVSurf2f, aVSurf2l, aPeriod, aWLine[i]->Curve(), + i, theTol3D, theTol2D, Standard_False)) + { + isAdded = Standard_True; + } } - for(Standard_Integer i = 0; i < aNbWLines; i++) + if(!isAdded) { - if((aWLFindStatus[i] != WLFStatus_Exist)) - continue; - - Standard_Real aU2c = 0.0, aV1c = 0.0, aV2c = 0.0; - Standard_Boolean isAdded = Standard_False; - - //Try to add current point - if(CylCylComputeParameters(anU1, i, anEquationCoeffs, aU2c, aV1c, aV2c)) + Standard_Real anUmaxAdded = RealFirst(); + for(Standard_Integer i = 0; i < aNbWLines; i++) { - InscribePoint(aUSurf2f, aUSurf2l, aU2c, theTol2D, aPeriod, Standard_False); + Standard_Real aU1c = 0.0, aV1c = 0.0; + if(isTheReverse) + aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS2(aU1c, aV1c); + else + aWLine[i]->Curve()->Value(aWLine[i]->NbPnts()).ParametersOnS1(aU1c, aV1c); - isAdded = AddPointIntoWL( theQuad1, theQuad2, anEquationCoeffs, isTheReverse, - Standard_True, gp_Pnt2d(anU1, aV1c), gp_Pnt2d(aU2c, aV2c), - aUSurf1f, aUSurf1l, aUSurf2f, aUSurf2l, - aVSurf1f, aVSurf1l, aVSurf2f, aVSurf2l, aPeriod, - aWLine[i]->Curve(), i, theTol3D, theTol2D, Standard_False); + anUmaxAdded = Max(anUmaxAdded, aU1c); } - if(isAdded) - continue; + for(Standard_Integer i = 0; i < aNbWLines; i++) + { + if(isAddingWLEnabled[i]) + { + continue; + } - if(anULastAdded == anU1) - {//strictly equal only - continue; + CylCylComputeParameters(anUmaxAdded, i, anEquationCoeffs, aU2[i], aV1[i], aV2[i]); + + AddPointIntoWL( theQuad1, theQuad2, anEquationCoeffs, isTheReverse, + Standard_True, gp_Pnt2d(anUmaxAdded, aV1[i]), + gp_Pnt2d(aU2[i], aV2[i]), aUSurf1f, aUSurf1l, + aUSurf2f, aUSurf2l, aVSurf1f, aVSurf1l, + aVSurf2f, aVSurf2l, aPeriod, aWLine[i]->Curve(), + i, theTol3D, theTol2D, Standard_False); } - - //Try to add last added point - - if(!CylCylComputeParameters(anULastAdded, i, anEquationCoeffs, aU2c, aV1c, aV2c)) - continue; - - InscribePoint(aUSurf2f, aUSurf2l, aU2c, theTol2D, aPeriod, Standard_False); - - AddPointIntoWL( theQuad1, theQuad2, anEquationCoeffs, isTheReverse, Standard_True, - gp_Pnt2d(anULastAdded, aV1c), gp_Pnt2d(aU2c, aV2c), - aUSurf1f, aUSurf1l, aUSurf2f, aUSurf2l, - aVSurf1f, aVSurf1l, aVSurf2f, aVSurf2l, aPeriod, - aWLine[i]->Curve(), i, theTol3D, theTol2D, Standard_False); } break; @@ -2892,7 +2961,7 @@ Standard_Boolean IntCyCyTrim( const IntSurf_Quadric& theQuad1, CylCylComputeParameters(anUf, anIndex, anEquationCoeffs, anU2, anV1, anV2); anUf += aDU; - + if(!isDone) { continue; @@ -2918,7 +2987,7 @@ Standard_Boolean IntCyCyTrim( const IntSurf_Quadric& theQuad1, aWLine->ComputeVertexParameters(theTol3D); theSlin.Append(aWLine); - + theSPnt.Remove(aNbPnt); aNbPnt--; } diff --git a/src/IntPatch/IntPatch_Intersection.cxx b/src/IntPatch/IntPatch_Intersection.cxx index 1ecb466ea9..7d89406f64 100644 --- a/src/IntPatch/IntPatch_Intersection.cxx +++ b/src/IntPatch/IntPatch_Intersection.cxx @@ -107,7 +107,7 @@ static void JoinWLines(IntPatch_SequenceOfLine& theSlin, const Handle(IntPatch_WLine)& aWLine1 = Handle(IntPatch_WLine)::DownCast(theSlin.Value(aNumOfLine1)); if(aWLine1.IsNull()) - {//We must have failure to join not-point-lines + {//We must have failed to join not-point-lines return; } diff --git a/tests/bugs/modalg_5/bug24915 b/tests/bugs/modalg_5/bug24915 index f33a47d3ac..b3b6fa6f72 100755 --- a/tests/bugs/modalg_5/bug24915 +++ b/tests/bugs/modalg_5/bug24915 @@ -1,4 +1,5 @@ puts "TODO OCC25929 ALL: Error: Tolerance is too big!" +puts "TODO OCC25929 ALL: Error : T=0.818182" puts "=========" puts "CR24915" puts "=========" diff --git a/tests/bugs/modalg_6/bug26193 b/tests/bugs/modalg_6/bug26193 new file mode 100644 index 0000000000..ebb35cb4d4 --- /dev/null +++ b/tests/bugs/modalg_6/bug26193 @@ -0,0 +1,51 @@ +puts "========" +puts "OCC26193" +puts "========" +puts "" +##@@########################### +# Incomplete intersection curve +############################### + +restore [locate_data_file OCC26193_qfv.brep] q +explode q +copy q_1 b1 +copy q_2 b2 + +explode b1 e + +set NbVertGood 8 + +bsection rr b1 b2 + +set lst [checksection rr] +set i 1 +while {$i} { + if {[regexp "is a shape VERTEX" [whatis alone_$i]]} { + distmini dd1 alone_$i b1_1 + distmini dd2 alone_$i b1_3 + + set dd1 [dval dd1_val] + set dd2 [dval dd2_val] + + set dist [expr min( $dd1, $dd2 ) ] + + if {$dist > 1.0e-7} { + puts "Error: Vertex alone_$i is not on boundary" + } + + incr i + } else { + break + } +} + +set NbVertFound [expr $i-1] + +if {$NbVertFound != $NbVertGood} { + puts "Error: $NbVertFound found but $NbVertGood expected" +} + +smallview +donly b1 b2 rr +fit +set only_screen_axo 1 diff --git a/tests/bugs/modalg_6/bug26208 b/tests/bugs/modalg_6/bug26208 new file mode 100644 index 0000000000..2ef25e2831 --- /dev/null +++ b/tests/bugs/modalg_6/bug26208 @@ -0,0 +1,51 @@ +puts "========" +puts "OCC26208" +puts "========" +puts "" +##@@########################### +# Incomplete intersection curve. [Episode 2] +############################### + +restore [locate_data_file OCC26208_qf.brep] q +explode q +copy q_1 b1 +copy q_2 b2 + +explode b2 e + +set NbVertGood 4 + +bsection rr b1 b2 + +set lst [checksection rr] +set i 1 +while {$i} { + if {[regexp "is a shape VERTEX" [whatis alone_$i]]} { + distmini dd1 alone_$i b2_1 + distmini dd2 alone_$i b2_3 + + set dd1 [dval dd1_val] + set dd2 [dval dd2_val] + + set dist [expr min( $dd1, $dd2 ) ] + + if {$dist > 1.0e-7} { + puts "Error: Vertex alone_$i is not on boundary" + } + + incr i + } else { + break + } +} + +set NbVertFound [expr $i-1] + +if {$NbVertFound != $NbVertGood} { + puts "Error: $NbVertFound found but $NbVertGood expected" +} + +smallview +donly b1 b2 rr +fit +set only_screen_axo 1