diff --git a/src/BOP/BOP_SDFWESFiller.cxx b/src/BOP/BOP_SDFWESFiller.cxx index fe93bf2420..33e0c1f14a 100755 --- a/src/BOP/BOP_SDFWESFiller.cxx +++ b/src/BOP/BOP_SDFWESFiller.cxx @@ -84,6 +84,11 @@ static void TreatSDSeams (const TopoDS_Edge& aSpE1Seam11, BOP_WireEdgeSet& aWES, const Handle(IntTools_Context)& aContext); +//modified by NIZNHY-PKV Tue Sep 25 14:26:14 2012f +static + Standard_Boolean IsClosed(const TopoDS_Edge& aE, + const TopoDS_Face& aF); +//modified by NIZNHY-PKV Tue Sep 25 14:26:17 2012t //======================================================================= // function: BOP_SDFWESFiller::BOP_SDFWESFiller @@ -664,7 +669,10 @@ static void TreatSDSeams (const TopoDS_Edge& aSpE1Seam11, // aWES.AddStartElement (aSS); // - if (BRep_Tool::IsClosed(aSS, aF2FWD)){ + //modified by NIZNHY-PKV Tue Sep 25 14:25:13 2012f + if (IsClosed(aSS, aF2FWD)){ + //if (BRep_Tool::IsClosed(aSS, aF2FWD)){ + //modified by NIZNHY-PKV Tue Sep 25 14:25:35 2012t TopoDS_Shape EE=aSS.Reversed(); aWES.AddStartElement (EE); } @@ -1320,3 +1328,40 @@ void TreatSDSeams (const TopoDS_Edge& aSpE1Seam11, aSS=aSpE1Seam21; } } +//modified by NIZNHY-PKV Tue Sep 25 14:25:53 2012f +//======================================================================= +//function : IsClosed +//purpose : +//======================================================================= +Standard_Boolean IsClosed(const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + Standard_Boolean bRet; + // + bRet=BRep_Tool::IsClosed(aE, aF); + if (bRet) { + Standard_Integer iCnt; + TopoDS_Shape aE1; + // + bRet=!bRet; + iCnt=0; + TopExp_Explorer aExp(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aEx=aExp.Current(); + // + if (aEx.IsSame(aE)) { + ++iCnt; + if (iCnt==1) { + aE1=aEx; + } + else if (iCnt==2){ + aE1.Reverse(); + bRet=(aE1==aEx); + break; + } + } + } + } + return bRet; +} +//modified by NIZNHY-PKV Tue Sep 25 14:25:56 2012t diff --git a/src/BOP/BOP_ShellShell.cxx b/src/BOP/BOP_ShellShell.cxx index 77510856fa..199dc76e65 100755 --- a/src/BOP/BOP_ShellShell.cxx +++ b/src/BOP/BOP_ShellShell.cxx @@ -65,6 +65,7 @@ #include #include #include +#include @@ -80,13 +81,14 @@ BOP_ShellShell::BOP_ShellShell() // function: Destroy // purpose: //======================================================================= - void BOP_ShellShell::Destroy() {} +void BOP_ShellShell::Destroy() { +} //======================================================================= // function: DoWithFiller // purpose: //======================================================================= - void BOP_ShellShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller) +void BOP_ShellShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller) { myErrorStatus=0; myIsDone=Standard_False; @@ -99,14 +101,12 @@ BOP_ShellShell::BOP_ShellShell() try { OCC_CATCH_SIGNALS - // modified by NIZHNY-MKK Fri Sep 3 15:14:17 2004.BEGIN if(!myDSFiller->IsDone()) { myErrorStatus = 1; BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n"); return; } - // modified by NIZHNY-MKK Fri Sep 3 15:14:20 2004.END - + // Standard_Boolean bIsNewFiller; bIsNewFiller=aDSFiller.IsNewFiller(); @@ -141,7 +141,7 @@ BOP_ShellShell::BOP_ShellShell() // function: BuildResult // purpose: //================================================================================= - void BOP_ShellShell::BuildResult() +void BOP_ShellShell::BuildResult() { const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); @@ -231,7 +231,7 @@ BOP_ShellShell::BOP_ShellShell() // // vars Standard_Boolean bIsTouchCase, bIsTouch; - Standard_Integer i, aNb, j, aNbj, iFF, nF1, iRank; + Standard_Integer i, aNb, j, aNbj, iFF, nF1, iRank, nF2; TopTools_ListOfShape aListOfNewFaces; TopTools_IndexedMapOfShape anEMap; TopAbs_Orientation anOriF1; @@ -283,6 +283,65 @@ BOP_ShellShell::BOP_ShellShell() } } // 3. Add IN2D, ON2D Parts to the WES + // + //modified by NIZNHY-PKV Fri Sep 14 10:00:44 2012f + BOP_WireEdgeSet aWES1 (myFace); + // + for (j=1; j<=aNbj; j++) { + iFF=aFFIndicesMap(j); + BOPTools_SSInterference& aFF=aFFs(iFF); + bIsTouch=aFF.IsTangentFaces(); + if (bIsTouch) { + nF2=aFF.OppositeIndex(nF1); + AddINON2DPartsSh(nF1, iFF, aWES1); + } + } + // + if (iRank==2 || (iRank==1 && myOperation==BOP_CUT)) { + // #0023431 + // Refine WES to remove duplicated edges: + // - for the faces of the Object: Cut operation + // - for the faces of the Tool: all operations + // + // The duplications caused by the separated treatment + // the faces of an argument for the cases when: + // -these faces contain shared edges and + // -they are same domain faces with the faces of the other argument. + TopTools_DataMapOfShapeInteger aDMSI; + + //-- + aWES1.InitStartElements(); + for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aWES1.StartElement()); + if (!aDMSI.IsBound(aE)) { + Standard_Integer iCnt=1; + // + aDMSI.Bind(aE, iCnt); + } + else { + Standard_Integer& iCnt=aDMSI.ChangeFind(aE); + ++iCnt; + } + } + // + aWES1.InitStartElements(); + for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { + const TopoDS_Shape& aE=aWES1.StartElement(); + const Standard_Integer& iCnt=aDMSI.Find(aE); + if (iCnt==1) { + aWES.AddStartElement(aE); + } + } + } + else { + aWES1.InitStartElements(); + for (; aWES1.MoreStartElements(); aWES1.NextStartElement()) { + const TopoDS_Shape& aE=aWES1.StartElement(); + aWES.AddStartElement(aE); + } + } + //-- + /* for (j=1; j<=aNbj; j++) { iFF=aFFIndicesMap(j); BOPTools_SSInterference& aFF=aFFs(iFF); @@ -293,6 +352,8 @@ BOP_ShellShell::BOP_ShellShell() AddINON2DPartsSh(nF1, iFF, aWES); } } + */ + //modified by NIZNHY-PKV Fri Sep 14 10:00:48 2012t // 4. Add EF parts (E (from F2) on F1 ), // where F2 is non-same-domain face to F1 anEMap.Clear(); @@ -358,15 +419,6 @@ BOP_ShellShell::BOP_ShellShell() } }// end of (bIsTouchCase)'s else // - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the WES - if (myDraw) { - const TopTools_ListOfShape& aWESL=aWES.StartElements(); - BOP_Draw::DrawListOfEdgesWithPC (myFace, aWESL, i, "ew_"); - BOP_Draw::Wait(); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // // d. Build new Faces from myFace BOP_FaceBuilder aFB; @@ -396,12 +448,24 @@ BOP_ShellShell::BOP_ShellShell() // }// for (i=1; i<=aNb; i++) // - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Display the new Faces - if (myDraw) { - BOP_Draw::DrawListOfShape(aListOfNewFaces, "fn_"); - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + myNewFaces.Clear(); myNewFaces.Append(aListOfNewFaces); } +/* DEB + { + TopoDS_Compound aCx; + BRep_Builder aBB; + // + aBB.MakeCompound(aCx); + aBB.Add(aCx, myFace); + // + aWES.InitStartElements(); + for (; aWES.MoreStartElements(); aWES.NextStartElement()) { + const TopoDS_Shape& aE = aWES.StartElement(); + aBB.Add(aCx, aE); + } + int a=0; + } + +*/ diff --git a/tests/boolean/bopcut_simple/ZQ1 b/tests/boolean/bopcut_simple/ZQ1 new file mode 100755 index 0000000000..0210d837e7 --- /dev/null +++ b/tests/boolean/bopcut_simple/ZQ1 @@ -0,0 +1,39 @@ +puts "============" +puts "CR23431" +puts "============" +puts "" +################################################################################### +# BOP Cut produces invalid shape +################################################################################### + +plane pl1 +mkface face_1 pl1 -100 100 -100 100 + +circle c1 0 0 0 20 +circle c2 0 0 0 30 + +mkedge e1 c1 +wire w1 e1 +mkface d1 pl1 w1 + +mkedge e2 c2 +wire w2 e2 +mkface d2 pl1 w2 + +bop d2 d1 +bopcut D_coupe_1 + +bop D_coupe_1 d1 +bopfuse Union_1 + +bop face_1 Union_1 +bopcut result + +set square 37172.6 + + + + + + +