]> OCCT Git - occt-copy.git/commitdiff
0029312: Using OBB to speed up Boolean Operations
authoremv <emv@opencascade.com>
Wed, 1 Nov 2017 08:30:30 +0000 (11:30 +0300)
committeremv <emv@opencascade.com>
Fri, 29 Jun 2018 10:55:26 +0000 (13:55 +0300)
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.

34 files changed:
dox/user_guides/boolean_operations/boolean_operations.md
src/BOPAlgo/BOPAlgo_BOP.cxx
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_CheckerSI.cxx
src/BOPAlgo/BOPAlgo_MakerVolume.cxx
src/BOPAlgo/BOPAlgo_Options.cxx
src/BOPAlgo/BOPAlgo_Options.hxx
src/BOPAlgo/BOPAlgo_PaveFiller.cxx
src/BOPAlgo/BOPAlgo_Splitter.cxx
src/BOPDS/BOPDS_Iterator.cxx
src/BOPDS/BOPDS_Iterator.hxx
src/BOPDS/BOPDS_IteratorSI.cxx
src/BOPDS/BOPDS_IteratorSI.hxx
src/BOPTest/BOPTest_APICommands.cxx
src/BOPTest/BOPTest_BOPCommands.cxx
src/BOPTest/BOPTest_CellsCommands.cxx
src/BOPTest/BOPTest_DebugCommands.cxx
src/BOPTest/BOPTest_Objects.cxx
src/BOPTest/BOPTest_Objects.hxx
src/BOPTest/BOPTest_OptionCommands.cxx
src/BOPTest/BOPTest_PartitionCommands.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Algo.hxx
src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx
src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx
src/IntTools/IntTools_Context.cxx
src/IntTools/IntTools_Context.hxx
tests/perf/modalg/bug24751_1
tests/perf/modalg/bug24751_2
tests/perf/modalg/bug24751_3
tests/perf/modalg/bug24751_4
tests/perf/modalg/bug24751_5
tests/perf/modalg/bug29237_2
tests/perf/modalg/bug29237_3

index f76693658b044785ec4dd979ea4c90f807c176dc..992faf4390e78944e66bbe44320a499989932e57 100644 (file)
@@ -548,7 +548,8 @@ The class *BOPAlgo_Options* provides the following options for the algorithms:
 * Check the presence of the Errors and Warnings;
 * Turn on/off the parallel processing;
 * Set the additional tolerance for the operation;
-* Break the operations by user request.
+* Break the operations by user request;
+* Usage of Oriented Bounding boxes in the operation.
 
 @subsection occt_algorithms_root_classes_2 Class BOPAlgo_Algo
 
@@ -785,6 +786,118 @@ The types of resulting shapes depend on the type of the corresponding argument p
 | 7    | EDGE  | Set of split EDGEs    | |
 | 8    | VERTEX | VERTEX | |
 
+@subsection occt_algorithms_7_3a Options
+
+The General Fuse algorithm has a set of options, which allow speeding-up the operation and improving the quality of the result:
+* Parallel processing option allows running the algorithm in parallel mode;
+* Fuzzy option allows setting the additional tolerance for the operation;
+* Safe input shapes option allows preventing modification of the input shapes;
+* Gluing option allows speeding-up the intersection of the arguments;
+* Possibility to disable the check for the inverted solids among input shapes;
+* Usage of Oriented Bounding Boxes in the operation;
+* History support.
+
+For more detailed information on these options please see the @ref occt_algorithms_11a "Advanced options" section.
+
+@subsection occt_algorithms_7_3b Usage
+
+The following example illustrates how to use the GF algorithm:
+
+#### Usage of the GF algorithm on C++ level
+
+~~~~
+BOPAlgo_Builder aBuilder;
+// Setting arguments
+TopTools_ListOfShape aLSObjects = …; // Objects
+aBuilder.SetArguments(aLSObjects);
+
+// Setting options for GF
+
+// Set parallel processing mode (default is false)
+Standard_Boolean bRunParallel = Standard_True;
+aBuilder.SetRunParallel(bRunParallel);
+
+// Set Fuzzy value (default is Precision::Confusion())
+Standard_Real aFuzzyValue = 1.e-5;
+aBuilder.SetFuzzyValue(aFuzzyValue);
+
+// Set safe processing mode (default is false)
+Standard_Boolean bSafeMode = Standard_True;
+aBuilder.SetNonDestructive(bSafeMode);
+
+// Set Gluing mode for coinciding arguments (default is off)
+BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueShift;
+aBuilder.SetGlue(aGlue);
+
+// Disabling/Enabling the check for inverted solids (default is true)
+Standard Boolean bCheckInverted = Standard_False;
+aBuilder.SetCheckInverted(bCheckInverted);
+
+// Set OBB usage (default is false)
+Standard_Boolean bUseOBB = Standard_True;
+aBuilder.SetUseOBB(buseobb);
+
+// Perform the operation
+aBuilder.Perform();
+
+// Check for the errors
+if (aBuilder.HasErrors())
+{
+  return;
+}
+
+// Check for the warnings
+if (aBuilder.HasWarnings())
+{
+  // treatment of the warnings
+  ...
+}
+
+// result of the operation
+const TopoDS_Shape& aResult = aBuilder.Shape();
+~~~~
+
+#### Usage of the GF algorithm on Tcl level
+
+~~~~
+# prepare the arguments
+box b1 10 10 10 
+box b2 3 4 5 10 10 10 
+box b3 5 6 7 10 10 10 
+
+# clear inner contents
+bclearobjects; bcleartools;
+
+# set the arguments
+baddobjects b1 b2 b3
+
+# setting options for GF
+
+# set parallel processing mode (default is 0)
+brunparallel 1
+
+# set Fuzzy value
+bfuzzyvalue 1.e-5
+
+# set safe processing mode (default is 0)
+bnondestructive 1
+
+# set gluing mode (default is 0)
+bglue 1
+
+# set check for inverted (default is 1)
+bcheckinverted 0
+
+# set obb usage (default is 0)
+buseobb 1
+
+# perform intersection
+bfillds
+
+# perform GF operaton
+bbuild result
+~~~~
+
 @subsection occt_algorithms_7_3 Examples
 
 Please, have a look at the examples, which can help to better understand the definitions.
@@ -1061,7 +1174,7 @@ The input data for this step is a *BOPAlgo_Builder* object after building result
 @section occt_algorithms_8  Splitter Algorithm
 
 The Splitter algorithm allows splitting a group of arbitrary shapes by another group of arbitrary shapes.<br>
-It is based on the General Fuse  algorithm, thus all options of the General Fuse such as Fuzzy mode, safe processing mode, parallel mode, gluing mode and history support are also available in this algorithm.
+It is based on the General Fuse  algorithm, thus all options of the General Fuse (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
 
 @subsection occt_algorithms_8_1 Arguments
 
@@ -1082,22 +1195,18 @@ It is based on the General Fuse  algorithm, thus all options of the General Fuse
 On the low level the Splitter algorithm is implemented in class *BOPAlgo_Splitter*. The usage of this algorithm looks as follows:
 ~~~~~
 BOPAlgo_Splitter aSplitter;
-BOPCol_ListOfShape aLSObjects = …; // Objects
-BOPCol_ListOfShape aLSTools = …; // Tools
-Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
-Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
-Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
-BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
-// setting arguments
+// Setting arguments and tools
+TopTools_ListOfShape aLSObjects = …; // Objects
+TopTools_ListOfShape aLSTools = …; // Tools
 aSplitter.SetArguments(aLSObjects);
 aSplitter.SetTools(aLSTools);
-// setting options
-aSplitter.SetRunParallel(bRunParallel);
-aSplitter.SetFuzzyValue(aTol);
-aSplitter.SetNonDestructive(bSafeMode);
-aSplitter.SetGlue(aGlue);
-//
-aSplitter.Perform(); //perform the operation
+
+// Set options for the algorithm
+// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+...
+
+// Perform the operation
+aSplitter.Perform();
 if (aSplitter.HasErrors()) { //check error status
   return;
 }
@@ -2041,7 +2150,7 @@ The algorithm creates only closed solids. In general case the result solids are
 But the algorithm allows preventing the addition of the internal for solids parts into result. In this case the result solids will be manifold and not contain any internal parts. However, this option does not prevent from the occurrence of the internal edges or vertices in the faces.<br>
 Non-closed faces, free wires etc. located outside of any solid are always excluded from the result.
 
-The Volume Maker algorithm is implemented in the class BOPAlgo_MakerVolume. It is based on the General Fuse (GF) algorithm. All the options of the GF algorithm such as possibility to run algorithm in parallel mode, fuzzy option, safe mode, glue options and history support are also available in this algorithm.
+The Volume Maker algorithm is implemented in the class BOPAlgo_MakerVolume. It is based on the General Fuse (GF) algorithm. All the options of the GF algorithm (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
 
 The requirements for the arguments are the same as for the arguments of GF algorithm - they could be of any type, but each argument should be valid and not self-interfered.
 
@@ -2054,23 +2163,19 @@ This option is useful e.g. for building a solid from the faces of one shell or f
 The usage of the algorithm on the API level:
 ~~~~
 BOPAlgo_MakerVolume aMV;
-BOPCol_ListOfShape aLS = …; // arguments
-Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
-Standard_Boolean bIntersect = Standard_True; /* intersect or not the arguments (the default value is TRUE)*/
-Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
-Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
-BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
-Standard_Boolean bAvoidInternalShapes = Standard_False; /* Avoid or not the internal for solids shapes in the result*/
-//
+// Set the arguments
+TopTools_ListOfShape aLS = …; // arguments
 aMV.SetArguments(aLS);
-aMV.SetRunParallel(bRunParallel);
-aMV.SetIntersect(bIntersect);
-aMV.SetFuzzyValue(aTol);
-aMV.SetNonDestructive(bSafeMode);
-aMV.SetGlue(aGlue);
+
+// Set options for the algorithm
+// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+...
+// Additional option of the algorithm
+Standard_Boolean bAvoidInternalShapes = Standard_False; /* Avoid or not the internal for solids shapes in the result*/
 aMV.SetAvoidInternalShapes(bAvoidInternalShapes);
-//
-aMV.Perform(); //perform the operation
+
+// Perform the operation
+aMV.Perform();
 if (aMV.HasErrors()) { //check error status
   return;
 }
@@ -2128,7 +2233,7 @@ The algorithm can also create containers from the connected Cells added into res
 
 The algorithm has been implemented in the *BOPAlgo_CellsBuilder* class.
 
-Cells Builder is based on the General Fuse algorithm. Thus all options of the General Fuse algorithm, such as parallel processing mode, fuzzy mode, safe processing mode, gluing mode and history support are also available in this algorithm.
+Cells Builder is based on the General Fuse algorithm. Thus all options of the General Fuse algorithm (see @ref occt_algorithms_7_3a "GF Options") are also available in this algorithm.
 
 The requirements for the input shapes are the same as for General Fuse - each argument should be valid in terms of *BRepCheck_Analyzer* and *BOPAlgo_ArgumentAnalyzer*.
 
@@ -2148,18 +2253,14 @@ It is possible to create typed Containers from the parts added into result by us
 Here is the example of the algorithm use on the API level:
 ~~~~
 BOPAlgo_CellsBuilder aCBuilder;
-BOPCol_ListOfShape aLS = …; // arguments
-Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
-Standard_Real aTol = 0.0; /* fuzzy option (the default value is 0)*/
-Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
-BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up the intersection of arguments*/
-//
+// Set the arguments
+TopTools_ListOfShape aLS = …; // arguments
 aCBuilder.SetArguments(aLS);
-aCBuilder.SetRunParallel(bRunParallel);
-aCBuilder.SetFuzzyValue(aTol);
-aCBuilder.SetNonDestructive(bSafeMode);
-aCBuilder.SetGlue(aGlue);
-//
+
+// Set options for the algorithm
+// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+...
+
 aCBuilder.Perform(); // build splits of all arguments (GF)
 if (aCBuilder.HasErrors()) { // check error status
   return;
@@ -2749,6 +2850,31 @@ To enable/disable the classification of the solids in DRAW, it is necessary to c
 bcheckinverted 0
 ~~~~
 
+@subsection occt_algorithms_11a_5_obb Usage of Oriented Bounding Boxes
+
+Since Oriented Bounding Boxes are usually much tighter than Axes Aligned Bounding Boxes (for more information on OBB please see the @ref occt_modat_6 "Bounding boxes" chapter of Modeling data User guide) its usage can significantly speed-up the intersection stage of the operation by reducing the number of interfering objects.
+
+@subsubsection occt_algorithms_11a_5_obb_1 Usage
+
+#### API level
+To enable/disable the usage of OBB in the operation it is necessary to call the *SetUseOBB()* method with the approriate value:
+~~~~
+BOPAlgo_Builder aGF;
+//
+....
+// Enabling the usage of OBB in the operation
+aGF.SetUseOBB(Standard_True);
+//
+....
+~~~~
+
+#### TCL level
+To enable/disable the usage of OBB in the operation in DRAW it is necessary to call the *buseobb* command with the approriate value: 
+* 0 - disabling the usage of OBB;
+* 1 - enabling the usage of OBB.
+~~~~
+buseobb 1
+~~~~
 
 @section occt_algorithms_ers Errors and warnings reporting system
 
@@ -2845,41 +2971,18 @@ The following example illustrates how to use General Fuse operator:
 #include <TopTools_ListOfShape.hxx>
 #include <BRepAlgoAPI_BuilderAlgo.hxx>
  {…
-  Standard_Boolean bRunParallel;
-  Standard_Real aFuzzyValue;
   BRepAlgoAPI_BuilderAlgo aBuilder;
   //
   // prepare the arguments
   TopTools_ListOfShape& aLS=…;
   //
-  bRunParallel=Standard_True;
-  aFuzzyValue=2.1e-5;
-  //
   // set the arguments 
   aBuilder.SetArguments(aLS);
-  // set parallel processing mode 
-  // if  bRunParallel= Standard_True :  the parallel processing is switched on
-  // if  bRunParallel= Standard_False :  the parallel processing is switched off
-  aBuilder.SetRunParallel(bRunParallel);
-  //
-  // set Fuzzy value
-  // if aFuzzyValue=0.: the Fuzzy option is off
-  //  if aFuzzyValue>0.: the Fuzzy option is on
-  aBuilder.SetFuzzyValue(aFuzzyValue);
-  //
-  // safe mode - avoid modification of the arguments
-  Standard_Boolean bSafeMode = Standard_True;
-  // if bSafeMode == Standard_True  - the safe mode is switched on
-  // if bSafeMode == Standard_False - the safe mode is switched off
-  aBuilder.SetNonDestructive(bSafeMode);
-  //
-  // gluing options - for coinciding arguments
-  BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-  // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-  // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-  // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-  aBuilder.SetGlue(aGlueOpt);
-  //
+  
+  // Set options for the algorithm
+  // setting options on this level is similar to setting options to GF algorithm on low level (see "GF Usage" chapter)
+  ...
+
   // run the algorithm 
   aBuilder.Build(); 
   if (aBuilder.HasErrors()) {
@@ -2906,28 +3009,10 @@ bclearobjects; bcleartools;
 #
 # set the arguments
 baddobjects b1 b2 b3
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1 
-#
-# set Fuzzy value
-# 0.    : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-#
-# set gluing mode
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
-#
+
+# set options for the algorithm (see "GF Usage" chapter)
+...
+
 # run the algorithm
 # r is the result of the operation
 bapibuild r 
@@ -2956,31 +3041,9 @@ TopTools_ListOfShape& aLSTools = … ;
 aSplitter.SetArguments(aLSObjects);
 aSplitter.SetTools(aLSTools);
 //
-// set options
-// parallel processing mode 
-Standard_Boolean bRunParallel = Standard_True;
-// bRunParallel == Standard_True  - the parallel processing is switched on
-// bRunParallel == Standard_False - the parallel processing is switched off
-aSplitter.SetRunParallel();
-//
-// fuzzy value - additional tolerance for the operation
-Standard_Real aFuzzyValue = 1.e-5;
-// if aFuzzyValue == 0. - the Fuzzy option is off
-// if aFuzzyValue > 0.  - the Fuzzy option is on
-aSplitter.SetFuzzyValue(aFuzzyValue);
-//
-// safe mode - avoid modification of the arguments
-Standard_Boolean bSafeMode = Standard_True;
-// if bSafeMode == Standard_True  - the safe mode is switched on
-// if bSafeMode == Standard_False - the safe mode is switched off
-aSplitter.SetNonDestructive(bSafeMode);
-//
-// gluing options - for coinciding arguments
-BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-// if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-// if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-// if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-aSplitter.SetGlue(aGlueOpt);
+// Set options for the algorithm
+// setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+...
 //
 // run the algorithm 
 aSplitter.Build(); 
@@ -3013,27 +3076,8 @@ baddobjects b1 b2
 # set the tools
 baddtools f
 #
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1 
-#
-# set Fuzzy value
-# 0.  : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-#
-# set gluing mode
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
+# set options for the algorithm (see "GF Usage" chapter)
+...
 #
 # run the algorithm
 # r is the result of the operation
@@ -3066,28 +3110,9 @@ The following example illustrates how to use Common operation:
   aBuilder.SetArguments(aLS);
   aBuilder.SetTools(aLT);
   //   
-  // set parallel processing mode 
-  // if  bRunParallel= Standard_True :  the parallel processing is switched on
-  // if  bRunParallel= Standard_False :  the parallel processing is switched off
-  aBuilder.SetRunParallel(bRunParallel);
-  //
-  // set Fuzzy value
-  // if aFuzzyValue=0.: the Fuzzy option is off
-  //  if aFuzzyValue>0.: the Fuzzy option is on
-  aBuilder.SetFuzzyValue(aFuzzyValue);
-  //
-  // safe mode - avoid modification of the arguments
-  Standard_Boolean bSafeMode = Standard_True;
-  // if bSafeMode == Standard_True  - the safe mode is switched on
-  // if bSafeMode == Standard_False - the safe mode is switched off
-  aBuilder.SetNonDestructive(bSafeMode);
-  //
-  // gluing options - for coinciding arguments
-  BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-  // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-  // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-  // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-  aBuilder.SetGlue(aGlueOpt);
+  // Set options for the algorithm
+  // setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+  ...
   //
   // run the algorithm 
   aBuilder.Build(); 
@@ -3117,27 +3142,8 @@ bclearobjects; bcleartools;
 baddobjects b1 b3
 baddtools b2
 #
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1
-#
-# set Fuzzy value
-# 0.    : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-#
-# set gluing mode
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
+# set options for the algorithm (see "GF Usage" chapter)
+...
 #
 # run the algorithm
 # r is the result of the operation
@@ -3171,28 +3177,9 @@ The following example illustrates how to use Fuse operation:
   aBuilder.SetArguments(aLS);
   aBuilder.SetTools(aLT);
   //   
-  // set parallel processing mode 
-  // if  bRunParallel= Standard_True :  the parallel processing is switched on
-  // if  bRunParallel= Standard_False :  the parallel processing is switched off
-  aBuilder.SetRunParallel(bRunParallel);
-  //
-  // set Fuzzy value
-  // if aFuzzyValue=0.: the Fuzzy option is off
-  //  if aFuzzyValue>0.: the Fuzzy option is on
-  aBuilder.SetFuzzyValue(aFuzzyValue);
-  //
-  // safe mode - avoid modification of the arguments
-  Standard_Boolean bSafeMode = Standard_True;
-  // if bSafeMode == Standard_True  - the safe mode is switched on
-  // if bSafeMode == Standard_False - the safe mode is switched off
-  aBuilder.SetNonDestructive(bSafeMode);
-  //
-  // gluing options - for coinciding arguments
-  BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-  // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-  // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-  // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-  aBuilder.SetGlue(aGlueOpt);
+  // Set options for the algorithm
+  // setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+  ...
   //
   // run the algorithm 
   aBuilder.Build(); 
@@ -3222,27 +3209,8 @@ bclearobjects; bcleartools;
 baddobjects b1 b3
 baddtools b2
 #
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1
-#
-# set Fuzzy value
-# 0.    : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-#
-# set gluing mode
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
+# set options for the algorithm (see "GF Usage" chapter)
+...
 #
 # run the algorithm
 # r is the result of the operation
@@ -3276,28 +3244,9 @@ The following example illustrates how to use Cut operation:
   aBuilder.SetArguments(aLS);
   aBuilder.SetTools(aLT);
   //   
-  // set parallel processing mode 
-  // if  bRunParallel= Standard_True :  the parallel processing is switched on
-  // if  bRunParallel= Standard_False :  the parallel processing is switched off
-  aBuilder.SetRunParallel(bRunParallel);
-  //
-  // set Fuzzy value
-  // if aFuzzyValue=0.: the Fuzzy option is off
-  //  if aFuzzyValue>0.: the Fuzzy option is on
-  aBuilder.SetFuzzyValue(aFuzzyValue);
-  //
-  // safe mode - avoid modification of the arguments
-  Standard_Boolean bSafeMode = Standard_True;
-  // if bSafeMode == Standard_True  - the safe mode is switched on
-  // if bSafeMode == Standard_False - the safe mode is switched off
-  aBuilder.SetNonDestructive(bSafeMode);
-  //
-  // gluing options - for coinciding arguments
-  BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-  // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-  // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-  // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-  aBuilder.SetGlue(aGlueOpt);
+  // Set options for the algorithm
+  // setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+  ...
   //
   // run the algorithm 
   aBuilder.Build(); 
@@ -3327,27 +3276,8 @@ bclearobjects; bcleartools;
 baddobjects b1 b3
 baddtools b2
 #
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1
-#
-# set Fuzzy value
-# 0.    : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-# set gluing mode
-#
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
+# set options for the algorithm (see "GF Usage" chapter)
+...
 #
 # run the algorithm
 # r is the result of the operation
@@ -3382,28 +3312,9 @@ The following example illustrates how to use Section operation:
   aBuilder.SetArguments(aLS);
   aBuilder.SetTools(aLT);
   //   
-  // set parallel processing mode 
-  // if  bRunParallel= Standard_True :  the parallel processing is switched on
-  // if  bRunParallel= Standard_False :  the parallel processing is switched off
-  aBuilder.SetRunParallel(bRunParallel);
-  //
-  // set Fuzzy value
-  // if aFuzzyValue=0.: the Fuzzy option is off
-  //  if aFuzzyValue>0.: the Fuzzy option is on
-  aBuilder.SetFuzzyValue(aFuzzyValue);
-  //
-  // safe mode - avoid modification of the arguments
-  Standard_Boolean bSafeMode = Standard_True;
-  // if bSafeMode == Standard_True  - the safe mode is switched on
-  // if bSafeMode == Standard_False - the safe mode is switched off
-  aBuilder.SetNonDestructive(bSafeMode);
-  //
-  // gluing options - for coinciding arguments
-  BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
-  // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
-  // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
-  // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
-  aBuilder.SetGlue(aGlueOpt);
+  // Set options for the algorithm
+  // setting options for this algorithm is similar to setting options for GF algorithm (see "GF Usage" chapter)
+  ...
   //
   // run the algorithm 
   aBuilder.Build(); 
@@ -3433,27 +3344,8 @@ bclearobjects; bcleartools;
 baddobjects b1 b3
 baddtools b2
 #
-# set parallel processing mode
-# 1:  the parallel processing is switched on
-# 0:  the parallel processing is switched off
-brunparallel 1
-#
-# set Fuzzy value
-# 0.    : the Fuzzy option is off
-# >0. : the Fuzzy option is on
-bfuzzyvalue 0.
-#
-# set safe processing mode
-bnondestructive 1
-# set safe mode
-# 1 - the safe processing mode is switched on
-# 0 - the safe processing mode is switched off
-#
-# set gluing mode
-bglue 1
-# set the gluing mode
-# 1 or 2 - the gluing mode is switched on
-# 0 - the gluing mode is switched off
+# set options for the algorithm (see "GF Usage" chapter)
+...
 #
 # run the algorithm
 # r is the result of the operation
index 27e7ce4b295681a4f7617966eed4f48c7c7b35c5..ed85aa10074cfeb614bf9c74d2a3d0ccbc651f4a 100644 (file)
@@ -412,6 +412,7 @@ void BOPAlgo_BOP::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
index 9b2302f5547777ac2623265e3036d51921c7d45f..20f74f4362a321fdb0219ed45f3c4dcc1357aa24 100644 (file)
@@ -286,6 +286,7 @@ void BOPAlgo_Builder::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
@@ -303,6 +304,7 @@ void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
   myNonDestructive = theFiller.NonDestructive();
   myFuzzyValue = theFiller.FuzzyValue();
   myGlue = theFiller.Glue();
+  myUseOBB = theFiller.UseOBB();
   PerformInternal(theFiller);
 }
 //=======================================================================
index 35dfe50e7be47c50d1569de758f89dfe9256dca8..865c17d365c252fdb1e4766d6ea8697a2b7cd605 100644 (file)
@@ -159,16 +159,16 @@ void BOPAlgo_CheckerSI::Init()
   myDS->SetArguments(myArguments);
   myDS->Init(myFuzzyValue);
   //
-  // 2.myIterator 
+  // 2 myContext
+  myContext=new IntTools_Context;
+  //
+  // 3.myIterator 
   BOPDS_PIteratorSI theIterSI=new BOPDS_IteratorSI(myAllocator);
   theIterSI->SetDS(myDS);
-  theIterSI->Prepare();
+  theIterSI->Prepare(myContext, myUseOBB, myFuzzyValue);
   theIterSI->UpdateByLevelOfCheck(myLevelOfCheck);
   //
   myIterator=theIterSI;
-  //
-  // 3 myContext
-  myContext=new IntTools_Context;
 }
 //=======================================================================
 //function : Perform
index 2a7afbcbc9b40bb5da910419eee69963186d6c91..da912808b371613c294ced8ce59f6384a5c48ec2 100644 (file)
@@ -91,6 +91,7 @@ void BOPAlgo_MakerVolume::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   pPF->Perform();
   //
   myEntryPoint = 1;
index ac5445b4d02a19c3d7c1e6339083b5231a0d8150..a8864186d2d51fb8d75c682065ce6cc5fcfc3b24 100644 (file)
@@ -51,7 +51,8 @@ BOPAlgo_Options::BOPAlgo_Options()
   myReport(new Message_Report),
   myRunParallel(myGlobalRunParallel),
   myFuzzyValue(Precision::Confusion()),
-  myCheckInverted(Standard_True)
+  myCheckInverted(Standard_True),
+  myUseOBB(Standard_False)
 {
   BOPAlgo_LoadMessages();
 }
@@ -67,7 +68,8 @@ BOPAlgo_Options::BOPAlgo_Options
   myReport(new Message_Report),
   myRunParallel(myGlobalRunParallel),
   myFuzzyValue(Precision::Confusion()),
-  myCheckInverted(Standard_True)
+  myCheckInverted(Standard_True),
+  myUseOBB(Standard_False)
 {
   BOPAlgo_LoadMessages();
 }
index e10cf0e1ec4b9aa258828c71f50889eef6c8dc51..5d6a6be0555e4a74f946ed5975d60ea1f687b0a1 100644 (file)
@@ -36,6 +36,8 @@ class Message_ProgressIndicator;
 //!                          for inverted status (holes in the space). The default value is TRUE,
 //!                          i.e. the check is performed. Setting this flag to FALSE for inverted solids,
 //!                          most likely will lead to incorrect results.
+//! - *Using the Oriented Bounding Boxes* - Allows using the Oriented Bounding Boxes of the shapes
+//!                          for filtering the intersections.
 //!
 class BOPAlgo_Options
 {
@@ -176,6 +178,22 @@ public:
     return myCheckInverted;
   }
 
+public:
+  //!@name Usage of Oriented Bounding boxes
+
+  //! Enables/Disables the usage of OBB
+  void SetUseOBB(const Standard_Boolean theUseOBB)
+  {
+    myUseOBB = theUseOBB;
+  }
+
+  //! Returns the flag defining usage of OBB
+  Standard_Boolean UseOBB() const
+  {
+    return myUseOBB;
+  }
+
+
 protected:
 
   //! Breaks the execution if the break signal
@@ -190,6 +208,7 @@ protected:
   Standard_Real myFuzzyValue;
   Handle(Message_ProgressIndicator) myProgressIndicator;
   Standard_Boolean myCheckInverted;
+  Standard_Boolean myUseOBB;
 
 };
 
index 28bc7963a3e943af5344ae1981e83a192cc8738d..6efe3f104ebe46767bf38d71287d17ccb112d70c 100644 (file)
@@ -211,14 +211,14 @@ void BOPAlgo_PaveFiller::Init()
   myDS->SetArguments(myArguments);
   myDS->Init(myFuzzyValue);
   //
-  // 2.myIterator 
+  // 2 myContext
+  myContext=new IntTools_Context;
+  //
+  // 3.myIterator 
   myIterator=new BOPDS_Iterator(myAllocator);
   myIterator->SetRunParallel(myRunParallel);
   myIterator->SetDS(myDS);
-  myIterator->Prepare();
-  //
-  // 3 myContext
-  myContext=new IntTools_Context;
+  myIterator->Prepare(myContext, myUseOBB, myFuzzyValue);
   //
   // 4 NonDestructive flag
   SetNonDestructive();
index 0d073b08c8e17a9261ad8b192820242b81f06847..8c4a4720b1a83b065e4591db9f0d154c3af2ba1b 100644 (file)
@@ -131,6 +131,7 @@ void BOPAlgo_Splitter::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
index d3e80582ad6c2ba92aff1f12cee85af4a2812b54..b274569442e3331e549716933a841d887cd13732 100644 (file)
@@ -17,6 +17,7 @@
 
 
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
 #include <BOPCol_BoxBndTree.hxx>
 #include <BOPCol_NCVector.hxx>
 #include <BOPCol_Parallel.hxx>
@@ -26,6 +27,7 @@
 #include <BOPDS_Pair.hxx>
 #include <BOPDS_MapOfPair.hxx>
 #include <BOPDS_Tools.hxx>
+#include <IntTools_Context.hxx>
 #include <NCollection_UBTreeFiller.hxx>
 #include <TopoDS_Shape.hxx>
 #include <algorithm>
@@ -240,7 +242,9 @@ void BOPDS_Iterator::Value(Standard_Integer& theI1,
 // function: Prepare
 // purpose: 
 //=======================================================================
-void BOPDS_Iterator::Prepare()
+void BOPDS_Iterator::Prepare(const Handle(IntTools_Context)& theCtx,
+                             const Standard_Boolean theCheckOBB,
+                             const Standard_Real theFuzzyValue)
 {
   Standard_Integer i, aNbInterfTypes;
   //
@@ -253,14 +257,16 @@ void BOPDS_Iterator::Prepare()
   if (myDS==NULL){
     return;
   }
-  Intersect();
+  Intersect(theCtx, theCheckOBB, theFuzzyValue);
 }
 //
 //=======================================================================
 // function: Intersect
 // purpose: 
 //=======================================================================
-void BOPDS_Iterator::Intersect()
+void BOPDS_Iterator::Intersect(const Handle(IntTools_Context)& theCtx,
+                               const Standard_Boolean theCheckOBB,
+                               const Standard_Real theFuzzyValue)
 {
   Standard_Integer i, j, iX, i1, i2, iR, aNb, aNbR;
   Standard_Integer iTi, iTj;
@@ -339,6 +345,16 @@ void BOPDS_Iterator::Intersect()
         //
         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))
+              continue;
+          }
+
           iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
           myLists(iX).Append(aPair);
         }// if (aMPFence.Add(aPair)) {
index 9e3313092b2d002454720bae8a7c7fb4411dcb99..ef6ed001a9c59e416753861096f1564333174178 100644 (file)
 #include <BOPDS_PDS.hxx>
 #include <BOPDS_VectorOfPair.hxx>
 #include <BOPDS_VectorOfVectorOfPair.hxx>
+#include <Precision.hxx>
 #include <Standard_Boolean.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 class BOPDS_DS;
-
+class IntTools_Context;
 
 
 //! The class BOPDS_Iterator is
@@ -81,7 +82,9 @@ public:
 
   //! Perform the intersection algorithm and prepare
   //! the results to be used
-  Standard_EXPORT virtual void Prepare();
+  Standard_EXPORT virtual void Prepare(const Handle(IntTools_Context)& theCtx = Handle(IntTools_Context)(),
+                                       const Standard_Boolean theCheckOBB = Standard_False,
+                                       const Standard_Real theFuzzyValue = Precision::Confusion());
 
   //! Returns the number of intersections founded
   Standard_EXPORT Standard_Integer ExpectedLength() const;
@@ -99,7 +102,9 @@ public:
 
 protected:
 
-  Standard_EXPORT virtual void Intersect();
+  Standard_EXPORT virtual void Intersect(const Handle(IntTools_Context)& theCtx = Handle(IntTools_Context)(),
+                                         const Standard_Boolean theCheckOBB = Standard_False,
+                                         const Standard_Real theFuzzyValue = Precision::Confusion());
 
   BOPCol_BaseAllocator myAllocator;
   Standard_Integer myLength;
index 2feaa9b761d0642a76c286d9abdfda6502c69c33..0af06d00167e72b260676e495053d5de0863e0ae 100644 (file)
@@ -13,6 +13,7 @@
 // commercial license or contractual agreement.
 
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
 #include <BOPCol_BoxBndTree.hxx>
 #include <BOPCol_DataMapOfIntegerInteger.hxx>
 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
@@ -28,6 +29,7 @@
 #include <BOPDS_Tools.hxx>
 #include <BRep_Tool.hxx>
 #include <gp_Pnt.hxx>
+#include <IntTools_Context.hxx>
 #include <NCollection_UBTreeFiller.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS.hxx>
@@ -78,7 +80,9 @@ void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
 // function: Intersect
 // purpose: 
 //=======================================================================
-void BOPDS_IteratorSI::Intersect()
+void BOPDS_IteratorSI::Intersect(const Handle(IntTools_Context)& theCtx,
+                                 const Standard_Boolean theCheckOBB,
+                                 const Standard_Real theFuzzyValue)
 {
   Standard_Integer i, j, iX, aNbS;
   Standard_Integer iTi, iTj;
@@ -138,6 +142,16 @@ void BOPDS_IteratorSI::Intersect()
       //
       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))
+            continue;
+        }
+
         iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
         myLists(iX).Append(aPair);
       }// if (aMPKXB.Add(aPKXB)) {
index a0d9b9ab455eb660521f5e716b70279417d6d337..9675db41eea50425bf40aa757a06691744baf174 100644 (file)
@@ -68,7 +68,9 @@ Standard_EXPORT virtual ~BOPDS_IteratorSI();
 protected:
 
   
-  Standard_EXPORT virtual void Intersect() Standard_OVERRIDE;
+  Standard_EXPORT virtual void Intersect(const Handle(IntTools_Context)& theCtx = Handle(IntTools_Context)(),
+                                         const Standard_Boolean theCheckOBB = Standard_False,
+                                         const Standard_Real theFuzzyValue = Precision::Confusion()) Standard_OVERRIDE;
 
 
 
index 4096800bdfee1d18fa9b438265bd67bae37abb2c..b6ce3f102b783f17b153898fbc536c7a8096dfea 100644 (file)
@@ -134,6 +134,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(); 
   //
@@ -195,6 +196,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(); 
   //
@@ -260,6 +262,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();
index 427f052cab30b6706b71a74e7660981e03369760..bb1e09c1869204475af7bd9ec35dbcb9b7bf943d 100644 (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);
index 037305314611d5963d60d4594427bde18207ff43..87b09cc28148b88de44631bc35be09fdbf0d5a18 100644 (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);
index f5b5279e40ced73e813cfbc8e1d7be32432e638c..6daed55906b5d9eb2fae3e54c8aa0e75a176b1fd 100644 (file)
@@ -40,6 +40,7 @@
 #include <BOPCol_DataMapOfShapeShape.hxx>
 #include <BOPCol_DataMapOfShapeListOfShape.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
index 61c3416fa2386c24f17bf59f984245db7a1fabcb..70aafb19be7598bc65ca357611b973416f2a8c9e 100644 (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  : 
 //=======================================================================
index 02911bc0d0df3c0f8bb2eb5f92fbd3685cf2eac7..221f0e66d860a55cfb740807b8e095e5a16b124b 100644 (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:
index b90a40f5ec564ae7f6951cd3825700c8358fa7ff..c7ef3ab9427b28996b63426c2dfb17c1e9d9a319 100644 (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;
+}
index 9cc1cea800da7e6f4bf7a8e2c494f9c90feb4aff..148f3d1266088624fdcdbd1c276432c567a1a441 100644 (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();
index 1850e0e7dc7e8cd52a22c781d12ccb99c15d0f5f..dfce856e7d6f496a054dde6d736a0d46ffcce494 100644 (file)
@@ -56,7 +56,7 @@ public:
   using BOPAlgo_Options::GetReport;
   using BOPAlgo_Options::SetProgressIndicator;
   using BOPAlgo_Options::SetCheckInverted;
-
+  using BOPAlgo_Options::SetUseOBB;
 protected:
 
   //! Empty constructor
index dbddf3dd9363bd94e8c3341d1551fe12c540180c..e3b9205824b1c811d2c17cc00bca4b814a038b0f 100644 (file)
@@ -311,6 +311,7 @@ void BRepAlgoAPI_BooleanOperation::Build()
     myDSFiller->SetFuzzyValue(myFuzzyValue);
     myDSFiller->SetNonDestructive(myNonDestructive);
     myDSFiller->SetGlue(myGlue);
+    myDSFiller->SetUseOBB(myUseOBB);
     //
     SetAttributes();
     //
index f0c565f770c07e1e6a8ca3c08476c0fcf3918636..e746b5bac1352de5aa02856056cd2c4586f64e7f 100644 (file)
@@ -143,6 +143,7 @@ void BRepAlgoAPI_BuilderAlgo::Build()
     myDSFiller->SetFuzzyValue(myFuzzyValue);
     myDSFiller->SetNonDestructive(myNonDestructive);
     myDSFiller->SetGlue(myGlue);
+    myDSFiller->SetUseOBB(myUseOBB);
     //
     myDSFiller->Perform();
     //
index b28fb2f37331cd95b090c2841bc4a80d78a8ba09..97b75ff7d8c8ebf66e3689d5ef1c0d39c8d0b8b0 100644 (file)
@@ -98,6 +98,7 @@ void BRepAlgoAPI_Splitter::Build()
     myDSFiller->SetFuzzyValue(myFuzzyValue);
     myDSFiller->SetNonDestructive(myNonDestructive);
     myDSFiller->SetGlue(myGlue);
+    myDSFiller->SetUseOBB(myUseOBB);
     //
     myDSFiller->Perform();
     //
index 903a0e38f99c5cb8ccd28e7cdeee5b03c7c5e148..9323c48bbea181ad4d3183506277ee14e3f0fbdf 100644 (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  : 
index 0da262e92e82607696fc06c85ee4c47ee9366a67..8171bfdddb12c74d8f829dc58820b4fbbfb9de2e 100644 (file)
@@ -44,6 +44,7 @@ class gp_Pnt2d;
 class IntTools_Curve;
 class Bnd_Box;
 class TopoDS_Shape;
+class Bnd_OBB;
 
 
 //! The intersection Context contains geometrical
@@ -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,
@@ -250,6 +256,7 @@ protected:
   BOPCol_DataMapOfShapeAddress myProjSDataMap;
   BOPCol_DataMapOfShapeAddress myBndBoxDataMap;
   BOPCol_DataMapOfShapeAddress mySurfAdaptorMap;
+  BOPCol_DataMapOfShapeAddress myOBBMap; // Map of oriented bounding boxes
   Standard_Integer myCreateFlag;
   Standard_Real myPOnSTolerance;
 
index 41c61ac1cd9fb9f93e056f88db850c44e1235c65..42fc40253e75d1d7f51df9f4fa523102803e7992 100644 (file)
@@ -8,6 +8,9 @@ puts ""
 
 pload QAcommands
 
+# enable OBB usage in BOP
+buseobb 1
+
 dchrono h restart
 
 restore [locate_data_file bug24696_cx_e1200_nurbs.brep] cx
@@ -27,4 +30,6 @@ bbuild result
 
 dchrono h stop counter EdgeIntersection
 
+buseobb 0
+
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 0fff551f5431a658073425e06cda9ba611a9a8ee..cc5fdd0bc41cd856080de0a76ca0e0aed09b1b1b 100644 (file)
@@ -8,6 +8,9 @@ puts ""
 
 pload QAcommands
 
+# enable OBB usage in BOP
+buseobb 1
+
 dchrono h restart
 
 restore [locate_data_file bug24696_cx_e1200_nurbs.brep] cx
@@ -27,4 +30,6 @@ bbuild result
 
 dchrono h stop counter EdgeIntersection
 
+buseobb 0
+
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 7c9938d9cf05be2085280f0abc0658a13bec92b3..cd444c13f734fb3a3ac6b19feb8a425bc9b9590b 100644 (file)
@@ -8,6 +8,9 @@ puts ""
 
 pload QAcommands
 
+# enable OBB usage in BOP
+buseobb 1
+
 dchrono h restart
 
 restore [locate_data_file bug24696_cx_e1200_nurbs.brep] cx
@@ -27,4 +30,6 @@ bbuild result
 
 dchrono h stop counter EdgeIntersection
 
+buseobb 0
+
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index e6d11c905ac9e96d78df187ffdedc88e3c6c5327..f10a0a84f303da153ac9d7bb46407842106c066e 100644 (file)
@@ -8,6 +8,9 @@ puts ""
 
 pload QAcommands
 
+# enable OBB usage in BOP
+buseobb 1
+
 dchrono h restart
 
 restore [locate_data_file bug24696_cx_e1200_nurbs.brep] cx
@@ -27,4 +30,6 @@ bbuild result
 
 dchrono h stop counter EdgeIntersection
 
+buseobb 0
+
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index 9d882d69c125550ee453bd914b3d825531ca9a65..2251d8054322fe683d648c767f84bd8de584fef7 100644 (file)
@@ -8,6 +8,9 @@ puts ""
 
 pload QAcommands
 
+# enable OBB usage in BOP
+buseobb 1
+
 dchrono h restart
 
 restore [locate_data_file bug24696_cx_e1200_nurbs.brep] cx
@@ -27,4 +30,6 @@ bbuild result
 
 dchrono h stop counter EdgeIntersection
 
+buseobb 0
+
 checkview -display result -2d -path ${imagedir}/${test_image}.png
index d7024b85939821379b62d144f4e2ff4a21361ea3..7f75538a4172222c1d09b6a5bbbb6db63e1869a3 100644 (file)
@@ -11,6 +11,7 @@ brestore [locate_data_file bug29237_dom8364_s32_c2.rhs.brep] b
 
 bglue 1
 bcheckinverted 0
+buseobb 1
 
 bclearobjects
 bcleartools
index 1f38f4fe2a8292e44dcd948db3faaf73dd947fd9..8b4064c932b24c19f600c76a2f1f55edf85f46d6 100644 (file)
@@ -11,6 +11,7 @@ brestore [locate_data_file bug29237_no_overlap.rhs.brep] b
 
 bglue 1
 bcheckinverted 0
+buseobb 1
 
 bclearobjects
 bcleartools