From d2d9e8dc0e9f884d2968cfc2b10009faf5647f3a Mon Sep 17 00:00:00 2001 From: emv Date: Fri, 28 Nov 2014 13:25:00 +0300 Subject: [PATCH] 0025470: Wrong result of COMMON operation Fix for correct splitting of infinite faces. Test cases for issue CR25470 --- src/BOPAlgo/BOPAlgo_BuilderFace.cxx | 54 ++++++++++++++++++++++++++--- tests/bugs/modalg_5/bug25470 | 31 +++++++++++++++++ 2 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 tests/bugs/modalg_5/bug25470 diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx index bc78246bd9..d9104c9dca 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -45,6 +45,10 @@ #include #include // +#include +// +#include +// #include #include @@ -451,7 +455,7 @@ void BOPAlgo_BuilderFace::PerformLoops() void BOPAlgo_BuilderFace::PerformAreas() { Standard_Boolean bIsGrowth, bIsHole; - Standard_Integer k, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap;; + Standard_Integer k, aNbS, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap; Standard_Real aTol; TopLoc_Location aLoc; Handle(Geom_Surface) aS; @@ -469,6 +473,7 @@ void BOPAlgo_BuilderFace::PerformAreas() NCollection_UBTreeFiller aTreeFiller(aBBTree); // myErrorStatus=0; + aNbHoles=0; // aTol=BRep_Tool::Tolerance(myFace); aS=BRep_Tool::Surface(myFace, aLoc); @@ -498,8 +503,8 @@ void BOPAlgo_BuilderFace::PerformAreas() bIsHole=aClsf.IsHole(); if (bIsHole) { BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE); - // - bIsHole=Standard_True; + // + bIsHole=Standard_True; } else { bIsHole=Standard_False; @@ -525,6 +530,7 @@ void BOPAlgo_BuilderFace::PerformAreas() if (bIsHole) { const Bnd_Box2d& aBox2D=aSB2D.Box2D(); aTreeFiller.Add(k, aBox2D); + ++aNbHoles; } } // @@ -546,7 +552,10 @@ void BOPAlgo_BuilderFace::PerformAreas() aSelector.Clear(); aSelector.SetBox(aBox2DF); // - aNbHoles=aBBTree.Select(aSelector); + aNbS = aBBTree.Select(aSelector); + if (!aNbS) { + continue; + } // const BOPCol_ListOfInteger& aLI=aSelector.Indices(); // @@ -572,7 +581,7 @@ void BOPAlgo_BuilderFace::PerformAreas() } }// for (m=1; m<=aNbDMISB; ++m) // - // 5. Map [Face/Holes] -> aMSH + // 5.1 Map [Face/Holes] -> aMSH aNbInOutMap=aInOutMap.Extent(); for (m=1; m<=aNbInOutMap; ++m) { const TopoDS_Shape& aHole=aInOutMap.FindKey(m); @@ -589,6 +598,41 @@ void BOPAlgo_BuilderFace::PerformAreas() } } // + // 5.2. Add unused holes to the original face + if (aNbHoles != aNbInOutMap) { + Bnd_Box aBoxF; + BRepBndLib::Add(myFace, aBoxF); + if (aBoxF.IsOpenXmin() || aBoxF.IsOpenXmax() || + aBoxF.IsOpenYmin() || aBoxF.IsOpenYmax() || + aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax()) { + // + BOPCol_ListOfShape anUnUsedHoles; + for (m = 1; m <= aNbDMISB; ++m) { + const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m); + if (aSB2D.IsHole()) { + const TopoDS_Shape& aHole = aSB2D.Shape(); + if (!aInOutMap.Contains(aHole)) { + anUnUsedHoles.Append(aHole); + } + } + } + // + if (anUnUsedHoles.Extent()) { + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aMSH.Add(aFace, anUnUsedHoles); + // + BOPAlgo_ShapeBox2D aSB2D; + // + aSB2D.SetShape(aFace); + aSB2D.SetIsHole(Standard_False); + // + aDMISB.Add(aNbDMISB, aSB2D); + ++aNbDMISB; + } + } + } + // // 6. Add aHoles to Faces aNbMSH=aMSH.Extent(); for (m=1; m<=aNbMSH; ++m) { diff --git a/tests/bugs/modalg_5/bug25470 b/tests/bugs/modalg_5/bug25470 new file mode 100644 index 0000000000..c6ce67965f --- /dev/null +++ b/tests/bugs/modalg_5/bug25470 @@ -0,0 +1,31 @@ +puts "==========" +puts "OCC25470" +puts "==========" +puts "" +#################################################### +# Wrong result of COMMON operation +#################################################### + +restore [locate_data_file bug25470_s.brep] b1 +restore [locate_data_file bug25470_t.brep] b2 + +bclearobjects +bcleartools +baddobjects b1 +baddtools b2 +bfillds -s +bbop result 0 + +set square 893.011 + +set nb_v_good 45 +set nb_e_good 77 +set nb_w_good 32 +set nb_f_good 32 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 189 + +set 2dviewer 1 -- 2.39.5