]> OCCT Git - occt.git/commitdiff
0028795: Boolean operations corrupt the p-curve of the source planar face if "non...
authornbv <nbv@opencascade.com>
Mon, 29 May 2017 07:42:30 +0000 (10:42 +0300)
committerapv <apv@opencascade.com>
Fri, 2 Jun 2017 08:47:42 +0000 (11:47 +0300)
Now, the range of BRep_CurveRepresentation of the edge is updated if at least one of its boundary is not infinite (earlier, it was updated if all two boundaries are not infinite only).

src/BRep/BRep_Builder.cxx
tests/bugs/modalg_6/bug28795 [new file with mode: 0644]

index 682a471f6a242df04fda47ef3c94d051d189df78..a93ef4a688be9f0a375e6e1c59395f3aeb996645 100644 (file)
@@ -108,9 +108,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
   Handle(BRep_CurveRepresentation) cr;
   Handle(BRep_GCurve) GC;
-  Standard_Real f = 0.,l = 0.;
-  Standard_Boolean rangeFound = Standard_False;
-
+  Standard_Real f = -Precision::Infinite(), l = Precision::Infinite();
   // search the range of the 3d curve
   // and remove any existing representation
 
@@ -124,13 +122,6 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
         //             see lbo & flo, to determine whether range is defined
         //             compare first and last parameters with default values.
         GC->Range(f, l);
-        //lvt 15/6/99: On enleve la comparaison de reels infinis.
-        Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) ||
-                                      Precision::IsNegativeInfinite(f));
-        
-        if (!undefined) {
-          rangeFound = Standard_True;
-        }
       }
       if (GC->IsCurveOnSurface(S,L)) {
         // remove existing curve on surface
@@ -148,12 +139,21 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
     }
   }
 
-  if (! C.IsNull()) {
-    Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C,S,L);
-    // test if there is already a range
-    if (rangeFound) {
-      COS->SetRange(f,l);
+  if (!C.IsNull()) {
+    Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C, S, L);
+    Standard_Real aFCur = 0.0, aLCur = 0.0;
+    COS->Range(aFCur, aLCur);
+    if (!Precision::IsInfinite(f))
+    {
+      aFCur = f;
+    }
+
+    if (!Precision::IsInfinite(l))
+    {
+      aLCur = l;
     }
+
+    COS->SetRange(aFCur, aLCur);
     lcr.Append(COS);
   }
 }
@@ -174,8 +174,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
   Handle(BRep_CurveRepresentation) cr;
   Handle(BRep_GCurve) GC;
-  Standard_Real f = 0.,l = 0.;
-  Standard_Boolean rangeFound = Standard_False;
+  Standard_Real f = -Precision::Infinite(), l = Precision::Infinite();
 
   // search the range of the 3d curve
   // and remove any existing representation
@@ -190,13 +189,6 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
         //             see lbo & flo, to determine whether range is defined
         //             compare first and last parameters with default values.
         GC->Range(f, l);
-        //lvt 15/6/99: On enleve la comparaison de reels infinis.
-        Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) ||
-                                      Precision::IsNegativeInfinite(f));
-        
-        if (!undefined) {
-          rangeFound = Standard_True;
-        }
       }
       if (GC->IsCurveOnSurface(S,L)) {
         // remove existing curve on surface
@@ -216,11 +208,20 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
 
   if (! C.IsNull()) {
     Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C,S,L);
-    // test if there is already a range
-    if (rangeFound) {
-      COS->SetRange(f,l);
+    Standard_Real aFCur = 0.0, aLCur = 0.0;
+    COS->Range(aFCur, aLCur);
+    if (!Precision::IsInfinite(f))
+    {
+      aFCur = f;
+    }
+
+    if (!Precision::IsInfinite(l))
+    {
+      aLCur = l;
     }
-    COS->SetUVPoints(Pf,Pl);
+
+    COS->SetRange(aFCur, aLCur);
+    COS->SetUVPoints(Pf, Pl);
     lcr.Append(COS);
   }
 }
@@ -241,20 +242,13 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
   Handle(BRep_CurveRepresentation) cr;
   Handle(BRep_GCurve) GC;
-  Standard_Real f = 0.,l = 0.;
-  Standard_Boolean rangeFound = Standard_False;
+  Standard_Real f = -Precision::Infinite(), l = Precision::Infinite();
 
   while (itcr.More()) {
     GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
     if ( !GC.IsNull() ) {
       if (GC->IsCurve3D()) {
         GC->Range(f,l);
-        Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) ||
-                                      Precision::IsNegativeInfinite(f));
-          
-        if (!undefined) {
-          rangeFound = Standard_True;
-        }
       }
       Standard_Boolean iscos = GC->IsCurveOnSurface(S,L);
       if (iscos) break;
@@ -270,12 +264,21 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   }
 
   if ( !C1.IsNull() && !C2.IsNull() ) {
-    Handle(BRep_CurveOnClosedSurface) COS =
-      new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0);
-    // test if there is already a range
-    if (rangeFound) {
-      COS->SetRange(f,l);
+    Handle(BRep_CurveOnClosedSurface) COS = new 
+                    BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0);
+    Standard_Real aFCur = 0.0, aLCur = 0.0;
+    COS->Range(aFCur, aLCur);
+    if (!Precision::IsInfinite(f))
+    {
+      aFCur = f;
     }
+
+    if (!Precision::IsInfinite(l))
+    {
+      aLCur = l;
+    }
+
+    COS->SetRange(aFCur, aLCur);
     lcr.Append(COS);
   }
 }
@@ -297,20 +300,13 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
   Handle(BRep_CurveRepresentation) cr;
   Handle(BRep_GCurve) GC;
-  Standard_Real f = 0.,l = 0.;
-  Standard_Boolean rangeFound = Standard_False;
+  Standard_Real f = -Precision::Infinite(), l = Precision::Infinite();
 
   while (itcr.More()) {
     GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
     if ( !GC.IsNull() ) {
       if (GC->IsCurve3D()) {
         GC->Range(f,l);
-        Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) ||
-                                      Precision::IsNegativeInfinite(f));
-          
-        if (!undefined) {
-          rangeFound = Standard_True;
-        }
       }
       Standard_Boolean iscos = GC->IsCurveOnSurface(S,L);
       if (iscos) break;
@@ -326,13 +322,22 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   }
 
   if ( !C1.IsNull() && !C2.IsNull() ) {
-    Handle(BRep_CurveOnClosedSurface) COS =
-      new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0);
-    // test if there is already a range
-    if (rangeFound) {
-      COS->SetRange(f,l);
+    Handle(BRep_CurveOnClosedSurface) COS = new 
+                    BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0);
+    Standard_Real aFCur = 0.0, aLCur = 0.0;
+    COS->Range(aFCur, aLCur);
+    if (!Precision::IsInfinite(f))
+    {
+      aFCur = f;
     }
-    COS->SetUVPoints2(Pf,Pl);
+
+    if (!Precision::IsInfinite(l))
+    {
+      aLCur = l;
+    }
+
+    COS->SetRange(aFCur, aLCur);
+    COS->SetUVPoints2(Pf, Pl);
     lcr.Append(COS);
   }
 }
diff --git a/tests/bugs/modalg_6/bug28795 b/tests/bugs/modalg_6/bug28795
new file mode 100644 (file)
index 0000000..bf432e8
--- /dev/null
@@ -0,0 +1,32 @@
+puts "======="
+puts "OCC28795"
+puts "======="
+puts ""
+##################################################
+# Boolean operations corrupt the p-curve of the source planar face if "non-destructive" option is switched off
+##################################################
+
+set expected [list {UMin 0.0} {UMax 1.0} {VMin -2e+100} {VMax 0.0}]
+
+box mb -0.5 -0.5 -0.5 1 1 1
+explode mb F
+prism pryz mb_1 1 0 0 SemiInf
+box ab 0 -1 -1 2 2 2
+
+explode ab f
+explode pryz f
+
+set bounds [xbounds pryz_1]
+# check for expected result
+for {set i 0} {$i < 4} {incr i} {
+  checkreal "[lindex $expected $i 0]" [lindex $bounds $i] [lindex $expected $i 1] 0.0 1.0e-7
+}
+
+# Make a simple Boolean operation, e.g. "bsection"
+bsection rs ab_2 pryz_1
+
+set bounds [xbounds pryz_1]
+# check for expected result
+for {set i 0} {$i < 4} {incr i} {
+  checkreal "[lindex $expected $i 0]" [lindex $bounds $i] [lindex $expected $i 1] 0.0 1.0e-7
+}
\ No newline at end of file