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
myIterator=new BOPDS_Iterator(myAllocator);
myIterator->SetRunParallel(myRunParallel);
myIterator->SetDS(myDS);
myIterator->Prepare();
//

View File

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

View File

@@ -62,6 +62,8 @@
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_IndexedMapOfInteger.hxx>
#include <BOPCol_DataMapOfIntegerReal.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_TBB.hxx>
#include <BOPInt_Context.hxx>
#include <BOPInt_Tools.hxx>
@@ -94,6 +96,78 @@ static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2,
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
//purpose :
@@ -114,9 +188,11 @@ void BOPAlgo_PaveFiller::PerformFF()
Standard_Boolean bJustAdd, bApp, bCompC2D1, bCompC2D2, bIsDone;
Standard_Boolean bToSplit, bTangentFaces;
Standard_Integer nF1, nF2, aNbCurves, aNbPoints, iX, i, iP, iC, aNbLP;
Standard_Integer aNbFaceFace, k;
Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF;
BRepAdaptor_Surface aBAS1, aBAS2;
BOPCol_MapOfInteger aMI;
BOPAlgo_VectorOfFaceFace aVFaceFace;
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
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;
GetEFPnts(nF1, nF2, aListOfPnts);
@@ -173,10 +255,22 @@ void BOPAlgo_PaveFiller::PerformFF()
if (aNbLP) {
aFaceFace.SetList(aListOfPnts);
}
//
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();
if (bIsDone) {
@@ -184,8 +278,6 @@ void BOPAlgo_PaveFiller::PerformFF()
aTolR2D=aFaceFace.TolReached2d();
bTangentFaces=aFaceFace.TangentFaces();
//
ToleranceFF(aBAS1, aBAS2, aTolFF);
//
if (aTolR3D < aTolFF){
aTolR3D=aTolFF;
}
@@ -250,7 +342,7 @@ void BOPAlgo_PaveFiller::PerformFF()
aNbPoints=0;
aFF.Init(aNbCurves, aNbPoints);
}
}// for (; myIterator->More(); myIterator->Next()) {
}// for (k=0; k < aNbFaceFace; ++k) {
}
//=======================================================================
//function : MakeBlocks