1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +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

@@ -126,6 +126,7 @@ Standard_Integer bapibop(Draw_Interpretor& di,
pBuilder->SetNonDestructive(bNonDestructive);
pBuilder->SetGlue(aGlue);
pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
pBuilder->SetUseOBB(BOPTest_Objects::UseOBB());
//
pBuilder->Build();
//
@@ -184,6 +185,7 @@ Standard_Integer bapibuild(Draw_Interpretor& di,
aBuilder.SetNonDestructive(bNonDestructive);
aBuilder.SetGlue(aGlue);
aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBuilder.SetUseOBB(BOPTest_Objects::UseOBB());
//
aBuilder.Build();
//
@@ -234,6 +236,7 @@ Standard_Integer bapisplit(Draw_Interpretor& di,
aSplitter.SetNonDestructive(BOPTest_Objects::NonDestructive());
aSplitter.SetGlue(BOPTest_Objects::Glue());
aSplitter.SetCheckInverted(BOPTest_Objects::CheckInverted());
aSplitter.SetUseOBB(BOPTest_Objects::UseOBB());
//
// performing operation
aSplitter.Build();

View File

@@ -158,6 +158,7 @@ Standard_Integer bop(Draw_Interpretor& di,
pPF->SetRunParallel(bRunParallel);
pPF->SetNonDestructive(bNonDestructive);
pPF->SetGlue(aGlue);
pPF->SetUseOBB(BOPTest_Objects::UseOBB());
//
pPF->Perform();
BOPTest::ReportAlerts(*pPF);
@@ -427,6 +428,7 @@ Standard_Integer bsection(Draw_Interpretor& di,
aSec.SetRunParallel(bRunParallel);
aSec.SetNonDestructive(bNonDestructive);
aSec.SetGlue(aGlue);
aSec.SetUseOBB(BOPTest_Objects::UseOBB());
//
aSec.Build();
//
@@ -496,6 +498,7 @@ Standard_Integer bsmt (Draw_Interpretor& di,
aPF.SetRunParallel(bRunParallel);
aPF.SetNonDestructive(bNonDestructive);
aPF.SetGlue(aGlue);
aPF.SetUseOBB(BOPTest_Objects::UseOBB());
//
aPF.Perform();
BOPTest::ReportAlerts(aPF);
@@ -818,6 +821,7 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
aMV.SetNonDestructive(bNonDestructive);
aMV.SetAvoidInternalShapes(bAvoidInternal);
aMV.SetGlue(aGlue);
aMV.SetUseOBB(BOPTest_Objects::UseOBB());
//
aMV.Perform();
BOPTest::ReportAlerts(aMV);

View File

@@ -112,6 +112,7 @@ Standard_Integer bcbuild(Draw_Interpretor& di,
aCBuilder.SetNonDestructive(bNonDestructive);
aCBuilder.SetGlue(aGlue);
aCBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aCBuilder.SetUseOBB(BOPTest_Objects::UseOBB());
//
aCBuilder.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aCBuilder);

View File

@@ -40,6 +40,7 @@
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <IntTools_Context.hxx>
static
void GetTypeByName(const char* theName,
@@ -239,9 +240,11 @@ Standard_Integer bopiterator (Draw_Interpretor& di,
char buf[64], aST1[10], aST2[10];
BOPDS_Iterator aIt;
//
Handle(IntTools_Context) aCtx = new IntTools_Context();
BOPDS_DS& aDS = *pDS;
aIt.SetDS(&aDS);
aIt.Prepare();
aIt.Prepare(aCtx, BOPTest_Objects::UseOBB(), BOPTest_Objects::FuzzyValue());
//
if (n == 1) {
// type has not been defined. show all pairs

View File

@@ -21,6 +21,7 @@
#include <BOPAlgo_CellsBuilder.hxx>
#include <BOPAlgo_Splitter.hxx>
#include <NCollection_BaseAllocator.hxx>
#include <Precision.hxx>
static Handle(NCollection_BaseAllocator)& Allocator1();
@@ -52,10 +53,11 @@ class BOPTest_Session {
myBuilder=myBuilderDefault;
myRunParallel=Standard_False;
myNonDestructive = Standard_False;
myFuzzyValue = 0.;
myFuzzyValue = Precision::Confusion();
myGlue = BOPAlgo_GlueOff;
myDrawWarnShapes = Standard_False;
myCheckInverted = Standard_True;
myUseOBB = Standard_False;
};
//
// Clear
@@ -151,6 +153,13 @@ class BOPTest_Session {
return myCheckInverted;
};
//
void SetUseOBB(const Standard_Boolean bUse) {
myUseOBB = bUse;
};
//
Standard_Boolean UseOBB() const {
return myUseOBB;
};
protected:
//
BOPTest_Session(const BOPTest_Session&);
@@ -170,6 +179,7 @@ protected:
BOPAlgo_GlueEnum myGlue;
Standard_Boolean myDrawWarnShapes;
Standard_Boolean myCheckInverted;
Standard_Boolean myUseOBB;
};
//
//=======================================================================
@@ -396,6 +406,22 @@ Standard_Boolean BOPTest_Objects::CheckInverted()
return GetSession().CheckInverted();
}
//=======================================================================
//function : SetUseOBB
//purpose :
//=======================================================================
void BOPTest_Objects::SetUseOBB(const Standard_Boolean bUseOBB)
{
GetSession().SetUseOBB(bUseOBB);
}
//=======================================================================
//function : UseOBB
//purpose :
//=======================================================================
Standard_Boolean BOPTest_Objects::UseOBB()
{
return GetSession().UseOBB();
}
//=======================================================================
//function : Allocator1
//purpose :
//=======================================================================

View File

@@ -91,6 +91,10 @@ public:
Standard_EXPORT static Standard_Boolean CheckInverted();
Standard_EXPORT static void SetUseOBB(const Standard_Boolean bUseOBB);
Standard_EXPORT static Standard_Boolean UseOBB();
protected:
private:

View File

@@ -28,6 +28,7 @@ static Standard_Integer bfuzzyvalue(Draw_Interpretor&, Standard_Integer, const c
static Standard_Integer bGlue(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bdrawwarnshapes(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bcheckinverted(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer buseobb(Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : OptionCommands
@@ -51,6 +52,8 @@ void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
__FILE__, bdrawwarnshapes, g);
theCommands.Add("bcheckinverted", "Defines whether to check the input solids on inverted status or not\n"
"Usage: bcheckinverted [0 (off) / 1 (on)]", __FILE__, bcheckinverted, g);
theCommands.Add("buseobb", "Enables/disables the usage of OBB\n"
"Usage: buseobb [0 (off) / 1 (on)]", __FILE__, buseobb, g);
}
//=======================================================================
//function : boptions
@@ -76,6 +79,7 @@ Standard_Integer boptions(Draw_Interpretor& di,
aGlue = BOPTest_Objects::Glue();
Standard_Boolean bDrawWarnShapes = BOPTest_Objects::DrawWarnShapes();
Standard_Boolean bCheckInverted = BOPTest_Objects::CheckInverted();
Standard_Boolean bUseOBB = BOPTest_Objects::UseOBB();
//
Sprintf(buf, " RunParallel: %d\n", bRunParallel);
di << buf;
@@ -90,6 +94,8 @@ Standard_Integer boptions(Draw_Interpretor& di,
di << buf;
Sprintf(buf, " Check for inverted solids: %s\n", bCheckInverted ? "Yes" : "No");
di << buf;
Sprintf(buf, " Use OBB: %s\n", bUseOBB ? "Yes" : "No");
di << buf;
//
return 0;
}
@@ -233,3 +239,22 @@ Standard_Integer bcheckinverted(Draw_Interpretor& di,
BOPTest_Objects::SetCheckInverted(iCheck != 0);
return 0;
}
//=======================================================================
//function : buseobb
//purpose :
//=======================================================================
Standard_Integer buseobb(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iUse = Draw::Atoi(a[1]);
BOPTest_Objects::SetUseOBB(iUse != 0);
return 0;
}

View File

@@ -115,6 +115,7 @@ Standard_Integer bfillds(Draw_Interpretor& di,
aPF.SetNonDestructive(bNonDestructive);
aPF.SetFuzzyValue(aTol);
aPF.SetGlue(aGlue);
aPF.SetUseOBB(BOPTest_Objects::UseOBB());
//
OSD_Timer aTimer;
aTimer.Start();