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

0029312: Using OBB to speed up Boolean Operations

1. Implementation of the user-defined option for usage of Oriented Bounding Boxes (OBB) in Boolean Operations for additional filtering (rejection) of selected for intersection pairs of sub-shapes.

By default the usage of OBB is turned off.
To enable/disable its usage the method SetUseOBB(flag) should be used. This method is available for all operations in Boolean Component.
To enable/disable it in draw the command "buseobb 0/1" should be used. Note, that this will affect all subsequent operations.

The OBB for the shapes are built by first necessity and stored into operation context (IntTools_Context).

2. Usage of the OBB in some test cases.
This commit is contained in:
emv
2017-11-01 11:30:30 +03:00
committed by bugmaster
parent 1a0339b464
commit 944768d277
34 changed files with 432 additions and 330 deletions

View File

@@ -14,6 +14,7 @@
#include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
@@ -65,6 +66,7 @@ IntTools_Context::IntTools_Context()
myProjSDataMap(100, myAllocator),
myBndBoxDataMap(100, myAllocator),
mySurfAdaptorMap(100, myAllocator),
myOBBMap(100, myAllocator),
myCreateFlag(0),
myPOnSTolerance(1.e-12)
{
@@ -86,6 +88,7 @@ IntTools_Context::IntTools_Context
myProjSDataMap(100, myAllocator),
myBndBoxDataMap(100, myAllocator),
mySurfAdaptorMap(100, myAllocator),
myOBBMap(100, myAllocator),
myCreateFlag(1),
myPOnSTolerance(1.e-12)
{
@@ -183,6 +186,16 @@ IntTools_Context::~IntTools_Context()
myAllocator->Free(anAdr);
}
mySurfAdaptorMap.Clear();
//
Bnd_OBB* pOBB;
aIt.Initialize(myOBBMap);
for (; aIt.More(); aIt.Next()) {
anAdr=aIt.Value();
pOBB=(Bnd_OBB*)anAdr;
(*pOBB).~Bnd_OBB();
myAllocator->Free(anAdr);
}
myOBBMap.Clear();
}
//=======================================================================
//function : BndBox
@@ -472,6 +485,36 @@ Geom2dHatch_Hatcher& IntTools_Context::Hatcher(const TopoDS_Face& aF)
return *pHatcher;
}
//=======================================================================
//function : OBB
//purpose :
//=======================================================================
Bnd_OBB& IntTools_Context::OBB(const TopoDS_Shape& aS,
const Standard_Real theGap)
{
Standard_Address anAdr;
Bnd_OBB* pBox;
//
if (!myOBBMap.IsBound(aS))
{
pBox = (Bnd_OBB*)myAllocator->Allocate(sizeof(Bnd_OBB));
new (pBox) Bnd_OBB();
//
Bnd_OBB &aBox = *pBox;
BRepBndLib::AddOBB(aS, aBox);
aBox.Enlarge(theGap);
//
anAdr = (Standard_Address)pBox;
myOBBMap.Bind(aS, anAdr);
}
else
{
anAdr = myOBBMap.Find(aS);
pBox = (Bnd_OBB*)anAdr;
}
return *pBox;
}
//=======================================================================
//function : SurfaceData
//purpose :

View File

@@ -45,6 +45,7 @@ class gp_Pnt2d;
class IntTools_Curve;
class Bnd_Box;
class TopoDS_Shape;
class Bnd_OBB;
//! The intersection Context contains geometrical
//! and topological toolkit (classifiers, projectors, etc).
@@ -98,6 +99,11 @@ Standard_EXPORT virtual ~IntTools_Context();
//! Returns a reference to surface adaptor for given face
Standard_EXPORT BRepAdaptor_Surface& SurfaceAdaptor (const TopoDS_Face& theFace);
//! Builds and stores an Oriented Bounding Box for the shape.
//! Returns a reference to OBB.
Standard_EXPORT Bnd_OBB& OBB(const TopoDS_Shape& theShape,
const Standard_Real theFuzzyValue = Precision::Confusion());
//! Computes the boundaries of the face using surface adaptor
Standard_EXPORT void UVBounds (const TopoDS_Face& theFace,
Standard_Real& UMin,
@@ -256,6 +262,7 @@ protected:
DataMapOfShapeAddress myProjSDataMap;
DataMapOfShapeAddress myBndBoxDataMap;
DataMapOfShapeAddress mySurfAdaptorMap;
DataMapOfShapeAddress myOBBMap; // Map of oriented bounding boxes
Standard_Integer myCreateFlag;
Standard_Real myPOnSTolerance;