1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0024157: Parallelization of assembly part of BO

New features
class BOPAlgo_BuilderSolid
-method:
void BOPAlgo_BuilderSolid::SetSolid(const TopoDS_Solid& theSolid) has been added.
Purpose: Sets the source solid <theSolid>

class BOPAlgo_BuilderSolid
-method:
const TopoDS_Solid& BOPAlgo_BuilderSolid::Solid()const
has been added.
Purpose: Returns the source solid

Auxiliary classes
BOPAlgo_BuilderSolidFunctor
BOPAlgo_BuilderSolidCnt
have been added.
Purpose: The classes provide the interface and implementation of the parallel computations.

class BOPTools_AlgoTools
-method:
Standard_Boolean  BOPTools_AlgoTools::IsOpenShell(const TopoDS_Shell& theShell) has been added.
Purpose: Returns true if the shell <theShell> is open

class BOPTools_AlgoTools
-method:
Standard_Boolean  BOPTools_AlgoTools::IsInvertedSolid(const TopoDS_Solid& theSolid) has been added.
Purpose: Returns true if the solid <theSolid> is inverted

class BOPDS_DS
-protected  method:
void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex, Bnd_Box& theBoxS) has been added.
The method computes bouding box <theBoxS> for the solid with DS-index <theIndex>

Changes
class BOPDS_DS
- method:
void BOPDS_DS::Init()
The block to compute bouding box for the solids has been added.

class BOPAlgo_Builder
- method:
void BOPAlgo_Builder::FillIn3DParts
(BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const BOPCol_BaseAllocator& theAllocator)
The order of treatment of the unbalanced binary tree of overlapped bounding boxes has been changed

class BOPAlgo_Builder
- method:
 void BOPAlgo_Builder::BuildSplitSolids
(BOPCol_DataMapOfShapeListOfShape& theInParts,
BOPCol_DataMapOfShapeShape& theDraftSolids,
const BOPCol_BaseAllocator&  theAllocator)
The algorithm has been adapted to provide the parallel computations
This commit is contained in:
pkv 2013-12-10 09:08:44 +04:00 committed by bugmaster
parent 5a07b8e1c4
commit 30ecd5f8bf
9 changed files with 330 additions and 207 deletions

View File

@ -205,11 +205,6 @@ is
theAllocator:BaseAllocator from BOPCol) theAllocator:BaseAllocator from BOPCol)
is protected; is protected;
BuildBndBox(me:out;
theIndex:Integer from Standard;
theBox: out Box from Bnd)
is protected;
FillInternalShapes(me:out) FillInternalShapes(me:out)
is protected; is protected;
-- --

View File

@ -21,7 +21,8 @@ class BuilderSolid from BOPAlgo
---Purpose: The algorithm to build solids from set of faces ---Purpose: The algorithm to build solids from set of faces
uses uses
BaseAllocator from BOPCol BaseAllocator from BOPCol,
Solid from TopoDS
--raises --raises
@ -34,6 +35,15 @@ is
Create (theAllocator: BaseAllocator from BOPCol) Create (theAllocator: BaseAllocator from BOPCol)
returns BuilderSolid from BOPAlgo; returns BuilderSolid from BOPAlgo;
SetSolid(me:out;
theSolid:Solid from TopoDS);
---Purpose: Sets the source solid <theSolid>
Solid(me)
returns Solid from TopoDS;
---C++: return const &
---Purpose: Returns the source solid
Perform(me:out) Perform(me:out)
---Purpose: Performs the algorithm ---Purpose: Performs the algorithm
is redefined; is redefined;
@ -60,6 +70,7 @@ is
---Purpose: Build finalized solids with internal shells ---Purpose: Build finalized solids with internal shells
is redefined protected; is redefined protected;
--fields fields
mySolid:Solid from TopoDS is protected;
end BuilderSolid; end BuilderSolid;

View File

@ -103,6 +103,22 @@ static
{ {
} }
//======================================================================= //=======================================================================
//function : SetSolid
//purpose :
//=======================================================================
void BOPAlgo_BuilderSolid::SetSolid(const TopoDS_Solid& aS)
{
mySolid=aS;
}
//=======================================================================
//function : Solid
//purpose :
//=======================================================================
const TopoDS_Solid& BOPAlgo_BuilderSolid::Solid()const
{
return mySolid;
}
//=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================

View File

@ -30,16 +30,14 @@
#include <BOPInt_Context.hxx> #include <BOPInt_Context.hxx>
#include <BOPAlgo_BuilderFace.hxx> #include <BOPAlgo_BuilderFace.hxx>
#include <BOPAlgo_BuilderSolid.hxx>
//=======================================================================
//class : BOPAlgo_VectorOfBuilderFace
//purpose :
//=======================================================================
typedef BOPCol_NCVector<BOPAlgo_BuilderFace> BOPAlgo_VectorOfBuilderFace; typedef BOPCol_NCVector<BOPAlgo_BuilderFace> BOPAlgo_VectorOfBuilderFace;
// //
//======================================================================= //=======================================================================
//class : BOPAlgo_BuilderFaceFunctor //class : BOPAlgo_BuilderFaceFunctor
//purpose : //purpose : The class provides the interface and implementation
// of the parallel computations
//======================================================================= //=======================================================================
class BOPAlgo_BuilderFaceFunctor { class BOPAlgo_BuilderFaceFunctor {
protected: protected:
@ -67,7 +65,8 @@ class BOPAlgo_BuilderFaceFunctor {
}; };
//======================================================================= //=======================================================================
//class : BOPAlgo_BuilderFaceCnt //class : BOPAlgo_BuilderFaceCnt
//purpose : //purpose : The class provides the interface and implementation
// of the parallel computations
//======================================================================= //=======================================================================
class BOPAlgo_BuilderFaceCnt { class BOPAlgo_BuilderFaceCnt {
public: public:
@ -89,10 +88,11 @@ class BOPAlgo_BuilderFaceCnt {
// //
}; };
// //
//-------------------------------------------------------------------------
typedef BOPCol_NCVector<TopoDS_Shape> BOPAlgo_VectorOfShape; typedef BOPCol_NCVector<TopoDS_Shape> BOPAlgo_VectorOfShape;
typedef BOPCol_NCVector<BOPAlgo_VectorOfShape> BOPAlgo_VectorOfVectorOfShape; //
typedef BOPCol_NCVector<BOPAlgo_VectorOfShape> \
BOPAlgo_VectorOfVectorOfShape;
//
typedef NCollection_IndexedDataMap\ typedef NCollection_IndexedDataMap\
<BOPTools_Set, Standard_Integer, BOPTools_SetMapHasher> \ <BOPTools_Set, Standard_Integer, BOPTools_SetMapHasher> \
BOPAlgo_IndexedDataMapOfSetInteger; BOPAlgo_IndexedDataMapOfSetInteger;
@ -124,13 +124,14 @@ class BOPAlgo_PairOfShapeBoolean {
TopoDS_Shape myShape1; TopoDS_Shape myShape1;
TopoDS_Shape myShape2; TopoDS_Shape myShape2;
}; };
typedef BOPCol_NCVector<BOPAlgo_PairOfShapeBoolean> BOPAlgo_VectorOfPairOfShapeBoolean;
// //
typedef BOPCol_NCVector<BOPAlgo_PairOfShapeBoolean> \
BOPAlgo_VectorOfPairOfShapeBoolean;
//
//======================================================================= //=======================================================================
//function : BOPAlgo_BuilderSDFaceFunctor //function : BOPAlgo_BuilderSDFaceFunctor
//purpose : //purpose : The class provides the interface and implementation
// of the parallel computations
//======================================================================= //=======================================================================
class BOPAlgo_BuilderSDFaceFunctor { class BOPAlgo_BuilderSDFaceFunctor {
protected: protected:
@ -167,7 +168,8 @@ class BOPAlgo_BuilderSDFaceFunctor {
// //
//======================================================================= //=======================================================================
//function : BOPAlgo_BuilderSDFaceCnt //function : BOPAlgo_BuilderSDFaceCnt
//purpose : //purpose : The class provides the interface and implementation
// of the parallel computations
//======================================================================= //=======================================================================
class BOPAlgo_BuilderSDFaceCnt { class BOPAlgo_BuilderSDFaceCnt {
public: public:
@ -190,6 +192,61 @@ class BOPAlgo_BuilderSDFaceCnt {
} }
// //
}; };
//
typedef BOPCol_NCVector<BOPAlgo_BuilderSolid> BOPAlgo_VectorOfBuilderSolid;
//
//=======================================================================
//class : BOPAlgo_BuilderSolidFunctor
//purpose : The class provides the interface and implementation
// of the parallel computations
//=======================================================================
class BOPAlgo_BuilderSolidFunctor {
protected:
BOPAlgo_VectorOfBuilderSolid* myPVBS;
//
public:
//
BOPAlgo_BuilderSolidFunctor(BOPAlgo_VectorOfBuilderSolid& aVBS)
: myPVBS(&aVBS) {
}
//
void operator()( const flexible_range<Standard_Integer>& aBR ) const{
Standard_Integer i, iBeg, iEnd;
//
BOPAlgo_VectorOfBuilderSolid& aVBS=*myPVBS;
//
iBeg=aBR.begin();
iEnd=aBR.end();
for(i=iBeg; i!=iEnd; ++i) {
BOPAlgo_BuilderSolid& aBS=aVBS(i);
//
aBS.Perform();
}
}
};
//=======================================================================
//class : BOPAlgo_BuilderSolidCnt
//purpose : The class provides the interface and implementation
// of the parallel computations
//=======================================================================
class BOPAlgo_BuilderSolidCnt {
public:
//-------------------------------
// Perform
Standard_EXPORT static void Perform(const Standard_Boolean bRunParallel,
BOPAlgo_VectorOfBuilderSolid& aVBS) {
Standard_Size aNbBS=aVBS.Extent();
BOPAlgo_BuilderSolidFunctor aBSF(aVBS);
//
if (bRunParallel) {
flexible_for(flexible_range<Standard_Integer>(0,aNbBS), aBSF);
}
else {
aBSF.operator()(flexible_range<Standard_Integer>(0,aNbBS));
}
}
//
};
#endif #endif

View File

@ -63,11 +63,9 @@
#include <BOPDS_BoxBndTree.hxx> #include <BOPDS_BoxBndTree.hxx>
#include <BOPCol_ListOfInteger.hxx> #include <BOPCol_ListOfInteger.hxx>
#include <BOPInt_Context.hxx> #include <BOPInt_Context.hxx>
#include <BOPAlgo_Builder_2Cnt.hxx>
static
Standard_Boolean IsClosedShell(const TopoDS_Shell& aSh);
static static
void OwnInternalShapes(const TopoDS_Shape& , void OwnInternalShapes(const TopoDS_Shape& ,
BOPCol_IndexedMapOfShape& ); BOPCol_IndexedMapOfShape& );
@ -146,7 +144,6 @@ void BOPAlgo_Builder::FillImagesSolids()
Handle(NCollection_IncAllocator) aAlr; Handle(NCollection_IncAllocator) aAlr;
// //
aAlr=new NCollection_IncAllocator(); aAlr=new NCollection_IncAllocator();
//
BOPCol_DataMapOfShapeListOfShape theInParts(100, aAlr); BOPCol_DataMapOfShapeListOfShape theInParts(100, aAlr);
BOPCol_DataMapOfShapeShape theDraftSolids(100, aAlr); BOPCol_DataMapOfShapeShape theDraftSolids(100, aAlr);
// //
@ -220,6 +217,23 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
} }
}//for (i=0; i<aNbS; ++i) { }//for (i=0; i<aNbS; ++i) {
// //
// 1.2. Prepare TreeFiller
BOPDS_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
aItDMISB.Initialize(aDMISB);
for (; aItDMISB.More(); aItDMISB.Next()) {
k=aItDMISB.Key();
const BOPAlgo_ShapeBox& aSBk=aItDMISB.Value();
const Bnd_Box& aBk=aSBk.Box();
//
aTreeFiller.Add(k, aBk);
}
//
// 1.3. Shake TreeFiller
aTreeFiller.Fill();
//
//---------------------------------------------
// 2. Solids // 2. Solids
for (i=0; i<aNbS; ++i) { for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i); const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
@ -236,10 +250,7 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
BOPCol_ListOfShape aLIF(aAlr1); BOPCol_ListOfShape aLIF(aAlr1);
BOPCol_IndexedMapOfShape aMF(100, aAlr1); BOPCol_IndexedMapOfShape aMF(100, aAlr1);
BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, aAlr1); BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, aAlr1);
//
BOPDS_BoxBndTreeSelector aSelector; BOPDS_BoxBndTreeSelector aSelector;
BOPDS_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
Bnd_Box aBoxS; Bnd_Box aBoxS;
// //
const TopoDS_Shape& aS=aSI.Shape(); const TopoDS_Shape& aS=aSI.Shape();
@ -256,8 +267,8 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
} }
} }
// //
// 2.1 Compute Bnd_Box for the solid aS [ aBoxS ] // 2.1 Bounding box for the solid aS [ aBoxS ]
BuildBndBox(i, aBoxS); aBoxS=aSI.Box();
//----- //-----
// //
// 2.2 Build Draft Solid [aSD] // 2.2 Build Draft Solid [aSD]
@ -277,25 +288,7 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
aMF.Add(aFI); aMF.Add(aFI);
} }
// //
// 2.4. Prepare TreeFiller // 2.4. Select boxes of faces that are not out of aBoxS
aItDMISB.Initialize(aDMISB);
for (; aItDMISB.More(); aItDMISB.Next()) {
k=aItDMISB.Key();
const BOPAlgo_ShapeBox& aSBk=aItDMISB.Value();
const TopoDS_Shape& aFk=aSBk.Shape();
if (aMF.Contains(aFk)) {
continue;
}
//
const Bnd_Box& aBk=aSBk.Box();
//
aTreeFiller.Add(k, aBk);
}
//
// 2.5. Shake TreeFiller
aTreeFiller.Fill();
//
// 2.6. Select boxes of faces that are not out of aBoxS
aSelector.Clear(); aSelector.Clear();
aSelector.SetBox(aBoxS); aSelector.SetBox(aBoxS);
// //
@ -303,7 +296,7 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
// //
const BOPCol_ListOfInteger& aLIFP=aSelector.Indices(); const BOPCol_ListOfInteger& aLIFP=aSelector.Indices();
// //
// 2.7. Collect faces that are IN aSolid [ aLFIN ] // 2.5. Collect faces that are IN aSolid [ aLFIN ]
BOPCol_ListOfShape aLFP(aAlr1); BOPCol_ListOfShape aLFP(aAlr1);
BOPCol_ListOfShape aLCBF(aAlr1); BOPCol_ListOfShape aLCBF(aAlr1);
BOPCol_MapOfShape aMFDone(100, aAlr1); BOPCol_MapOfShape aMFDone(100, aAlr1);
@ -316,6 +309,9 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
nFP=aItLI.Value(); nFP=aItLI.Value();
const BOPAlgo_ShapeBox& aSBF=aDMISB.Find(nFP); const BOPAlgo_ShapeBox& aSBF=aDMISB.Find(nFP);
const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape()); const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape());
if (aMF.Contains(aFP)) {
continue;
}
if (aMFDone.Contains(aFP)) { if (aMFDone.Contains(aFP)) {
continue; continue;
} }
@ -354,7 +350,7 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
} }
}// for (; aItLI.More(); aItLI.Next()) { }// for (; aItLI.More(); aItLI.Next()) {
// //
// 2.8. Store the results in theInParts, theDraftSolids // 2.6. Store the results in theInParts, theDraftSolids
aNbFIN=aLFIN.Extent(); aNbFIN=aLFIN.Extent();
if (aNbFIN || aNbLIF) { if (aNbFIN || aNbLIF) {
aItLS.Initialize(aLIF); aItLS.Initialize(aLIF);
@ -474,7 +470,7 @@ void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInPa
myErrorStatus=0; myErrorStatus=0;
// //
Standard_Boolean bFlagSD; Standard_Boolean bFlagSD;
Standard_Integer i, aNbS, iErr, aNbSFS; Standard_Integer i, aNbS, aNbSFS;//, iErr
TopExp_Explorer aExp; TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aIt; BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_DataMapIteratorOfDataMapOfShapeShape aIt1; BOPCol_DataMapIteratorOfDataMapOfShapeShape aIt1;
@ -485,6 +481,7 @@ void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInPa
BOPCol_ListOfShape aSFS(aAlr0), aLSEmpty(aAlr0); BOPCol_ListOfShape aSFS(aAlr0), aLSEmpty(aAlr0);
BOPCol_MapOfShape aMFence(100, aAlr0); BOPCol_MapOfShape aMFence(100, aAlr0);
BOPTools_MapOfSet aMST(100, aAlr0); BOPTools_MapOfSet aMST(100, aAlr0);
BOPAlgo_VectorOfBuilderSolid aVBS;
// //
// 0. Find same domain solids for non-interferred solids // 0. Find same domain solids for non-interferred solids
aNbS=myDS->NbSourceShapes(); aNbS=myDS->NbSourceShapes();
@ -519,6 +516,7 @@ void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInPa
} }
// //
const TopoDS_Shape& aS=aSI.Shape(); const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
if(!theDraftSolids.IsBound(aS)) { if(!theDraftSolids.IsBound(aS)) {
continue; continue;
} }
@ -550,21 +548,24 @@ void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInPa
Handle(NCollection_IncAllocator) aAlr1; Handle(NCollection_IncAllocator) aAlr1;
aAlr1=new NCollection_IncAllocator(); aAlr1=new NCollection_IncAllocator();
// //
BOPAlgo_BuilderSolid aSB(aAlr1); BOPAlgo_BuilderSolid& aBS=aVBS.Append1();
aBS.SetSolid(aSolid);
aBS.SetShapes(aSFS);
}//for (i=0; i<aNbS; ++i) {
// //
//aSB.SetContext(myContext); Standard_Integer k, aNbBS;
aSB.SetShapes(aSFS);
aSB.Perform();
iErr=aSB.ErrorStatus();
if (iErr) {
myErrorStatus=30; // SolidBuilder failed
return;
}
// //
const BOPCol_ListOfShape& aLSR=aSB.Areas(); aNbBS=aVBS.Extent();
//
//===================================================
BOPAlgo_BuilderSolidCnt::Perform(myRunParallel, aVBS);
//===================================================
//
for (k=0; k<aNbBS; ++k) {
BOPAlgo_BuilderSolid& aBS=aVBS(k);
const TopoDS_Solid& aS=aBS.Solid();
const BOPCol_ListOfShape& aLSR=aBS.Areas();
// //
// 1.4 Collect resulting solids and theirs set of faces.
// Update Images.
if (!myImages.IsBound(aS)) { if (!myImages.IsBound(aS)) {
BOPCol_ListOfShape aLSx; BOPCol_ListOfShape aLSx;
// //
@ -589,9 +590,8 @@ void BOPAlgo_Builder::BuildSplitSolids(BOPCol_DataMapOfShapeListOfShape& theInPa
} }
} }
} }
}// for (i=0; i<aNbS; ++i) {
} }
}
//======================================================================= //=======================================================================
//function :FillInternalShapes //function :FillInternalShapes
//purpose : //purpose :
@ -812,85 +812,6 @@ void BOPAlgo_Builder::FillInternalShapes()
aMSx.Clear(); aMSx.Clear();
} }
//======================================================================= //=======================================================================
//function : BuildBndBox
//purpose :
//=======================================================================
void BOPAlgo_Builder::BuildBndBox(const Standard_Integer theIndex,
Bnd_Box& aBoxS)
{
Standard_Boolean bIsOpenBox;
Standard_Integer nSh, nFc;
Standard_Real aTolS, aTolFc;
TopAbs_State aState;
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
//
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(theIndex);
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
//
bIsOpenBox=Standard_False;
//
aTolS=0.;
const BOPCol_ListOfInteger& aLISh=aSI.SubShapes();
aItLI.Initialize(aLISh);
for (; aItLI.More(); aItLI.Next()) {
nSh=aItLI.Value();
const BOPDS_ShapeInfo& aSISh=myDS->ShapeInfo(nSh);
if (aSISh.ShapeType()!=TopAbs_SHELL) {
continue;
}
//
const BOPCol_ListOfInteger& aLIFc=aSISh.SubShapes();
aItLI1.Initialize(aLIFc);
for (; aItLI1.More(); aItLI1.Next()) {
nFc=aItLI1.Value();
const BOPDS_ShapeInfo& aSIFc=myDS->ShapeInfo(nFc);
if (aSIFc.ShapeType()!=TopAbs_FACE) {
continue;
}
//
const Bnd_Box& aBFc=aSIFc.Box();
aBoxS.Add(aBFc);
//
if (!bIsOpenBox) {
bIsOpenBox=(aBFc.IsOpenXmin() || aBFc.IsOpenXmax() ||
aBFc.IsOpenYmin() || aBFc.IsOpenYmax() ||
aBFc.IsOpenZmin() || aBFc.IsOpenZmax());
if (bIsOpenBox) {
break;
}
}
//
const TopoDS_Face& aFc=*((TopoDS_Face*)&aSIFc.Shape());
aTolFc=BRep_Tool::Tolerance(aFc);
if (aTolFc>aTolS) {
aTolS=aTolFc;
}
}//for (; aItLI1.More(); aItLI1.Next()) {
if (bIsOpenBox) {
break;
}
//
const TopoDS_Shell& aSh=*((TopoDS_Shell*)&aSISh.Shape());
bIsOpenBox=IsClosedShell(aSh);
if (bIsOpenBox) {
break;
}
}//for (; aItLI.More(); aItLI.Next()) {
//
if (bIsOpenBox) {
aBoxS.SetWhole();
}
else {
BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
aSC.PerformInfinitePoint(aTolS);
aState=aSC.State();
if (aState==TopAbs_IN) {
aBoxS.SetWhole();
}
}
}
//=======================================================================
//function : OwnInternalShapes //function : OwnInternalShapes
//purpose : //purpose :
//======================================================================= //=======================================================================
@ -908,49 +829,6 @@ void BOPAlgo_Builder::BuildBndBox(const Standard_Integer theIndex,
} }
} }
//======================================================================= //=======================================================================
//function : IsClosedShell
//purpose :
//=======================================================================
Standard_Boolean IsClosedShell(const TopoDS_Shell& aSh)
{
Standard_Boolean bRet;
Standard_Integer i, aNbE, aNbF;
TopAbs_Orientation aOrF;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
BOPCol_ListIteratorOfListOfShape aItLS;
//
bRet=Standard_False;
//
BOPTools::MapShapesAndAncestors(aSh, TopAbs_EDGE, TopAbs_FACE, aMEF);
//
aNbE=aMEF.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aMEF.FindKey(i));
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
aNbF=0;
const BOPCol_ListOfShape& aLF=aMEF(i);
aItLS.Initialize(aLF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aF=aItLS.Value();
aOrF=aF.Orientation();
if (aOrF==TopAbs_INTERNAL || aOrF==TopAbs_EXTERNAL) {
continue;
}
++aNbF;
}
//
if (aNbF==1) {
bRet=!bRet; // True
break;
}
}
//
return bRet;
}
//=======================================================================
//function : TreatCompound //function : TreatCompound
//purpose : //purpose :
//======================================================================= //=======================================================================

View File

@ -34,6 +34,7 @@ class DS from BOPDS
uses uses
ShapeEnum from TopAbs, ShapeEnum from TopAbs,
Box from Bnd,
Shape from TopoDS, Shape from TopoDS,
-- --
ListOfShape from BOPCol, ListOfShape from BOPCol,
@ -581,6 +582,13 @@ is
--- Updates tolerance of the sub-shapes of the shape with index <theIndex>. --- Updates tolerance of the sub-shapes of the shape with index <theIndex>.
--- ---
BuildBndBoxSolid (me:out;
theIndex:Integer from Standard;
theBox:out Box from Bnd)
is protected;
---Purpose:
--- Computes bouding box <theBox> for the solid with DS-index <theIndex>
---
fields fields
myAllocator : BaseAllocator from BOPCol is protected; myAllocator : BaseAllocator from BOPCol is protected;
myArguments : ListOfShape from BOPCol is protected; myArguments : ListOfShape from BOPCol is protected;

View File

@ -522,6 +522,17 @@ void BOPDS_DS::Init()
}//if (aTS==TopAbs_FACE) { }//if (aTS==TopAbs_FACE) {
}//for (j=0; j<myNbSourceShapes; ++j) { }//for (j=0; j<myNbSourceShapes; ++j) {
// //
// 2.4 Solids
for (j=0; j<myNbSourceShapes; ++j) {
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
//
aTS=aSI.ShapeType();
if (aTS==TopAbs_SOLID) {
Bnd_Box& aBox=aSI.ChangeBox();
BuildBndBoxSolid(j, aBox);
}
}//for (j=0; j<myNbSourceShapes; ++j) {
//
aMI.Clear(); aMI.Clear();
aAllocator.Nullify(); aAllocator.Nullify();
//-----------------------------------------------------scope_1 t //-----------------------------------------------------scope_1 t
@ -1832,3 +1843,79 @@ void SortShell(const int n, BOPDS_Pave *a)
}//for (i=0; i<nd; ++i) }//for (i=0; i<nd; ++i)
}//while (1) }//while (1)
} }
//=======================================================================
//function : BuildBndBoxSolid
//purpose :
//=======================================================================
void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex,
Bnd_Box& aBoxS)
{
Standard_Boolean bIsOpenBox, bIsInverted;
Standard_Integer nSh, nFc;
Standard_Real aTolS, aTolFc;
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1;
//
const BOPDS_ShapeInfo& aSI=ShapeInfo(theIndex);
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aS));
//
bIsOpenBox=Standard_False;
//
aTolS=0.;
const BOPCol_ListOfInteger& aLISh=aSI.SubShapes();
aItLI.Initialize(aLISh);
for (; aItLI.More(); aItLI.Next()) {
nSh=aItLI.Value();
const BOPDS_ShapeInfo& aSISh=ShapeInfo(nSh);
if (aSISh.ShapeType()!=TopAbs_SHELL) {
continue;
}
//
const BOPCol_ListOfInteger& aLIFc=aSISh.SubShapes();
aItLI1.Initialize(aLIFc);
for (; aItLI1.More(); aItLI1.Next()) {
nFc=aItLI1.Value();
const BOPDS_ShapeInfo& aSIFc=ShapeInfo(nFc);
if (aSIFc.ShapeType()!=TopAbs_FACE) {
continue;
}
//
const Bnd_Box& aBFc=aSIFc.Box();
aBoxS.Add(aBFc);
//
if (!bIsOpenBox) {
bIsOpenBox=(aBFc.IsOpenXmin() || aBFc.IsOpenXmax() ||
aBFc.IsOpenYmin() || aBFc.IsOpenYmax() ||
aBFc.IsOpenZmin() || aBFc.IsOpenZmax());
if (bIsOpenBox) {
break;
}
}
//
const TopoDS_Face& aFc=*((TopoDS_Face*)&aSIFc.Shape());
aTolFc=BRep_Tool::Tolerance(aFc);
if (aTolFc>aTolS) {
aTolS=aTolFc;
}
}//for (; aItLI1.More(); aItLI1.Next()) {
if (bIsOpenBox) {
break;
}
//
const TopoDS_Shell& aSh=*((TopoDS_Shell*)&aSISh.Shape());
bIsOpenBox=BOPTools_AlgoTools::IsOpenShell(aSh);
if (bIsOpenBox) {
break;
}
}//for (; aItLI.More(); aItLI.Next()) {
//
if (bIsOpenBox) {
aBoxS.SetWhole();
}
else {
bIsInverted=BOPTools_AlgoTools::IsInvertedSolid(aSolid);
if (bIsInverted) {
aBoxS.SetWhole();
}
}
}

View File

@ -31,6 +31,7 @@ uses
Edge from TopoDS, Edge from TopoDS,
Face from TopoDS, Face from TopoDS,
Wire from TopoDS, Wire from TopoDS,
Shell from TopoDS,
Solid from TopoDS, Solid from TopoDS,
-- --
BaseAllocator from BOPCol, BaseAllocator from BOPCol,
@ -447,4 +448,14 @@ is
---Purpose: ---Purpose:
--- Retutns dimension of the shape <theS>. --- Retutns dimension of the shape <theS>.
IsOpenShell(myclass;
theShell:Shell from TopoDS)
returns Boolean from Standard;
---Purpose: Returns true if the shell <theShell> is open
IsInvertedSolid(myclass;
theSolid:Solid from TopoDS)
returns Boolean from Standard;
---Purpose: Returns true if the solid <theSolid> is inverted
end AlgoTools; end AlgoTools;

View File

@ -1880,3 +1880,63 @@ Standard_Boolean FindPointInFace(const TopoDS_Edge& aE,
bRet = aDist < Precision::Angular(); bRet = aDist < Precision::Angular();
return bRet; return bRet;
} }
//=======================================================================
//function : IsOpenShell
//purpose :
//=======================================================================
Standard_Boolean
BOPTools_AlgoTools::IsOpenShell(const TopoDS_Shell& aSh)
{
Standard_Boolean bRet;
Standard_Integer i, aNbE, aNbF;
TopAbs_Orientation aOrF;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
BOPCol_ListIteratorOfListOfShape aItLS;
//
bRet=Standard_False;
//
BOPTools::MapShapesAndAncestors(aSh, TopAbs_EDGE, TopAbs_FACE, aMEF);
//
aNbE=aMEF.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aMEF.FindKey(i));
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
aNbF=0;
const BOPCol_ListOfShape& aLF=aMEF(i);
aItLS.Initialize(aLF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aF=aItLS.Value();
aOrF=aF.Orientation();
if (aOrF==TopAbs_INTERNAL || aOrF==TopAbs_EXTERNAL) {
continue;
}
++aNbF;
}
//
if (aNbF==1) {
bRet=!bRet; // True
break;
}
}
//
return bRet;
}
//=======================================================================
//function : IsInvertedSolid
//purpose :
//=======================================================================
Standard_Boolean
BOPTools_AlgoTools::IsInvertedSolid(const TopoDS_Solid& aSolid)
{
Standard_Real aTolS;
TopAbs_State aState;
BRepClass3d_SolidClassifier aSC(aSolid);
//
aTolS=1.e-7;
aSC.PerformInfinitePoint(aTolS);
aState=aSC.State();
return (aState==TopAbs_IN);
}