From 8620e18d6e79600655295e8861eb89e64a3f6f1c Mon Sep 17 00:00:00 2001 From: pkv Date: Thu, 17 Apr 2014 16:04:29 +0400 Subject: [PATCH] 0024825: Fit Boolean Operation Algorithm to treat multiple arguments. class BOPTest class BOPAlgo_BOP class BOPAlgo_Builder class BOPTest class BRepFeat_Builder class BRepFeat_MakeCylindricalHole The format of the command has been changed: bbop r op [-s -t] The following options has been added: -s - run in serial mode -t - print the CPU time Test cases for issue CR24825 --- src/BOPAlgo/BOPAlgo_BOP.cdl | 88 +-- src/BOPAlgo/BOPAlgo_BOP.cxx | 716 +++++++++++------- src/BOPAlgo/BOPAlgo_BOP_1.cxx | 27 +- src/BOPAlgo/BOPAlgo_Builder_3.cxx | 3 +- src/BOPAlgo/BOPAlgo_Builder_4.cxx | 20 +- src/BOPTest/BOPTest_ObjCommands.cxx | 37 +- src/BOPTest/BOPTest_PartitionCommands.cxx | 43 +- src/BRepFeat/BRepFeat_Builder.cxx | 17 +- src/BRepFeat/BRepFeat_MakeCylindricalHole.cxx | 47 +- tests/boolean/bcommon_2d/A7 | 2 +- tests/boolean/bcommon_2d/B1 | 2 +- tests/boolean/bopcommon_2d/A7 | 2 +- tests/boolean/bopcommon_2d/B1 | 2 +- tests/bugs/modalg_5/bug24825_common | 58 ++ tests/bugs/modalg_5/bug24825_cut | 58 ++ tests/bugs/modalg_5/bug24825_fuse | 59 ++ 16 files changed, 774 insertions(+), 407 deletions(-) mode change 100644 => 100755 tests/boolean/bcommon_2d/A7 mode change 100644 => 100755 tests/boolean/bcommon_2d/B1 mode change 100644 => 100755 tests/boolean/bopcommon_2d/A7 mode change 100644 => 100755 tests/boolean/bopcommon_2d/B1 create mode 100644 tests/bugs/modalg_5/bug24825_common create mode 100644 tests/bugs/modalg_5/bug24825_cut create mode 100644 tests/bugs/modalg_5/bug24825_fuse diff --git a/src/BOPAlgo/BOPAlgo_BOP.cdl b/src/BOPAlgo/BOPAlgo_BOP.cdl index 5c49614400..4a8daa7eff 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.cdl +++ b/src/BOPAlgo/BOPAlgo_BOP.cdl @@ -10,20 +10,26 @@ -- distribution for complete text of the license and disclaimer of any warranty. -- -- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. +-- commercial license or contractual agreement. +--BOPAlgo_BOP.cdl + class BOP from BOPAlgo inherits Builder from BOPAlgo + ---Purpose: -uses - Shape from TopoDS, +uses + ShapeEnum from TopAbs, + Shape from TopoDS, + ListOfShape from TopTools, + -- BaseAllocator from BOPCol, ListOfShape from BOPCol, - ListOfShape from TopTools, - MapOfShape from BOPCol, - IndexedDataMapOfShapeListOfShape from BOPCol, - Operation from BOPAlgo, + MapOfShape from BOPCol, + IndexedDataMapOfShapeListOfShape from BOPCol, + -- + Operation from BOPAlgo, PaveFiller from BOPAlgo --raises @@ -31,85 +37,79 @@ uses is Create ---Purpose: Empty constructor - returns BOP from BOPAlgo; + returns BOP from BOPAlgo; ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BOP();" Create (theAllocator: BaseAllocator from BOPCol) - returns BOP from BOPAlgo; + returns BOP from BOPAlgo; Clear(me:out) is redefined; ---Purpose: Clears internal fields and arguments - AddArgument (me:out; - theShape: Shape from TopoDS) - ---Purpose: Adds Object argument of the operation - is redefined; - AddTool (me:out; - theShape: Shape from TopoDS) + theShape: Shape from TopoDS) ---Purpose: Adds Tool argument of the operation - is virtual; - - Object(me) - returns Shape from TopoDS; - ---C++: return const & - - Tool(me) - returns Shape from TopoDS; - ---C++: return const & + is virtual; SetOperation(me:out; - theOperation: Operation from BOPAlgo); + theOperation: Operation from BOPAlgo); Operation(me) - returns Operation from BOPAlgo; + returns Operation from BOPAlgo; + -- + Perform(me:out) + is redefined; -- -- protected methods -- CheckData(me:out) - is redefined protected; + is redefined protected; Prepare(me:out) - is redefined protected; + is redefined protected; ---Purpose: Provides preparing actions PerformInternal(me:out; thePF:PaveFiller from BOPAlgo) - is redefined protected; + is redefined protected; ---Purpose: Performs calculations using prepared Filler -- object theDSF - + + BuildResult(me:out; + theType: ShapeEnum from TopAbs) + is redefined protected; + BuildShape(me:out) - is protected; + is protected; BuildRC(me:out) - is protected; + is protected; BuildSolid(me:out) - is protected; + is protected; BuildSection(me:out) - is protected; + is protected; IsBoundSplits(me:out; - theS:Shape from TopoDS; - theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol) - returns Boolean from Standard - is protected; + theS:Shape from TopoDS; + theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol) + returns Boolean from Standard + is protected; Generated (me:out; - theS : Shape from TopoDS) + theS : Shape from TopoDS) + returns ListOfShape from TopTools + is redefined; + ---C++: return const & ---Purpose: Returns the list of shapes generated from the -- shape theS. - returns ListOfShape from TopTools - is redefined; - ---C++: return const & + + fields - myNbArgs : Integer from Standard is protected; myOperation : Operation from BOPAlgo is protected; - myArgs : Shape from TopoDS[2] is protected; myDims : Integer from Standard[2] is protected; -- myRC : Shape from TopoDS is protected; diff --git a/src/BOPAlgo/BOPAlgo_BOP.cxx b/src/BOPAlgo/BOPAlgo_BOP.cxx index 53f0617434..47a392ca23 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.cxx +++ b/src/BOPAlgo/BOPAlgo_BOP.cxx @@ -18,58 +18,69 @@ #include #include +#include #include #include +#include +#include +#include +#include +#include + +#include + #include #include #include +#include -#include #include -#include + +#include + static TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim); + //======================================================================= //function : //purpose : //======================================================================= - BOPAlgo_BOP::BOPAlgo_BOP() +BOPAlgo_BOP::BOPAlgo_BOP() : BOPAlgo_Builder(), myTools(myAllocator), myMapTools(100, myAllocator) { - myNbArgs=2; Clear(); } //======================================================================= //function : //purpose : //======================================================================= - BOPAlgo_BOP::BOPAlgo_BOP(const Handle(NCollection_BaseAllocator)& theAllocator) +BOPAlgo_BOP::BOPAlgo_BOP + (const Handle(NCollection_BaseAllocator)& theAllocator) : BOPAlgo_Builder(theAllocator), myTools(myAllocator), myMapTools(100, myAllocator) { - myNbArgs=2; Clear(); } //======================================================================= //function : ~ //purpose : //======================================================================= - BOPAlgo_BOP::~BOPAlgo_BOP() +BOPAlgo_BOP::~BOPAlgo_BOP() { } //======================================================================= //function : Clear //purpose : //======================================================================= - void BOPAlgo_BOP::Clear() +void BOPAlgo_BOP::Clear() { myOperation=BOPAlgo_UNKNOWN; myTools.Clear(); @@ -80,52 +91,10 @@ static BOPAlgo_Builder::Clear(); } //======================================================================= -//function : AddArgument -//purpose : -//======================================================================= - void BOPAlgo_BOP::AddArgument(const TopoDS_Shape& theShape) -{ - if (myMapFence.Add(theShape)) { - myArguments.Append(theShape); - myArgs[0]=theShape; - } -} -//======================================================================= -//function : AddTool -//purpose : -//======================================================================= - void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape) -{ - if (myMapTools.Add(theShape)) { - myTools.Append(theShape); - myArgs[1]=theShape; - // - if (myMapFence.Add(theShape)) { - myArguments.Append(theShape); - } - } -} -//======================================================================= -//function : Object -//purpose : -//======================================================================= - const TopoDS_Shape& BOPAlgo_BOP::Object()const -{ - return myArgs[0]; -} -//======================================================================= -//function : Tool -//purpose : -//======================================================================= - const TopoDS_Shape& BOPAlgo_BOP::Tool()const -{ - return myArgs[1]; -} -//======================================================================= //function : SetOperation //purpose : //======================================================================= - void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation) +void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation) { myOperation=theOperation; } @@ -133,27 +102,42 @@ static //function : Operation //purpose : //======================================================================= - BOPAlgo_Operation BOPAlgo_BOP::Operation()const +BOPAlgo_Operation BOPAlgo_BOP::Operation()const { return myOperation; } //======================================================================= +//function : AddTool +//purpose : +//======================================================================= +void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape) +{ + if (myMapTools.Add(theShape)) { + myTools.Append(theShape); + } +} +//======================================================================= //function : CheckData //purpose : //======================================================================= - void BOPAlgo_BOP::CheckData() +void BOPAlgo_BOP::CheckData() { - Standard_Integer i, aNb; + Standard_Integer i, j, iDim, aNbArgs, aNbTools; Standard_Boolean bFlag; + BOPCol_ListIteratorOfListOfShape aItLS; // myErrorStatus=0; // - aNb=myArguments.Extent(); - if (aNb!=myNbArgs) { - if (aNb!=1 || !(myArgs[0].IsSame(myArgs[1]))) { - myErrorStatus=10; // invalid number of arguments - return; - } + aNbArgs=myArguments.Extent(); + if (!aNbArgs) { + myErrorStatus=100; // invalid number of Arguments + return; + } + // + aNbTools=myTools.Extent(); + if (!aNbTools) { + myErrorStatus=100; // invalid number of Tools + return; } // if (!myPaveFiller) { @@ -166,25 +150,31 @@ static return; } // - for (i=0; iArguments(); + aIt.Initialize(aLA); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aType=aS.ShapeType(); + if (aType==theType) { + if (myImages.IsBound(aS)){ + const BOPCol_ListOfShape& aLSIm=myImages.Find(aS); + aItIm.Initialize(aLSIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSIm=aItIm.Value(); + if (aM.Add(aSIm)) { + aBB.Add(myShape, aSIm); + } + } + } + else { + if (aM.Add(aS)) { + aBB.Add(myShape, aS); + } + } } } } //======================================================================= +//function : Perform +//purpose : +//======================================================================= +void BOPAlgo_BOP::Perform() +{ + Handle(NCollection_BaseAllocator) aAllocator; + BOPAlgo_PaveFiller* pPF; + BOPCol_ListIteratorOfListOfShape aItLS; + // + myErrorStatus=0; + // + if (myEntryPoint==1) { + if (myPaveFiller) { + delete myPaveFiller; + myPaveFiller=NULL; + } + } + // + aAllocator=new NCollection_IncAllocator; + BOPCol_ListOfShape aLS(aAllocator); + // + aItLS.Initialize(myArguments); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aS=aItLS.Value(); + aLS.Append(aS); + } + // + aItLS.Initialize(myTools); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aS=aItLS.Value(); + aLS.Append(aS); + } + // + pPF=new BOPAlgo_PaveFiller(aAllocator); + pPF->SetArguments(aLS); + // + pPF->Perform(); + // + myEntryPoint=1; + PerformInternal(*pPF); +} +//======================================================================= //function : PerformInternal //purpose : //======================================================================= - void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller) +void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller) { myErrorStatus=0; myWarningStatus=0; @@ -271,10 +356,10 @@ static if (myErrorStatus) { return; } + // if(myWarningStatus == 2) { return; } - // // 3. Fill Images // 3.1 Vertices FillImagesVertices(); @@ -296,14 +381,14 @@ static if (myErrorStatus) { return; } - //-------------------------------- SECTION f + //-------------------------------- SECTION if (myOperation==BOPAlgo_SECTION) { BuildSection(); PrepareHistory(); PostTreat(); return; } - //-------------------------------- SECTION t + //-------------------------------- // // 3.3 Wires FillImagesContainers(TopAbs_WIRE); @@ -368,21 +453,204 @@ static return; } // - // 6.BuildShape; + // 4.BuildShape; BuildShape(); + if (myErrorStatus) { + return; + } // - // 4.History + // 5.History PrepareHistory(); - // - // 5 Post-treatment + // 6 Post-treatment PostTreat(); } //======================================================================= +//function : BuildRC +//purpose : +//======================================================================= +void BOPAlgo_BOP::BuildRC() +{ + Standard_Boolean bFlag1, bFlag2, bIsBound; + Standard_Integer aDmin; + TopAbs_ShapeEnum aTmin; + TopoDS_Compound aC; + TopoDS_Shape aSAIm, aSTIm; + BRep_Builder aBB; + TopExp_Explorer aExp; + BOPCol_DataMapOfShapeShape aDMSSA; + BOPCol_ListIteratorOfListOfShape aItLS, aItIm; + // + myErrorStatus=0; + // + aBB.MakeCompound(aC); + // + // A. Fuse + if (myOperation==BOPAlgo_FUSE) { + aTmin=TypeToExplore(myDims[0]); + aExp.Init(myShape, aTmin); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS=aExp.Current(); + aBB.Add(aC, aS); + } + myRC=aC; + return; + } + // + aDmin=myDims[1]; + if (myDims[0] < myDims[1]) { + aDmin=myDims[0]; + } + aTmin=TypeToExplore(aDmin); + // + // B. Common, Cut, Cut21 + // + bFlag1=(myOperation==BOPAlgo_COMMON || myOperation==BOPAlgo_CUT21); + bFlag2=(myOperation==BOPAlgo_CUT || myOperation==BOPAlgo_CUT21); + // + const BOPCol_ListOfShape& aLA=( bFlag1) ? myArguments : myTools; + aItLS.Initialize(aLA); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSA=aItLS.Value(); + // + if (myImages.IsBound(aSA)){ + const BOPCol_ListOfShape& aLSAIm=myImages.Find(aSA); + aItIm.Initialize(aLSAIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSAIm=aItIm.Value(); + aExp.Init(aSAIm, aTmin); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape aSIm=aExp.Current(); + aDMSSA.Bind(aSIm, aSIm); + } + } + } + // + else { + aExp.Init(aSA, aTmin); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape aSIm=aExp.Current(); + aDMSSA.Bind(aSIm, aSIm); + } + } + } //for (; aItLS.More(); aItLS.Next()) + // + const BOPCol_ListOfShape& aLT=(!bFlag1) ? myArguments : myTools; + aItLS.Initialize(aLT); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aST=aItLS.Value(); + if (myImages.IsBound(aST)){ + const BOPCol_ListOfShape& aLSTIm=myImages.Find(aST); + aItIm.Initialize(aLSTIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSTIm=aItIm.Value(); + aExp.Init(aSTIm, aTmin); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape aSIm=aExp.Current(); + // skip degenerated edges + if (aTmin==TopAbs_EDGE) { + const TopoDS_Edge& aEIm=*((TopoDS_Edge*)&aSIm); + if (BRep_Tool::Degenerated(aEIm)) { + continue; + } + } + // + bIsBound=aDMSSA.IsBound(aSIm); + if (!bFlag2) { // ie common + if (bIsBound) { + const TopoDS_Shape& aSImA=aDMSSA.Find(aSIm); + aBB.Add(aC, aSImA); + } + } + else {// ie cut or cut21 + if (!bIsBound) { + aBB.Add(aC, aSIm); + } + } + } + } + } + else { + aExp.Init(aST, aTmin); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape aSIm=aExp.Current(); + // skip degenerated edges + if (aTmin==TopAbs_EDGE) { + const TopoDS_Edge& aEIm=*((TopoDS_Edge*)&aSIm); + if (BRep_Tool::Degenerated(aEIm)) { + continue; + } + } + bIsBound=aDMSSA.IsBound(aSIm); + if (!bFlag2) { // ie common + if (bIsBound) { + const TopoDS_Shape& aSImA=aDMSSA.Find(aSIm); + aBB.Add(aC, aSImA); + } + } + else {// ie cut or cut21 + if (!bIsBound) { + aBB.Add(aC, aSIm); + } + } + } + } + } //for (; aItLS.More(); aItLS.Next()) + // + // the squats around degeneracy + if (aTmin!=TopAbs_EDGE) { + myRC=aC; + return; + } + //--------------------------------------------------------- + // + // The squats around degenerated edges + Standard_Integer i, aNbS, nVD; + TopAbs_ShapeEnum aType; + BOPCol_IndexedMapOfShape aMVC; + // + // 1. Vertices of aC + BOPTools::MapShapes(aC, TopAbs_VERTEX, aMVC); + // + // 2. DE candidates + aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); + aType=aSI.ShapeType(); + if (aType!=aTmin) { + continue; + } + // + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aSI.Shape()); + if (!BRep_Tool::Degenerated(aE)) { + continue; + } + // + nVD=aSI.SubShapes().First(); + const TopoDS_Shape& aVD=myDS->Shape(nVD); + // + if (!aMVC.Contains(aVD)) { + continue; + } + // + if (myDS->IsNewShape(nVD)) { + continue; + } + // + if (myDS->HasInterf(nVD)) { + continue; + } + // + aBB.Add(aC, aE); + } + // + myRC=aC; +} +//======================================================================= //function : BuildShape //purpose : //======================================================================= - void BOPAlgo_BOP::BuildShape() +void BOPAlgo_BOP::BuildShape() { Standard_Integer aDmin, aNbLCB; TopAbs_ShapeEnum aT1, aT2, aTR; @@ -395,7 +663,6 @@ static myErrorStatus=0; // BuildRC(); - //myShape=myRC; // aDmin=myDims[1]; if (myDims[0]aNb[1])? 1 : 0; - } else { - iX=(myDims[0]Arguments(); + aIt.Initialize(aArguments); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); TreatCompound(aS, aMFence, aLSC); diff --git a/src/BOPAlgo/BOPAlgo_Builder_4.cxx b/src/BOPAlgo/BOPAlgo_Builder_4.cxx index 48c77da07c..04ac50c3fc 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_4.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_4.cxx @@ -22,14 +22,18 @@ #include #include +#include + #include #include + //======================================================================= //function : Generated //purpose : //======================================================================= - const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape&) +const TopTools_ListOfShape& BOPAlgo_Builder::Generated + (const TopoDS_Shape&) { myHistShapes.Clear(); return myHistShapes; @@ -38,7 +42,8 @@ //function : Modified //purpose : //======================================================================= - const TopTools_ListOfShape& BOPAlgo_Builder::Modified(const TopoDS_Shape& theS) +const TopTools_ListOfShape& BOPAlgo_Builder::Modified + (const TopoDS_Shape& theS) { Standard_Boolean bHasImage, bToReverse; TopAbs_ShapeEnum aType; @@ -78,7 +83,8 @@ aSp.Orientation(theS.Orientation()); } else { - bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext); + bToReverse= + BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext); if (bToReverse) { aSp.Reverse(); } @@ -94,7 +100,8 @@ //function : IsDeleted //purpose : //======================================================================= - Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS) +Standard_Boolean BOPAlgo_Builder::IsDeleted + (const TopoDS_Shape& theS) { Standard_Boolean bRet, bHasImage, bContains; TopAbs_ShapeEnum aType; @@ -147,7 +154,7 @@ //function : PrepareHistory //purpose : //======================================================================= - void BOPAlgo_Builder::PrepareHistory() +void BOPAlgo_Builder::PrepareHistory() { if (!myFlagHistory) { return; @@ -170,7 +177,8 @@ BOPTools::MapShapes(myShape, myMapShape); // // 3. MS - all argument shapes with theirs sub-shapes - aIt.Initialize(myArguments); + const BOPCol_ListOfShape& aArguments=myDS->Arguments(); + aIt.Initialize(aArguments); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSx=aIt.Value(); BOPTools::MapShapes(aSx, aMS); diff --git a/src/BOPTest/BOPTest_ObjCommands.cxx b/src/BOPTest/BOPTest_ObjCommands.cxx index c3345c1287..d7bc828173 100644 --- a/src/BOPTest/BOPTest_ObjCommands.cxx +++ b/src/BOPTest/BOPTest_ObjCommands.cxx @@ -30,6 +30,7 @@ static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , co static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** ); +static Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer , const char** ); // //======================================================================= //function :ObjCommands @@ -43,11 +44,12 @@ static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , cons // Chapter's name const char* g = "BOP commands"; // Commands - theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g); - theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g); - theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g); - theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g); - theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g); + theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g); + theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g); + theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g); + theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g); + theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g); + theCommands.Add("baddctools" , "baddctools c" , __FILE__, baddctools, g); } //======================================================================= //function : baddcompound @@ -74,6 +76,31 @@ Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const cha // return 0; } +//======================================================================= +//function : baddctools +//purpose : +//======================================================================= +Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer n, const char** a) +{ + if (n<2) { + printf(" Use baddctools c\n"); + return 0; + } + // + TopoDS_Iterator aIt; + TopoDS_Shape aS; + // + aS=DBRep::Get(a[1]); + // + BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools(); + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aLT.Append(aSx); + } + // + return 0; +} // //======================================================================= //function :baddobjects diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index d01c630de9..d735a98b33 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -117,10 +117,10 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands) // Chapter's name const char* g = "Partition commands"; // Commands - theCommands.Add("bfillds" , "use bfillds [-s -t]" , __FILE__, bfillds, g); - theCommands.Add("bbuild" , "use bbuild r [-s -t]", __FILE__, bbuild, g); - theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g); - theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g); + theCommands.Add("bfillds", "use bfillds [-s -t]" , __FILE__, bfillds, g); + theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g); + theCommands.Add("bbop" , "use bbop r op [-s -t]", __FILE__, bbop, g); + theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g); } //======================================================================= @@ -314,8 +314,8 @@ Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n!=3) { - di << " use bbop r op\n"; + if (n<3) { + di << " use bbop r op [-s -t]\n"; return 0; } // @@ -326,16 +326,30 @@ Standard_Integer bbop(Draw_Interpretor& di, } // char buf[32]; - Standard_Integer iErr, iOp; + Standard_Boolean bRunParallel, bShowTime; + Standard_Integer iErr, iOp, i; BOPAlgo_Operation aOp; - BOPCol_ListIteratorOfListOfShape aIt; + BOPCol_ListIteratorOfListOfShape aIt; + BOPTime_Chronometer aChrono; // iOp=Draw::Atoi(a[2]); if (iOp<0 || iOp>4) { di << " invalid operation type\n"; + return 0; } aOp=(BOPAlgo_Operation)iOp; // + bShowTime=Standard_False; + bRunParallel=Standard_True; + for (i=3; i Length) { myStatus = BRepFeat_InvalidPlacement; return; diff --git a/tests/boolean/bcommon_2d/A7 b/tests/boolean/bcommon_2d/A7 old mode 100644 new mode 100755 index c1b65e0917..eae2028f4b --- a/tests/boolean/bcommon_2d/A7 +++ b/tests/boolean/bcommon_2d/A7 @@ -3,4 +3,4 @@ restore [locate_data_file case_1_wire3.brep] b bcommon result b a set length 942.478 set nbsh_v 2 -set nbsh_e 4 +set nbsh_e 2 diff --git a/tests/boolean/bcommon_2d/B1 b/tests/boolean/bcommon_2d/B1 old mode 100644 new mode 100755 index 0416f3accb..79df60b89b --- a/tests/boolean/bcommon_2d/B1 +++ b/tests/boolean/bcommon_2d/B1 @@ -3,4 +3,4 @@ restore [locate_data_file case_1_wire3.brep] b bcommon result b a set length 942.478 set nbsh_v 2 -set nbsh_e 4 +set nbsh_e 2 diff --git a/tests/boolean/bopcommon_2d/A7 b/tests/boolean/bopcommon_2d/A7 old mode 100644 new mode 100755 index 38d15b62c3..5a83db882d --- a/tests/boolean/bopcommon_2d/A7 +++ b/tests/boolean/bopcommon_2d/A7 @@ -4,4 +4,4 @@ bop a b bopcommon result set length 942.478 set nbsh_v 2 -set nbsh_e 4 +set nbsh_e 2 diff --git a/tests/boolean/bopcommon_2d/B1 b/tests/boolean/bopcommon_2d/B1 old mode 100644 new mode 100755 index 1184d199c3..b58c041997 --- a/tests/boolean/bopcommon_2d/B1 +++ b/tests/boolean/bopcommon_2d/B1 @@ -4,4 +4,4 @@ bop a b bopcommon result set length 942.478 set nbsh_v 2 -set nbsh_e 4 +set nbsh_e 2 diff --git a/tests/bugs/modalg_5/bug24825_common b/tests/bugs/modalg_5/bug24825_common new file mode 100644 index 0000000000..16adc1853e --- /dev/null +++ b/tests/bugs/modalg_5/bug24825_common @@ -0,0 +1,58 @@ +puts "=========" +puts "OCC24825" +puts "=========" +puts "" +########################################################### +# Fit Boolean Operation Algorithm to treat multiple arguments. +########################################################### + +restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1 +restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2 +restore [locate_data_file bug24825_steering-wheel-drum.brep] b4 +restore [locate_data_file bug24825_steering-wheel-handle.brep] hb + +set qs {} + +set N 10 +set N1 [expr 360. / $N ] + +for {set i 0} {$i < $N} {incr i} { + tcopy hb hb_${i} + trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ] + lappend qs hb_${i} +} +eval compound $qs b3 + +tcopy b1 b5 +ttranslate b5 0 0 100 + +tcopy b2 b6 +ttranslate b6 0 0 100 + +tcopy b3 b7 +ttranslate b7 0 0 100 + +#-common-# + +bclearobjects +bcleartools +baddobjects b2 b6 b4 b1 b5 +baddctools b3 +baddctools b7 + +bfillds +bbop result 0 + +set square 10008.5 + +set nb_v_good 86 +set nb_e_good 132 +set nb_w_good 126 +set nb_f_good 126 +set nb_sh_good 40 +set nb_sol_good 40 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 551 + +set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug24825_cut b/tests/bugs/modalg_5/bug24825_cut new file mode 100644 index 0000000000..4b404481fe --- /dev/null +++ b/tests/bugs/modalg_5/bug24825_cut @@ -0,0 +1,58 @@ +puts "=========" +puts "OCC24825" +puts "=========" +puts "" +########################################################### +# Fit Boolean Operation Algorithm to treat multiple arguments. +########################################################### + +restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1 +restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2 +restore [locate_data_file bug24825_steering-wheel-drum.brep] b4 +restore [locate_data_file bug24825_steering-wheel-handle.brep] hb + +set qs {} + +set N 10 +set N1 [expr 360. / $N ] + +for {set i 0} {$i < $N} {incr i} { + tcopy hb hb_${i} + trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ] + lappend qs hb_${i} +} +eval compound $qs b3 + +tcopy b1 b5 +ttranslate b5 0 0 100 + +tcopy b2 b6 +ttranslate b6 0 0 100 + +tcopy b3 b7 +ttranslate b7 0 0 100 + +#-cut-# + +bclearobjects +bcleartools +baddobjects b2 b6 b4 b1 b5 +baddctools b3 +baddctools b7 + +bfillds +bbop result 2 + +set square 103838 + +set nb_v_good 106 +set nb_e_good 164 +set nb_w_good 142 +set nb_f_good 80 +set nb_sh_good 3 +set nb_sol_good 3 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 499 + +set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug24825_fuse b/tests/bugs/modalg_5/bug24825_fuse new file mode 100644 index 0000000000..a3f9aad3d7 --- /dev/null +++ b/tests/bugs/modalg_5/bug24825_fuse @@ -0,0 +1,59 @@ +puts "=========" +puts "OCC24825" +puts "=========" +puts "" +########################################################### +# Fit Boolean Operation Algorithm to treat multiple arguments. +########################################################### + +restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1 +restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2 +restore [locate_data_file bug24825_steering-wheel-drum.brep] b4 +restore [locate_data_file bug24825_steering-wheel-handle.brep] hb + +set qs {} + +set N 10 +set N1 [expr 360. / $N ] + +for {set i 0} {$i < $N} {incr i} { + tcopy hb hb_${i} + trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ] + lappend qs hb_${i} +} +eval compound $qs b3 + +tcopy b1 b5 +ttranslate b5 0 0 100 + +tcopy b2 b6 +ttranslate b6 0 0 100 + +tcopy b3 b7 +ttranslate b7 0 0 100 + +#-fuse-# + +bclearobjects +bcleartools +baddobjects b2 b6 b4 +baddtools b1 b5 +baddctools b3 +baddctools b7 + +bfillds +bbop result 1 + +set square 157211 + +set nb_v_good 106 +set nb_e_good 164 +set nb_w_good 142 +set nb_f_good 80 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 495 + +set 2dviewer 1