0026193: Incomplete intersection curve
authornbv <nbv@opencascade.com>
Thu, 4 Jun 2015 11:05:33 +0000 (14:05 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Jun 2015 11:06:34 +0000 (14:06 +0300)
1. Conditions for adjusting and for breaking Walking-lines have been amended.
2. Processing of case when WLine should be broken has been changed.

Test cases for issues 26193 and 26208 have been added

Cosmetic correction of test-cases

Modification of test-case according to the new behavior.

src/IntPatch/IntPatch_ImpImpIntersection_4.gxx
src/IntPatch/IntPatch_Intersection.cxx
tests/bugs/modalg_5/bug24915
tests/bugs/modalg_6/bug26193 [new file with mode: 0644]
tests/bugs/modalg_6/bug26208 [new file with mode: 0644]

index 93fd1b1..398a33e 100644 (file)
@@ -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);
 
-          for(Standard_Integer i = 0; i < aNbWLines; i++)
-          {
-            if((aWLFindStatus[i] != WLFStatus_Exist))
-              continue;
-
-            Standard_Real aU2c = 0.0, aV1c = 0.0, aV2c = 0.0;
-            Standard_Boolean isAdded = Standard_False;
+            if(isFound1 || isFound2)
+            {
+              isAdded = Standard_True;
+            }
 
-            //Try to add current point
-            if(CylCylComputeParameters(anU1, i, anEquationCoeffs, aU2c, aV1c, aV2c))
+            if(aWLine[i]->NbPnts() > 0)
             {
-              InscribePoint(aUSurf2f, aUSurf2l, aU2c, theTol2D, aPeriod, Standard_False);
+              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;
+                }
+              }
+            }
 
-              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);
+            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;
             }
+          }
 
-            if(isAdded)
-              continue;
+          if(!isAdded)
+          {
+            Standard_Real anUmaxAdded = RealFirst();
+            for(Standard_Integer i = 0; i < aNbWLines; i++)
+            {
+              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);
 
-            if(anULastAdded == anU1)
-            {//strictly equal only
-              continue;
+              anUmaxAdded = Max(anUmaxAdded, aU1c);
             }
 
-            //Try to add last added point
-            
-            if(!CylCylComputeParameters(anULastAdded, i, anEquationCoeffs, aU2c, aV1c, aV2c))
-              continue;
+            for(Standard_Integer i = 0; i < aNbWLines; i++)
+            {
+              if(isAddingWLEnabled[i])
+              {
+                continue;
+              }
 
-            InscribePoint(aUSurf2f, aUSurf2l, aU2c, theTol2D, aPeriod, Standard_False);
+              CylCylComputeParameters(anUmaxAdded, i, anEquationCoeffs, aU2[i], aV1[i], aV2[i]);
 
-            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);
+              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);
+            }
           }
 
           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--;
     }
index 1ecb466..7d89406 100644 (file)
@@ -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;
     }
 
index f33a47d..b3b6fa6 100755 (executable)
@@ -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 (file)
index 0000000..ebb35cb
--- /dev/null
@@ -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 (file)
index 0000000..2ef25e2
--- /dev/null
@@ -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