1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024639: Parallelization FillDS part of BO

The contents dealing with:
Parallel computation of Face/Face interferences;
Parallel computation of Edge/Edge interferences (Post-Treatment Level);
Parallel intersection of bounding boxes (BOPDS_Iterator Level).
This commit is contained in:
pkv
2014-04-15 07:19:00 +04:00
committed by apn
parent 8620e18d6e
commit a20983607c
5 changed files with 533 additions and 239 deletions

View File

@@ -145,6 +145,7 @@ void BOPAlgo_PaveFiller::Init()
// //
// 2.myIterator // 2.myIterator
myIterator=new BOPDS_Iterator(myAllocator); myIterator=new BOPDS_Iterator(myAllocator);
myIterator->SetRunParallel(myRunParallel);
myIterator->SetDS(myDS); myIterator->SetDS(myDS);
myIterator->Prepare(); myIterator->Prepare();
// //

View File

@@ -42,6 +42,7 @@
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
// //
#include <BOPCol_DataMapOfShapeInteger.hxx> #include <BOPCol_DataMapOfShapeInteger.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_DataMapOfIntegerShape.hxx> #include <BOPCol_DataMapOfIntegerShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeBox.hxx> #include <BOPCol_IndexedDataMapOfShapeBox.hxx>
#include <BOPCol_BoxBndTree.hxx> #include <BOPCol_BoxBndTree.hxx>
@@ -64,6 +65,7 @@
// //
#include <BOPAlgo_Tools.hxx> #include <BOPAlgo_Tools.hxx>
/////////////////////////////////////////////////////////////////////////
//======================================================================= //=======================================================================
//class : BOPAlgo_EdgeEdge //class : BOPAlgo_EdgeEdge
//purpose : //purpose :
@@ -110,6 +112,147 @@ typedef BOPCol_TBBCnt
<BOPAlgo_EdgeEdgeFunctor, <BOPAlgo_EdgeEdgeFunctor,
BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeCnt; BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeCnt;
// //
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPAlgo_TNV
//purpose :
//=======================================================================
class BOPAlgo_TNV : public BOPCol_BoxBndTreeSelector{
public:
BOPAlgo_TNV()
: BOPCol_BoxBndTreeSelector(), myTree(NULL) {
};
//
~BOPAlgo_TNV(){
};
//
void SetVertex(const TopoDS_Vertex& aV) {
myV=aV;
}
//
const TopoDS_Vertex& Vertex()const {
return myV;
}
//
void SetTree(BOPCol_BoxBndTree& aTree) {
myTree=&aTree;
}
//
void Perform() {
myTree->Select(*this);
}
//
protected:
TopoDS_Vertex myV;
BOPCol_BoxBndTree *myTree;
};
//
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_TNV> BOPAlgo_VectorOfTNV;
//
typedef BOPCol_TBBFunctor
<BOPAlgo_TNV,
BOPAlgo_VectorOfTNV> BOPAlgo_TNVFunctor;
//
typedef BOPCol_TBBCnt
<BOPAlgo_TNVFunctor,
BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt;
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPAlgo_PVE
//purpose :
//=======================================================================
class BOPAlgo_PVE {
public:
BOPAlgo_PVE()
: myIV(-1), myIE(-1), myFlag(-1), myT(-1.) {
};
//
~BOPAlgo_PVE(){
};
//
void SetIndices(const Standard_Integer nV,
const Standard_Integer nE){
myIV=nV;
myIE=nE;
}
//
void Indices(Standard_Integer& nV,
Standard_Integer& nE) const {
nV=myIV;
nE=myIE;
}
//
void SetVertex(const TopoDS_Vertex& aV) {
myV=aV;
}
//
const TopoDS_Vertex& Vertex()const {
return myV;
}
//
void SetEdge(const TopoDS_Edge& aE) {
myE=aE;
}
//
const TopoDS_Edge& Edge()const {
return myE;
}
//
void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
myPB=aPB;
}
//
Handle(BOPDS_PaveBlock)& PaveBlock() {
return myPB;
}
//
Standard_Integer Flag()const {
return myFlag;
}
//
Standard_Real Parameter()const {
return myT;
}
//
void SetContext(const Handle(BOPInt_Context)& aContext) {
myContext=aContext;
}
//
const Handle(BOPInt_Context)& Context()const {
return myContext;
}
//
void Perform() {
myFlag=myContext->ComputeVE (myV, myE, myT);
};
//
protected:
Standard_Integer myIV;
Standard_Integer myIE;
Standard_Integer myFlag;
Standard_Real myT;
TopoDS_Vertex myV;
TopoDS_Edge myE;
Handle(BOPDS_PaveBlock) myPB;
Handle(BOPInt_Context) myContext;
};
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_PVE> BOPAlgo_VectorOfPVE;
//
typedef BOPCol_TBBContextFunctor
<BOPAlgo_PVE,
BOPAlgo_VectorOfPVE,
Handle_BOPInt_Context,
BOPInt_Context> BOPAlgo_PVEFunctor;
//
typedef BOPCol_TBBContextCnt
<BOPAlgo_PVEFunctor,
BOPAlgo_VectorOfPVE,
Handle_BOPInt_Context> BOPAlgo_PVECnt;
/////////////////////////////////////////////////////////////////////////
//======================================================================= //=======================================================================
// function: PerformEE // function: PerformEE
// purpose: // purpose:
@@ -492,10 +635,13 @@ Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
} }
} }
} }
//
// 5 // 5
// 5.1 Compute Extra Paves and // 5.1 Compute Extra Paves and
// 5.2. Add Extra Paves to the PaveBlocks // 5.2. Add Extra Paves to the PaveBlocks
//-------------------------------------------------------------
Standard_Integer k, aNbVPVE;
BOPAlgo_VectorOfPVE aVPVE;
//
aNb=aMPBLI.Extent(); aNb=aMPBLI.Extent();
for(i=1; i<=aNb; ++i) { for(i=1; i<=aNb; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i); Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
@@ -508,14 +654,32 @@ Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
nVx=aItLI.Value(); nVx=aItLI.Value();
const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
// //
iFlag=myContext->ComputeVE (aVx, aE, aT); BOPAlgo_PVE& aPVE=aVPVE.Append1();
aPVE.SetIndices(nVx, nE);
aPVE.SetVertex(aVx);
aPVE.SetEdge(aE);
aPVE.SetPaveBlock(aPB);
}
}
//
aNbVPVE=aVPVE.Extent();
//=============================================================
BOPAlgo_PVECnt::Perform(myRunParallel, aVPVE, myContext);
//=============================================================
//
for (k=0; k < aNbVPVE; ++k) {
BOPAlgo_PVE& aPVE=aVPVE(k);
iFlag=aPVE.Flag();
if (!iFlag) { if (!iFlag) {
aPVE.Indices(nVx, nE);
aT=aPVE.Parameter();
Handle(BOPDS_PaveBlock)& aPB=aPVE.PaveBlock();
//
aPave.SetIndex(nVx); aPave.SetIndex(nVx);
aPave.SetParameter(aT); aPave.SetParameter(aT);
aPB->AppendExtPave(aPave); aPB->AppendExtPave(aPave);
} }
} }
}
// 6 Split PaveBlocksa // 6 Split PaveBlocksa
aNb=aMPBLI.Extent(); aNb=aMPBLI.Extent();
for(i=1; i<=aNb; ++i) { for(i=1; i<=aNb; ++i) {
@@ -533,7 +697,6 @@ Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
// //
return iRet; return iRet;
} }
//======================================================================= //=======================================================================
//function : TreatNewVertices //function : TreatNewVertices
//purpose : //purpose :
@@ -542,136 +705,117 @@ void BOPAlgo_PaveFiller::TreatNewVertices
(const BOPCol_IndexedDataMapOfShapeInteger& aMapVI, (const BOPCol_IndexedDataMapOfShapeInteger& aMapVI,
BOPCol_IndexedDataMapOfShapeListOfShape& myImages) BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
{ {
Standard_Integer j, i, aNbV, aNbVSD; Standard_Integer i, aNbV;//, aNbVSD;
Standard_Real aTol; Standard_Real aTol;
TopoDS_Shape aVF;
TopoDS_Vertex aVnew; TopoDS_Vertex aVnew;
TopoDS_Shape aVF;
BOPCol_IndexedMapOfShape aMVProcessed; BOPCol_IndexedMapOfShape aMVProcessed;
BOPCol_MapOfInteger aMFence;
BOPCol_ListIteratorOfListOfInteger aIt; BOPCol_ListIteratorOfListOfInteger aIt;
BOPCol_IndexedDataMapOfShapeListOfShape aMVLV; BOPCol_DataMapOfShapeListOfShape aDMVLV;
BOPCol_DataMapOfIntegerShape aMIS; BOPCol_DataMapIteratorOfDataMapOfShapeListOfShape aItDMVLV;
BOPCol_IndexedDataMapOfShapeBox aMSB;
// //
BOPCol_BoxBndTreeSelector aSelector; BOPCol_BoxBndTreeSelector aSelector;
BOPCol_BoxBndTree aBBTree; BOPCol_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree); NCollection_UBTreeFiller <Standard_Integer,
Bnd_Box> aTreeFiller(aBBTree);
BOPAlgo_VectorOfTNV aVTNV;
// //
aNbV = aMapVI.Extent(); aNbV = aMapVI.Extent();
for (i=1; i<=aNbV; ++i) { for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMapVI.FindKey(i); const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMapVI.FindKey(i));
Bnd_Box aBox; Bnd_Box aBox;
// //
aTol=BRep_Tool::Tolerance(*(TopoDS_Vertex*)(&aV)); aTol=BRep_Tool::Tolerance(aV);
aBox.SetGap(aTol); aBox.SetGap(aTol);
BRepBndLib::Add(aV, aBox); aBox.Add(BRep_Tool::Pnt(aV));
aBox.Enlarge(aTol);
// //
aTreeFiller.Add(i, aBox); aTreeFiller.Add(i, aBox);
// //
aMIS.Bind(i, aV); BOPAlgo_TNV& aTNV=aVTNV.Append1();
aMSB.Add(aV, aBox); aTNV.SetTree(aBBTree);
aTNV.SetBox(aBox);
aTNV.SetVertex(aV);
} }
// //
aTreeFiller.Fill(); aTreeFiller.Fill();
//
//===========================================
BOPAlgo_TNVCnt::Perform(myRunParallel, aVTNV);
//===========================================
//
// Chains // Chains
for (i=1; i<=aNbV; ++i) { for (i=1; i<=aNbV; ++i) {
const TopoDS_Shape& aV=aMapVI.FindKey(i); if (!aMFence.Add(i)) {
//
if (aMVProcessed.Contains(aV)) {
continue; continue;
} }
// //
Standard_Integer aNbIP, aIP, aNbIP1, aIP1; Standard_Integer aIP, aNbIP1, aIP1;
BOPCol_ListOfShape aLVSD; BOPCol_ListOfShape aLVSD;
BOPCol_MapOfInteger aMIP, aMIP1, aMIPC; BOPCol_MapIteratorOfMapOfInteger aItMI;
BOPCol_MapIteratorOfMapOfInteger aIt1; BOPCol_ListOfInteger aLIP, aLIP1, aLIPC;
BOPCol_ListIteratorOfListOfInteger aItLIP;
// //
aMIP.Add(i); aLIPC.Append(i);
aLIP.Append(i);
for(;;) { for(;;) {
aNbIP=aMIP.Extent(); aItLIP.Initialize(aLIP);
aIt1.Initialize(aMIP); for(; aItLIP.More(); aItLIP.Next()) {
for(; aIt1.More(); aIt1.Next()) { aIP=aItLIP.Value();
aIP=aIt1.Key();
if (aMIPC.Contains(aIP)) {
continue;
}
// //
const TopoDS_Shape& aVP=aMIS.Find(aIP); BOPAlgo_TNV& aTNV=aVTNV(aIP-1);
const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP); const BOPCol_ListOfInteger& aLI=aTNV.Indices();
//
aSelector.Clear();
aSelector.SetBox(aBoxVP);
//
aNbVSD=aBBTree.Select(aSelector);
if (!aNbVSD) {
continue; // it must not be
}
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
aIt.Initialize(aLI); aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
aIP1=aIt.Value(); aIP1=aIt.Value();
if (aMIP.Contains(aIP1)) { if (!aMFence.Add(aIP1)) {
continue; continue;
} }
aMIP1.Add(aIP1); aLIP1.Append(aIP1);
} //for (; aIt.More(); aIt.Next()) { } //for (; aIt.More(); aIt.Next()) {
}//for(; aIt1.More(); aIt1.Next()) { }//for(; aIt1.More(); aIt1.Next()) {
// //
aNbIP1=aMIP1.Extent(); aNbIP1=aLIP1.Extent();
if (!aNbIP1) { if (!aNbIP1) {
break; // from while(1) break; // from for(;;)
} }
// //
aIt1.Initialize(aMIP); aLIP.Clear();
for(; aIt1.More(); aIt1.Next()) { aItLIP.Initialize(aLIP1);
aIP=aIt1.Key(); for(; aItLIP.More(); aItLIP.Next()) {
aMIPC.Add(aIP); aIP=aItLIP.Value();
aLIP.Append(aIP);
aLIPC.Append(aIP);
} }
aLIP1.Clear();
}// for(;;) {
// //
aMIP.Clear(); aItLIP.Initialize(aLIPC);
aIt1.Initialize(aMIP1); for(; aItLIP.More(); aItLIP.Next()) {
for(; aIt1.More(); aIt1.Next()) { aIP=aItLIP.Value();
aIP=aIt1.Key(); const TopoDS_Vertex& aVP=aVTNV(aIP-1).Vertex();
aMIP.Add(aIP);
}
aMIP1.Clear();
}// while(1)
//...
aNbIP=aMIPC.Extent();
if (!aNbIP) {
aMIPC.Add(i);
}
//
aIt1.Initialize(aMIPC);
for(j=0; aIt1.More(); aIt1.Next(), ++j) {
aIP=aIt1.Key();
const TopoDS_Shape& aVP=aMIS.Find(aIP);
if (!j) {
aVF=aVP;
}
aLVSD.Append(aVP); aLVSD.Append(aVP);
aMVProcessed.Add(aVP);
} }
aMVLV.Add(aVF, aLVSD); aVF=aLVSD.First();
aDMVLV.Bind(aVF, aLVSD);
}// for (i=1; i<=aNbV; ++i) { }// for (i=1; i<=aNbV; ++i) {
// Make new vertices // Make new vertices
aNbV=aMVLV.Extent(); aItDMVLV.Initialize(aDMVLV);
for (i=1; i<=aNbV; ++i) { for(; aItDMVLV.More(); aItDMVLV.Next()) {
const TopoDS_Shape& aV=aMVLV.FindKey(i); const TopoDS_Shape& aV=aItDMVLV.Key();
BOPCol_ListOfShape& aLVSD=aMVLV.ChangeFromIndex(i); const BOPCol_ListOfShape& aLVSD=aItDMVLV.Value();
aNbVSD=aLVSD.Extent(); if (aLVSD.IsEmpty()) {
if (aNbVSD>1) {
BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
myImages.Add(aVnew, aLVSD);
} else {
myImages.Add(aV, aLVSD); myImages.Add(aV, aLVSD);
} }
else {
BOPCol_ListOfShape* pLVSD=(BOPCol_ListOfShape*)&aLVSD;
BOPTools_AlgoTools::MakeVertex(*pLVSD, aVnew);
myImages.Add(aVnew, aLVSD);
}
} }
} }
//======================================================================= //=======================================================================
//function : FillShrunkData //function : FillShrunkData
//purpose : //purpose :

View File

@@ -62,6 +62,8 @@
#include <BOPCol_ListOfInteger.hxx> #include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_IndexedMapOfInteger.hxx> #include <BOPCol_IndexedMapOfInteger.hxx>
#include <BOPCol_DataMapOfIntegerReal.hxx> #include <BOPCol_DataMapOfIntegerReal.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_TBB.hxx>
#include <BOPInt_Context.hxx> #include <BOPInt_Context.hxx>
#include <BOPInt_Tools.hxx> #include <BOPInt_Tools.hxx>
@@ -94,6 +96,78 @@ static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2, const BRepAdaptor_Surface& aBAS2,
Standard_Real& aTolFF); Standard_Real& aTolFF);
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPAlgo_FaceFace
//purpose :
//=======================================================================
class BOPAlgo_FaceFace : public IntTools_FaceFace {
public:
BOPAlgo_FaceFace()
: IntTools_FaceFace(), myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
}
//
~BOPAlgo_FaceFace() {
}
//
void SetIndices(const Standard_Integer nF1,
const Standard_Integer nF2) {
myIF1=nF1;
myIF2=nF2;
}
//
void Indices(Standard_Integer& nF1,
Standard_Integer& nF2) const {
nF1=myIF1;
nF2=myIF2;
}
//
void SetFaces(const TopoDS_Face& aF1,
const TopoDS_Face& aF2) {
myF1=aF1;
myF2=aF2;
}
//
const TopoDS_Face& Face1()const {
return myF1;
}
//
const TopoDS_Face& Face2()const {
return myF2;
}
//
void SetTolFF(const Standard_Real aTolFF) {
myTolFF=aTolFF;
}
//
Standard_Real TolFF() const{
return myTolFF;
}
//
void Perform() {
IntTools_FaceFace::Perform(myF1, myF2);
}
//
protected:
Standard_Integer myIF1;
Standard_Integer myIF2;
Standard_Real myTolFF;
TopoDS_Face myF1;
TopoDS_Face myF2;
};
//
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_FaceFace> BOPAlgo_VectorOfFaceFace;
//
typedef BOPCol_TBBFunctor
<BOPAlgo_FaceFace,
BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceFunctor;
//
typedef BOPCol_TBBCnt
<BOPAlgo_FaceFaceFunctor,
BOPAlgo_VectorOfFaceFace> BOPAlgo_FaceFaceCnt;
/////////////////////////////////////////////////////////////////////////
//======================================================================= //=======================================================================
//function : PerformFF //function : PerformFF
//purpose : //purpose :
@@ -114,9 +188,11 @@ void BOPAlgo_PaveFiller::PerformFF()
Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone; Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone;
Standard_Boolean bToSplit, bTangentFaces; Standard_Boolean bToSplit, bTangentFaces;
Standard_Integer nF1, nF2, aNbCurves, aNbPoints, iX, i, iP, iC, aNbLP; Standard_Integer nF1, nF2, aNbCurves, aNbPoints, iX, i, iP, iC, aNbLP;
Standard_Integer aNbFaceFace, k;
Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF; Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF;
BRepAdaptor_Surface aBAS1, aBAS2; BRepAdaptor_Surface aBAS1, aBAS2;
BOPCol_MapOfInteger aMI; BOPCol_MapOfInteger aMI;
BOPAlgo_VectorOfFaceFace aVFaceFace;
// //
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF(); BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
aFFs.SetStartSize(iSize); aFFs.SetStartSize(iSize);
@@ -165,7 +241,13 @@ void BOPAlgo_PaveFiller::PerformFF()
} }
} }
// //
IntTools_FaceFace aFaceFace; ToleranceFF(aBAS1, aBAS2, aTolFF);
//
BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1();
//
aFaceFace.SetIndices(nF1, nF2);
aFaceFace.SetFaces(aF1, aF2);
aFaceFace.SetTolFF(aTolFF);
// //
IntSurf_ListOfPntOn2S aListOfPnts; IntSurf_ListOfPntOn2S aListOfPnts;
GetEFPnts(nF1, nF2, aListOfPnts); GetEFPnts(nF1, nF2, aListOfPnts);
@@ -173,10 +255,22 @@ void BOPAlgo_PaveFiller::PerformFF()
if (aNbLP) { if (aNbLP) {
aFaceFace.SetList(aListOfPnts); aFaceFace.SetList(aListOfPnts);
} }
//
aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol); aFaceFace.SetParameters(bApp, bCompC2D1, bCompC2D2, aApproxTol);
// //
aFaceFace.Perform(aF1, aF2); //aFaceFace.Perform(aF1, aF2);
}//for (; myIterator->More(); myIterator->Next()) {
//
aNbFaceFace=aVFaceFace.Extent();
//======================================================
BOPAlgo_FaceFaceCnt::Perform(myRunParallel, aVFaceFace);
//======================================================
//
for (k=0; k < aNbFaceFace; ++k) {
BOPAlgo_FaceFace& aFaceFace=aVFaceFace(k);
//
aFaceFace.Indices(nF1, nF2);
aTolFF=aFaceFace.TolFF();
// //
bIsDone=aFaceFace.IsDone(); bIsDone=aFaceFace.IsDone();
if (bIsDone) { if (bIsDone) {
@@ -184,8 +278,6 @@ void BOPAlgo_PaveFiller::PerformFF()
aTolR2D=aFaceFace.TolReached2d(); aTolR2D=aFaceFace.TolReached2d();
bTangentFaces=aFaceFace.TangentFaces(); bTangentFaces=aFaceFace.TangentFaces();
// //
ToleranceFF(aBAS1, aBAS2, aTolFF);
//
if (aTolR3D < aTolFF){ if (aTolR3D < aTolFF){
aTolR3D=aTolFF; aTolR3D=aTolFF;
} }
@@ -250,7 +342,7 @@ void BOPAlgo_PaveFiller::PerformFF()
aNbPoints=0; aNbPoints=0;
aFF.Init(aNbCurves, aNbPoints); aFF.Init(aNbCurves, aNbPoints);
} }
}// for (; myIterator->More(); myIterator->Next()) { }// for (k=0; k < aNbFaceFace; ++k) {
} }
//======================================================================= //=======================================================================
//function : MakeBlocks //function : MakeBlocks

View File

@@ -35,7 +35,6 @@ uses
ListIteratorOfListOfPassKeyBoolean from BOPDS, ListIteratorOfListOfPassKeyBoolean from BOPDS,
VectorOfListOfPassKeyBoolean from BOPDS VectorOfListOfPassKeyBoolean from BOPDS
--raises
is is
Create Create
@@ -113,11 +112,22 @@ is
Intersect(me:out) Intersect(me:out)
is virtual protected; is virtual protected;
SetRunParallel(me:out;
theFlag:Boolean from Standard);
---Purpose: Set the flag of parallel processing
-- if <theFlag> is true the parallel processing is switched on
-- if <theFlag> is false the parallel processing is switched off
--
RunParallel(me)
returns Boolean from Standard;
---Purpose: Returns the flag of parallel processing
fields fields
myAllocator: BaseAllocator from BOPCol is protected; myAllocator: BaseAllocator from BOPCol is protected;
myLength : Integer from Standard is protected; myLength : Integer from Standard is protected;
myDS : PDS from BOPDS is protected; myDS : PDS from BOPDS is protected;
myLists : VectorOfListOfPassKeyBoolean from BOPDS is protected; myLists : VectorOfListOfPassKeyBoolean from BOPDS is protected;
myIterator : ListIteratorOfListOfPassKeyBoolean from BOPDS is protected; myIterator : ListIteratorOfListOfPassKeyBoolean from BOPDS is protected;
myRunParallel : Boolean from Standard is protected;
end Iterator; end Iterator;

View File

@@ -22,21 +22,57 @@
#include <NCollection_BaseAllocator.hxx> #include <NCollection_BaseAllocator.hxx>
#include <NCollection_UBTreeFiller.hxx> #include <NCollection_UBTreeFiller.hxx>
// //
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
// //
#include <BOPCol_IndexedDataMapOfShapeBox.hxx> #include <BOPCol_NCVector.hxx>
#include <BOPCol_DataMapOfIntegerInteger.hxx> #include <BOPCol_TBB.hxx>
#include <BOPCol_DataMapOfIntegerMapOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
//
#include <BOPCol_BoxBndTree.hxx> #include <BOPCol_BoxBndTree.hxx>
//
#include <BOPDS_IndexRange.hxx> #include <BOPDS_IndexRange.hxx>
#include <BOPDS_PassKeyBoolean.hxx> #include <BOPDS_PassKeyBoolean.hxx>
#include <BOPDS_MapOfPassKeyBoolean.hxx> #include <BOPDS_MapOfPassKeyBoolean.hxx>
#include <BOPDS_Tools.hxx> #include <BOPDS_Tools.hxx>
#include <BOPDS_MapOfPassKeyBoolean.hxx>
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPDS_TreeSelector
//purpose :
//=======================================================================
class BOPDS_TSR : public BOPCol_BoxBndTreeSelector{
public:
BOPDS_TSR() :
BOPCol_BoxBndTreeSelector(),
myHasBRep(Standard_False),
myTree(NULL) {
}
//
virtual ~BOPDS_TSR() {
}
//
void SetHasBRep(const Standard_Boolean bFlag) {
myHasBRep=bFlag;
}
//
void SetTree(BOPCol_BoxBndTree& aTree) {
myTree=&aTree;
}
//
void Perform() {
if (myHasBRep) {
myTree->Select(*this);
}
}
//
protected:
Standard_Boolean myHasBRep;
BOPCol_BoxBndTree *myTree;
};
//
//=======================================================================
typedef BOPCol_NCVector <BOPDS_TSR> BOPDS_VectorOfTSR;
typedef BOPCol_TBBFunctor <BOPDS_TSR,BOPDS_VectorOfTSR> BOPDS_TSRFunctor;
typedef BOPCol_TBBCnt <BOPDS_TSRFunctor, BOPDS_VectorOfTSR> BOPDS_TSRCnt;
/////////////////////////////////////////////////////////////////////////
//======================================================================= //=======================================================================
@@ -45,7 +81,8 @@
//======================================================================= //=======================================================================
BOPDS_Iterator::BOPDS_Iterator() BOPDS_Iterator::BOPDS_Iterator()
: :
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()) myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
myRunParallel(Standard_False)
{ {
myDS=NULL; myDS=NULL;
myLength=0; myLength=0;
@@ -61,7 +98,8 @@ BOPDS_Iterator::BOPDS_Iterator
(const Handle(NCollection_BaseAllocator)& theAllocator) (const Handle(NCollection_BaseAllocator)& theAllocator)
: :
myAllocator(theAllocator), myAllocator(theAllocator),
myLists(theAllocator) myLists(theAllocator),
myRunParallel(Standard_False)
{ {
myDS=NULL; myDS=NULL;
myLength=0; myLength=0;
@@ -77,6 +115,22 @@ BOPDS_Iterator::~BOPDS_Iterator()
{ {
} }
//======================================================================= //=======================================================================
//function : SetRunParallel
//purpose :
//=======================================================================
void BOPDS_Iterator::SetRunParallel(const Standard_Boolean theFlag)
{
myRunParallel=theFlag;
}
//=======================================================================
//function : RunParallel
//purpose :
//=======================================================================
Standard_Boolean BOPDS_Iterator::RunParallel()const
{
return myRunParallel;
}
//=======================================================================
// function: SetDS // function: SetDS
// purpose: // purpose:
//======================================================================= //=======================================================================
@@ -154,7 +208,8 @@ void BOPDS_Iterator::Next()
// function: Value // function: Value
// purpose: // purpose:
//======================================================================= //=======================================================================
void BOPDS_Iterator::Value(Standard_Integer& theI1, void BOPDS_Iterator::Value
(Standard_Integer& theI1,
Standard_Integer& theI2, Standard_Integer& theI2,
Standard_Boolean& theWithSubShape) const Standard_Boolean& theWithSubShape) const
{ {
@@ -175,7 +230,6 @@ void BOPDS_Iterator::Value(Standard_Integer& theI1,
// //
theWithSubShape=aPKB.Flag(); theWithSubShape=aPKB.Flag();
} }
//======================================================================= //=======================================================================
// function: Prepare // function: Prepare
// purpose: // purpose:
@@ -195,6 +249,7 @@ void BOPDS_Iterator::Prepare()
} }
Intersect(); Intersect();
} }
//
//======================================================================= //=======================================================================
// function: Intersect // function: Intersect
// purpose: // purpose:
@@ -202,20 +257,16 @@ void BOPDS_Iterator::Prepare()
void BOPDS_Iterator::Intersect() void BOPDS_Iterator::Intersect()
{ {
Standard_Boolean bFlag; Standard_Boolean bFlag;
Standard_Integer aNb, i, aNbB, aNbR, iTi, iTj; Standard_Integer aNb, i, aNbR, iTi, iTj;
Standard_Integer i1, i2, aNbSD, iX, j, iDS, jB, iR; Standard_Integer i1, i2, aNbSD, iX, j, iR;
TopAbs_ShapeEnum aTi, aTj; TopAbs_ShapeEnum aTi, aTj;
Handle(NCollection_IncAllocator) aAllocator; Handle(NCollection_IncAllocator) aAllocator;
//
BOPCol_ListIteratorOfListOfInteger aIt; BOPCol_ListIteratorOfListOfInteger aIt;
// //
//-----------------------------------------------------scope_1 f //-----------------------------------------------------scope_1 f
aAllocator=new NCollection_IncAllocator(); aAllocator=new NCollection_IncAllocator();
// //
BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator); BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
BOPDS_PassKeyBoolean aPKXB; BOPDS_PassKeyBoolean aPKXB;
// //
BOPCol_BoxBndTreeSelector aSelector; BOPCol_BoxBndTreeSelector aSelector;
@@ -223,29 +274,32 @@ void BOPDS_Iterator::Intersect()
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree); NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
// //
aNb=myDS->NbSourceShapes(); aNb=myDS->NbSourceShapes();
BOPDS_VectorOfTSR aVTSR(aNb, aAllocator);
//
for (i=0; i<aNb; ++i) { for (i=0; i<aNb; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
if (aSI.HasBRep()) { bFlag=aSI.HasBRep();
const TopoDS_Shape& aS=aSI.Shape(); //
const Bnd_Box& aBoxEx=aSI.Box(); BOPDS_TSR& aTSR=aVTSR.Append1();
aMSI.Bind(aS, i); //
aMSB.Add(aS, aBoxEx); aTSR.SetHasBRep(bFlag);
} if (!bFlag) {
continue;
} }
// //
aNbB=aMSB.Extent(); const Bnd_Box& aBoxEx=aSI.Box();
for (i=1; i<=aNbB; ++i) { aTSR.SetTree(aBBTree);
const TopoDS_Shape& aS=aMSB.FindKey(i); aTSR.SetBox(aBoxEx);
const Bnd_Box& aBoxEx=aMSB(i);
// //
aTreeFiller.Add(i, aBoxEx); aTreeFiller.Add(i, aBoxEx);
//
iDS=aMSI.Find(aS);
aMII.Bind(i, iDS);
} }
// //
aTreeFiller.Fill(); aTreeFiller.Fill();
// //
//===========================================
BOPDS_TSRCnt::Perform(myRunParallel, aVTSR);
//===========================================
//
aNbR=myDS->NbRanges()-1; aNbR=myDS->NbRanges()-1;
for (iR=0; iR<aNbR; ++iR) { for (iR=0; iR<aNbR; ++iR) {
const BOPDS_IndexRange& aR=myDS->Range(iR); const BOPDS_IndexRange& aR=myDS->Range(iR);
@@ -259,23 +313,18 @@ void BOPDS_Iterator::Intersect()
} }
// //
aTi=aSI.ShapeType(); aTi=aSI.ShapeType();
const TopoDS_Shape& aSi=aSI.Shape(); const Bnd_Box& aBoxi=aSI.Box();
const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
aSelector.Clear();
aSelector.SetBox(aBoxEx);
// //
aNbSD=aBBTree.Select(aSelector); BOPDS_TSR& aTSRi=aVTSR(i);
const BOPCol_ListOfInteger& aLI=aTSRi.Indices();
aNbSD=aLI.Extent();
if (!aNbSD){ if (!aNbSD){
continue; continue;
} }
// //
const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
aIt.Initialize(aLI); aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
jB=aIt.Value(); // box index in MII j=aIt.Value(); // DS index
j=aMII.Find(jB); // DS index
if (j>=i1 && j<=i2) { if (j>=i1 && j<=i2) {
continue;// same range continue;// same range
} }
@@ -284,6 +333,7 @@ void BOPDS_Iterator::Intersect()
aTj=aSIj.ShapeType(); aTj=aSIj.ShapeType();
iTi=BOPDS_Tools::TypeToInteger(aTi); iTi=BOPDS_Tools::TypeToInteger(aTi);
iTj=BOPDS_Tools::TypeToInteger(aTj); iTj=BOPDS_Tools::TypeToInteger(aTj);
//
bFlag=Standard_False; bFlag=Standard_False;
if (iTi<iTj) { if (iTi<iTj) {
bFlag=aSI.HasSubShape(j); bFlag=aSI.HasSubShape(j);
@@ -298,7 +348,7 @@ void BOPDS_Iterator::Intersect()
aPKXB.SetIds(i, j); aPKXB.SetIds(i, j);
if (aMPKXB.Add(aPKXB)) { if (aMPKXB.Add(aPKXB)) {
bFlag=Standard_False;// Bounding boxes are intersected bFlag=Standard_False;// Bounding boxes are intersected
const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box(); const Bnd_Box& aBoxj=aSIj.Box();
if (aBoxi.IsOut(aBoxj)) { if (aBoxi.IsOut(aBoxj)) {
bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
} }
@@ -311,11 +361,8 @@ void BOPDS_Iterator::Intersect()
}//for (i=i1; i<=i2; ++i) { }//for (i=i1; i<=i2; ++i) {
}//for (iR=1; iR<aNbR; ++iR) { }//for (iR=1; iR<aNbR; ++iR) {
// //
aMSI.Clear();
aMII.Clear();
aMPKXB.Clear(); aMPKXB.Clear();
aMSB.Clear(); aVTSR.Clear();
//
aAllocator.Nullify(); aAllocator.Nullify();
//-----------------------------------------------------scope_1 t //-----------------------------------------------------scope_1 t
} }