]> OCCT Git - occt-copy.git/commitdiff
0025828: BRepAlgoAPI_Section fails for a solid and a face depending on order of arguments
authornbv <nbv@opencascade.com>
Thu, 26 Feb 2015 06:32:29 +0000 (09:32 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 26 Feb 2015 09:52:49 +0000 (12:52 +0300)
If Walking-lines are coincided we kept line, which contains more points or has more length (because it is more precisely, most likely).

Test cases for issue CR25828
Some test cases were changed

src/IntPatch/IntPatch_PrmPrmIntersection.cxx
tests/boolean/bsection/R9
tests/bugs/modalg_5/bug25828_1 [new file with mode: 0755]
tests/bugs/modalg_5/bug25828_2 [new file with mode: 0755]
tests/bugs/modalg_5/bug25828_3 [new file with mode: 0755]
tests/bugs/modalg_5/bug25828_4 [new file with mode: 0755]
tests/bugs/modalg_5/bug25828_5 [new file with mode: 0755]
tests/bugs/modalg_5/bug25828_6 [new file with mode: 0755]
tests/bugs/moddata_1/bug13

index 8c6728367cdff2114139a419b64513c659c8e62b..7a54be1ebf63249d97cfa1fc8bbaa8b2ca4e15a7 100644 (file)
@@ -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;
index 3d3a76a18f32872d1ae9f7d8a2883e33acc121c5..89d3d7994066f9c7634fb8376f14252ddffddb35 100644 (file)
@@ -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 (executable)
index 0000000..c35b9cd
--- /dev/null
@@ -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 (executable)
index 0000000..5e1aae8
--- /dev/null
@@ -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 (executable)
index 0000000..847d958
--- /dev/null
@@ -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 (executable)
index 0000000..4010990
--- /dev/null
@@ -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 (executable)
index 0000000..cddef0e
--- /dev/null
@@ -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 (executable)
index 0000000..3257c70
--- /dev/null
@@ -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
index 2fc3254fdf107bcc42e00072c3f36cf4cd60ff2e..2f589084587ee6d19b162adaa55c77a7b25d8c2c 100755 (executable)
@@ -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"