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

0030656: Modeling Algorithms - Change Boolean Operations algorithm to use BVH tree instead of UBTree

Switching the Boolean Operations algorithm to use the BVH tree instead of UB tree as selection of the elements from BVH tree is usually faster.
This commit is contained in:
emv
2019-04-18 15:34:37 +03:00
parent ce37d08a7b
commit 06b59f24f4
15 changed files with 392 additions and 289 deletions

View File

@@ -264,11 +264,11 @@ bfuse _model _model t_s
explode _model e explode _model e
# Make a weld at joint edges of platform and wedge # Make a weld at joint edges of platform and wedge
blend _model _model 2 _model_26
blend _model _model 2 _model_27 blend _model _model 2 _model_27
blend _model _model 2 _model_28 blend _model _model 2 _model_28
blend _model _model 2 _model_29 blend _model _model 2 _model_29
blend _model _model 2 _model_31 blend _model _model 2 _model_30
blend _model _model 2 _model_32
# Cylinder on wedge # Cylinder on wedge
blend result _model 2 _model_161 blend result _model 2 _model_161

View File

@@ -24,7 +24,8 @@
#include <BOPAlgo_Alerts.hxx> #include <BOPAlgo_Alerts.hxx>
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx> #include <BOPTools_AlgoTools2D.hxx>
#include <BOPTools_BoxSelector.hxx> #include <BOPTools_BoxTree.hxx>
#include <Bnd_Tools.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
@@ -38,8 +39,7 @@
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#include <IntTools_FClass2d.hxx> #include <IntTools_FClass2d.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include <NCollection_UBTreeFiller.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
@@ -443,32 +443,33 @@ void BOPAlgo_BuilderFace::PerformAreas()
{ {
// No holes, stop the analysis // No holes, stop the analysis
myAreas.Append(aNewFaces); myAreas.Append(aNewFaces);
return;
} }
// Classify holes relatively faces // Classify holes relatively faces
// Prepare tree filler with the boxes of the hole faces // Prepare tree filler with the boxes of the hole faces
NCollection_UBTree<Standard_Integer, Bnd_Box2d> aBBTree; Handle(BOPTools_Box2dTree) aBoxTree = new BOPTools_Box2dTree();
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
Standard_Integer i, aNbH = aHoleFaces.Extent(); Standard_Integer i, aNbH = aHoleFaces.Extent();
aBoxTree->SetSize (aNbH);
for (i = 1; i <= aNbH; ++i) for (i = 1; i <= aNbH; ++i)
{ {
const TopoDS_Face& aHFace = TopoDS::Face(aHoleFaces(i)); const TopoDS_Face& aHFace = TopoDS::Face(aHoleFaces(i));
// //
Bnd_Box2d aBox; Bnd_Box2d aBox;
BRepTools::AddUVBounds(aHFace, aBox); BRepTools::AddUVBounds(aHFace, aBox);
aTreeFiller.Add(i, aBox); aBoxTree->Add(i, Bnd_Tools::Bnd2BVH (aBox));
} }
// Shake TreeFiller // Build BVH
aTreeFiller.Fill(); aBoxTree->Build();
// Find outer growth face that is most close to each hole face // Find outer growth face that is most close to each hole face
TopTools_IndexedDataMapOfShapeShape aHoleFaceMap; TopTools_IndexedDataMapOfShapeShape aHoleFaceMap;
// Selector // Selector
BOPTools_BoxSelector<Bnd_Box2d> aSelector; BOPTools_Box2dTreeSelector aSelector;
aSelector.SetBVHSet (aBoxTree.get());
TopTools_ListIteratorOfListOfShape aItLS(aNewFaces); TopTools_ListIteratorOfListOfShape aItLS(aNewFaces);
for (; aItLS.More(); aItLS.Next()) for (; aItLS.More(); aItLS.Next())
@@ -480,8 +481,8 @@ void BOPAlgo_BuilderFace::PerformAreas()
BRepTools::AddUVBounds(aFace, aBox); BRepTools::AddUVBounds(aFace, aBox);
aSelector.Clear(); aSelector.Clear();
aSelector.SetBox(aBox); aSelector.SetBox(Bnd_Tools::Bnd2BVH (aBox));
aBBTree.Select(aSelector); aSelector.Select();
const TColStd_ListOfInteger& aLI = aSelector.Indices(); const TColStd_ListOfInteger& aLI = aSelector.Indices();
TColStd_ListIteratorOfListOfInteger aItLI(aLI); TColStd_ListIteratorOfListOfInteger aItLI(aLI);

View File

@@ -21,9 +21,10 @@
#include <BOPAlgo_Tools.hxx> #include <BOPAlgo_Tools.hxx>
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx> #include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <BOPTools_CoupleOfShape.hxx> #include <BOPTools_CoupleOfShape.hxx>
#include <BOPTools_Parallel.hxx> #include <BOPTools_Parallel.hxx>
#include <Bnd_Tools.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
@@ -39,7 +40,6 @@
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_Vector.hxx> #include <NCollection_Vector.hxx>
#include <TColStd_MapIntegerHasher.hxx> #include <TColStd_MapIntegerHasher.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
@@ -444,23 +444,22 @@ void BOPAlgo_BuilderSolid::PerformAreas()
// Classify holes relatively solids // Classify holes relatively solids
// Prepare tree filler with the boxes of the hole shells // Prepare tree filler with the boxes of the hole shells
BOPTools_BoxBndTree aBBTree; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
Standard_Integer i, aNbH = aHoleShells.Extent(); Standard_Integer i, aNbH = aHoleShells.Extent();
aBBTree->SetSize (aNbH);
for (i = 1; i <= aNbH; ++i) for (i = 1; i <= aNbH; ++i)
{ {
const TopoDS_Shape& aHShell = aHoleShells(i); const TopoDS_Shape& aHShell = aHoleShells(i);
// //
Bnd_Box aBox; Bnd_Box aBox;
BRepBndLib::Add(aHShell, aBox); BRepBndLib::Add(aHShell, aBox);
aTreeFiller.Add(i, aBox); aBBTree->Add(i, Bnd_Tools::Bnd2BVH(aBox));
myBoxes.Bind(aHShell, aBox); myBoxes.Bind(aHShell, aBox);
} }
// Shake TreeFiller // Shake TreeFiller
aTreeFiller.Fill(); aBBTree->Build();
// Find outer growth shell that is most close to each hole shell // Find outer growth shell that is most close to each hole shell
TopTools_IndexedDataMapOfShapeShape aHoleSolidMap; TopTools_IndexedDataMapOfShapeShape aHoleSolidMap;
@@ -476,9 +475,10 @@ void BOPAlgo_BuilderSolid::PerformAreas()
myBoxes.Bind(aSolid, aBox); myBoxes.Bind(aSolid, aBox);
BOPTools_BoxBndTreeSelector aSelector; BOPTools_BoxTreeSelector aSelector;
aSelector.SetBox(aBox); aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBox));
aBBTree.Select(aSelector); aSelector.SetBVHSet (aBBTree.get());
aSelector.Select();
const TColStd_ListOfInteger& aLI = aSelector.Indices(); const TColStd_ListOfInteger& aLI = aSelector.Indices();
TColStd_ListIteratorOfListOfInteger aItLI(aLI); TColStd_ListIteratorOfListOfInteger aItLI(aLI);

View File

@@ -284,7 +284,7 @@ void BOPAlgo_PaveFiller::PerformInternal()
// //
MakeSplitEdges(); MakeSplitEdges();
if (HasErrors()) { if (HasErrors()) {
return; return;
} }
// //
UpdatePaveBlocksWithSDVertices(); UpdatePaveBlocksWithSDVertices();

View File

@@ -25,7 +25,7 @@
#include <BOPDS_PaveBlock.hxx> #include <BOPDS_PaveBlock.hxx>
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx> #include <BOPTools_AlgoTools2D.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <BOPTools_Parallel.hxx> #include <BOPTools_Parallel.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
@@ -33,6 +33,7 @@
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepBuilderAPI_MakeFace.hxx> #include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepLib.hxx> #include <BRepLib.hxx>
#include <Bnd_Tools.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx> #include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx> #include <GeomAPI_ProjectPointOnSurf.hxx>
#include <gp_Circ.hxx> #include <gp_Circ.hxx>
@@ -45,7 +46,6 @@
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#include <NCollection_IncAllocator.hxx> #include <NCollection_IncAllocator.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_Vector.hxx> #include <NCollection_Vector.hxx>
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
@@ -957,14 +957,14 @@ typedef BOPTools_Cnt
<BOPAlgo_TNVFunctor, <BOPAlgo_TNVFunctor,
BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt; BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt;
//======================================================================= //=======================================================================
class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{ class BOPAlgo_TNV : public BOPTools_BoxTreeSelector{
public: public:
BOPAlgo_TNV() BOPAlgo_TNV()
: BOPTools_BoxBndTreeSelector(), : BOPTools_BoxTreeSelector(),
myTol (0.), myFuzzyValue(0.), myTree(NULL), myVecTNV(NULL) { myTol (0.), myFuzzyValue(0.), myVecTNV(NULL) {
}; };
// //
~BOPAlgo_TNV(){ virtual ~BOPAlgo_TNV(){
}; };
// //
void SetVertex(const TopoDS_Vertex& aV) { void SetVertex(const TopoDS_Vertex& aV) {
@@ -976,10 +976,6 @@ class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{
return myV; return myV;
} }
// //
void SetTree(BOPTools_BoxBndTree& aTree) {
myTree=&aTree;
}
//
void SetTolerance(const Standard_Real theTol) { void SetTolerance(const Standard_Real theTol) {
myTol = theTol; myTol = theTol;
} }
@@ -1000,19 +996,24 @@ class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{
myVecTNV = &theVec; myVecTNV = &theVec;
} }
// //
virtual Standard_Boolean Accept(const Standard_Integer& theIndex) virtual Standard_Boolean Accept(const Standard_Integer theIndex,
const Standard_Boolean& theIsInside) override
{ {
const BOPAlgo_TNV& aTNV = myVecTNV->Value(theIndex - 1); if (theIsInside || !RejectElement (theIndex))
Standard_Real aTolSum2 = myTol + aTNV.Tolerance() + myFuzzyValue; {
aTolSum2 *= aTolSum2; const Standard_Integer anInd = myBVHSet->Element (theIndex);
Standard_Real aD2 = myPnt.SquareDistance(aTNV.Pnt()); const BOPAlgo_TNV& aTNV = myVecTNV->Value(anInd - 1);
if (aD2 < aTolSum2) Standard_Real aTolSum2 = myTol + aTNV.Tolerance() + myFuzzyValue;
return BOPTools_BoxBndTreeSelector::Accept(theIndex); aTolSum2 *= aTolSum2;
Standard_Real aD2 = myPnt.SquareDistance(aTNV.Pnt());
if (aD2 < aTolSum2)
return BOPTools_BoxTreeSelector::Accept(theIndex, Standard_True);
}
return Standard_False; return Standard_False;
} }
// //
void Perform() { void Perform() {
myTree->Select(*this); Select();
} }
// //
protected: protected:
@@ -1020,7 +1021,6 @@ class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{
Standard_Real myFuzzyValue; Standard_Real myFuzzyValue;
gp_Pnt myPnt; gp_Pnt myPnt;
TopoDS_Vertex myV; TopoDS_Vertex myV;
BOPTools_BoxBndTree *myTree;
const BOPAlgo_VectorOfTNV *myVecTNV; const BOPAlgo_VectorOfTNV *myVecTNV;
}; };
// //
@@ -1044,9 +1044,8 @@ void BOPAlgo_Tools::IntersectVertices(const TopTools_IndexedDataMapOfShapeReal&
} }
// //
// Use unbalanced binary tree of bounding boxes for sorting of the vertices. // Use unbalanced binary tree of bounding boxes for sorting of the vertices.
BOPTools_BoxBndTree aBBTree; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
NCollection_UBTreeFiller <Standard_Integer, aBBTree->SetSize (aNbV);
Bnd_Box> aTreeFiller(aBBTree);
// Perform intersection of the vertices // Perform intersection of the vertices
BOPAlgo_VectorOfTNV aVTNV; BOPAlgo_VectorOfTNV aVTNV;
// //
@@ -1064,18 +1063,18 @@ void BOPAlgo_Tools::IntersectVertices(const TopTools_IndexedDataMapOfShapeReal&
aBox.Add(BRep_Tool::Pnt(aV)); aBox.Add(BRep_Tool::Pnt(aV));
aBox.SetGap(aTol + aTolAdd); aBox.SetGap(aTol + aTolAdd);
// //
aTreeFiller.Add(i, aBox); aBBTree->Add(i, Bnd_Tools::Bnd2BVH(aBox));
// //
BOPAlgo_TNV& aTNV=aVTNV.Appended(); BOPAlgo_TNV& aTNV=aVTNV.Appended();
aTNV.SetTree(aBBTree); aTNV.SetBVHSet (aBBTree.get());
aTNV.SetBox(aBox); aTNV.SetBox(Bnd_Tools::Bnd2BVH(aBox));
aTNV.SetVertex(aV); aTNV.SetVertex(aV);
aTNV.SetTolerance(aTol); aTNV.SetTolerance(aTol);
aTNV.SetFuzzyValue(theFuzzyValue); aTNV.SetFuzzyValue(theFuzzyValue);
aTNV.SetVectorOfTNV(aVTNV); aTNV.SetVectorOfTNV(aVTNV);
} }
// Shake the tree // Shake the tree
aTreeFiller.Fill(); aBBTree->Build();
// //
// Perform intersection // Perform intersection
BOPAlgo_TNVCnt::Perform(theRunParallel, aVTNV); BOPAlgo_TNVCnt::Perform(theRunParallel, aVTNV);
@@ -1232,9 +1231,9 @@ public:
}; };
//! Sets the Bounding Box tree //! Sets the Bounding Box tree
void SetBBTree(const BOPTools_BoxBndTree& theBBTree) void SetBBTree(const Handle(BOPTools_BoxTree)& theBBTree)
{ {
myBBTree = (BOPTools_BoxBndTree*)&theBBTree; myBBTree = theBBTree;
}; };
//! Sets the ShapeBox structure //! Sets the ShapeBox structure
@@ -1284,7 +1283,7 @@ private:
TopTools_ListOfShape myOwnIF; //! Own INTERNAL faces of the solid TopTools_ListOfShape myOwnIF; //! Own INTERNAL faces of the solid
TopTools_ListOfShape myInFaces; //! Faces classified as IN TopTools_ListOfShape myInFaces; //! Faces classified as IN
BOPTools_BoxBndTree* myBBTree; //! UB tree of bounding boxes Handle(BOPTools_BoxTree) myBBTree; //! UB tree of bounding boxes
BOPAlgo_VectorOfShapeBox* myVShapeBox; //! ShapeBoxMap BOPAlgo_VectorOfShapeBox* myVShapeBox; //! ShapeBoxMap
TopoDS_Iterator myItF; //! Iterators TopoDS_Iterator myItF; //! Iterators
@@ -1304,10 +1303,11 @@ void BOPAlgo_FillIn3DParts::Perform()
myInFaces.Clear(); myInFaces.Clear();
// 1. Select boxes of faces that are not out of aBoxS // 1. Select boxes of faces that are not out of aBoxS
BOPTools_BoxBndTreeSelector aSelector; BOPTools_BoxTreeSelector aSelector;
aSelector.SetBox(myBoxS); aSelector.SetBox(Bnd_Tools::Bnd2BVH(myBoxS));
aSelector.SetBVHSet (myBBTree.get());
// //
if (!myBBTree->Select(aSelector)) if (!aSelector.Select())
return; return;
const TColStd_ListOfInteger& aLIFP = aSelector.Indices(); const TColStd_ListOfInteger& aLIFP = aSelector.Indices();
@@ -1567,17 +1567,16 @@ void BOPAlgo_Tools::ClassifyFaces(const TopTools_ListOfShape& theFaces,
// Prepare UB tree of bounding boxes of the faces to classify // Prepare UB tree of bounding boxes of the faces to classify
// taking the bounding boxes from the just prepared vector // taking the bounding boxes from the just prepared vector
BOPTools_BoxBndTree aBBTree; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
Standard_Integer aNbF = aVSB.Length(); Standard_Integer aNbF = aVSB.Length();
for (Standard_Integer i = 0; i < aNbF; ++i) for (Standard_Integer i = 0; i < aNbF; ++i)
{ {
aTreeFiller.Add(i, aVSB(i).Box()); aBBTree->Add(i, Bnd_Tools::Bnd2BVH(aVSB(i).Box()));
} }
// Shake tree filler // Shake tree filler
aTreeFiller.Fill(); aBBTree->Build();
// Prepare vector of solids to classify // Prepare vector of solids to classify
BOPAlgo_VectorOfFillIn3DParts aVFIP; BOPAlgo_VectorOfFillIn3DParts aVFIP;

View File

@@ -18,62 +18,20 @@
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx> #include <Bnd_OBB.hxx>
#include <Bnd_Tools.hxx>
#include <BOPDS_DS.hxx> #include <BOPDS_DS.hxx>
#include <BOPDS_IndexRange.hxx> #include <BOPDS_IndexRange.hxx>
#include <BOPDS_Iterator.hxx> #include <BOPDS_Iterator.hxx>
#include <BOPDS_Pair.hxx> #include <BOPDS_Pair.hxx>
#include <BOPDS_MapOfPair.hxx> #include <BOPDS_MapOfPair.hxx>
#include <BOPDS_Tools.hxx> #include <BOPDS_Tools.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <BOPTools_Parallel.hxx> #include <BOPTools_Parallel.hxx>
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_Vector.hxx> #include <NCollection_Vector.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <algorithm> #include <algorithm>
/////////////////////////////////////////////////////////////////////////
//=======================================================================
//class : BOPDS_TreeSelector
//purpose :
//=======================================================================
class BOPDS_TSR : public BOPTools_BoxBndTreeSelector{
public:
BOPDS_TSR() :
BOPTools_BoxBndTreeSelector(),
myHasBRep(Standard_False),
myTree(NULL) {
}
//
virtual ~BOPDS_TSR() {
}
//
void SetHasBRep(const Standard_Boolean bFlag) {
myHasBRep=bFlag;
}
//
void SetTree(BOPTools_BoxBndTree& aTree) {
myTree=&aTree;
}
//
void Perform() {
if (myHasBRep) {
myTree->Select(*this);
}
}
//
protected:
Standard_Boolean myHasBRep;
BOPTools_BoxBndTree *myTree;
};
//
//=======================================================================
typedef NCollection_Vector <BOPDS_TSR> BOPDS_VectorOfTSR;
typedef BOPTools_Functor <BOPDS_TSR,BOPDS_VectorOfTSR> BOPDS_TSRFunctor;
typedef BOPTools_Cnt <BOPDS_TSRFunctor, BOPDS_VectorOfTSR> BOPDS_TSRCnt;
/////////////////////////////////////////////////////////////////////////
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
@@ -268,101 +226,80 @@ void BOPDS_Iterator::Intersect(const Handle(IntTools_Context)& theCtx,
const Standard_Boolean theCheckOBB, const Standard_Boolean theCheckOBB,
const Standard_Real theFuzzyValue) const Standard_Real theFuzzyValue)
{ {
Standard_Integer i, j, iX, i1, i2, iR, aNb, aNbR; const Standard_Integer aNb = myDS->NbSourceShapes();
Standard_Integer iTi, iTj;
TopAbs_ShapeEnum aTi, aTj; // Prepare BVH
// Handle(BOPTools_BoxTree) aBoxTree = new BOPTools_BoxTree();
BOPTools_BoxBndTree aBBTree; aBoxTree->SetSize (aNb);
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree); for (Standard_Integer i = 0; i < aNb; ++i)
// {
aNb = myDS->NbSourceShapes(); const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
BOPDS_VectorOfTSR aVTSR(aNb); if (!aSI.HasBRep())
//
for (i=0; i<aNb; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
Standard_Boolean bHasBrep = aSI.IsInterfering() && !(aSI.ShapeType() == TopAbs_SOLID);
//
BOPDS_TSR& aTSR=aVTSR.Appended();
//
aTSR.SetHasBRep(bHasBrep);
if (!bHasBrep) {
continue; continue;
} const Bnd_Box& aBox = aSI.Box();
// aBoxTree->Add (i, Bnd_Tools::Bnd2BVH (aBox));
const Bnd_Box& aBoxEx=aSI.Box();
aTSR.SetTree(aBBTree);
aTSR.SetBox(aBoxEx);
//
aTreeFiller.Add(i, aBoxEx);
} }
//
aTreeFiller.Fill(); // Build BVH
// aBoxTree->Build();
//===========================================
BOPDS_TSRCnt::Perform(myRunParallel, aVTSR); // Select pairs of shapes with interfering bounding boxes
//=========================================== BOPTools_BoxPairSelector aPairSelector;
// aPairSelector.SetBVHSets (aBoxTree.get(), aBoxTree.get());
BOPDS_MapOfPair aMPFence; aPairSelector.SetSame (Standard_True);
// aPairSelector.Select();
aNbR = myDS->NbRanges() - 1; aPairSelector.Sort();
for (iR = 0; iR < aNbR; ++iR) {
const BOPDS_IndexRange& aR = myDS->Range(iR); // Treat the selected pairs
i1 = aR.First(); const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aPairSelector.Pairs();
i2 = aR.Last(); const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
for (i = i1; i <= i2; ++i) {
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); Standard_Integer iPair = 0;
//
if (!aSI.IsInterfering() || (aSI.ShapeType() == TopAbs_SOLID)) { const Standard_Integer aNbR = myDS->NbRanges();
for (Standard_Integer iR = 0; iR < aNbR; ++iR)
{
const BOPDS_IndexRange& aRange = myDS->Range(iR);
for (; iPair < aNbPairs; ++iPair)
{
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
if (!aRange.Contains (aPair.ID1))
// Go to the next range
break;
if (aRange.Contains (aPair.ID2))
// Go to the next pair
continue; continue;
}
// const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo (aPair.ID1);
BOPDS_TSR& aTSRi = aVTSR(i); const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo (aPair.ID2);
const TColStd_ListOfInteger& aLI = aTSRi.Indices();
Standard_Integer aNbSD = aLI.Extent(); const TopAbs_ShapeEnum aType1 = aSI1.ShapeType();
if (!aNbSD) { const TopAbs_ShapeEnum aType2 = aSI2.ShapeType();
Standard_Integer iType1 = BOPDS_Tools::TypeToInteger (aType1);
Standard_Integer iType2 = BOPDS_Tools::TypeToInteger (aType2);
// avoid interfering of the same shapes and shape with its sub-shapes
if (((iType1 < iType2) && aSI1.HasSubShape (aPair.ID2)) ||
((iType1 > iType2) && aSI2.HasSubShape (aPair.ID1)))
continue; continue;
}
// if (theCheckOBB)
aTi = aSI.ShapeType(); {
iTi = BOPDS_Tools::TypeToInteger(aTi); // Check intersection of Oriented bounding boxes of the shapes
// Bnd_OBB& anOBB1 = theCtx->OBB (aSI1.Shape(), theFuzzyValue);
TColStd_ListIteratorOfListOfInteger aIt(aLI); Bnd_OBB& anOBB2 = theCtx->OBB (aSI2.Shape(), theFuzzyValue);
for (; aIt.More(); aIt.Next()) {
j = aIt.Value(); // DS index if (anOBB1.IsOut (anOBB2))
if (j >= i1 && j <= i2) {
continue;// same range
}
//
const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
aTj = aSJ.ShapeType();
iTj = BOPDS_Tools::TypeToInteger(aTj);
//
// avoid interfering of the same shapes and shape with its sub-shapes
if (((iTi < iTj) && aSI.HasSubShape(j)) ||
((iTi > iTj) && aSJ.HasSubShape(i))) {
continue; continue;
} }
//
BOPDS_Pair aPair(i, j);
if (aMPFence.Add(aPair)) {
if (theCheckOBB)
{
// Check intersection of Oriented bounding boxes of the shapes
Bnd_OBB& anOBBi = theCtx->OBB(aSI.Shape(), theFuzzyValue);
Bnd_OBB& anOBBj = theCtx->OBB(aSJ.Shape(), theFuzzyValue);
if (anOBBi.IsOut(anOBBj)) Standard_Integer iX = BOPDS_Tools::TypeToInteger (aType1, aType2);
continue; myLists(iX).Append (BOPDS_Pair (Min (aPair.ID1, aPair.ID2),
} Max (aPair.ID1, aPair.ID2)));
}
iX = BOPDS_Tools::TypeToInteger(aTi, aTj); }
myLists(iX).Append(aPair);
}// if (aMPFence.Add(aPair)) {
}// for (; aIt.More(); aIt.Next()) {
}//for (i=i1; i<=i2; ++i) {
}//for (iR=1; iR<aNbR; ++iR) {
//
aMPFence.Clear();
aVTSR.Clear();
//-----------------------------------------------------scope_1 t
} }

View File

@@ -14,6 +14,7 @@
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx> #include <Bnd_OBB.hxx>
#include <Bnd_Tools.hxx>
#include <BOPDS_DS.hxx> #include <BOPDS_DS.hxx>
#include <BOPDS_IndexRange.hxx> #include <BOPDS_IndexRange.hxx>
#include <BOPDS_IteratorSI.hxx> #include <BOPDS_IteratorSI.hxx>
@@ -21,11 +22,10 @@
#include <BOPDS_Pair.hxx> #include <BOPDS_Pair.hxx>
#include <BOPDS_ShapeInfo.hxx> #include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_Tools.hxx> #include <BOPDS_Tools.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <TopAbs_ShapeEnum.hxx> #include <TopAbs_ShapeEnum.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx> #include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_DataMapOfIntegerListOfInteger.hxx> #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
@@ -87,11 +87,9 @@ void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
Standard_Integer iTi, iTj; Standard_Integer iTi, iTj;
TopAbs_ShapeEnum aTi, aTj; TopAbs_ShapeEnum aTi, aTj;
// //
BOPTools_BoxBndTreeSelector aSelector; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
BOPTools_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
//
aNbS = myDS->NbSourceShapes(); aNbS = myDS->NbSourceShapes();
aBBTree->SetSize (aNbS);
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);
if (!aSI.IsInterfering()) { if (!aSI.IsInterfering()) {
@@ -99,10 +97,10 @@ void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
} }
// //
const Bnd_Box& aBoxEx = aSI.Box(); const Bnd_Box& aBoxEx = aSI.Box();
aTreeFiller.Add(i, aBoxEx); aBBTree->Add(i, Bnd_Tools::Bnd2BVH(aBoxEx));
} }
// //
aTreeFiller.Fill(); aBBTree->Build();
// //
BOPDS_MapOfPair aMPFence; BOPDS_MapOfPair aMPFence;
// //
@@ -114,10 +112,11 @@ void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
// //
const Bnd_Box& aBoxEx = aSI.Box(); const Bnd_Box& aBoxEx = aSI.Box();
// //
aSelector.Clear(); BOPTools_BoxTreeSelector aSelector;
aSelector.SetBox(aBoxEx); aSelector.SetBox (Bnd_Tools::Bnd2BVH (aBoxEx));
aSelector.SetBVHSet (aBBTree.get());
// //
Standard_Integer aNbSD = aBBTree.Select(aSelector); Standard_Integer aNbSD = aSelector.Select();
if (!aNbSD) { if (!aNbSD) {
continue; continue;
} }

View File

@@ -126,18 +126,7 @@ inline TColStd_ListOfInteger& BOPDS_ShapeInfo::ChangeSubShapes()
inline Standard_Boolean BOPDS_ShapeInfo::HasSubShape inline Standard_Boolean BOPDS_ShapeInfo::HasSubShape
(const Standard_Integer theI)const (const Standard_Integer theI)const
{ {
Standard_Boolean bRet; return mySubShapes.Contains (theI);
TColStd_ListIteratorOfListOfInteger aIt;
//
bRet=Standard_False;
aIt.Initialize(mySubShapes);
for (; aIt.More(); aIt.Next()) {
bRet=(theI==aIt.Value());
if (bRet) {
return bRet;
}
}
return bRet;
} }
//======================================================================= //=======================================================================
//function : HasReference //function : HasReference

View File

@@ -16,14 +16,13 @@
#include <BOPDS_SubIterator.hxx> #include <BOPDS_SubIterator.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <Bnd_Tools.hxx>
#include <BOPDS_DS.hxx> #include <BOPDS_DS.hxx>
#include <BOPDS_Pair.hxx> #include <BOPDS_Pair.hxx>
#include <BOPDS_MapOfPair.hxx> #include <BOPDS_MapOfPair.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
@@ -118,9 +117,9 @@ void BOPDS_SubIterator::Initialize()
void BOPDS_SubIterator::Intersect() void BOPDS_SubIterator::Intersect()
{ {
Standard_Integer i, j, iTi, iTj; Standard_Integer i, j, iTi, iTj;
BOPTools_BoxBndTree aBBTree; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree); aBBTree->SetSize (mySubSet1->Extent());
//
TColStd_ListIteratorOfListOfInteger aIt(*mySubSet1); TColStd_ListIteratorOfListOfInteger aIt(*mySubSet1);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
i = aIt.Value(); i = aIt.Value();
@@ -128,10 +127,10 @@ void BOPDS_SubIterator::Initialize()
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
const Bnd_Box& aBoxEx = aSI.Box(); const Bnd_Box& aBoxEx = aSI.Box();
// //
aTreeFiller.Add(i, aBoxEx); aBBTree->Add(i, Bnd_Tools::Bnd2BVH (aBoxEx));
} }
// //
aTreeFiller.Fill(); aBBTree->Build();
// //
BOPDS_MapOfPair aMPKFence; BOPDS_MapOfPair aMPKFence;
// //
@@ -142,9 +141,10 @@ void BOPDS_SubIterator::Initialize()
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
const Bnd_Box& aBoxEx = aSI.Box(); const Bnd_Box& aBoxEx = aSI.Box();
// //
BOPTools_BoxBndTreeSelector aSelector; BOPTools_BoxTreeSelector aSelector;
aSelector.SetBox(aBoxEx); aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxEx));
Standard_Integer aNbSD = aBBTree.Select(aSelector); aSelector.SetBVHSet (aBBTree.get());
Standard_Integer aNbSD = aSelector.Select();
if (!aNbSD) { if (!aNbSD) {
continue; continue;
} }

View File

@@ -1,26 +0,0 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// 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.
#ifndef BOPTools_BoxBndTree_HeaderFile
#define BOPTools_BoxBndTree_HeaderFile
#include <Bnd_Box.hxx>
#include <BOPTools_BoxSelector.hxx>
#include <NCollection_UBTree.hxx>
#include <Standard_Integer.hxx>
typedef NCollection_UBTree<Standard_Integer, Bnd_Box> BOPTools_BoxBndTree;
typedef BOPTools_BoxSelector<Bnd_Box> BOPTools_BoxBndTreeSelector;
#endif

View File

@@ -15,32 +15,27 @@
#ifndef BOPTools_BoxSelector_HeaderFile #ifndef BOPTools_BoxSelector_HeaderFile
#define BOPTools_BoxSelector_HeaderFile #define BOPTools_BoxSelector_HeaderFile
#include <TColStd_ListOfInteger.hxx> #include <BVH_Traverse.hxx>
#include <NCollection_UBTree.hxx> #include <BVH_BoxSet.hxx>
#include <Standard_Integer.hxx>
//! Template Selector for the unbalanced binary tree #include <Standard_Integer.hxx>
//! of overlapped bounding boxes. #include <TColStd_ListOfInteger.hxx>
template <class BoxType> class BOPTools_BoxSelector :
public NCollection_UBTree<Standard_Integer, BoxType>::Selector //! Template Selector for elements selection from BVH tree.
template <int Dimension>
class BOPTools_BoxSelector :
public BVH_Traverse <Standard_Real, Dimension, BVH_BoxSet <Standard_Real, Dimension, Standard_Integer>, Standard_Boolean>
{ {
public: public:
typedef typename BVH::VectorType<Standard_Real, Dimension>::Type BVH_VecNd;
public: //! @name Constructor
//! Empty constructor //! Empty constructor
BOPTools_BoxSelector() {}; BOPTools_BoxSelector() {};
//! Checks if the box should be rejected public: //! @name public interfaces
virtual Standard_Boolean Reject(const BoxType& theOther) const
{
return myBox.IsOut(theOther);
}
//! Accepts the index
virtual Standard_Boolean Accept(const Standard_Integer& theIndex)
{
myIndices.Append(theIndex);
return Standard_True;
}
//! Clears the indices //! Clears the indices
void Clear() void Clear()
@@ -49,7 +44,7 @@ public:
} }
//! Sets the box //! Sets the box
void SetBox(const BoxType& theBox) void SetBox (const BVH_Box <Standard_Real, Dimension>& theBox)
{ {
myBox = theBox; myBox = theBox;
} }
@@ -60,11 +55,46 @@ public:
return myIndices; return myIndices;
} }
private: public: //! @name Rejection/Acceptance rules
BoxType myBox; //! Checks if the box should be rejected
TColStd_ListOfInteger myIndices; virtual Standard_Boolean RejectNode (const BVH_VecNd& theCMin,
const BVH_VecNd& theCMax,
Standard_Boolean& theIsInside) const Standard_OVERRIDE
{
Standard_Boolean hasOverlap;
theIsInside = myBox.Contains (theCMin, theCMax, hasOverlap);
return !hasOverlap;
}
//! Rejects the element by the index
Standard_Boolean RejectElement (const Standard_Integer theIndex)
{
return myBox.IsOut (this->myBVHSet->Box (theIndex));
}
//! Accepts the index
virtual Standard_Boolean AcceptMetric (const Standard_Boolean& theIsInside) const Standard_OVERRIDE
{
return theIsInside;
}
//! Accepts the index
virtual Standard_Boolean Accept (const Standard_Integer theIndex,
const Standard_Boolean& theIsInside) Standard_OVERRIDE
{
if (theIsInside || !RejectElement (theIndex))
{
myIndices.Append (this->myBVHSet->Element (theIndex));
return Standard_True;
}
return Standard_False;
}
protected: //! @name Fields
BVH_Box <Standard_Real, Dimension> myBox; //!< Selection box
TColStd_ListOfInteger myIndices; //!< Selected indices
}; };
#endif #endif

View File

@@ -0,0 +1,47 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// 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.
#ifndef BOPTools_BoxTree_HeaderFile
#define BOPTools_BoxTree_HeaderFile
#include <BVH_BoxSet.hxx>
#include <BOPTools_BoxSelector.hxx>
#include <BOPTools_PairSelector.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <BVH_LinearBuilder.hxx>
//! Redefines BoxSet to use the Linear builder by default
template <class NumType, int Dimension, class DataType>
class BOPTools_BoxSet : public BVH_BoxSet <NumType, Dimension, DataType>
{
public: //! @name Constructors
//! Empty constructor for use the default BVH_Builder
BOPTools_BoxSet (const opencascade::handle <BVH_Builder <NumType, Dimension> >& theBuilder = NULL)
: BVH_BoxSet <NumType, Dimension, DataType> (theBuilder.IsNull() ? new BVH_LinearBuilder<NumType, Dimension>() : theBuilder)
{}
};
//! 2D definitions
typedef BOPTools_BoxSet <Standard_Real, 2, Standard_Integer> BOPTools_Box2dTree;
typedef BOPTools_BoxSelector<2> BOPTools_Box2dTreeSelector;
typedef BOPTools_PairSelector<2> BOPTools_Box2dPairSelector;
//! 3D definitions
typedef BOPTools_BoxSet <Standard_Real, 3, Standard_Integer> BOPTools_BoxTree;
typedef BOPTools_BoxSelector<3> BOPTools_BoxTreeSelector;
typedef BOPTools_PairSelector<3> BOPTools_BoxPairSelector;
#endif

View File

@@ -0,0 +1,125 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// 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.
#ifndef BOPTools_PairSelector_HeaderFile
#define BOPTools_PairSelector_HeaderFile
#include <BVH_Traverse.hxx>
#include <BVH_BoxSet.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <algorithm>
//! Template Selector for elements selection from BVH tree.
template <int Dimension>
class BOPTools_PairSelector :
public BVH_PairTraverse <Standard_Real, Dimension, BVH_BoxSet <Standard_Real, Dimension, Standard_Integer>>
{
public: //! @name public types
//! Auxiliary structure to keep the pair of indices
struct PairIDs
{
PairIDs (const Standard_Integer theId1 = -1,
const Standard_Integer theId2 = -1)
: ID1 (theId1), ID2 (theId2)
{}
Standard_Boolean operator< (const PairIDs& theOther) const
{
return ID1 < theOther.ID1 ||
(ID1 == theOther.ID1 && ID2 < theOther.ID2);
}
Standard_Integer ID1;
Standard_Integer ID2;
};
typedef typename BVH::VectorType<Standard_Real, Dimension>::Type BVH_VecNd;
public: //! @name Constructor
//! Empty constructor
BOPTools_PairSelector()
: mySameBVHs (Standard_False)
{}
public: //! @name public interfaces
//! Clears the indices
void Clear()
{
myPairs.Clear();
}
//! Sorts the indices
void Sort()
{
std::sort (myPairs.begin(), myPairs.end());
}
//! Tells to selector that BVH trees are the same
void SetSame (const Standard_Boolean theIsSame)
{
mySameBVHs = theIsSame;
}
//! Returns the list of accepted indices
const std::vector<PairIDs>& Pairs() const
{
return myPairs;
}
public: //! @name Rejection/Acceptance rules
//! Checks if the box should be rejected
virtual Standard_Boolean RejectNode (const BVH_VecNd& theCMin1,
const BVH_VecNd& theCMax1,
const BVH_VecNd& theCMin2,
const BVH_VecNd& theCMax2,
Standard_Real&) const Standard_OVERRIDE
{
return BVH_Box<Standard_Real, 3> (theCMin1, theCMax1).IsOut (theCMin2, theCMax2);
}
//! Rejects the element by the index
Standard_Boolean RejectElement (const Standard_Integer theID1,
const Standard_Integer theID2)
{
return (mySameBVHs && theID1 >= theID2) ||
this->myBVHSet1->Box (theID1).IsOut(
this->myBVHSet2->Box (theID2));
}
//! Accepts the index
virtual Standard_Boolean Accept (const Standard_Integer theID1,
const Standard_Integer theID2) Standard_OVERRIDE
{
if (!RejectElement (theID1, theID2))
{
myPairs.push_back (PairIDs (this->myBVHSet1->Element (theID1),
this->myBVHSet2->Element (theID2)));
return Standard_True;
}
return Standard_False;
}
protected: //! @name Fields
std::vector<PairIDs> myPairs; //!< Selected pairs of indices
Standard_Boolean mySameBVHs; //!< Selection is performed from the same BVH trees
};
#endif

View File

@@ -8,13 +8,14 @@ BOPTools_AlgoTools3D.hxx
BOPTools_AlgoTools_1.cxx BOPTools_AlgoTools_1.cxx
BOPTools_AlgoTools_2.cxx BOPTools_AlgoTools_2.cxx
BOPTools_BoxSelector.hxx BOPTools_BoxSelector.hxx
BOPTools_BoxBndTree.hxx BOPTools_BoxTree.hxx
BOPTools_ConnexityBlock.hxx BOPTools_ConnexityBlock.hxx
BOPTools_CoupleOfShape.hxx BOPTools_CoupleOfShape.hxx
BOPTools_IndexedDataMapOfSetShape.hxx BOPTools_IndexedDataMapOfSetShape.hxx
BOPTools_ListOfConnexityBlock.hxx BOPTools_ListOfConnexityBlock.hxx
BOPTools_ListOfCoupleOfShape.hxx BOPTools_ListOfCoupleOfShape.hxx
BOPTools_MapOfSet.hxx BOPTools_MapOfSet.hxx
BOPTools_PairSelector.hxx
BOPTools_Parallel.hxx BOPTools_Parallel.hxx
BOPTools_Set.cxx BOPTools_Set.cxx
BOPTools_Set.hxx BOPTools_Set.hxx

View File

@@ -16,6 +16,7 @@
// Modified by skv - Fri Dec 26 12:20:14 2003 OCC4455 // Modified by skv - Fri Dec 26 12:20:14 2003 OCC4455
#include <Bnd_Tools.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
@@ -46,8 +47,7 @@
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
// //
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BOPTools_BoxBndTree.hxx> #include <BOPTools_BoxTree.hxx>
#include <NCollection_UBTreeFiller.hxx>
// //
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
@@ -114,8 +114,8 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
//--------------------------------------------------------------- //---------------------------------------------------------------
// Prepare tools for sorting the bounding boxes // Prepare tools for sorting the bounding boxes
BOPTools_BoxBndTree aBBTree; Handle(BOPTools_BoxTree) aBBTree = new BOPTools_BoxTree();
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree); aBBTree->SetSize (SetOfFaces.Extent());
// //
NCollection_IndexedDataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> aMFaces; NCollection_IndexedDataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> aMFaces;
// Construct bounding boxes for faces and add them to the tree // Construct bounding boxes for faces and add them to the tree
@@ -129,11 +129,11 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
// //
Standard_Integer i = aMFaces.Add(aF, aBoxF); Standard_Integer i = aMFaces.Add(aF, aBoxF);
// //
aTreeFiller.Add(i, aBoxF); aBBTree->Add(i, Bnd_Tools::Bnd2BVH(aBoxF));
} }
// //
// shake tree filler // shake tree filler
aTreeFiller.Fill(); aBBTree->Build();
// //
// get faces with interfering bounding boxes // get faces with interfering bounding boxes
aItL.Initialize(SetOfFaces); aItL.Initialize(SetOfFaces);
@@ -141,9 +141,10 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
const TopoDS_Face& aF1 = TopoDS::Face(aItL.Value()); const TopoDS_Face& aF1 = TopoDS::Face(aItL.Value());
const Bnd_Box& aBoxF1 = aMFaces.FindFromKey(aF1); const Bnd_Box& aBoxF1 = aMFaces.FindFromKey(aF1);
// //
BOPTools_BoxBndTreeSelector aSelector; BOPTools_BoxTreeSelector aSelector;
aSelector.SetBox(aBoxF1); aSelector.SetBox (Bnd_Tools::Bnd2BVH(aBoxF1));
aBBTree.Select(aSelector); aSelector.SetBVHSet (aBBTree.get());
aSelector.Select ();
// //
const TColStd_ListOfInteger& aLI = aSelector.Indices(); const TColStd_ListOfInteger& aLI = aSelector.Indices();
TColStd_ListIteratorOfListOfInteger aItLI(aLI); TColStd_ListIteratorOfListOfInteger aItLI(aLI);