diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index 528f54b853..e096dee412 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -299,15 +299,13 @@ void BOPAlgo_Builder::BuildSplitFaces() void BOPAlgo_Builder::FillSameDomainFaces() { Standard_Boolean bFlag; - Standard_Integer i, aNbFFs, aNbCurves, aNbPoints, nF1, nF2, aNbS; - Standard_Integer j; + Standard_Integer i, j, k, aNbFFs, aNbCurves, aNbPoints, nF1, nF2, aNbS; Handle(NCollection_IncAllocator) aAllocator; - BOPCol_ListIteratorOfListOfShape aItF1, aItF2; - BOPTools_ListOfCoupleOfShape aLCS; - BOPCol_ListIteratorOfListOfShape aItLS; - BOPCol_MapOfShape aMF; - BOPCol_MapIteratorOfMapOfShape aItMF; - // + BOPCol_ListIteratorOfListOfShape aItF; + BOPCol_MapOfShape aMFence; + BOPAlgo_IndexedDataMapOfSetInteger aIDMSS; + BOPAlgo_VectorOfVectorOfShape aVVS; +// myErrorStatus=0; // const BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); @@ -316,13 +314,6 @@ void BOPAlgo_Builder::FillSameDomainFaces() if (!aNbFFs) { return; } - //-----------------------------------------------------scope f - aAllocator=new NCollection_IncAllocator(); - BOPCol_IndexedDataMapOfShapeListOfShape aDMSLS(100, aAllocator); - BOPCol_DataMapOfIntegerListOfShape aMBlocks(100, aAllocator); - BOPTools_DataMapOfShapeSet aMSST(100, aAllocator); - // - BOPCol_ListOfShape aLFIm; // for (i=0; iFaceInfo(nF1); const BOPDS_FaceInfo& aFI2=myDS->FaceInfo(nF2); - bFlag=HasPaveBlocksOnIn(aFI1, aFI2); // - const TopoDS_Face& aF1=(*(TopoDS_Face*)(&myDS->Shape(nF1))); - const TopoDS_Face& aF2=(*(TopoDS_Face*)(&myDS->Shape(nF2))); + const TopoDS_Shape& aF1=myDS->Shape(nF1); + const TopoDS_Shape& aF2=myDS->Shape(nF2); + // + bFlag=HasPaveBlocksOnIn(aFI1, aFI2); bFlag=bFlag && (mySplits.IsBound(aF1) && mySplits.IsBound(aF2)); // - if (!bFlag) { - //case when the faces have shared bounds - if (!aMSST.IsBound(aF1)) { - BOPTools_Set aST1(aAllocator); - aMSST.Bind(aF1, aST1); - BOPTools_Set& aST=aMSST.ChangeFind(aF1); - aST.AddEdges(aF1); + if (bFlag) { + for (k=0; k<2; ++k) { + const TopoDS_Shape& aF=(!k) ? aF1 : aF2; + const BOPCol_ListOfShape& aLF=mySplits.Find(aF); + // + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aFx=aItF.Value(); + // + if (aMFence.Add(aFx)) { + BOPTools_Set aSTx; + // + aSTx.AddEdges(aFx); + // + if (!aIDMSS.Contains(aSTx)) { + BOPAlgo_VectorOfShape& aVS=aVVS.Append1(); + aVS.Append(aFx); + // + j=aVVS.Extent()-1; + aIDMSS.Add (aSTx, j); + } + else { + j=aIDMSS.ChangeFromKey(aSTx); + BOPAlgo_VectorOfShape& aVS=aVVS(j); + aVS.Append(aFx); + } + } + } } + }// if (bFlag) { + else {// if (!bFlag) + BOPTools_Set aST1, aST2; // - if (!aMSST.IsBound(aF2)) { - BOPTools_Set aST2(aAllocator); - aMSST.Bind(aF2, aST2); - BOPTools_Set& aST=aMSST.ChangeFind(aF2); - aST.AddEdges(aF2); - } + aST1.AddEdges(aF1); + aST2.AddEdges(aF2); // - const BOPTools_Set& aST1=aMSST.Find(aF1); - const BOPTools_Set& aST2=aMSST.Find(aF2); if (aST1.IsEqual(aST2)) { - bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aF1, aF2, myContext); - if (bFlag) { - FillMap(aF1, aF2, aDMSLS, aAllocator); - aMF.Add(aF1); - aMF.Add(aF2); - } - } + if (!aIDMSS.Contains(aST1)) { + BOPAlgo_VectorOfShape& aVS=aVVS.Append1(); + if (aMFence.Add(aF1)) { + aVS.Append(aF1); + } + if (aMFence.Add(aF2)) { + aVS.Append(aF2); + } + // + k=aVVS.Extent()-1; + aIDMSS.Add (aST1, k); + } + else { + k=aIDMSS.ChangeFromKey(aST1); + BOPAlgo_VectorOfShape& aVS=aVVS(k); + if (aMFence.Add(aF1)) { + aVS.Append(aF1); + } + if (aMFence.Add(aF2)) { + aVS.Append(aF2); + } + } + }//if (aST1.IsEqual(aST2)) { + }// else {// if (!bFlag) + // + }// for (i=0; i + +#include +#include + +#include #include + +#include +#include +#include + +#include + #include -#ifdef HAVE_TBB -#include - -#define flexible_range blocked_range -#define flexible_for parallel_for -#else -#define flexible_range serial_range -#define flexible_for serial_for -#endif - -//======================================================================= -//class : serial_range -//purpose : -//======================================================================= -template class serial_range { - public: - serial_range(const Type& aBegin, - const Type& aEnd) - : myBegin(aBegin), myEnd(aEnd) { - } - // - ~serial_range() { - } - // - const Type& begin() const{ - return myBegin; - } - // - const Type& end() const{ - return myEnd; - }; - // - protected: - Type myBegin; - Type myEnd; -}; -//======================================================================= -//function : serial_for -//purpose : -//======================================================================= -template -static void serial_for( const Range& range, const Body& body ) { - body.operator()(range); -}; -// //======================================================================= //class : BOPAlgo_VectorOfBuilderFace //purpose : @@ -129,5 +92,108 @@ class BOPAlgo_BuilderFaceCnt { } // }; +// +//------------------------------------------------------------------------- +typedef BOPCol_NCVector BOPAlgo_VectorOfShape; +typedef BOPCol_NCVector BOPAlgo_VectorOfVectorOfShape; + +typedef NCollection_IndexedDataMap\ + \ + BOPAlgo_IndexedDataMapOfSetInteger; +// +//======================================================================= +//class : BOPAlgo_PairOfShapeBoolean +//purpose : +//======================================================================= +class BOPAlgo_PairOfShapeBoolean { + public: + BOPAlgo_PairOfShapeBoolean() + : myFlag(Standard_False) { + } + // + TopoDS_Shape& Shape1() { + return myShape1; + } + // + TopoDS_Shape& Shape2() { + return myShape2; + } + // + Standard_Boolean& Flag() { + return myFlag; + } + // + protected: + Standard_Boolean myFlag; + TopoDS_Shape myShape1; + TopoDS_Shape myShape2; +}; + +typedef BOPCol_NCVector BOPAlgo_VectorOfPairOfShapeBoolean; +// + +//======================================================================= +//function : BOPAlgo_BuilderSDFaceFunctor +//purpose : +//======================================================================= +class BOPAlgo_BuilderSDFaceFunctor { + protected: + BOPAlgo_VectorOfPairOfShapeBoolean* myPVPSB; + + public: + // + BOPAlgo_BuilderSDFaceFunctor(BOPAlgo_VectorOfPairOfShapeBoolean& aVPSB) + : myPVPSB(&aVPSB){ + } + // + void operator()( const flexible_range& aBR ) const { + Standard_Boolean bFlag; + Standard_Integer i, iBeg, iEnd; + Handle(BOPInt_Context) aContext; + // + aContext=new BOPInt_Context; + // + BOPAlgo_VectorOfPairOfShapeBoolean& aVPSB=*myPVPSB; + // + iBeg=aBR.begin(); + iEnd=aBR.end(); + for(i=iBeg; i!=iEnd; ++i) { + BOPAlgo_PairOfShapeBoolean& aPSB=aVPSB(i); + const TopoDS_Face& aFj=(*(TopoDS_Face*)(&aPSB.Shape1())); + const TopoDS_Face& aFk=(*(TopoDS_Face*)(&aPSB.Shape2())); + bFlag=BOPTools_AlgoTools::AreFacesSameDomain(aFj, aFk, aContext); + if (bFlag) { + aPSB.Flag()=bFlag; + } + } + } +}; +// +//======================================================================= +//function : BOPAlgo_BuilderSDFaceCnt +//purpose : +//======================================================================= +class BOPAlgo_BuilderSDFaceCnt { + public: + //------------------------------- + // Perform + Standard_EXPORT static + void Perform(const Standard_Boolean bRunParallel, + BOPAlgo_VectorOfPairOfShapeBoolean& aVPSB) { + Standard_Integer aNbVPSB; + // + aNbVPSB=aVPSB.Extent(); + BOPAlgo_BuilderSDFaceFunctor aBFF(aVPSB); + // + if (bRunParallel) { + flexible_for(flexible_range(0,aNbVPSB), aBFF); + } + else { + aBFF.operator()(flexible_range(0,aNbVPSB)); + } + } + // +}; + #endif diff --git a/src/BOPCol/BOPCol_TBB.hxx b/src/BOPCol/BOPCol_TBB.hxx index fbde3bc85e..7a3e7179a2 100644 --- a/src/BOPCol/BOPCol_TBB.hxx +++ b/src/BOPCol/BOPCol_TBB.hxx @@ -25,7 +25,50 @@ #include using namespace tbb; - -#endif +#define flexible_range blocked_range +#define flexible_for parallel_for + + +#else // not HAVE_TBB + +#define flexible_range serial_range +#define flexible_for serial_for + +//======================================================================= +//class : serial_range +//purpose : +//======================================================================= +template class serial_range { + public: + serial_range(const Type& aBegin, + const Type& aEnd) + : myBegin(aBegin), myEnd(aEnd) { + } + // + ~serial_range() { + } + // + const Type& begin() const{ + return myBegin; + } + // + const Type& end() const{ + return myEnd; + }; + // + protected: + Type myBegin; + Type myEnd; +}; + +//======================================================================= +//function : serial_for +//purpose : +//======================================================================= +template +static void serial_for( const Range& range, const Body& body ) { + body.operator()(range); +}; +#endif // not HAVE_TBB #endif diff --git a/tests/bugs/modalg_2/bug472_3 b/tests/bugs/modalg_2/bug472_3 index ab4d5b556f..1e67122a87 100755 --- a/tests/bugs/modalg_2/bug472_3 +++ b/tests/bugs/modalg_2/bug472_3 @@ -1,5 +1,6 @@ -puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_" -puts "TODO OCC12345 ALL: Error : The square of result shape is" +#puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_" +#puts "TODO OCC12345 ALL: Error : The square of result shape is" +puts "TODO OCC12345 ALL: Error : The command is not valid" puts "TODO OCC12345 ALL: Error : Result shape is WRONG because it must contains" puts "========================"