]> 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)
committerbugmaster <bugmaster@opencascade.com>
Fri, 8 Dec 2017 13:39:15 +0000 (16:39 +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 de6b050d3a17667d6da026d2c0edac99cc7f219a..26684475a1ae0c2ee7b63798bde1a553b8531c6a 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;
+// Setting arguments and tools
 TopTools_ListOfShape aLSObjects = …; // Objects
 TopTools_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
 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;
+// Set the arguments
 TopTools_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*/
-//
 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;
+// Set the arguments
 TopTools_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*/
-//
 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 c1e8804295037b236debe824df99aef620569556..17343295fd47fdd7541a4392d234d42db74ac6e1 100644 (file)
@@ -373,6 +373,7 @@ void BOPAlgo_BOP::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
index da6483598dd948832e7ea4acd8767d18d1c4f3e6..249519d7321eb9ec69e09f62cc00b8cc3397de2b 100644 (file)
@@ -195,6 +195,7 @@ void BOPAlgo_Builder::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
@@ -212,6 +213,7 @@ void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller)
   myNonDestructive = theFiller.NonDestructive();
   myFuzzyValue = theFiller.FuzzyValue();
   myGlue = theFiller.Glue();
+  myUseOBB = theFiller.UseOBB();
   PerformInternal(theFiller);
 }
 //=======================================================================
index 637060773b4a39c8afd8341261d9e37c6d579def..660e9aa7a66ed63a7b70b8f2c6132c8c3354e282 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 c4ead83d1b870418300ad381beff5c9a0a9817da..27748d76ff27905b1f5224f6baca347bd1605aa3 100644 (file)
@@ -90,6 +90,7 @@ void BOPAlgo_MakerVolume::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   pPF->Perform();
   //
   myEntryPoint = 1;
index ddbade6f5351364b1d909be39e226461b03e1e00..0ef8524f33b7274494dbc71496823341b8146b68 100644 (file)
@@ -50,7 +50,8 @@ BOPAlgo_Options::BOPAlgo_Options()
   myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
   myReport(new Message_Report),
   myRunParallel(myGlobalRunParallel),
-  myFuzzyValue(Precision::Confusion())
+  myFuzzyValue(Precision::Confusion()),
+  myUseOBB(Standard_False)
 {
   BOPAlgo_LoadMessages();
 }
@@ -65,7 +66,8 @@ BOPAlgo_Options::BOPAlgo_Options
   myAllocator(theAllocator),
   myReport(new Message_Report),
   myRunParallel(myGlobalRunParallel),
-  myFuzzyValue(Precision::Confusion())
+  myFuzzyValue(Precision::Confusion()),
+  myUseOBB(Standard_False)
 {
   BOPAlgo_LoadMessages();
 }
index a6cda3ab15c84cd87fa738befae8c5adefd099eb..2c8520890b5c4b3ce2f585fe7172ae0d8cde9129 100644 (file)
@@ -32,6 +32,8 @@ class Message_ProgressIndicator;
 //!                       touching or coinciding cases;
 //! - *Progress indicator* - provides interface to track the progress of
 //!                          operation and stop the operation by user's break.
+//! - *Using the Oriented Bounding Boxes* - Allows using the Oriented Bounding Boxes of the shapes
+//!                          for filtering the intersections.
 //!
 class BOPAlgo_Options
 {
@@ -156,6 +158,21 @@ public:
   //! Set the Progress Indicator object.
   Standard_EXPORT void SetProgressIndicator(const Handle(Message_ProgressIndicator)& theObj);
 
+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
@@ -169,6 +186,7 @@ protected:
   Standard_Boolean myRunParallel;
   Standard_Real myFuzzyValue;
   Handle(Message_ProgressIndicator) myProgressIndicator;
+  Standard_Boolean myUseOBB;
 
 };
 
index d990cfa14612acd5effb0f6c2db1d30e1573384b..ee3a1ac2b51ac7988f76c088b9ec914645e1865b 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 b95c42431b06c41da173d3029525ad08367c77ac..6f93a9c927e0bf815b951d64ab6e3f415fba4161 100644 (file)
@@ -91,6 +91,7 @@ void BOPAlgo_Splitter::Perform()
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
+  pPF->SetUseOBB(myUseOBB);
   //
   pPF->Perform();
   //
index d29b24b5589fd671653603addb565b2bba211c2f..7a196c1ae4aba9721075d99fb74da88a5a2a69b9 100644 (file)
@@ -17,6 +17,7 @@
 
 
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
 #include <BOPDS_DS.hxx>
 #include <BOPDS_IndexRange.hxx>
 #include <BOPDS_Iterator.hxx>
@@ -25,6 +26,7 @@
 #include <BOPDS_Tools.hxx>
 #include <BOPTools_BoxBndTree.hxx>
 #include <BOPTools_Parallel.hxx>
+#include <IntTools_Context.hxx>
 #include <NCollection_UBTreeFiller.hxx>
 #include <NCollection_Vector.hxx>
 #include <TopoDS_Shape.hxx>
@@ -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 d6c35873f1150a74d2bf7eeec222cc887253a9e2..22ceafabdfcc8cddbf3e47f3dba4524fbd5eb77d 100644 (file)
 #include <BOPDS_VectorOfPair.hxx>
 #include <BOPDS_VectorOfVectorOfPair.hxx>
 #include <NCollection_BaseAllocator.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());
 
   Handle(NCollection_BaseAllocator) myAllocator;
   Standard_Integer myLength;
index 0018bb2833ed0962e311b64c8087313ebe735af8..3b824010eb3694b3a3fcc710eb3e9be90f42e717 100644 (file)
@@ -13,6 +13,7 @@
 // commercial license or contractual agreement.
 
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
 #include <BOPDS_DS.hxx>
 #include <BOPDS_IndexRange.hxx>
 #include <BOPDS_IteratorSI.hxx>
@@ -23,6 +24,7 @@
 #include <BOPTools_BoxBndTree.hxx>
 #include <BRep_Tool.hxx>
 #include <gp_Pnt.hxx>
+#include <IntTools_Context.hxx>
 #include <NCollection_UBTreeFiller.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TColStd_DataMapOfIntegerInteger.hxx>
@@ -77,7 +79,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;
@@ -137,6 +141,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 2c3e1a26316e87d60dcc6a164ac8d4c26bbc4452..0f94f71f0b633c9ae99e1cafd94216ed2c501025 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 a15aaf119cf72bf1d19e3363dc94ed4649543d44..ac7a5b6c9531c2bc83214167d240cfd7ad488b8b 100644 (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();
index 873ecdeb07e6ddec8a480a001a5525ea9834d5cd..d6c1f552ea72736c110d59c203000e42ea6fa9c7 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 0876dfc283cf0a04c9cbadfe71e345803e879038..0a4924f7b5c984018fbf0aad65446562de854688 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 66db3f81673366f40f2d81e15373e28cfe064296..991cf0dfb34285f9c0369eed393a1640880188c6 100644 (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
index 8db3e1211ef51d39e0b79f7c1c82a31a8ec5fd9d..d0c82ec0ba21f957d92e3713d9acfd609d3cd5c3 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 a5d15705068ccd093bd67c187357963e10e74188..fbe19e86912a8d45adaebaf16612c53cfd3c12a3 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 dfbb4fc1b3d56a55f7765092fd648664a2ca40f8..5cf77bd67bb0af6866a6111e42a2d82cc50a4ee1 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 8f2262232a1e15bc35ae76671bedd38c5580063e..726ccb7d02048ba317e93c37749565b25b548050 100644 (file)
@@ -55,6 +55,7 @@ public:
   using BOPAlgo_Options::ClearWarnings;
   using BOPAlgo_Options::GetReport;
   using BOPAlgo_Options::SetProgressIndicator;
+  using BOPAlgo_Options::SetUseOBB;
 
 protected:
 
index e48bbd5cd85a38e8b45ea10776941b9be5557e43..d381153f477f345e62c66380f1e4da64cca16178 100644 (file)
@@ -311,6 +311,7 @@ void BRepAlgoAPI_BooleanOperation::Build()
     myDSFiller->SetFuzzyValue(myFuzzyValue);
     myDSFiller->SetNonDestructive(myNonDestructive);
     myDSFiller->SetGlue(myGlue);
+    myDSFiller->SetUseOBB(myUseOBB);
     //
     SetAttributes();
     //
index d40583ec772cfeaf88f802756cb26ded00307bb8..f7e77e75d0d0e4f5e65516682086667ee59856a1 100644 (file)
@@ -145,6 +145,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 8bb615bebaaa5b34ce2abf172d21d9bb2da89eee..010425c16bc0e5336af3934e1ee1f2d56570bc0a 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 a2f6ca88528d473ad226dedb7d9c36088cf290a5..3ec1dcf554a2e5125499d435cecb3e6e1b2f5642 100644 (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;
 
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 dc464816212bc278bcd9199d4b30ba9288635464..025548555451f15e394516702817078872ac61f9 100644 (file)
@@ -11,6 +11,7 @@ brestore [locate_data_file bug29237_no_overlap.rhs.brep] b
 
 bglue 1
 bcheckinverted 0
+buseobb 1
 
 bclearobjects
 bcleartools