mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +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:
parent
0616aa9ecf
commit
9324aa2d0d
@ -1751,3 +1751,13 @@ Proxy classes *SelectBasics_SensitiveEntity* and *SelectBasics_EntityOwner* have
|
|||||||
*env.bat* produced by Visual Studio project generator *genproj.bat* has been modified so that *%CSF_DEFINES%* variable is reset to initial state.
|
*env.bat* produced by Visual Studio project generator *genproj.bat* has been modified so that *%CSF_DEFINES%* variable is reset to initial state.
|
||||||
Custom building environment relying on old behavior and setting extra macros within *%CSF_DEFINES%* before env.bat should be updated
|
Custom building environment relying on old behavior and setting extra macros within *%CSF_DEFINES%* before env.bat should be updated
|
||||||
to either modify custom.bat or setup new variable *%CSF_DEFINES_EXTRA%* instead.
|
to either modify custom.bat or setup new variable *%CSF_DEFINES_EXTRA%* instead.
|
||||||
|
|
||||||
|
@subsection upgrade_740_BVH_in_BOP Switching Boolean Operations algorithm to use BVH tree instead of UB tree
|
||||||
|
|
||||||
|
Since OCCT 7.4.0 Boolean Operations algorithm uses BVH tree instead of UBTree to find the pairs of entities with interfering bounding boxes.
|
||||||
|
The following API changes have been made:
|
||||||
|
* BOPTools_BoxBndTree and BOPTools_BoxBndTreeSelector have been removed. Use the BOPTools_BoxTree and BOPTools_BoxTreeSelector instead.
|
||||||
|
* BOPTools_BoxSelector::SetBox() method now accepts the BVH_Box instead of Bnd_Box.
|
||||||
|
* Methods BOPTools_BoxSelector::Reject and BOPTools_BoxSelector::Accept have been removed as unused.
|
||||||
|
* The RunParallel flag has been removed from the list of parameters of BOPAlgo_Tools::IntersectVertices method. Earlier, it performed selection from the UB tree in parallel mode. Now all interfering pairs are found in one pass, using pair traverse of the same BVH tree.
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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,7 +39,6 @@
|
|||||||
#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_MapOfInteger.hxx>
|
||||||
#include <TopAbs.hxx>
|
#include <TopAbs.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
@ -448,28 +448,28 @@ void BOPAlgo_BuilderFace::PerformAreas()
|
|||||||
|
|
||||||
// Classify holes relatively faces
|
// Classify holes relatively faces
|
||||||
|
|
||||||
// Prepare tree filler with the boxes of the hole faces
|
// Prepare tree with the boxes of the hole faces
|
||||||
NCollection_UBTree<Standard_Integer, Bnd_Box2d> aBBTree;
|
BOPTools_Box2dTree aBoxTree;
|
||||||
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);
|
||||||
|
|
||||||
TopTools_ListIteratorOfListOfShape aItLS(aNewFaces);
|
TopTools_ListIteratorOfListOfShape aItLS(aNewFaces);
|
||||||
for (; aItLS.More(); aItLS.Next())
|
for (; aItLS.More(); aItLS.Next())
|
||||||
@ -481,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);
|
||||||
@ -590,9 +590,8 @@ void BOPAlgo_BuilderFace::PerformInternalShapes()
|
|||||||
// No edges left for classification
|
// No edges left for classification
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Prepare tree filler with the boxes of the edges to classify
|
// Prepare tree with the boxes of the edges to classify
|
||||||
NCollection_UBTree<Standard_Integer, Bnd_Box2d> aBBTree;
|
BOPTools_Box2dTree aBoxTree;
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
|
|
||||||
|
|
||||||
// Map of edges to classify
|
// Map of edges to classify
|
||||||
TopTools_IndexedMapOfShape anEdgesMap;
|
TopTools_IndexedMapOfShape anEdgesMap;
|
||||||
@ -611,13 +610,13 @@ void BOPAlgo_BuilderFace::PerformInternalShapes()
|
|||||||
BRepTools::AddUVBounds(myFace, aE, aBoxE);
|
BRepTools::AddUVBounds(myFace, aE, aBoxE);
|
||||||
// Make sure the index of edge in the map and
|
// Make sure the index of edge in the map and
|
||||||
// of the box in the tree is the same
|
// of the box in the tree is the same
|
||||||
aTreeFiller.Add(anEdgesMap.Add(aE), aBoxE);
|
aBoxTree.Add(anEdgesMap.Add(aE), Bnd_Tools::Bnd2BVH (aBoxE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shake the tree
|
// Build BVH
|
||||||
aTreeFiller.Fill();
|
aBoxTree.Build();
|
||||||
|
|
||||||
// Fence map
|
// Fence map
|
||||||
TColStd_MapOfInteger aMEDone;
|
TColStd_MapOfInteger aMEDone;
|
||||||
@ -633,9 +632,10 @@ void BOPAlgo_BuilderFace::PerformInternalShapes()
|
|||||||
BRepTools::AddUVBounds(aF, aBoxF);
|
BRepTools::AddUVBounds(aF, aBoxF);
|
||||||
|
|
||||||
// Select edges for the classification
|
// Select edges for the classification
|
||||||
BOPTools_BoxSelector<Bnd_Box2d> aSelector;
|
BOPTools_Box2dTreeSelector aSelector;
|
||||||
aSelector.SetBox(aBoxF);
|
aSelector.SetBVHSet (&aBoxTree);
|
||||||
if (!aBBTree.Select(aSelector))
|
aSelector.SetBox(Bnd_Tools::Bnd2BVH (aBoxF));
|
||||||
|
if (!aSelector.Select())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Collect edges inside the face
|
// Collect edges inside the face
|
||||||
|
@ -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>
|
||||||
@ -443,24 +443,23 @@ void BOPAlgo_BuilderSolid::PerformAreas()
|
|||||||
|
|
||||||
// Classify holes relatively solids
|
// Classify holes relatively solids
|
||||||
|
|
||||||
// Prepare tree filler with the boxes of the hole shells
|
// Prepare tree with the boxes of the hole shells
|
||||||
BOPTools_BoxBndTree aBBTree;
|
BOPTools_BoxTree aBBTree;
|
||||||
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
|
// Build BVH
|
||||||
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);
|
||||||
|
aSelector.Select();
|
||||||
|
|
||||||
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
||||||
TColStd_ListIteratorOfListOfInteger aItLI(aLI);
|
TColStd_ListIteratorOfListOfInteger aItLI(aLI);
|
||||||
|
@ -361,7 +361,7 @@ void BOPAlgo_PaveFiller::RepeatIntersection()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Update iterator of pairs of shapes with interfering boxes
|
// Update iterator of pairs of shapes with interfering boxes
|
||||||
myIterator->PrepareExt(anExtraInterfMap);
|
myIterator->IntersectExt(anExtraInterfMap);
|
||||||
|
|
||||||
// Perform intersections with vertices
|
// Perform intersections with vertices
|
||||||
PerformVV();
|
PerformVV();
|
||||||
|
@ -595,7 +595,7 @@ void BOPAlgo_PaveFiller::TreatNewVertices
|
|||||||
//
|
//
|
||||||
// Perform intersection
|
// Perform intersection
|
||||||
TopTools_ListOfListOfShape aChains;
|
TopTools_ListOfListOfShape aChains;
|
||||||
BOPAlgo_Tools::IntersectVertices(aVerts, myRunParallel, myFuzzyValue, aChains);
|
BOPAlgo_Tools::IntersectVertices(aVerts, myFuzzyValue, aChains);
|
||||||
//
|
//
|
||||||
// Treat the results - make new vertices for each chain
|
// Treat the results - make new vertices for each chain
|
||||||
TopTools_ListOfListOfShape::Iterator aItC(aChains);
|
TopTools_ListOfListOfShape::Iterator aItC(aChains);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <Bnd_Tools.hxx>
|
||||||
#include <BOPAlgo_PaveFiller.hxx>
|
#include <BOPAlgo_PaveFiller.hxx>
|
||||||
#include <BOPAlgo_Alerts.hxx>
|
#include <BOPAlgo_Alerts.hxx>
|
||||||
#include <BOPAlgo_Tools.hxx>
|
#include <BOPAlgo_Tools.hxx>
|
||||||
@ -31,7 +32,6 @@
|
|||||||
#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_BoxSelector.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>
|
||||||
@ -729,8 +729,7 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Fill the tree with bounding boxes of the pave blocks
|
// Fill the tree with bounding boxes of the pave blocks
|
||||||
NCollection_UBTree<Standard_Integer, Bnd_Box> aBBTree;
|
BOPTools_BoxTree aBBTree;
|
||||||
NCollection_UBTreeFiller<Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
|
||||||
|
|
||||||
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
|
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
|
||||||
BOPDS_IndexedMapOfPaveBlock aPBMap(1, anAlloc);
|
BOPDS_IndexedMapOfPaveBlock aPBMap(1, anAlloc);
|
||||||
@ -751,11 +750,11 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
Standard_Boolean isSplit;
|
Standard_Boolean isSplit;
|
||||||
aPB->ShrunkData(f, l, aPBBox, isSplit);
|
aPB->ShrunkData(f, l, aPBBox, isSplit);
|
||||||
|
|
||||||
aTreeFiller.Add(aPBMap.Add(aPB), aPBBox);
|
aBBTree.Add(aPBMap.Add(aPB), Bnd_Tools::Bnd2BVH(aPBBox));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shake the tree
|
// Shake the tree
|
||||||
aTreeFiller.Fill();
|
aBBTree.Build();
|
||||||
|
|
||||||
// Find pairs of Face/PaveBlock containing the same vertices
|
// Find pairs of Face/PaveBlock containing the same vertices
|
||||||
// and prepare those pairs for intersection.
|
// and prepare those pairs for intersection.
|
||||||
@ -774,10 +773,10 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Bnd_Box& aBoxF = aSI.Box();
|
const Bnd_Box& aBoxF = aSI.Box();
|
||||||
BOPTools_BoxSelector<Bnd_Box> aSelector;
|
BOPTools_BoxTreeSelector aSelector;
|
||||||
aSelector.SetBox(aBoxF);
|
aSelector.SetBox(Bnd_Tools::Bnd2BVH(aBoxF));
|
||||||
|
aSelector.SetBVHSet (&aBBTree);
|
||||||
if (!aBBTree.Select(aSelector))
|
if (!aSelector.Select())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const TopoDS_Face& aF = TopoDS::Face(aSI.Shape());
|
const TopoDS_Face& aF = TopoDS::Face(aSI.Shape());
|
||||||
|
@ -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>
|
||||||
@ -954,78 +954,66 @@ Standard_Boolean FindPlane(const TopoDS_Shape& theWire,
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//class : BOPAlgo_TNV
|
//class : BOPAlgo_PairVerticesSelector
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
class BOPAlgo_TNV;
|
class BOPAlgo_PairVerticesSelector : public BOPTools_BoxPairSelector
|
||||||
typedef NCollection_Vector<BOPAlgo_TNV> BOPAlgo_VectorOfTNV;
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
//=======================================================================
|
BOPAlgo_PairVerticesSelector()
|
||||||
class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{
|
: myVertices(NULL),
|
||||||
public:
|
myFuzzyValue(Precision::Confusion())
|
||||||
BOPAlgo_TNV()
|
{}
|
||||||
: BOPTools_BoxBndTreeSelector(),
|
|
||||||
myTol (0.), myFuzzyValue(0.), myTree(NULL), myVecTNV(NULL) {
|
//! Sets the map of vertices with tolerances
|
||||||
};
|
void SetMapOfVerticesTolerances (const TopTools_IndexedDataMapOfShapeReal& theVertices)
|
||||||
//
|
{
|
||||||
~BOPAlgo_TNV(){
|
myVertices = &theVertices;
|
||||||
};
|
|
||||||
//
|
|
||||||
void SetVertex(const TopoDS_Vertex& aV) {
|
|
||||||
myV=aV;
|
|
||||||
myPnt = BRep_Tool::Pnt(myV);
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
const TopoDS_Vertex& Vertex()const {
|
//! Sets the fuzzy value
|
||||||
return myV;
|
void SetFuzzyValue (const Standard_Real theFuzzyValue)
|
||||||
}
|
{
|
||||||
//
|
|
||||||
void SetTree(BOPTools_BoxBndTree& aTree) {
|
|
||||||
myTree=&aTree;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
void SetTolerance(const Standard_Real theTol) {
|
|
||||||
myTol = theTol;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
Standard_Real Tolerance() const {
|
|
||||||
return myTol;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const gp_Pnt& Pnt() const {
|
|
||||||
return myPnt;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
void SetFuzzyValue(const Standard_Real theFuzzyValue) {
|
|
||||||
myFuzzyValue = theFuzzyValue;
|
myFuzzyValue = theFuzzyValue;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
void SetVectorOfTNV(const BOPAlgo_VectorOfTNV& theVec) {
|
//! Checks and accepts the pair of elements.
|
||||||
myVecTNV = &theVec;
|
virtual Standard_Boolean Accept (const Standard_Integer theID1,
|
||||||
}
|
const Standard_Integer theID2) Standard_OVERRIDE
|
||||||
//
|
|
||||||
virtual Standard_Boolean Accept(const Standard_Integer& theIndex)
|
|
||||||
{
|
{
|
||||||
const BOPAlgo_TNV& aTNV = myVecTNV->Value(theIndex - 1);
|
if (!RejectElement (theID1, theID2))
|
||||||
Standard_Real aTolSum2 = myTol + aTNV.Tolerance() + myFuzzyValue;
|
{
|
||||||
aTolSum2 *= aTolSum2;
|
const Standard_Integer anID1 = this->myBVHSet1->Element (theID1);
|
||||||
Standard_Real aD2 = myPnt.SquareDistance(aTNV.Pnt());
|
const TopoDS_Vertex& aV1 = TopoDS::Vertex (myVertices->FindKey (anID1));
|
||||||
if (aD2 < aTolSum2)
|
Standard_Real aTolV1 = BRep_Tool::Tolerance (aV1);
|
||||||
return BOPTools_BoxBndTreeSelector::Accept(theIndex);
|
if (aTolV1 < myVertices->FindFromIndex (anID1))
|
||||||
|
aTolV1 = myVertices->FindFromIndex (anID1);
|
||||||
|
gp_Pnt aP1 = BRep_Tool::Pnt (aV1);
|
||||||
|
|
||||||
|
const Standard_Integer anID2 = this->myBVHSet1->Element (theID2);
|
||||||
|
const TopoDS_Vertex& aV2 = TopoDS::Vertex (myVertices->FindKey (anID2));
|
||||||
|
Standard_Real aTolV2 = BRep_Tool::Tolerance (aV2);
|
||||||
|
if (aTolV2 < myVertices->FindFromIndex (anID2))
|
||||||
|
aTolV2 = myVertices->FindFromIndex (anID2);
|
||||||
|
gp_Pnt aP2 = BRep_Tool::Pnt (aV2);
|
||||||
|
|
||||||
|
Standard_Real aTolSum2 = aTolV1 + aTolV2 + myFuzzyValue;
|
||||||
|
aTolSum2 *= aTolSum2;
|
||||||
|
|
||||||
|
Standard_Real aD2 = aP1.SquareDistance (aP2);
|
||||||
|
if (aD2 < aTolSum2)
|
||||||
|
{
|
||||||
|
myPairs.push_back (PairIDs (anID1, anID2));
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
void Perform() {
|
protected:
|
||||||
myTree->Select(*this);
|
const TopTools_IndexedDataMapOfShapeReal * myVertices;
|
||||||
}
|
|
||||||
//
|
|
||||||
protected:
|
|
||||||
Standard_Real myTol;
|
|
||||||
Standard_Real myFuzzyValue;
|
Standard_Real myFuzzyValue;
|
||||||
gp_Pnt myPnt;
|
|
||||||
TopoDS_Vertex myV;
|
|
||||||
BOPTools_BoxBndTree *myTree;
|
|
||||||
const BOPAlgo_VectorOfTNV *myVecTNV;
|
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
@ -1035,84 +1023,82 @@ class BOPAlgo_TNV : public BOPTools_BoxBndTreeSelector{
|
|||||||
//purpose : Builds the chains of intersecting vertices
|
//purpose : Builds the chains of intersecting vertices
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BOPAlgo_Tools::IntersectVertices(const TopTools_IndexedDataMapOfShapeReal& theVertices,
|
void BOPAlgo_Tools::IntersectVertices(const TopTools_IndexedDataMapOfShapeReal& theVertices,
|
||||||
const Standard_Boolean theRunParallel,
|
|
||||||
const Standard_Real theFuzzyValue,
|
const Standard_Real theFuzzyValue,
|
||||||
TopTools_ListOfListOfShape& theChains)
|
TopTools_ListOfListOfShape& theChains)
|
||||||
{
|
{
|
||||||
Standard_Integer i, j, aNbV = theVertices.Extent();
|
Standard_Integer aNbV = theVertices.Extent();
|
||||||
if (aNbV <= 1) {
|
if (aNbV <= 1) {
|
||||||
if (aNbV == 1) {
|
if (aNbV == 1) {
|
||||||
theChains.Append(TopTools_ListOfShape()).Append(theVertices.FindKey(1));
|
theChains.Append(TopTools_ListOfShape()).Append(theVertices.FindKey(1));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Use unbalanced binary tree of bounding boxes for sorting of the vertices.
|
// Additional tolerance for intersection
|
||||||
BOPTools_BoxBndTree aBBTree;
|
|
||||||
NCollection_UBTreeFiller <Standard_Integer,
|
|
||||||
Bnd_Box> aTreeFiller(aBBTree);
|
|
||||||
// Perform intersection of the vertices
|
|
||||||
BOPAlgo_VectorOfTNV aVTNV;
|
|
||||||
//
|
|
||||||
// Use additional tolerance for intersection
|
|
||||||
Standard_Real aTolAdd = theFuzzyValue / 2.;
|
Standard_Real aTolAdd = theFuzzyValue / 2.;
|
||||||
// Prepare the tree
|
|
||||||
for (i = 1; i <= aNbV; ++i) {
|
// Use BVH Tree for sorting the vertices
|
||||||
|
BOPTools_BoxTree aBBTree;
|
||||||
|
aBBTree.SetSize (aNbV);
|
||||||
|
|
||||||
|
for (Standard_Integer i = 1; i <= aNbV; ++i)
|
||||||
|
{
|
||||||
const TopoDS_Vertex& aV = TopoDS::Vertex(theVertices.FindKey(i));
|
const TopoDS_Vertex& aV = TopoDS::Vertex(theVertices.FindKey(i));
|
||||||
Standard_Real aTol = BRep_Tool::Tolerance(aV);
|
Standard_Real aTol = BRep_Tool::Tolerance(aV);
|
||||||
if (aTol < theVertices(i)) {
|
if (aTol < theVertices(i))
|
||||||
aTol = theVertices(i);
|
aTol = theVertices(i);
|
||||||
}
|
|
||||||
// Build bnd box for vertex
|
// Build bnd box for vertex
|
||||||
Bnd_Box aBox;
|
Bnd_Box aBox;
|
||||||
aBox.Add(BRep_Tool::Pnt(aV));
|
aBox.Add(BRep_Tool::Pnt(aV));
|
||||||
aBox.SetGap(aTol + aTolAdd);
|
aBox.SetGap(aTol + aTolAdd);
|
||||||
//
|
aBBTree.Add(i, Bnd_Tools::Bnd2BVH(aBox));
|
||||||
aTreeFiller.Add(i, aBox);
|
|
||||||
//
|
|
||||||
BOPAlgo_TNV& aTNV=aVTNV.Appended();
|
|
||||||
aTNV.SetTree(aBBTree);
|
|
||||||
aTNV.SetBox(aBox);
|
|
||||||
aTNV.SetVertex(aV);
|
|
||||||
aTNV.SetTolerance(aTol);
|
|
||||||
aTNV.SetFuzzyValue(theFuzzyValue);
|
|
||||||
aTNV.SetVectorOfTNV(aVTNV);
|
|
||||||
}
|
}
|
||||||
// Shake the tree
|
|
||||||
aTreeFiller.Fill();
|
aBBTree.Build();
|
||||||
//
|
|
||||||
// Perform intersection
|
// Perform selection of the interfering vertices
|
||||||
BOPTools_Parallel::Perform (theRunParallel, aVTNV);
|
BOPAlgo_PairVerticesSelector aPairSelector;
|
||||||
//
|
aPairSelector.SetBVHSets (&aBBTree, &aBBTree);
|
||||||
// Fence map
|
aPairSelector.SetSame (Standard_True);
|
||||||
TColStd_MapOfInteger aMFence;
|
aPairSelector.SetMapOfVerticesTolerances (theVertices);
|
||||||
// Build chains of intersecting vertices
|
aPairSelector.SetFuzzyValue (theFuzzyValue);
|
||||||
for (i = 1; i <= aNbV; ++i) {
|
aPairSelector.Select();
|
||||||
if (!aMFence.Add(i)) {
|
|
||||||
continue;
|
// Treat the selected pairs
|
||||||
}
|
const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aPairSelector.Pairs();
|
||||||
// Start the chain
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
|
||||||
TColStd_IndexedMapOfInteger aMChain;
|
|
||||||
aMChain.Add(i);
|
// Collect interfering pairs
|
||||||
//
|
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
|
||||||
for (j = 1; j <= aMChain.Extent(); ++j) {
|
NCollection_IndexedDataMap<Standard_Integer, TColStd_ListOfInteger> aMILI (1, anAlloc);
|
||||||
BOPAlgo_TNV& aTNV = aVTNV(aMChain(j) - 1);
|
|
||||||
const TColStd_ListOfInteger& aLI = aTNV.Indices();
|
for (Standard_Integer iPair = 0; iPair < aNbPairs; ++iPair)
|
||||||
// Add these vertices into the chain
|
{
|
||||||
for (TColStd_ListIteratorOfListOfInteger aItLI(aLI); aItLI.More(); aItLI.Next()) {
|
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
|
||||||
if (aMFence.Add(aItLI.Value())) {
|
BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher> (aPair.ID1, aPair.ID2, aMILI, anAlloc);
|
||||||
aMChain.Add(aItLI.Value());
|
}
|
||||||
}
|
|
||||||
}
|
NCollection_List<TColStd_ListOfInteger> aBlocks (anAlloc);
|
||||||
}
|
BOPAlgo_Tools::MakeBlocks<Standard_Integer, TColStd_MapIntegerHasher> (aMILI, aBlocks, anAlloc);
|
||||||
//
|
|
||||||
// Put vertices of the chain into the list
|
NCollection_List<TColStd_ListOfInteger>::Iterator itLI (aBlocks);
|
||||||
TopTools_ListOfShape& aChain = theChains.Append(TopTools_ListOfShape());
|
for (; itLI.More(); itLI.Next())
|
||||||
//
|
{
|
||||||
Standard_Integer aNbVChain = aMChain.Extent();
|
const TColStd_ListOfInteger& aLI = itLI.Value();
|
||||||
for (j = 1; j <= aNbVChain; ++j) {
|
TopTools_ListOfShape &aChain = theChains.Append (TopTools_ListOfShape());
|
||||||
const TopoDS_Vertex& aVP = aVTNV(aMChain(j) - 1).Vertex();
|
|
||||||
aChain.Append(aVP);
|
for (TColStd_ListOfInteger::Iterator itI (aLI); itI.More(); itI.Next())
|
||||||
|
aChain.Append (theVertices.FindKey (itI.Value()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add not interfered vertices as a chain of 1 element
|
||||||
|
for (Standard_Integer i = 1; i <= aNbV; ++i)
|
||||||
|
{
|
||||||
|
if (!aMILI.Contains (i))
|
||||||
|
{
|
||||||
|
TopTools_ListOfShape &aChain = theChains.Append (TopTools_ListOfShape());
|
||||||
|
aChain.Append (theVertices.FindKey(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1236,9 +1222,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Sets the Bounding Box tree
|
//! Sets the Bounding Box tree
|
||||||
void SetBBTree(const BOPTools_BoxBndTree& theBBTree)
|
void SetBBTree(BOPTools_BoxTree* theBBTree)
|
||||||
{
|
{
|
||||||
myBBTree = (BOPTools_BoxBndTree*)&theBBTree;
|
myBBTree = theBBTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Sets the ShapeBox structure
|
//! Sets the ShapeBox structure
|
||||||
@ -1288,7 +1274,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
|
BOPTools_BoxTree* myBBTree; //! BVH tree of bounding boxes
|
||||||
BOPAlgo_VectorOfShapeBox* myVShapeBox; //! ShapeBoxMap
|
BOPAlgo_VectorOfShapeBox* myVShapeBox; //! ShapeBoxMap
|
||||||
|
|
||||||
TopoDS_Iterator myItF; //! Iterators
|
TopoDS_Iterator myItF; //! Iterators
|
||||||
@ -1308,10 +1294,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);
|
||||||
//
|
//
|
||||||
if (!myBBTree->Select(aSelector))
|
if (!aSelector.Select())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const TColStd_ListOfInteger& aLIFP = aSelector.Indices();
|
const TColStd_ListOfInteger& aLIFP = aSelector.Indices();
|
||||||
@ -1559,19 +1546,18 @@ void BOPAlgo_Tools::ClassifyFaces(const TopTools_ListOfShape& theFaces,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare UB tree of bounding boxes of the faces to classify
|
// Prepare BVH 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;
|
BOPTools_BoxTree aBBTree;
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
|
||||||
|
|
||||||
Standard_Integer aNbF = aVSB.Length();
|
Standard_Integer aNbF = aVSB.Length();
|
||||||
|
aBBTree.SetSize (aNbF);
|
||||||
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;
|
||||||
@ -1605,7 +1591,7 @@ void BOPAlgo_Tools::ClassifyFaces(const TopTools_ListOfShape& theFaces,
|
|||||||
if (pLIF)
|
if (pLIF)
|
||||||
aFIP.SetOwnIF(*pLIF);
|
aFIP.SetOwnIF(*pLIF);
|
||||||
|
|
||||||
aFIP.SetBBTree(aBBTree);
|
aFIP.SetBBTree(&aBBTree);
|
||||||
aFIP.SetShapeBoxVector(aVSB);
|
aFIP.SetShapeBoxVector(aVSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,6 @@ public:
|
|||||||
|
|
||||||
//! Finds chains of intersecting vertices
|
//! Finds chains of intersecting vertices
|
||||||
Standard_EXPORT static void IntersectVertices(const TopTools_IndexedDataMapOfShapeReal& theVertices,
|
Standard_EXPORT static void IntersectVertices(const TopTools_IndexedDataMapOfShapeReal& theVertices,
|
||||||
const Standard_Boolean theRunParallel,
|
|
||||||
const Standard_Real theFuzzyValue,
|
const Standard_Real theFuzzyValue,
|
||||||
TopTools_ListOfListOfShape& theChains);
|
TopTools_ListOfListOfShape& theChains);
|
||||||
|
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#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>
|
||||||
@ -37,12 +37,12 @@
|
|||||||
//class : BOPDS_TreeSelector
|
//class : BOPDS_TreeSelector
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
class BOPDS_TSR : public BOPTools_BoxBndTreeSelector{
|
class BOPDS_TSR : public BOPTools_BoxTreeSelector
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
BOPDS_TSR() :
|
BOPDS_TSR() :
|
||||||
BOPTools_BoxBndTreeSelector(),
|
BOPTools_BoxTreeSelector(),
|
||||||
myHasBRep(Standard_False),
|
myHasBRep(Standard_False),
|
||||||
myTree(NULL),
|
|
||||||
myIndex(-1) {}
|
myIndex(-1) {}
|
||||||
//
|
//
|
||||||
virtual ~BOPDS_TSR() {
|
virtual ~BOPDS_TSR() {
|
||||||
@ -52,23 +52,18 @@ class BOPDS_TSR : public BOPTools_BoxBndTreeSelector{
|
|||||||
myHasBRep=bFlag;
|
myHasBRep=bFlag;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void SetTree(BOPTools_BoxBndTree& aTree) {
|
|
||||||
myTree=&aTree;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
void SetIndex(const Standard_Integer theIndex) { myIndex = theIndex; }
|
void SetIndex(const Standard_Integer theIndex) { myIndex = theIndex; }
|
||||||
//
|
//
|
||||||
Standard_Integer Index() const { return myIndex; }
|
Standard_Integer Index() const { return myIndex; }
|
||||||
//
|
//
|
||||||
void Perform() {
|
void Perform() {
|
||||||
if (myHasBRep) {
|
if (myHasBRep) {
|
||||||
myTree->Select(*this);
|
Select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
Standard_Boolean myHasBRep;
|
Standard_Boolean myHasBRep;
|
||||||
BOPTools_BoxBndTree *myTree;
|
|
||||||
Standard_Integer myIndex;
|
Standard_Integer myIndex;
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
@ -76,7 +71,6 @@ class BOPDS_TSR : public BOPTools_BoxBndTreeSelector{
|
|||||||
typedef NCollection_Vector<BOPDS_TSR> BOPDS_VectorOfTSR;
|
typedef NCollection_Vector<BOPDS_TSR> BOPDS_VectorOfTSR;
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :
|
//function :
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -289,142 +283,81 @@ 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;
|
|
||||||
//
|
|
||||||
myBoxTree.Clear();
|
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(myBoxTree);
|
|
||||||
//
|
|
||||||
aNb = myDS->NbSourceShapes();
|
|
||||||
BOPDS_VectorOfTSR aVTSR(aNb);
|
|
||||||
//
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const Bnd_Box& aBoxEx=aSI.Box();
|
|
||||||
aTSR.SetTree(myBoxTree);
|
|
||||||
aTSR.SetBox(aBoxEx);
|
|
||||||
aTSR.SetIndex(i);
|
|
||||||
//
|
|
||||||
aTreeFiller.Add(i, aBoxEx);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
aTreeFiller.Fill();
|
|
||||||
//
|
|
||||||
//===========================================
|
|
||||||
BOPTools_Parallel::Perform (myRunParallel, aVTSR);
|
|
||||||
//===========================================
|
|
||||||
//
|
|
||||||
BOPDS_MapOfPair aMPFence;
|
|
||||||
//
|
|
||||||
aNbR = myDS->NbRanges() - 1;
|
|
||||||
for (iR = 0; iR < aNbR; ++iR) {
|
|
||||||
const BOPDS_IndexRange& aR = myDS->Range(iR);
|
|
||||||
i1 = aR.First();
|
|
||||||
i2 = aR.Last();
|
|
||||||
for (i = i1; i <= i2; ++i) {
|
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
|
|
||||||
//
|
|
||||||
if (!aSI.IsInterfering() || (aSI.ShapeType() == TopAbs_SOLID)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
BOPDS_TSR& aTSRi = aVTSR(i);
|
|
||||||
const TColStd_ListOfInteger& aLI = aTSRi.Indices();
|
|
||||||
Standard_Integer aNbSD = aLI.Extent();
|
|
||||||
if (!aNbSD) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
aTi = aSI.ShapeType();
|
|
||||||
iTi = BOPDS_Tools::TypeToInteger(aTi);
|
|
||||||
//
|
|
||||||
TColStd_ListIteratorOfListOfInteger aIt(aLI);
|
|
||||||
for (; aIt.More(); aIt.Next()) {
|
|
||||||
j = aIt.Value(); // DS index
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
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))
|
// Prepare BVH
|
||||||
continue;
|
BOPTools_BoxTree aBoxTree;
|
||||||
}
|
aBoxTree.SetSize (aNb);
|
||||||
|
for (Standard_Integer i = 0; i < aNb; ++i)
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// function: PrepareExt
|
|
||||||
// purpose:
|
|
||||||
//=======================================================================
|
|
||||||
void BOPDS_Iterator::PrepareExt(const TColStd_MapOfInteger& theIndices)
|
|
||||||
{
|
|
||||||
if (!myDS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update UB tree of bounding boxes with the increased shapes.
|
|
||||||
// It is expected that not too many shapes will be modified during
|
|
||||||
// the intersection, so after updating the tree it should not become
|
|
||||||
// too unbalanced.
|
|
||||||
TColStd_MapIteratorOfMapOfInteger itM(theIndices);
|
|
||||||
for (; itM.More(); itM.Next())
|
|
||||||
{
|
{
|
||||||
Standard_Integer nV = itM.Value();
|
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
|
||||||
myBoxTree.Remove(nV);
|
if (!aSI.HasBRep())
|
||||||
|
continue;
|
||||||
// Add with new box
|
|
||||||
Standard_Integer nVSD = nV;
|
|
||||||
myDS->HasShapeSD(nV, nVSD);
|
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nVSD);
|
|
||||||
const Bnd_Box& aBox = aSI.Box();
|
const Bnd_Box& aBox = aSI.Box();
|
||||||
myBoxTree.Add(nV, aBox);
|
aBoxTree.Add (i, Bnd_Tools::Bnd2BVH (aBox));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the extra lists
|
// Build BVH
|
||||||
const Standard_Integer aNbExt = BOPDS_Iterator::NbExtInterfs();
|
aBoxTree.Build();
|
||||||
myLength = 0;
|
|
||||||
for (Standard_Integer i = 0; i < aNbExt; ++i)
|
|
||||||
myExtLists(i).Clear();
|
|
||||||
|
|
||||||
IntersectExt(theIndices);
|
// Select pairs of shapes with interfering bounding boxes
|
||||||
|
BOPTools_BoxPairSelector aPairSelector;
|
||||||
|
aPairSelector.SetBVHSets (&aBoxTree, &aBoxTree);
|
||||||
|
aPairSelector.SetSame (Standard_True);
|
||||||
|
aPairSelector.Select();
|
||||||
|
aPairSelector.Sort();
|
||||||
|
|
||||||
myUseExt = Standard_True;
|
// Treat the selected pairs
|
||||||
|
const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aPairSelector.Pairs();
|
||||||
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
|
||||||
|
|
||||||
|
Standard_Integer iPair = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo (aPair.ID1);
|
||||||
|
const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo (aPair.ID2);
|
||||||
|
|
||||||
|
const TopAbs_ShapeEnum aType1 = aSI1.ShapeType();
|
||||||
|
const TopAbs_ShapeEnum aType2 = aSI2.ShapeType();
|
||||||
|
|
||||||
|
Standard_Integer iType1 = BOPDS_Tools::TypeToInteger (aType1);
|
||||||
|
Standard_Integer iType2 = BOPDS_Tools::TypeToInteger (aType2);
|
||||||
|
|
||||||
|
// avoid interfering of the shape with its sub-shapes
|
||||||
|
if (((iType1 < iType2) && aSI1.HasSubShape (aPair.ID2)) ||
|
||||||
|
((iType1 > iType2) && aSI2.HasSubShape (aPair.ID1)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (theCheckOBB)
|
||||||
|
{
|
||||||
|
// Check intersection of Oriented bounding boxes of the shapes
|
||||||
|
const Bnd_OBB& anOBB1 = theCtx->OBB (aSI1.Shape(), theFuzzyValue);
|
||||||
|
const Bnd_OBB& anOBB2 = theCtx->OBB (aSI2.Shape(), theFuzzyValue);
|
||||||
|
|
||||||
|
if (anOBB1.IsOut (anOBB2))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer iX = BOPDS_Tools::TypeToInteger (aType1, aType2);
|
||||||
|
myLists(iX).Append (BOPDS_Pair (Min (aPair.ID1, aPair.ID2),
|
||||||
|
Max (aPair.ID1, aPair.ID2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -433,24 +366,43 @@ void BOPDS_Iterator::PrepareExt(const TColStd_MapOfInteger& theIndices)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BOPDS_Iterator::IntersectExt(const TColStd_MapOfInteger& theIndices)
|
void BOPDS_Iterator::IntersectExt(const TColStd_MapOfInteger& theIndices)
|
||||||
{
|
{
|
||||||
// Prepare vector for parallel selection
|
if (!myDS)
|
||||||
BOPDS_VectorOfTSR aVTSR(theIndices.Extent());
|
return;
|
||||||
|
|
||||||
TColStd_MapIteratorOfMapOfInteger itM(theIndices);
|
const Standard_Integer aNb = myDS->NbSourceShapes();
|
||||||
for (; itM.More(); itM.Next())
|
|
||||||
|
BOPTools_BoxTree aBoxTree;
|
||||||
|
aBoxTree.SetSize (aNb);
|
||||||
|
BOPDS_VectorOfTSR aVTSR(theIndices.Extent());
|
||||||
|
//
|
||||||
|
for (Standard_Integer i = 0; i < aNb; ++i)
|
||||||
{
|
{
|
||||||
Standard_Integer nV = itM.Value();
|
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
|
||||||
Standard_Integer nVSD = nV;
|
if (!aSI.IsInterfering() || (aSI.ShapeType() == TopAbs_SOLID))
|
||||||
myDS->HasShapeSD(nV, nVSD);
|
continue;
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nVSD);
|
//
|
||||||
const Bnd_Box& aBox = aSI.Box();
|
if (theIndices.Contains (i))
|
||||||
BOPDS_TSR& aTSR = aVTSR.Appended();
|
{
|
||||||
aTSR.SetHasBRep(Standard_True);
|
Standard_Integer nVSD = i;
|
||||||
aTSR.SetTree(myBoxTree);
|
myDS->HasShapeSD (i, nVSD);
|
||||||
aTSR.SetBox(aBox);
|
const BOPDS_ShapeInfo& aSISD = myDS->ShapeInfo (nVSD);
|
||||||
aTSR.SetIndex(nV);
|
const Bnd_Box& aBox = aSISD.Box ();
|
||||||
|
aBoxTree.Add (i, Bnd_Tools::Bnd2BVH(aBox));
|
||||||
|
|
||||||
|
BOPDS_TSR& aTSR=aVTSR.Appended();
|
||||||
|
aTSR.SetHasBRep(Standard_True);
|
||||||
|
aTSR.SetBVHSet (&aBoxTree);
|
||||||
|
aTSR.SetBox (Bnd_Tools::Bnd2BVH (aBox));
|
||||||
|
aTSR.SetIndex (i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aBoxTree.Add (i, Bnd_Tools::Bnd2BVH (aSI.Box ()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aBoxTree.Build();
|
||||||
|
|
||||||
// Perform selection
|
// Perform selection
|
||||||
BOPTools_Parallel::Perform (myRunParallel, aVTSR);
|
BOPTools_Parallel::Perform (myRunParallel, aVTSR);
|
||||||
|
|
||||||
@ -459,8 +411,8 @@ void BOPDS_Iterator::IntersectExt(const TColStd_MapOfInteger& theIndices)
|
|||||||
// Fence map to avoid duplicating pairs
|
// Fence map to avoid duplicating pairs
|
||||||
BOPDS_MapOfPair aMPFence;
|
BOPDS_MapOfPair aMPFence;
|
||||||
|
|
||||||
const Standard_Integer aNb = aVTSR.Length();
|
const Standard_Integer aNbV = aVTSR.Length();
|
||||||
for (Standard_Integer k = 0; k < aNb; ++k)
|
for (Standard_Integer k = 0; k < aNbV; ++k)
|
||||||
{
|
{
|
||||||
BOPDS_TSR& aTSRi = aVTSR(k);
|
BOPDS_TSR& aTSRi = aVTSR(k);
|
||||||
const TColStd_ListOfInteger& aLI = aTSRi.Indices();
|
const TColStd_ListOfInteger& aLI = aTSRi.Indices();
|
||||||
@ -485,7 +437,7 @@ void BOPDS_Iterator::IntersectExt(const TColStd_MapOfInteger& theIndices)
|
|||||||
const TopAbs_ShapeEnum aTJ = aSJ.ShapeType();
|
const TopAbs_ShapeEnum aTJ = aSJ.ShapeType();
|
||||||
const Standard_Integer iTJ = BOPDS_Tools::TypeToInteger(aTJ);
|
const Standard_Integer iTJ = BOPDS_Tools::TypeToInteger(aTJ);
|
||||||
|
|
||||||
// avoid interfering of the same shapes and shape with its sub-shapes
|
// avoid interfering of the shape with its sub-shapes
|
||||||
if (((iTI < iTJ) && aSI.HasSubShape(j)) ||
|
if (((iTI < iTJ) && aSI.HasSubShape(j)) ||
|
||||||
((iTI > iTJ) && aSJ.HasSubShape(i)))
|
((iTI > iTJ) && aSJ.HasSubShape(i)))
|
||||||
continue;
|
continue;
|
||||||
@ -499,4 +451,6 @@ void BOPDS_Iterator::IntersectExt(const TColStd_MapOfInteger& theIndices)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myUseExt = Standard_True;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <BOPDS_PDS.hxx>
|
#include <BOPDS_PDS.hxx>
|
||||||
#include <BOPDS_VectorOfPair.hxx>
|
#include <BOPDS_VectorOfPair.hxx>
|
||||||
#include <BOPDS_VectorOfVectorOfPair.hxx>
|
#include <BOPDS_VectorOfVectorOfPair.hxx>
|
||||||
#include <BOPTools_BoxBndTree.hxx>
|
#include <BOPTools_BoxTree.hxx>
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
|
|
||||||
//! Updates the tree of Bounding Boxes with increased boxes and
|
//! Updates the tree of Bounding Boxes with increased boxes and
|
||||||
//! intersects such elements with the tree.
|
//! intersects such elements with the tree.
|
||||||
Standard_EXPORT void PrepareExt(const TColStd_MapOfInteger& theIndicies);
|
Standard_EXPORT void IntersectExt(const TColStd_MapOfInteger& theIndicies);
|
||||||
|
|
||||||
//! Returns the number of intersections founded
|
//! Returns the number of intersections founded
|
||||||
Standard_EXPORT Standard_Integer ExpectedLength() const;
|
Standard_EXPORT Standard_Integer ExpectedLength() const;
|
||||||
@ -119,12 +119,6 @@ protected: //! @name Protected methods for bounding boxes intersection
|
|||||||
const Standard_Boolean theCheckOBB = Standard_False,
|
const Standard_Boolean theCheckOBB = Standard_False,
|
||||||
const Standard_Real theFuzzyValue = Precision::Confusion());
|
const Standard_Real theFuzzyValue = Precision::Confusion());
|
||||||
|
|
||||||
//! Intersects the bounding boxes of the shapes with given indices in DS
|
|
||||||
//! with the tree of bounding boxes and saves the interfering pairs in
|
|
||||||
//! extra lists for further geometrical intersection.
|
|
||||||
Standard_EXPORT void IntersectExt(const TColStd_MapOfInteger& theIndices);
|
|
||||||
|
|
||||||
|
|
||||||
protected: //! @name Fields
|
protected: //! @name Fields
|
||||||
|
|
||||||
Handle(NCollection_BaseAllocator) myAllocator; //!< Allocator
|
Handle(NCollection_BaseAllocator) myAllocator; //!< Allocator
|
||||||
@ -134,7 +128,6 @@ protected: //! @name Fields
|
|||||||
BOPDS_VectorOfVectorOfPair myLists; //!< Pairs with interfering bounding boxes
|
BOPDS_VectorOfVectorOfPair myLists; //!< Pairs with interfering bounding boxes
|
||||||
BOPDS_VectorOfPair::Iterator myIterator; //!< Iterator on each interfering type
|
BOPDS_VectorOfPair::Iterator myIterator; //!< Iterator on each interfering type
|
||||||
Standard_Boolean myRunParallel; //!< Flag for parallel processing
|
Standard_Boolean myRunParallel; //!< Flag for parallel processing
|
||||||
BOPTools_BoxBndTree myBoxTree; //!< Unbalanced tree of bounding boxes
|
|
||||||
BOPDS_VectorOfVectorOfPair myExtLists; //!< Extra pairs of sub-shapes found after
|
BOPDS_VectorOfVectorOfPair myExtLists; //!< Extra pairs of sub-shapes found after
|
||||||
//! intersection of increased sub-shapes
|
//! intersection of increased sub-shapes
|
||||||
Standard_Boolean myUseExt; //!< Information flag for using the extra lists
|
Standard_Boolean myUseExt; //!< Information flag for using the extra lists
|
||||||
|
@ -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>
|
||||||
@ -79,83 +79,68 @@ void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
|
|||||||
// function: Intersect
|
// function: Intersect
|
||||||
// purpose:
|
// purpose:
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
|
void BOPDS_IteratorSI::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, aNbS;
|
const Standard_Integer aNbS = myDS->NbSourceShapes();
|
||||||
Standard_Integer iTi, iTj;
|
|
||||||
TopAbs_ShapeEnum aTi, aTj;
|
BOPTools_BoxTree aBBTree;
|
||||||
//
|
aBBTree.SetSize (aNbS);
|
||||||
BOPTools_BoxBndTreeSelector aSelector;
|
|
||||||
BOPTools_BoxBndTree aBBTree;
|
for (Standard_Integer i = 0; i < aNbS; ++i)
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
{
|
||||||
//
|
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo (i);
|
||||||
aNbS = myDS->NbSourceShapes();
|
if (!aSI.IsInterfering())
|
||||||
for (i=0; i<aNbS; ++i) {
|
|
||||||
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
|
|
||||||
if (!aSI.IsInterfering()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
//
|
|
||||||
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;
|
// Select pairs of shapes with interfering bounding boxes
|
||||||
//
|
BOPTools_BoxPairSelector aPairSelector;
|
||||||
for (i = 0; i < aNbS; ++i) {
|
aPairSelector.SetBVHSets (&aBBTree, &aBBTree);
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
|
aPairSelector.SetSame (Standard_True);
|
||||||
if (!aSI.IsInterfering()){
|
aPairSelector.Select();
|
||||||
|
aPairSelector.Sort();
|
||||||
|
|
||||||
|
// Treat the selected pairs
|
||||||
|
const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aPairSelector.Pairs();
|
||||||
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
|
||||||
|
|
||||||
|
for (Standard_Integer iPair = 0; iPair < aNbPairs; ++iPair)
|
||||||
|
{
|
||||||
|
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
|
||||||
|
|
||||||
|
const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo (aPair.ID1);
|
||||||
|
const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo (aPair.ID2);
|
||||||
|
|
||||||
|
const TopAbs_ShapeEnum aType1 = aSI1.ShapeType();
|
||||||
|
const TopAbs_ShapeEnum aType2 = aSI2.ShapeType();
|
||||||
|
|
||||||
|
Standard_Integer iType1 = BOPDS_Tools::TypeToInteger (aType1);
|
||||||
|
Standard_Integer iType2 = BOPDS_Tools::TypeToInteger (aType2);
|
||||||
|
|
||||||
|
// avoid interfering of the shape with its sub-shapes
|
||||||
|
if (((iType1 < iType2) && aSI1.HasSubShape (aPair.ID2)) ||
|
||||||
|
((iType1 > iType2) && aSI2.HasSubShape (aPair.ID1)))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
//
|
if (theCheckOBB)
|
||||||
const Bnd_Box& aBoxEx = aSI.Box();
|
{
|
||||||
//
|
// Check intersection of Oriented bounding boxes of the shapes
|
||||||
aSelector.Clear();
|
const Bnd_OBB& anOBB1 = theCtx->OBB (aSI1.Shape (), theFuzzyValue);
|
||||||
aSelector.SetBox(aBoxEx);
|
const Bnd_OBB& anOBB2 = theCtx->OBB (aSI2.Shape (), theFuzzyValue);
|
||||||
//
|
|
||||||
Standard_Integer aNbSD = aBBTree.Select(aSelector);
|
if (anOBB1.IsOut (anOBB2))
|
||||||
if (!aNbSD) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
aTi = aSI.ShapeType();
|
|
||||||
iTi = BOPDS_Tools::TypeToInteger(aTi);
|
|
||||||
//
|
|
||||||
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
|
||||||
TColStd_ListIteratorOfListOfInteger aIt(aLI);
|
|
||||||
for (; aIt.More(); aIt.Next()) {
|
|
||||||
j = aIt.Value();
|
|
||||||
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 ((i == j) || ((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 (aMPKXB.Add(aPKXB)) {
|
|
||||||
}// for (; aIt.More(); aIt.Next()) {
|
|
||||||
}//for (i=1; i<=aNbS; ++i) {
|
|
||||||
//
|
|
||||||
aMPFence.Clear();
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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>
|
||||||
|
|
||||||
@ -115,60 +114,65 @@ void BOPDS_SubIterator::Initialize()
|
|||||||
// function: Intersect
|
// function: Intersect
|
||||||
// purpose:
|
// purpose:
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BOPDS_SubIterator::Intersect()
|
void BOPDS_SubIterator::Intersect()
|
||||||
{
|
{
|
||||||
Standard_Integer i, j, iTi, iTj;
|
if (!mySubSet1->Extent() || !mySubSet2->Extent())
|
||||||
BOPTools_BoxBndTree aBBTree;
|
return;
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
|
||||||
//
|
// Construct BVH tree for each sub-set
|
||||||
TColStd_ListIteratorOfListOfInteger aIt(*mySubSet1);
|
BOPTools_BoxTree aBBTree[2];
|
||||||
for (; aIt.More(); aIt.Next()) {
|
for (Standard_Integer i = 0; i < 2; ++i)
|
||||||
i = aIt.Value();
|
{
|
||||||
//
|
const TColStd_ListOfInteger* aSubSet = !i ? mySubSet1 : mySubSet2;
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
|
aBBTree[i].SetSize (aSubSet->Extent());
|
||||||
const Bnd_Box& aBoxEx = aSI.Box();
|
for (TColStd_ListOfInteger::Iterator it (*aSubSet); it.More(); it.Next())
|
||||||
//
|
{
|
||||||
aTreeFiller.Add(i, aBoxEx);
|
const Standard_Integer nS = it.Value();
|
||||||
|
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nS);
|
||||||
|
const Bnd_Box& aBoxEx = aSI.Box();
|
||||||
|
aBBTree[i].Add(nS, Bnd_Tools::Bnd2BVH (aBoxEx));
|
||||||
|
}
|
||||||
|
aBBTree[i].Build();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
aTreeFiller.Fill();
|
// Perform selection of the interfering pairs
|
||||||
//
|
BOPTools_BoxPairSelector aPairSelector;
|
||||||
|
aPairSelector.SetBVHSets (&aBBTree[0], &aBBTree[1]);
|
||||||
|
aPairSelector.Select();
|
||||||
|
aPairSelector.Sort();
|
||||||
|
|
||||||
|
// Treat the selected pairs
|
||||||
|
const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aPairSelector.Pairs();
|
||||||
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
|
||||||
|
|
||||||
|
// Fence map
|
||||||
BOPDS_MapOfPair aMPKFence;
|
BOPDS_MapOfPair aMPKFence;
|
||||||
//
|
|
||||||
aIt.Initialize(*mySubSet2);
|
for (Standard_Integer iPair = 0; iPair < aNbPairs; ++iPair)
|
||||||
for (; aIt.More(); aIt.Next()) {
|
{
|
||||||
i = aIt.Value();
|
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
|
||||||
//
|
if (aPair.ID1 == aPair.ID2)
|
||||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
|
|
||||||
const Bnd_Box& aBoxEx = aSI.Box();
|
|
||||||
//
|
|
||||||
BOPTools_BoxBndTreeSelector aSelector;
|
|
||||||
aSelector.SetBox(aBoxEx);
|
|
||||||
Standard_Integer aNbSD = aBBTree.Select(aSelector);
|
|
||||||
if (!aNbSD) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
//
|
BOPDS_Pair aDSPair (Min(aPair.ID1, aPair.ID2),
|
||||||
iTi = BOPDS_Tools::TypeToInteger(aSI.ShapeType());
|
Max(aPair.ID1, aPair.ID2));
|
||||||
//
|
if (!aMPKFence.Add(aDSPair))
|
||||||
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
continue;
|
||||||
TColStd_ListIteratorOfListOfInteger aItLI(aLI);
|
|
||||||
for (; aItLI.More(); aItLI.Next()) {
|
const BOPDS_ShapeInfo& aSI1 = myDS->ShapeInfo (aPair.ID1);
|
||||||
j = aItLI.Value();
|
const BOPDS_ShapeInfo& aSI2 = myDS->ShapeInfo (aPair.ID2);
|
||||||
//
|
|
||||||
const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
|
const TopAbs_ShapeEnum aType1 = aSI1.ShapeType();
|
||||||
iTj = BOPDS_Tools::TypeToInteger(aSJ.ShapeType());
|
const TopAbs_ShapeEnum aType2 = aSI2.ShapeType();
|
||||||
//
|
|
||||||
// avoid interfering of the same shapes and shape with its sub-shapes
|
Standard_Integer iType1 = BOPDS_Tools::TypeToInteger (aType1);
|
||||||
if ((i == j) || ((iTi < iTj) && aSI.HasSubShape(j)) ||
|
Standard_Integer iType2 = BOPDS_Tools::TypeToInteger (aType2);
|
||||||
((iTi > iTj) && aSJ.HasSubShape(i))) {
|
|
||||||
continue;
|
// avoid interfering of the shape with its sub-shapes
|
||||||
}
|
if (((iType1 < iType2) && aSI1.HasSubShape (aPair.ID2)) ||
|
||||||
//
|
((iType1 > iType2) && aSI2.HasSubShape (aPair.ID1)))
|
||||||
BOPDS_Pair aPair(j, i);
|
continue;
|
||||||
if (aMPKFence.Add(aPair)) {
|
|
||||||
myList.Append(aPair);
|
myList.Append(aDSPair);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_EBTree.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
|
|
||||||
typedef NCollection_EBTree<Standard_Integer, Bnd_Box> BOPTools_BoxBndTree;
|
|
||||||
typedef BOPTools_BoxSelector<Bnd_Box> BOPTools_BoxBndTreeSelector;
|
|
||||||
|
|
||||||
#endif
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Checks if the element should be rejected
|
||||||
|
Standard_Boolean RejectElement (const Standard_Integer theIndex)
|
||||||
|
{
|
||||||
|
return myBox.IsOut (this->myBVHSet->Box (theIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Checks if the metric of the node may be accepted
|
||||||
|
virtual Standard_Boolean AcceptMetric (const Standard_Boolean& theIsInside) const Standard_OVERRIDE
|
||||||
|
{
|
||||||
|
return theIsInside;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Accepts the element with the index <theIndex> in BVH tree
|
||||||
|
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
|
||||||
|
47
src/BOPTools/BOPTools_BoxTree.hxx
Normal file
47
src/BOPTools/BOPTools_BoxTree.hxx
Normal 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
|
131
src/BOPTools/BOPTools_PairSelector.hxx
Normal file
131
src/BOPTools/BOPTools_PairSelector.hxx
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
// 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 selection of the elements from two BVH trees.
|
||||||
|
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.
|
||||||
|
//! If the flag is set to true the resulting vector will contain
|
||||||
|
//! only unique pairs (mirrored pairs will be rejected,
|
||||||
|
//! e.g. (1, 2) will be taken, (2, 1) will be rejected) and will
|
||||||
|
//! not contain pairs in which IDs are the same (pair (1, 1) will be rejected).
|
||||||
|
//! If it is required to have a full vector of pairs even
|
||||||
|
//! for the same BVH trees, just keep the false value of this flag.
|
||||||
|
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
|
||||||
|
|
||||||
|
//! Basing on the bounding boxes of the nodes checks if the pair of nodes 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Checks if the pair of elements should be rejected.
|
||||||
|
Standard_Boolean RejectElement (const Standard_Integer theID1,
|
||||||
|
const Standard_Integer theID2)
|
||||||
|
{
|
||||||
|
return (mySameBVHs && theID1 >= theID2) ||
|
||||||
|
this->myBVHSet1->Box (theID1).IsOut(
|
||||||
|
this->myBVHSet2->Box (theID2));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Checks and accepts the pair of elements.
|
||||||
|
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
|
@ -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
|
||||||
|
@ -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;
|
BOPTools_BoxTree aBBTree;
|
||||||
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
|
||||||
@ -127,37 +127,37 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
|
|||||||
Bnd_Box aBoxF;
|
Bnd_Box aBoxF;
|
||||||
BRepBndLib::Add(aF, aBoxF);
|
BRepBndLib::Add(aF, aBoxF);
|
||||||
//
|
//
|
||||||
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
|
// Build BVH
|
||||||
aTreeFiller.Fill();
|
aBBTree.Build();
|
||||||
//
|
|
||||||
// get faces with interfering bounding boxes
|
// Perform selection of the pairs
|
||||||
aItL.Initialize(SetOfFaces);
|
BOPTools_BoxPairSelector aSelector;
|
||||||
for (; aItL.More(); aItL.Next()) {
|
aSelector.SetBVHSets (&aBBTree, &aBBTree);
|
||||||
const TopoDS_Face& aF1 = TopoDS::Face(aItL.Value());
|
aSelector.SetSame (Standard_True);
|
||||||
const Bnd_Box& aBoxF1 = aMFaces.FindFromKey(aF1);
|
aSelector.Select();
|
||||||
//
|
aSelector.Sort();
|
||||||
BOPTools_BoxBndTreeSelector aSelector;
|
|
||||||
aSelector.SetBox(aBoxF1);
|
// Treat the selected pairs
|
||||||
aBBTree.Select(aSelector);
|
const std::vector<BOPTools_BoxPairSelector::PairIDs>& aPairs = aSelector.Pairs();
|
||||||
//
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer> (aPairs.size());
|
||||||
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
|
||||||
TColStd_ListIteratorOfListOfInteger aItLI(aLI);
|
for (Standard_Integer iPair = 0; iPair < aNbPairs; ++iPair)
|
||||||
for (; aItLI.More(); aItLI.Next()) {
|
{
|
||||||
Standard_Integer i = aItLI.Value();
|
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
|
||||||
const TopoDS_Face& aF2 = TopoDS::Face(aMFaces.FindKey(i));
|
|
||||||
//
|
const TopoDS_Face& aF1 = TopoDS::Face (aMFaces.FindKey (Min (aPair.ID1, aPair.ID2)));
|
||||||
// intersect faces
|
const TopoDS_Face& aF2 = TopoDS::Face (aMFaces.FindKey (Max (aPair.ID1, aPair.ID2)));
|
||||||
FaceInter(aF1, aF2, InitOffsetFace);
|
|
||||||
}
|
// intersect faces
|
||||||
|
FaceInter(aF1, aF2, InitOffsetFace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : FaceInter
|
//function : FaceInter
|
||||||
//purpose : Performs intersection of the given faces
|
//purpose : Performs intersection of the given faces
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
#include <Bnd_BoundSortBox.hxx>
|
#include <Bnd_BoundSortBox.hxx>
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <Bnd_HArray1OfBox.hxx>
|
#include <Bnd_HArray1OfBox.hxx>
|
||||||
|
#include <Bnd_Tools.hxx>
|
||||||
|
#include <BVH_BoxSet.hxx>
|
||||||
|
#include <BVH_LinearBuilder.hxx>
|
||||||
|
#include <BVH_Traverse.hxx>
|
||||||
#include <gp.hxx>
|
#include <gp.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <IntPolyh_ListOfCouples.hxx>
|
#include <IntPolyh_ListOfCouples.hxx>
|
||||||
@ -42,16 +46,14 @@
|
|||||||
#include <TColStd_Array1OfInteger.hxx>
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
#include <TColStd_MapOfInteger.hxx>
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
#include <NCollection_UBTree.hxx>
|
|
||||||
#include <NCollection_UBTreeFiller.hxx>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <NCollection_IndexedDataMap.hxx>
|
#include <NCollection_IndexedDataMap.hxx>
|
||||||
|
|
||||||
typedef NCollection_Array1<Standard_Integer> IntPolyh_ArrayOfInteger;
|
typedef NCollection_Array1<Standard_Integer> IntPolyh_ArrayOfInteger;
|
||||||
typedef NCollection_IndexedDataMap
|
typedef NCollection_IndexedDataMap
|
||||||
<Standard_Integer,
|
<Standard_Integer,
|
||||||
IntPolyh_ArrayOfInteger,
|
TColStd_ListOfInteger,
|
||||||
TColStd_MapIntegerHasher> IntPolyh_IndexedDataMapOfIntegerArrayOfInteger;
|
TColStd_MapIntegerHasher> IntPolyh_IndexedDataMapOfIntegerListOfInteger;
|
||||||
|
|
||||||
|
|
||||||
static Standard_Real MyTolerance=10.0e-7;
|
static Standard_Real MyTolerance=10.0e-7;
|
||||||
@ -133,32 +135,82 @@ static
|
|||||||
Standard_Integer& aI2);
|
Standard_Integer& aI2);
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//class : IntPolyh_BoxBndTreeSelector
|
//class : IntPolyh_BoxBndTree
|
||||||
//purpose : Select interfering bounding boxes
|
//purpose : BVH structure to contain the boxes of triangles
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
typedef NCollection_UBTree<Standard_Integer, Bnd_Box> IntPolyh_BoxBndTree;
|
typedef BVH_BoxSet <Standard_Real, 3, Standard_Integer> IntPolyh_BoxBndTree;
|
||||||
class IntPolyh_BoxBndTreeSelector : public IntPolyh_BoxBndTree::Selector {
|
|
||||||
public:
|
//=======================================================================
|
||||||
IntPolyh_BoxBndTreeSelector(const Bnd_Box& theBox) : myBox(theBox) {}
|
//class : IntPolyh_BoxBndTreeSelector
|
||||||
//
|
//purpose : Selector of interfering boxes
|
||||||
virtual Standard_Boolean Reject(const Bnd_Box& theOther) const
|
//=======================================================================
|
||||||
|
class IntPolyh_BoxBndTreeSelector :
|
||||||
|
public BVH_PairTraverse<Standard_Real, 3, IntPolyh_BoxBndTree>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef BVH_Box<Standard_Real, 3>::BVH_VecNt BVH_Vec3d;
|
||||||
|
|
||||||
|
//! Auxiliary structure to keep the pair of indices
|
||||||
|
struct PairIDs
|
||||||
{
|
{
|
||||||
return myBox.IsOut(theOther);
|
PairIDs (const Standard_Integer theId1 = -1,
|
||||||
}
|
const Standard_Integer theId2 = -1)
|
||||||
//
|
: ID1 (theId1), ID2 (theId2)
|
||||||
virtual Standard_Boolean Accept(const Standard_Integer &theInd)
|
{}
|
||||||
|
|
||||||
|
Standard_Boolean operator< (const PairIDs& theOther) const
|
||||||
|
{
|
||||||
|
return ID1 < theOther.ID1 ||
|
||||||
|
(ID1 == theOther.ID1 && ID2 < theOther.ID2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer ID1;
|
||||||
|
Standard_Integer ID2;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
IntPolyh_BoxBndTreeSelector ()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! Rejects the node
|
||||||
|
virtual Standard_Boolean RejectNode (const BVH_Vec3d& theCMin1,
|
||||||
|
const BVH_Vec3d& theCMax1,
|
||||||
|
const BVH_Vec3d& theCMin2,
|
||||||
|
const BVH_Vec3d& theCMax2,
|
||||||
|
Standard_Real&) const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
myIndices.Append(theInd);
|
return BVH_Box<Standard_Real, 3> (theCMin1, theCMax1).IsOut (theCMin2, theCMax2);
|
||||||
return Standard_True;
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
const TColStd_ListOfInteger& Indices() const
|
//! Accepts the element
|
||||||
|
virtual Standard_Boolean Accept (const Standard_Integer theID1,
|
||||||
|
const Standard_Integer theID2) Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
return myIndices;
|
if (!myBVHSet1->Box (theID1).IsOut (myBVHSet2->Box (theID2)))
|
||||||
|
{
|
||||||
|
myPairs.push_back (PairIDs (myBVHSet1->Element (theID1), myBVHSet2->Element (theID2)));
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
Bnd_Box myBox;
|
//! Returns indices
|
||||||
TColStd_ListOfInteger myIndices;
|
const std::vector<PairIDs>& Pairs() const
|
||||||
|
{
|
||||||
|
return myPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sorts the resulting indices
|
||||||
|
void Sort()
|
||||||
|
{
|
||||||
|
std::sort (myPairs.begin(), myPairs.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<PairIDs> myPairs;
|
||||||
};
|
};
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -170,59 +222,57 @@ static
|
|||||||
const IntPolyh_ArrayOfPoints& thePoints1,
|
const IntPolyh_ArrayOfPoints& thePoints1,
|
||||||
IntPolyh_ArrayOfTriangles& theTriangles2,
|
IntPolyh_ArrayOfTriangles& theTriangles2,
|
||||||
const IntPolyh_ArrayOfPoints& thePoints2,
|
const IntPolyh_ArrayOfPoints& thePoints2,
|
||||||
IntPolyh_IndexedDataMapOfIntegerArrayOfInteger& theCouples)
|
IntPolyh_IndexedDataMapOfIntegerListOfInteger& theCouples)
|
||||||
{
|
{
|
||||||
// To find the triangles with interfering bounding boxes
|
// Use linear builder for BVH construction
|
||||||
// use the algorithm of unbalanced binary tree of overlapping bounding boxes
|
opencascade::handle<BVH_LinearBuilder<Standard_Real, 3>> aLBuilder =
|
||||||
IntPolyh_BoxBndTree aBBTree;
|
new BVH_LinearBuilder<Standard_Real, 3> (10);
|
||||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
|
||||||
// 1. Fill the tree with the boxes of the triangles from second surface
|
|
||||||
Standard_Integer i, aNbT2 = theTriangles2.NbItems();
|
|
||||||
Standard_Boolean bAdded = Standard_False;
|
|
||||||
for (i = 0; i < aNbT2; ++i) {
|
|
||||||
IntPolyh_Triangle& aT = theTriangles2[i];
|
|
||||||
if (!aT.IsIntersectionPossible() || aT.IsDegenerated()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const Bnd_Box& aBox = aT.BoundingBox(thePoints2);
|
|
||||||
aTreeFiller.Add(i, aBox);
|
|
||||||
bAdded = Standard_True;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (!bAdded)
|
|
||||||
// Intersection is not possible for all triangles in theTriangles2
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 2. Shake the tree filler
|
// To find the triangles with interfering bounding boxes
|
||||||
aTreeFiller.Fill();
|
// use the BVH structure
|
||||||
//
|
IntPolyh_BoxBndTree aBBTree1 (aLBuilder), aBBTree2 (aLBuilder);
|
||||||
// 3. Find boxes interfering with the first triangles
|
|
||||||
Standard_Integer aNbT1 = theTriangles1.NbItems();
|
// 1. Fill the trees with the boxes of the surfaces triangles
|
||||||
for (i = 0; i < aNbT1; ++i) {
|
for (Standard_Integer i = 0; i < 2; ++i)
|
||||||
IntPolyh_Triangle& aT = theTriangles1[i];
|
{
|
||||||
if (!aT.IsIntersectionPossible() || aT.IsDegenerated()) {
|
IntPolyh_BoxBndTree &aBBTree = !i ? aBBTree1 : aBBTree2;
|
||||||
continue;
|
IntPolyh_ArrayOfTriangles& aTriangles = !i ? theTriangles1 : theTriangles2;
|
||||||
|
const IntPolyh_ArrayOfPoints& aPoints = !i ? thePoints1 : thePoints2;
|
||||||
|
|
||||||
|
const Standard_Integer aNbT = aTriangles.NbItems();
|
||||||
|
aBBTree.SetSize (aNbT);
|
||||||
|
for (Standard_Integer j = 0; j < aNbT; ++j)
|
||||||
|
{
|
||||||
|
IntPolyh_Triangle& aT = aTriangles[j];
|
||||||
|
if (!aT.IsIntersectionPossible() || aT.IsDegenerated())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
aBBTree.Add (j, Bnd_Tools::Bnd2BVH (aT.BoundingBox(aPoints)));
|
||||||
}
|
}
|
||||||
//
|
|
||||||
const Bnd_Box& aBox = aT.BoundingBox(thePoints1);
|
if (!aBBTree.Size())
|
||||||
//
|
return;
|
||||||
IntPolyh_BoxBndTreeSelector aSelector(aBox);
|
}
|
||||||
if (!aBBTree.Select(aSelector)) {
|
// 2. Construct BVH trees
|
||||||
continue;
|
aBBTree1.Build();
|
||||||
}
|
aBBTree2.Build();
|
||||||
//
|
|
||||||
const TColStd_ListOfInteger& aLI = aSelector.Indices();
|
// 3. Perform selection of the interfering triangles
|
||||||
// Sort the indices
|
IntPolyh_BoxBndTreeSelector aSelector;
|
||||||
IntPolyh_ArrayOfInteger anArr(1, aLI.Extent());
|
aSelector.SetBVHSets (&aBBTree1, &aBBTree2);
|
||||||
TColStd_ListIteratorOfListOfInteger aItLI(aLI);
|
aSelector.Select();
|
||||||
for (Standard_Integer j = 1; aItLI.More(); aItLI.Next(), ++j) {
|
aSelector.Sort();
|
||||||
anArr(j) = aItLI.Value();
|
|
||||||
}
|
const std::vector<IntPolyh_BoxBndTreeSelector::PairIDs>& aPairs = aSelector.Pairs();
|
||||||
//
|
const Standard_Integer aNbPairs = static_cast<Standard_Integer>(aPairs.size());
|
||||||
std::sort(anArr.begin(), anArr.end());
|
|
||||||
//
|
for (Standard_Integer i = 0; i < aNbPairs; ++i)
|
||||||
theCouples.Add(i, anArr);
|
{
|
||||||
|
const IntPolyh_BoxBndTreeSelector::PairIDs& aPair = aPairs[i];
|
||||||
|
TColStd_ListOfInteger* pTriangles2 = theCouples.ChangeSeek (aPair.ID1);
|
||||||
|
if (!pTriangles2)
|
||||||
|
pTriangles2 = &theCouples( theCouples.Add (aPair.ID1, TColStd_ListOfInteger()));
|
||||||
|
pTriangles2->Append (aPair.ID2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +971,7 @@ static
|
|||||||
const Standard_Real theFlecheCritique2)
|
const Standard_Real theFlecheCritique2)
|
||||||
{
|
{
|
||||||
// Find the intersecting triangles
|
// Find the intersecting triangles
|
||||||
IntPolyh_IndexedDataMapOfIntegerArrayOfInteger aDMILI;
|
IntPolyh_IndexedDataMapOfIntegerListOfInteger aDMILI;
|
||||||
GetInterferingTriangles(theTriangles1, thePoints1, theTriangles2, thePoints2, aDMILI);
|
GetInterferingTriangles(theTriangles1, thePoints1, theTriangles2, thePoints2, aDMILI);
|
||||||
//
|
//
|
||||||
// Interfering triangles of second surface
|
// Interfering triangles of second surface
|
||||||
@ -938,8 +988,8 @@ static
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
const IntPolyh_ArrayOfInteger *pLI = aDMILI.Seek(i_S1);
|
const TColStd_ListOfInteger *pLI = aDMILI.Seek(i_S1);
|
||||||
if (!pLI || !pLI->Length()) {
|
if (!pLI || pLI->IsEmpty()) {
|
||||||
// Mark non-interfering triangles of S1 to avoid their repeated usage
|
// Mark non-interfering triangles of S1 to avoid their repeated usage
|
||||||
aTriangle1.SetIntersectionPossible(Standard_False);
|
aTriangle1.SetIntersectionPossible(Standard_False);
|
||||||
continue;
|
continue;
|
||||||
@ -949,7 +999,7 @@ static
|
|||||||
aTriangle1.MiddleRefinement(i_S1, theS1, thePoints1, theTriangles1, theEdges1);
|
aTriangle1.MiddleRefinement(i_S1, theS1, thePoints1, theTriangles1, theEdges1);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
IntPolyh_ArrayOfInteger::Iterator Iter(*pLI);
|
TColStd_ListOfInteger::Iterator Iter(*pLI);
|
||||||
for (; Iter.More(); Iter.Next()) {
|
for (; Iter.More(); Iter.Next()) {
|
||||||
Standard_Integer i_S2 = Iter.Value();
|
Standard_Integer i_S2 = Iter.Value();
|
||||||
if (aMIntS2.Add(i_S2)) {
|
if (aMIntS2.Add(i_S2)) {
|
||||||
@ -2295,7 +2345,7 @@ Standard_Integer IntPolyh_MaillageAffinage::TriangleEdgeContact
|
|||||||
Standard_Integer IntPolyh_MaillageAffinage::TriangleCompare ()
|
Standard_Integer IntPolyh_MaillageAffinage::TriangleCompare ()
|
||||||
{
|
{
|
||||||
// Find couples with interfering bounding boxes
|
// Find couples with interfering bounding boxes
|
||||||
IntPolyh_IndexedDataMapOfIntegerArrayOfInteger aDMILI;
|
IntPolyh_IndexedDataMapOfIntegerListOfInteger aDMILI;
|
||||||
GetInterferingTriangles(TTriangles1, TPoints1,
|
GetInterferingTriangles(TTriangles1, TPoints1,
|
||||||
TTriangles2, TPoints2,
|
TTriangles2, TPoints2,
|
||||||
aDMILI);
|
aDMILI);
|
||||||
@ -2314,8 +2364,8 @@ Standard_Integer IntPolyh_MaillageAffinage::TriangleCompare ()
|
|||||||
const IntPolyh_Point& P2 = TPoints1[Triangle1.SecondPoint()];
|
const IntPolyh_Point& P2 = TPoints1[Triangle1.SecondPoint()];
|
||||||
const IntPolyh_Point& P3 = TPoints1[Triangle1.ThirdPoint()];
|
const IntPolyh_Point& P3 = TPoints1[Triangle1.ThirdPoint()];
|
||||||
//
|
//
|
||||||
const IntPolyh_ArrayOfInteger& aLI2 = aDMILI(i);
|
const TColStd_ListOfInteger& aLI2 = aDMILI(i);
|
||||||
IntPolyh_ArrayOfInteger::Iterator aItLI(aLI2);
|
TColStd_ListOfInteger::Iterator aItLI(aLI2);
|
||||||
for (; aItLI.More(); aItLI.Next()) {
|
for (; aItLI.More(); aItLI.Next()) {
|
||||||
const Standard_Integer i_S2 = aItLI.Value();
|
const Standard_Integer i_S2 = aItLI.Value();
|
||||||
IntPolyh_Triangle &Triangle2 = TTriangles2[i_S2];
|
IntPolyh_Triangle &Triangle2 = TTriangles2[i_S2];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user