From 9112bc3c6a177cf0620424be0c2717c28af3619b Mon Sep 17 00:00:00 2001 From: emv Date: Wed, 3 Aug 2016 10:58:06 +0300 Subject: [PATCH] 0027746: Incomplete result of SECTION operation 1. Partial porting of the fix for the issue #0026560: Function to compute subshape max tolerance has been added. Fixed bounding box expanding at Face/Face step of boolean operation. 2. New test cases are created. --- src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx | 13 +++++++++- src/BRep/BRep_Tool.cdl | 10 ++++++++ src/BRep/BRep_Tool.cxx | 38 ++++++++++++++++++++++++++++ tests/boolean/volumemaker/B7 | 2 ++ tests/boolean/volumemaker/C4 | 3 +++ tests/bugs/modalg_6/bug27746_1 | 25 ++++++++++++++++++ tests/bugs/modalg_6/bug27746_2 | 26 +++++++++++++++++++ tests/bugs/modalg_6/bug27746_3 | 26 +++++++++++++++++++ 8 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/modalg_6/bug27746_1 create mode 100644 tests/bugs/modalg_6/bug27746_2 create mode 100644 tests/bugs/modalg_6/bug27746_3 diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 317793d2ad..09a51996ec 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -306,6 +306,17 @@ void BOPAlgo_PaveFiller::PerformFF() // // Curves, Points aFF.Init(aNbCurves, aNbPoints); + + // 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; + } // // Curves BOPDS_VectorOfCurve& aVNC=aFF.ChangeCurves(); @@ -314,7 +325,7 @@ void BOPAlgo_PaveFiller::PerformFF() // 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); diff --git a/src/BRep/BRep_Tool.cdl b/src/BRep/BRep_Tool.cdl index c81e737b8a..d64d78bc72 100644 --- a/src/BRep/BRep_Tool.cdl +++ b/src/BRep/BRep_Tool.cdl @@ -32,6 +32,7 @@ uses Curve from Geom, Surface from Geom, Shape from GeomAbs, + ShapeEnum from TopAbs, Triangulation from Poly, Polygon3D from Poly, @@ -605,5 +606,14 @@ is raises NullObject from Standard; + MaxTolerance(myclass; + theShape : Shape from TopoDS; + theSubShape : ShapeEnum from TopAbs) + returns Real from Standard; + ---Purpose: + -- 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. + end Tool; diff --git a/src/BRep/BRep_Tool.cxx b/src/BRep/BRep_Tool.cxx index b20853c158..a9341840a9 100644 --- a/src/BRep/BRep_Tool.cxx +++ b/src/BRep/BRep_Tool.cxx @@ -1530,3 +1530,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; +} diff --git a/tests/boolean/volumemaker/B7 b/tests/boolean/volumemaker/B7 index a6e9633541..4f8d70b3e4 100644 --- a/tests/boolean/volumemaker/B7 +++ b/tests/boolean/volumemaker/B7 @@ -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 diff --git a/tests/boolean/volumemaker/C4 b/tests/boolean/volumemaker/C4 index 35302436f3..bcdf92574a 100644 --- a/tests/boolean/volumemaker/C4 +++ b/tests/boolean/volumemaker/C4 @@ -1,6 +1,9 @@ # test script on make volume operation # cylinder plane +puts "TODO OCC26737 ALL: Faulty shapes in variables faulty_1 to faulty_" +puts "TODO OCC26737 ALL: Error: bopcheck failed" + # planar face plane pln_f1 0 515 1.1102230246251565e-015 0 -1 -1.1102230246251565e-016 erase pln_f1 diff --git a/tests/bugs/modalg_6/bug27746_1 b/tests/bugs/modalg_6/bug27746_1 new file mode 100644 index 0000000000..55d16ed32a --- /dev/null +++ b/tests/bugs/modalg_6/bug27746_1 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC27746" +puts "========" +puts "" +################################################# +# Incomplete result of SECTION operation +################################################# + +restore [locate_data_file bug27746_first.brep] b1 +restore [locate_data_file bug27746_second.brep] b2 + +settolerance b2 1.e-7 +fixshape b2 b2 + +bclearobjects +bcleartools +baddobjects b1 +baddtools b2 +bfillds +bbop result 4 + +regexp {nb alone Vertices : ([-0-9.+eE]+)} [checksection result] full nbv +if { $nbv > 4 } { puts "Error : Section is incorrect" } + +set length 88.2082 \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27746_2 b/tests/bugs/modalg_6/bug27746_2 new file mode 100644 index 0000000000..e04bb09f31 --- /dev/null +++ b/tests/bugs/modalg_6/bug27746_2 @@ -0,0 +1,26 @@ +puts "========" +puts "OCC27746" +puts "========" +puts "" +################################################# +# Incomplete result of SECTION operation +################################################# + +restore [locate_data_file bug27746_first.brep] b1 +restore [locate_data_file bug27746_second.brep] b2 + +explode b1 f; compound b1_60 b1_61 b1 +explode b2 f; compound b2_14 b2_18 b2 +donly b1 b2 + +bclearobjects +bcleartools +baddobjects b1 +baddtools b2 +bfillds +bbop result 4 + +regexp {nb alone Vertices : ([-0-9.+eE]+)} [checksection result] full nbv +if { $nbv != 2 } { puts "Error : Section is incorrect" } + +set length 4.39869 \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug27746_3 b/tests/bugs/modalg_6/bug27746_3 new file mode 100644 index 0000000000..885d6eff3b --- /dev/null +++ b/tests/bugs/modalg_6/bug27746_3 @@ -0,0 +1,26 @@ +puts "========" +puts "OCC27746" +puts "========" +puts "" +################################################# +# Incomplete result of SECTION operation +################################################# + +restore [locate_data_file bug27746_first.brep] b1 +restore [locate_data_file bug27746_second.brep] b2 + +explode b1 f; compound b1_60 b1_61 b1 +explode b2 f; compound b2_21 b2_37 b2 +donly b1 b2 + +bclearobjects +bcleartools +baddobjects b1 +baddtools b2 +bfillds +bbop result 4 + +regexp {nb alone Vertices : ([-0-9.+eE]+)} [checksection result] full nbv +if { $nbv != 2 } { puts "Error : Section is incorrect" } + +set length 4.39869 \ No newline at end of file -- 2.39.5