]> OCCT Git - occt-copy.git/commitdiff
0026560: BRepBndLib build too large bounding box in Z direction for planar spline...
authoraml <aml@opencascade.com>
Thu, 8 Oct 2015 06:39:35 +0000 (09:39 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 8 Oct 2015 07:07:27 +0000 (10:07 +0300)
Poles bounding box for curve added for bezier and bspline curves.
Method Poles() for Bezier curve added.

Test case for issue CR26560

Function to compute subshape max tolerance has been added.
Fixed bounding box expanding at Face/Face step of boolean operation.
Test cases are updated to the new behavior.

18 files changed:
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BRep/BRep_Tool.cxx
src/BRep/BRep_Tool.hxx
src/BndLib/BndLib_Add3dCurve.cxx
src/Geom/Geom_BezierCurve.cxx
src/Geom/Geom_BezierCurve.hxx
tests/boolean/volumemaker/B7
tests/boolean/volumemaker/B9
tests/boolean/volumemaker/C4
tests/bugs/modalg_2/bug472_2
tests/bugs/modalg_2/bug472_3
tests/bugs/modalg_4/bug697_2
tests/bugs/modalg_4/bug697_4
tests/bugs/modalg_4/bug697_7
tests/bugs/modalg_4/bug697_8
tests/bugs/moddata_2/bug23165
tests/bugs/moddata_3/bug26560 [new file with mode: 0755]
tests/de/iges_2/H9

index bf019a43fba0d15374d9a4647c5379b9953c6e9d..bab10df97bee7f6db8dbf86d63c029bce94e2563 100644 (file)
@@ -296,13 +296,25 @@ void BOPAlgo_PaveFiller::PerformFF()
       aFF.Init(aNbCurves, aNbPoints);
       //
       // Curves
+
+      // Fix bounding box expanding coefficient.
+      Standard_Real aBoxExpandValue = aTolR3D;
+      if (aNbCurves > 0)
+      {
+        // Modify geometric expanding coefficient by topology value,
+        // since this bounging box used in sharing (vertex or edge).
+        Standard_Real aMaxVertexTol = Max (BRep_Tool::MaxTolerance(aFaceFace.Face1(), TopAbs_VERTEX),
+                                           BRep_Tool::MaxTolerance(aFaceFace.Face2(), TopAbs_VERTEX));
+        aBoxExpandValue += aMaxVertexTol;
+      }
+
       BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves();
       for (i=1; i<=aNbCurves; ++i) {
         Bnd_Box aBox;
         //
         const IntTools_Curve& aIC=aCvsX(i);
         const Handle(Geom_Curve)& aC3D= aIC.Curve();
-        bValid=IntTools_Tools::CheckCurve(aC3D, aTolR3D, aBox);
+        bValid=IntTools_Tools::CheckCurve(aC3D, aBoxExpandValue, aBox);
         if (bValid) {
           BOPDS_Curve& aNC=aVNC.Append1();
           aNC.SetCurve(aIC);
index 101d93f10617e9e09dafe6034e6b13f1d914772d..8b8e2f62c3497b29828367dc33a708b8a1725e01 100644 (file)
@@ -1538,3 +1538,41 @@ Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS)
   return bRet;
 }
 
+//=======================================================================
+//function : MaxTolerance
+//purpose  : 
+//=======================================================================
+Standard_Real BRep_Tool::MaxTolerance (const TopoDS_Shape& theShape,
+                                       const TopAbs_ShapeEnum theSubShape)
+{
+  Standard_Real aTol = 0.0;
+
+  // Explorer Shape-Subshape.
+  TopExp_Explorer anExpSS(theShape, theSubShape);
+  if (theSubShape == TopAbs_FACE)
+  {
+    for( ; anExpSS.More() ;  anExpSS.Next() )
+    {
+      const TopoDS_Shape& aCurrentSubShape = anExpSS.Current();
+      aTol = Max(aTol, Tolerance(TopoDS::Face(aCurrentSubShape)));
+    }
+  }
+  else if (theSubShape == TopAbs_EDGE)
+  {
+    for( ; anExpSS.More() ;  anExpSS.Next() )
+    {
+      const TopoDS_Shape& aCurrentSubShape = anExpSS.Current();
+      aTol = Max(aTol, Tolerance(TopoDS::Edge(aCurrentSubShape)));
+    }
+  }
+  else if (theSubShape == TopAbs_VERTEX)
+  {
+    for( ; anExpSS.More() ;  anExpSS.Next() )
+    {
+      const TopoDS_Shape& aCurrentSubShape = anExpSS.Current();
+      aTol = Max(aTol, Tolerance(TopoDS::Vertex(aCurrentSubShape)));
+    }
+  }
+
+  return aTol;
+}
index 103e60bfa7aecfa7491d818758c47e4a65215075..cd2a32c9ada374b4cb50e667fa34939ca58cb92e 100644 (file)
@@ -1,4 +1,4 @@
-// Created on: 1993-07-07
+;// Created on: 1993-07-07
 // Created by: Remi LEQUETTE
 // Copyright (c) 1993-1999 Matra Datavision
 // Copyright (c) 1999-2014 OPEN CASCADE SAS
@@ -31,6 +31,7 @@
 #include <Poly_Polygon3D.hxx>
 #include <Poly_Polygon2D.hxx>
 #include <Poly_PolygonOnTriangulation.hxx>
+#include <TopAbs_ShapeEnum.hxx>
 
 class TopoDS_Shape;
 class TopoDS_Face;
@@ -237,6 +238,11 @@ public:
   //! Returns the parameters of the vertex on the face.
   Standard_EXPORT static gp_Pnt2d Parameters (const TopoDS_Vertex& V, const TopoDS_Face& F);
 
+  //! Returns the maximum tolerance of input shape subshapes.
+  //@param theShape    - Shape to search tolerance.
+  //@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
+  Standard_EXPORT static Standard_Real MaxTolerance (const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theSubShape);
+
 };
 
 #endif // _BRep_Tool_HeaderFile
index 20c47af293d9edc4b6763436d85bc06b7a6aade7..45e16beb3d1f1883fe5094ee3a8ed9bec758fe84 100644 (file)
 #include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_Array1OfReal.hxx>
 
+//=======================================================================
+//function : reduceSplineBox
+//purpose  : This method intended to reduce box in case of 
+//           bezier and bspline curve.
+//=======================================================================
+static void reduceSplineBox(const Adaptor3d_Curve& theCurve,
+                            const Bnd_Box& theOrigBox,
+                            Bnd_Box & theReducedBox)
+{
+  // Guaranteed bounding box based on poles of bspline.
+  Bnd_Box aPolesBox;
+  Standard_Real aPolesXMin, aPolesYMin, aPolesZMin,
+                aPolesXMax, aPolesYMax, aPolesZMax;
+
+  if (theCurve.GetType() == GeomAbs_BSplineCurve)
+  {
+    Handle(Geom_BSplineCurve) aC = theCurve.BSpline();
+    const TColgp_Array1OfPnt& aPoles     = aC->Poles();
+
+    for(Standard_Integer anIdx  = aPoles.Lower();
+        anIdx <= aPoles.Upper();
+        ++anIdx)
+    {
+      aPolesBox.Add(aPoles.Value(anIdx));
+    }
+  }
+  if (theCurve.GetType() == GeomAbs_BezierCurve)
+  {
+    Handle(Geom_BezierCurve) aC = theCurve.Bezier();
+    const TColgp_Array1OfPnt& aPoles     = aC->Poles();
+
+    for(Standard_Integer anIdx  = aPoles.Lower();
+        anIdx <= aPoles.Upper();
+        ++anIdx)
+    {
+      aPolesBox.Add(aPoles.Value(anIdx));
+    }
+  }
+
+  aPolesBox.Get(aPolesXMin, aPolesYMin, aPolesZMin,
+                aPolesXMax, aPolesYMax, aPolesZMax);
+
+  Standard_Real x, y, z, X, Y, Z;
+  theOrigBox.Get(x, y, z, X, Y, Z);
+
+  // Left bound.
+  if (aPolesXMin > x)
+    x = aPolesXMin;
+  if (aPolesYMin > y)
+    y = aPolesYMin;
+  if (aPolesZMin > z)
+    z = aPolesZMin;
+
+  // Right bound.
+  if (aPolesXMax < X)
+    X = aPolesXMax;
+  if (aPolesYMax < Y)
+    Y = aPolesYMax;
+  if (aPolesZMax < Z)
+    Z = aPolesZMax;
+
+  theReducedBox.Update(x, y, z, X, Y, Z);
+}
+
 //=======================================================================
 //function : Add
 //purpose  : 
@@ -116,17 +180,13 @@ void BndLib_Add3dCurve::Add( const Adaptor3d_Curve& C,
   case GeomAbs_BezierCurve: 
     {
       Handle(Geom_BezierCurve) Bz = C.Bezier();
-      //OCC566(apo)->
       Standard_Integer N = Bz->Degree();
       GeomAdaptor_Curve GACurve(Bz);
       Bnd_Box B1;
       tol = FillBox(B1,GACurve,U1,U2,N);
       B1.Enlarge(weakness*tol);
-      Standard_Real x, y, z, X, Y, Z;
-      B1.Get(x, y, z, X, Y, Z);
-      B.Update(x, y, z, X, Y, Z);
+      reduceSplineBox(C, B1, B);
       B.Enlarge(Tol);
-      //<-OCC566(apo)
       break;
     }
   case GeomAbs_BSplineCurve: 
@@ -168,9 +228,7 @@ void BndLib_Add3dCurve::Add( const Adaptor3d_Curve& C,
       if (!B1.IsVoid())
       {
         B1.Enlarge(weakness*tol);
-        Standard_Real x, y, z, X, Y, Z;
-        B1.Get(x, y, z, X, Y, Z);
-        B.Update(x, y, z, X, Y, Z);
+        reduceSplineBox(C, B1, B);
         B.Enlarge(Tol);
       }
       //<-OCC566(apo)
index ec94e90911dea2431be2d36c942cbd9bc8fc6831..aa8f2e2d474bc1fbc997813ffc620eacbe6ef50c 100644 (file)
@@ -732,6 +732,17 @@ void Geom_BezierCurve::Poles (TColgp_Array1OfPnt& P) const
   P = poles->Array1();
 }
 
+
+//=======================================================================
+//function : Poles
+//purpose  : 
+//=======================================================================
+
+const TColgp_Array1OfPnt& Geom_BezierCurve::Poles() const
+{
+  return poles->Array1();
+}
+
 //=======================================================================
 //function : Weight
 //purpose  : 
index 8d405832fe31f621dc656f45a10ab918f6b28579..add41c0dcbbc7e2dde05d88b4297ba76a860daf1 100644 (file)
@@ -292,6 +292,9 @@ public:
   //!
   //! Raised if the length of P is not equal to the number of poles.
   Standard_EXPORT void Poles (TColgp_Array1OfPnt& P) const;
+
+    //! Returns all the poles of the curve.
+  Standard_EXPORT const TColgp_Array1OfPnt& Poles () const;
   
   //! Returns the weight of range Index.
   //! Raised if Index is not in the range [1, NbPoles]
index a6e96335410d3dd7a81ae46c29bb63f36f364eba..4f8d70b3e48b1e077f15dbbcfbe2adc5690de365 100644 (file)
@@ -1,7 +1,9 @@
 # test script on make volume operation
 # plane
 
+puts "TODO OCC26560 ALL: Faulty shapes in variables faulty_1 to faulty_"
 puts "TODO OCC26020 ALL: Error: bopcheck failed"
+puts "TODO OCC26560 ALL: Error : The area of the resulting shape is"
 
 # planar face 
 plane pln_f1 18.855982726712998 17.500000000800412 0 -0.96152394764524818 -0.27472112788189063 0
index 4bedb2a81842bb1e9fcd934137c94cd2d1d25a09..6a4df26bb2a3038f1324713bac9df688d4d97e46 100644 (file)
@@ -3,7 +3,7 @@
 
 puts "TODO OCC26020 ALL: Faulty shapes in variables faulty_1 to faulty_"
 puts "TODO OCC26020 ALL: Error: bopcheck failed"
-puts "TODO OCC26020 Linux: Error : The area of the resulting shape is"
+puts "TODO OCC26020 ALL: Error : The area of the resulting shape is"
 
 # planar face 
 plane pln_f1 32.294537607197917 1.8096910201742288e-014 -39.176406819310692 -0.77162458338772011 -6.6613381477509373e-016 -0.63607822027776384
index 35302436f31d7019bf596ff72fdf8521bfd24f46..4d27a2fbfbf954a848420a4fbaa74a3cdc64df63 100644 (file)
@@ -1,6 +1,8 @@
 # test script on make volume operation
 # cylinder plane
 
+puts "TODO OCC26737 ALL: Faulty shapes in variables faulty_1 to faulty_"
+
 # planar face 
 plane pln_f1 0 515 1.1102230246251565e-015 0 -1 -1.1102230246251565e-016
 erase pln_f1
index bb40ce531ae351463a138b128cb65bcebdc4c94b..82ea21a1fd1071965e74765cb9ab49578498ea99 100755 (executable)
@@ -1,4 +1,4 @@
-puts "TODO OCC25917 ALL: Error : The command is not valid. The square is"
+puts "TODO OCC25917 ALL: Faulty shapes in variables faulty_1 to faulty_"
 if { [regexp {Debug mode} [dversion]] } {
   puts "TODO OCC25917 ALL: TEST INCOMPLETE"
   puts "TODO OCC25917 ALL: Tcl Exception"
@@ -21,5 +21,5 @@ checkshape b2
 
 bcommon result b1 b2
 
-set square 0
+set square 0.01
 set 2dviewer 0
index db34c1aebe021b55f2226667b4a99a2ca8ed32aa..9dc5992847b82c09cf9fb1beaabfc9a0559cb204 100755 (executable)
@@ -1,3 +1,6 @@
+puts "TODO OCC25917 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC25917 ALL: Error : The square of result shape is"
+puts "TODO OCC25917 ALL: Error : Result shape is WRONG because it must contains"
 if { [regexp {Debug mode} [dversion]] } {
   puts "TODO OCC25917 ALL: TEST INCOMPLETE"
   puts "TODO OCC25917 ALL: Tcl Exception"
index a4ca44f48c6951fbc6ee337307f12e3f84556f1e..04206198ebf5820a90941c3a02281381f3a1922f 100755 (executable)
@@ -1,5 +1,5 @@
 puts "TODO OCC25829 ALL: Error : The square of result shape is"
-puts "TODO OCC25829 Linux: Faulty shapes in variables faulty_1 to"
+puts "TODO OCC25829 ALL: Faulty shapes in variables faulty_1 to"
 
 puts "============"
 puts "OCC697"
index dde93e7f1e9256fef4270edea1fbd87d6e2148bc..5621debb59c3db2ac8c151aae2634ec605f39214 100755 (executable)
@@ -1,5 +1,5 @@
 puts "TODO OCC25829 ALL: Error : The square of result shape is"
-puts "TODO OCC25829 Linux: Faulty shapes in variables faulty_1 to"
+puts "TODO OCC25829 ALL: Faulty shapes in variables faulty_1 to"
 
 puts "============"
 puts "OCC697"
index ace77912a0cb6865fa300407903ef73ab2c60af0..dc277be079686fd9dddad05ccdb321b7e937d572 100755 (executable)
@@ -1,5 +1,5 @@
 puts "TODO OCC25829 ALL: Error : The square of result shape is"
-puts "TODO OCC25829 Linux: Faulty shapes in variables faulty_1 to"
+puts "TODO OCC25829 ALL: Faulty shapes in variables faulty_1 to"
 
 puts "============"
 puts "OCC697"
index 0dc0e2d536e1dd03720e0618bf6af1020004f6f0..916774c0ada4eeb102a8d47d16955f7218b848e0 100755 (executable)
@@ -1,5 +1,5 @@
 puts "TODO OCC25829 ALL: Error : The square of result shape is"
-puts "TODO OCC25829 Linux: Faulty shapes in variables faulty_1 to"
+puts "TODO OCC25829 ALL: Faulty shapes in variables faulty_1 to"
 
 puts "============"
 puts "OCC697"
index 5b05ca9aa1916a602d0d4c9be452428aaf4d8bb6..47787eb750e6c91997964d0e80d7ce6b2533863d 100755 (executable)
@@ -54,8 +54,8 @@ if {$index > -1} {
   set e1_good_y1 -0.010622244944394899
   set e1_good_z1 -3.0106222449443973
   set e1_good_x2 -17.589377755055537
-  set e1_good_y2 5.7106222251726582
-  set e1_good_z2 -1.6146050638816589
+  set e1_good_y2 5.700038816113608
+  set e1_good_z2 -1.6251884728673096
 
   set e1_x1_percent [GetPercent ${e1_x1} ${e1_good_x1}]
   set e1_y1_percent [GetPercent ${e1_y1} ${e1_good_y1}]
@@ -110,8 +110,8 @@ set good_x1 -17.6105835090592
 set good_y1 -4.7133570660117909
 set good_z1 -4.3679100133425806
 set good_x2 -17.589416490940806
-set good_y2 5.7105834892874094
-set good_z2 -1.6146437997669054
+set good_y2 5.7000000802283299
+set good_z2 -1.6252272087525899
 
 set x1_percent [GetPercent ${x1} ${good_x1}]
 set y1_percent [GetPercent ${y1} ${good_y1}]
diff --git a/tests/bugs/moddata_3/bug26560 b/tests/bugs/moddata_3/bug26560
new file mode 100755 (executable)
index 0000000..0c40031
--- /dev/null
@@ -0,0 +1,37 @@
+puts "========="
+puts "OCC26560"
+puts "========="
+puts ""
+#####################################################################
+## BRepBndLib build too large bounding box in Z direction for planar spline edge.
+#####################################################################
+
+restore [locate_data_file bug26560_planarspline.brep] b1
+
+set rr [bounding b1]
+regexp { *([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $rr full v1_x v1_y v1_z v2_x v2_y v2_z
+
+set tol_abs 1.0e-4
+set tol_rel 0.0001
+
+set expected_v1_x -277.03883383200952
+checkreal "v1_x" ${v1_x} ${expected_v1_x} ${tol_abs} ${tol_rel}
+
+set expected_v1_y -562.56241861670651
+checkreal "v1_y" ${v1_y} ${expected_v1_y} ${tol_abs} ${tol_rel}
+
+set expected_v1_z -9.9999999999999995e-08
+checkreal "v1_z" ${v1_z} ${expected_v1_z} ${tol_abs} ${tol_rel}
+
+set expected_v2_x 20.000000100000001
+checkreal "v2_x" ${v2_x} ${expected_v2_x} ${tol_abs} ${tol_rel}
+
+set expected_v2_y -221.27317426638498
+checkreal "v2_y" ${v2_y} ${expected_v2_y} ${tol_abs} ${tol_rel}
+
+set expected_v2_z 9.9999999999999995e-08
+checkreal "v2_z" ${v2_z} ${expected_v2_z} ${tol_abs} ${tol_rel}
+
+smallview
+fit
+set only_screen_axo 1
index 8c0e68f860dc5d1bb8aed9875844def177be7fab..69b1f6d083a5482dff64eabb0480b19a2828a7d7 100755 (executable)
@@ -3,7 +3,7 @@ puts "TODO CR23096 ALL: NBSHAPES : Faulty"
 puts "TODO CR23096 ALL: TOLERANCE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
-puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
+puts "TODO CR25013 ALL: Error : 4 differences with reference data found" 
 
 set LinuxDiff 4
 set LinuxFaulties {STATSHAPE}