From: emv Date: Wed, 1 Nov 2017 08:30:30 +0000 (+0300) Subject: 0029312: Using OBB to speed up Boolean Operations X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=989b64326c10cef10868e2ccdbc246a7bb7fdbb9;p=occt-copy.git 0029312: Using OBB to speed up Boolean Operations 1. Implementation of the user-defined option for usage of Oriented Bounding Boxes (OBB) in Boolean Operations for additional filtering (rejection) of selected for intersection pairs of sub-shapes. By default the usage of OBB is turned off. To enable/disable its usage the method SetUseOBB(flag) should be used. This method is available for all operations in Boolean Component. To enable/disable it in draw the command "buseobb 0/1" should be used. Note, that this will affect all subsequent operations. The OBB for the shapes are built by first necessity and stored into operation context (IntTools_Context). 2. Usage of the OBB in some test cases. --- diff --git a/dox/user_guides/boolean_operations/boolean_operations.md b/dox/user_guides/boolean_operations/boolean_operations.md index f76693658b..992faf4390 100644 --- a/dox/user_guides/boolean_operations/boolean_operations.md +++ b/dox/user_guides/boolean_operations/boolean_operations.md @@ -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.
-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.
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 #include {… - 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 diff --git a/src/BOPAlgo/BOPAlgo_BOP.cxx b/src/BOPAlgo/BOPAlgo_BOP.cxx index 27e7ce4b29..ed85aa1007 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.cxx +++ b/src/BOPAlgo/BOPAlgo_BOP.cxx @@ -412,6 +412,7 @@ void BOPAlgo_BOP::Perform() pPF->SetFuzzyValue(myFuzzyValue); pPF->SetNonDestructive(myNonDestructive); pPF->SetGlue(myGlue); + pPF->SetUseOBB(myUseOBB); // pPF->Perform(); // diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx index 9b2302f554..20f74f4362 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -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); } //======================================================================= diff --git a/src/BOPAlgo/BOPAlgo_CheckerSI.cxx b/src/BOPAlgo/BOPAlgo_CheckerSI.cxx index 35dfe50e7b..865c17d365 100644 --- a/src/BOPAlgo/BOPAlgo_CheckerSI.cxx +++ b/src/BOPAlgo/BOPAlgo_CheckerSI.cxx @@ -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 diff --git a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx index 2a7afbcbc9..da912808b3 100644 --- a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx +++ b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx @@ -91,6 +91,7 @@ void BOPAlgo_MakerVolume::Perform() pPF->SetFuzzyValue(myFuzzyValue); pPF->SetNonDestructive(myNonDestructive); pPF->SetGlue(myGlue); + pPF->SetUseOBB(myUseOBB); pPF->Perform(); // myEntryPoint = 1; diff --git a/src/BOPAlgo/BOPAlgo_Options.cxx b/src/BOPAlgo/BOPAlgo_Options.cxx index ac5445b4d0..a8864186d2 100644 --- a/src/BOPAlgo/BOPAlgo_Options.cxx +++ b/src/BOPAlgo/BOPAlgo_Options.cxx @@ -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(); } diff --git a/src/BOPAlgo/BOPAlgo_Options.hxx b/src/BOPAlgo/BOPAlgo_Options.hxx index e10cf0e1ec..5d6a6be055 100644 --- a/src/BOPAlgo/BOPAlgo_Options.hxx +++ b/src/BOPAlgo/BOPAlgo_Options.hxx @@ -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; }; diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx index 28bc7963a3..6efe3f104e 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx @@ -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(); diff --git a/src/BOPAlgo/BOPAlgo_Splitter.cxx b/src/BOPAlgo/BOPAlgo_Splitter.cxx index 0d073b08c8..8c4a4720b1 100644 --- a/src/BOPAlgo/BOPAlgo_Splitter.cxx +++ b/src/BOPAlgo/BOPAlgo_Splitter.cxx @@ -131,6 +131,7 @@ void BOPAlgo_Splitter::Perform() pPF->SetFuzzyValue(myFuzzyValue); pPF->SetNonDestructive(myNonDestructive); pPF->SetGlue(myGlue); + pPF->SetUseOBB(myUseOBB); // pPF->Perform(); // diff --git a/src/BOPDS/BOPDS_Iterator.cxx b/src/BOPDS/BOPDS_Iterator.cxx index d3e80582ad..b274569442 100644 --- a/src/BOPDS/BOPDS_Iterator.cxx +++ b/src/BOPDS/BOPDS_Iterator.cxx @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -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)) { diff --git a/src/BOPDS/BOPDS_Iterator.hxx b/src/BOPDS/BOPDS_Iterator.hxx index 9e3313092b..ef6ed001a9 100644 --- a/src/BOPDS/BOPDS_Iterator.hxx +++ b/src/BOPDS/BOPDS_Iterator.hxx @@ -27,10 +27,11 @@ #include #include #include +#include #include #include 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; diff --git a/src/BOPDS/BOPDS_IteratorSI.cxx b/src/BOPDS/BOPDS_IteratorSI.cxx index 2feaa9b761..0af06d0016 100644 --- a/src/BOPDS/BOPDS_IteratorSI.cxx +++ b/src/BOPDS/BOPDS_IteratorSI.cxx @@ -13,6 +13,7 @@ // commercial license or contractual agreement. #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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)) { diff --git a/src/BOPDS/BOPDS_IteratorSI.hxx b/src/BOPDS/BOPDS_IteratorSI.hxx index a0d9b9ab45..9675db41ee 100644 --- a/src/BOPDS/BOPDS_IteratorSI.hxx +++ b/src/BOPDS/BOPDS_IteratorSI.hxx @@ -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; diff --git a/src/BOPTest/BOPTest_APICommands.cxx b/src/BOPTest/BOPTest_APICommands.cxx index 4096800bdf..b6ce3f102b 100644 --- a/src/BOPTest/BOPTest_APICommands.cxx +++ b/src/BOPTest/BOPTest_APICommands.cxx @@ -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(); diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index 427f052cab..bb1e09c186 100644 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -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); diff --git a/src/BOPTest/BOPTest_CellsCommands.cxx b/src/BOPTest/BOPTest_CellsCommands.cxx index 0373053146..87b09cc281 100644 --- a/src/BOPTest/BOPTest_CellsCommands.cxx +++ b/src/BOPTest/BOPTest_CellsCommands.cxx @@ -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); diff --git a/src/BOPTest/BOPTest_DebugCommands.cxx b/src/BOPTest/BOPTest_DebugCommands.cxx index f5b5279e40..6daed55906 100644 --- a/src/BOPTest/BOPTest_DebugCommands.cxx +++ b/src/BOPTest/BOPTest_DebugCommands.cxx @@ -40,6 +40,7 @@ #include #include +#include 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 diff --git a/src/BOPTest/BOPTest_Objects.cxx b/src/BOPTest/BOPTest_Objects.cxx index 61c3416fa2..70aafb19be 100644 --- a/src/BOPTest/BOPTest_Objects.cxx +++ b/src/BOPTest/BOPTest_Objects.cxx @@ -21,6 +21,7 @@ #include #include #include +#include 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 : //======================================================================= diff --git a/src/BOPTest/BOPTest_Objects.hxx b/src/BOPTest/BOPTest_Objects.hxx index 02911bc0d0..221f0e66d8 100644 --- a/src/BOPTest/BOPTest_Objects.hxx +++ b/src/BOPTest/BOPTest_Objects.hxx @@ -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: diff --git a/src/BOPTest/BOPTest_OptionCommands.cxx b/src/BOPTest/BOPTest_OptionCommands.cxx index b90a40f5ec..c7ef3ab942 100644 --- a/src/BOPTest/BOPTest_OptionCommands.cxx +++ b/src/BOPTest/BOPTest_OptionCommands.cxx @@ -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; +} diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index 9cc1cea800..148f3d1266 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -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(); diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Algo.hxx b/src/BRepAlgoAPI/BRepAlgoAPI_Algo.hxx index 1850e0e7dc..dfce856e7d 100644 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Algo.hxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Algo.hxx @@ -56,7 +56,7 @@ public: using BOPAlgo_Options::GetReport; using BOPAlgo_Options::SetProgressIndicator; using BOPAlgo_Options::SetCheckInverted; - + using BOPAlgo_Options::SetUseOBB; protected: //! Empty constructor diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx index dbddf3dd93..e3b9205824 100644 --- a/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx @@ -311,6 +311,7 @@ void BRepAlgoAPI_BooleanOperation::Build() myDSFiller->SetFuzzyValue(myFuzzyValue); myDSFiller->SetNonDestructive(myNonDestructive); myDSFiller->SetGlue(myGlue); + myDSFiller->SetUseOBB(myUseOBB); // SetAttributes(); // diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx index f0c565f770..e746b5bac1 100644 --- a/src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx @@ -143,6 +143,7 @@ void BRepAlgoAPI_BuilderAlgo::Build() myDSFiller->SetFuzzyValue(myFuzzyValue); myDSFiller->SetNonDestructive(myNonDestructive); myDSFiller->SetGlue(myGlue); + myDSFiller->SetUseOBB(myUseOBB); // myDSFiller->Perform(); // diff --git a/src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx b/src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx index b28fb2f373..97b75ff7d8 100644 --- a/src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx +++ b/src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx @@ -98,6 +98,7 @@ void BRepAlgoAPI_Splitter::Build() myDSFiller->SetFuzzyValue(myFuzzyValue); myDSFiller->SetNonDestructive(myNonDestructive); myDSFiller->SetGlue(myGlue); + myDSFiller->SetUseOBB(myUseOBB); // myDSFiller->Perform(); // diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx index 903a0e38f9..9323c48bbe 100644 --- a/src/IntTools/IntTools_Context.cxx +++ b/src/IntTools/IntTools_Context.cxx @@ -14,6 +14,7 @@ #include +#include #include #include #include @@ -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 : diff --git a/src/IntTools/IntTools_Context.hxx b/src/IntTools/IntTools_Context.hxx index 0da262e92e..8171bfdddb 100644 --- a/src/IntTools/IntTools_Context.hxx +++ b/src/IntTools/IntTools_Context.hxx @@ -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; diff --git a/tests/perf/modalg/bug24751_1 b/tests/perf/modalg/bug24751_1 index 41c61ac1cd..42fc40253e 100644 --- a/tests/perf/modalg/bug24751_1 +++ b/tests/perf/modalg/bug24751_1 @@ -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 diff --git a/tests/perf/modalg/bug24751_2 b/tests/perf/modalg/bug24751_2 index 0fff551f54..cc5fdd0bc4 100644 --- a/tests/perf/modalg/bug24751_2 +++ b/tests/perf/modalg/bug24751_2 @@ -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 diff --git a/tests/perf/modalg/bug24751_3 b/tests/perf/modalg/bug24751_3 index 7c9938d9cf..cd444c13f7 100644 --- a/tests/perf/modalg/bug24751_3 +++ b/tests/perf/modalg/bug24751_3 @@ -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 diff --git a/tests/perf/modalg/bug24751_4 b/tests/perf/modalg/bug24751_4 index e6d11c905a..f10a0a84f3 100644 --- a/tests/perf/modalg/bug24751_4 +++ b/tests/perf/modalg/bug24751_4 @@ -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 diff --git a/tests/perf/modalg/bug24751_5 b/tests/perf/modalg/bug24751_5 index 9d882d69c1..2251d80543 100644 --- a/tests/perf/modalg/bug24751_5 +++ b/tests/perf/modalg/bug24751_5 @@ -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 diff --git a/tests/perf/modalg/bug29237_2 b/tests/perf/modalg/bug29237_2 index d7024b8593..7f75538a41 100644 --- a/tests/perf/modalg/bug29237_2 +++ b/tests/perf/modalg/bug29237_2 @@ -11,6 +11,7 @@ brestore [locate_data_file bug29237_dom8364_s32_c2.rhs.brep] b bglue 1 bcheckinverted 0 +buseobb 1 bclearobjects bcleartools diff --git a/tests/perf/modalg/bug29237_3 b/tests/perf/modalg/bug29237_3 index 1f38f4fe2a..8b4064c932 100644 --- a/tests/perf/modalg/bug29237_3 +++ b/tests/perf/modalg/bug29237_3 @@ -11,6 +11,7 @@ brestore [locate_data_file bug29237_no_overlap.rhs.brep] b bglue 1 bcheckinverted 0 +buseobb 1 bclearobjects bcleartools