0026798: Boolean operations: keep desired cells and boundaries in the result
authoremv <emv@opencascade.com>
Fri, 30 Oct 2015 12:30:38 +0000 (15:30 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 12 Nov 2015 08:15:39 +0000 (11:15 +0300)
0026798: Boolean operations: keep desired cells and boundaries in the result

The algorithm is based on the General Fuse algorithm (GFA). The result of
GFA is all split parts of the Arguments.

The purpose of this algorithm is to provide the result with the content of:
1. Cells (parts) defined by the user;
2. Internal boundaries defined by the user.

In other words the algorithm should provide the possibility for the user
to add or remove any part to (from) result and remove any internal boundaries
between parts.

Requirements for the Data:
All the requirements of GFA for the DATA are inherited in this algorithm.
Plus all the arguments should have the same dimension.

The result of the algorithm is compound containing selected parts of
the basic type (VERTEX, EDGE, FACE or SOLID). The default result
is empty compound. It is possible to add any split part to the result
by using the methods AddToRessult() and AddAllToResult().
It is also possible to remove any part from the result by using methods
RemoveFromResult() and RemoveAllFromResult().
The method RemoveAllFromResult() is also suitable for clearing the result.

To remove Internal boundaries it is necessary to set the same material to the
parts between which the boundaries should be removed and call the method
RemoveInternalBoundaries(). The material should not be equal to 0, as this is
default material value. The boundaries between parts with this value
will not be removed.
One part cannot be added with the different materials.
It is also possible to remove the boundaries during combining the result.
To do this it is necessary to set the material for parts (not equal to 0)
and set the flag bUpdate to TRUE.
BUT for the arguments of the types FACE or EDGE it is recommended
to remove the boundaries in the end when the result is completely built.
It will help to avoid self-intersections in the result.

It is possible to create typed Containers from the parts added to result by using
method MakeContainers(). The type of the containers will depend on the type of
the arguments: WIRES for EEDGE, SHELLS for FACES and COMPSOLIDS for SOLIDS.
The result will be compound containing containers.
Adding of the parts to such result will not update containers. The result
compound will contain the containers and new added parts (of basic type).
Removing of the parts from such result may affect some containers if the
the parts that should be removed is in container. In this case this container
will be rebuilt without that part.

The algorithm supports history information. This information available through
the methods IsDeleted() and Modified(). In DRAW Test Harness it is available
through the same commands as for Boolean Operations (bmodified and bisdeleted).

1. API
BOPAlgo_CellsBuilder aCBuilder;
BOPCol_ListOfShape aLS = ...; // arguments
/* parallel or single mode (the default value is FALSE)*/
Standard_Boolean bRunParallel = Standard_False;
/* fuzzy option (default value is 0)*/
Standard_Real aTol = 0.0;
if (aCBuilder.ErrorStatus()) { // check error status
/* empty compound, as nothing has been added yet */
const TopoDS_Shape& aRes = aCBuilder.Shape();
/* all split parts */
const TopoDS_Shape& aRes = aCBuilder.GetAllParts();
BOPCol_ListOfShape aLSToTake = ...; // parts of these arguments will be taken into result
BOPCol_ListOfShape aLSToAvoid = ...; // parts of these arguments will not be taken into result
/* defines the material common for the cells, i.e.
   the boundaries between cells with the same material
   will be removed.
   By default it is set to 0. Thus, to remove some boundary
   the value of this variable should not be equal to 0 */
Standard_Integer iMaterial = ...;
/* defines whether to update the result right now or not */
Standard_Boolean bUpdate = ...;
// adding to result
aCBuilder.AddToResult(aLSToTake, aLSToAvoid, iMaterial, bUpdate);
aR = aCBuilder.Shape(); // the result
// removing of the boundaries

// removing from result
aCBuilder.RemoveFromResult(aLSToTake, aLSToAvoid);
aR = aCBuilder.Shape(); // the result

2. DRAW Test Harness
psphere s1 15
psphere s2 15
psphere s3 15
ttranslate s1 0 0 10
ttranslate s2 20 0 10
ttranslate s3 10 0 0

bclearobjects; bcleartools
baddobjects s1 s2 s3
# rx will contain all split parts
bcbuild rx
# add to result the part that is common for all three spheres
bcadd res s1 1 s2 1 s3 1 -m 1
# add to result the part that is common only for first and third shperes
bcadd res s1 1 s2 0 s3 1 -m 1
# remove internal boundaries
bcremoveint res

Added history support for Generated shapes (created in ShapeUpgrade_UnifySameDomain).

Methods AddToResult and RemoveFromResult have been documented in more details to clarify the procedure of adding and removing parts.

Adding external library to use ShapeUpgrade_UnifySameDomain.

Test-cases for issue #26798
74 files changed:
src/BOPAlgo/BOPAlgo_CellsBuilder.cxx [new file with mode: 0644]
src/BOPAlgo/BOPAlgo_CellsBuilder.hxx [new file with mode: 0644]
src/BOPTest/BOPTest_CellsCommands.cxx [new file with mode: 0644]
tests/boolean/cells_test/A1 [new file with mode: 0644]
tests/boolean/cells_test/A2 [new file with mode: 0644]
tests/boolean/cells_test/A3 [new file with mode: 0644]
tests/boolean/cells_test/A4 [new file with mode: 0644]
tests/boolean/cells_test/A5 [new file with mode: 0644]
tests/boolean/cells_test/A6 [new file with mode: 0644]
tests/boolean/cells_test/A7 [new file with mode: 0644]
tests/boolean/cells_test/A8 [new file with mode: 0644]
tests/boolean/cells_test/A9 [new file with mode: 0644]
tests/boolean/cells_test/B1 [new file with mode: 0644]
tests/boolean/cells_test/B2 [new file with mode: 0644]
tests/boolean/cells_test/B3 [new file with mode: 0644]
tests/boolean/cells_test/B4 [new file with mode: 0644]
tests/boolean/cells_test/B5 [new file with mode: 0644]
tests/boolean/cells_test/B6 [new file with mode: 0644]
tests/boolean/cells_test/C1 [new file with mode: 0644]
tests/boolean/cells_test/C2 [new file with mode: 0644]
tests/boolean/cells_test/C3 [new file with mode: 0644]
tests/boolean/cells_test/C4 [new file with mode: 0644]
tests/boolean/cells_test/C5 [new file with mode: 0644]
tests/boolean/cells_test/C6 [new file with mode: 0644]
tests/boolean/cells_test/C7 [new file with mode: 0644]
tests/boolean/cells_test/C8 [new file with mode: 0644]
tests/boolean/cells_test/C9 [new file with mode: 0644]
tests/boolean/cells_test/D1 [new file with mode: 0644]
tests/boolean/cells_test/D2 [new file with mode: 0644]
tests/boolean/cells_test/D3 [new file with mode: 0644]
tests/boolean/cells_test/D4 [new file with mode: 0644]
tests/boolean/cells_test/D5 [new file with mode: 0644]
tests/boolean/cells_test/E1 [new file with mode: 0644]
tests/boolean/cells_test/E2 [new file with mode: 0644]
tests/boolean/cells_test/E3 [new file with mode: 0644]
tests/boolean/cells_test/E4 [new file with mode: 0644]
tests/boolean/cells_test/E5 [new file with mode: 0644]
tests/boolean/cells_test/E6 [new file with mode: 0644]
tests/boolean/cells_test/E7 [new file with mode: 0644]
tests/boolean/cells_test/E8 [new file with mode: 0644]
tests/boolean/cells_test/E9 [new file with mode: 0644]
tests/boolean/cells_test/F1 [new file with mode: 0644]
tests/boolean/cells_test/F2 [new file with mode: 0644]
tests/boolean/cells_test/F3 [new file with mode: 0644]
tests/boolean/cells_test/F4 [new file with mode: 0644]
tests/boolean/cells_test/F5 [new file with mode: 0644]
tests/boolean/cells_test/F6 [new file with mode: 0644]
tests/boolean/cells_test/F7 [new file with mode: 0644]
tests/boolean/cells_test/F8 [new file with mode: 0644]
tests/boolean/cells_test/F9 [new file with mode: 0644]
tests/boolean/cells_test/G1 [new file with mode: 0644]
tests/boolean/cells_test/G2 [new file with mode: 0644]
tests/boolean/cells_test/G3 [new file with mode: 0644]
tests/boolean/cells_test/G4 [new file with mode: 0644]
tests/boolean/cells_test/G5 [new file with mode: 0644]
tests/boolean/cells_test/G6 [new file with mode: 0644]
tests/boolean/cells_test/G7 [new file with mode: 0644]
tests/boolean/cells_test/G8 [new file with mode: 0644]
tests/boolean/cells_test/H1 [new file with mode: 0644]
tests/boolean/cells_test/H2 [new file with mode: 0644]
tests/boolean/cells_test/H3 [new file with mode: 0644]
tests/boolean/cells_test/H4 [new file with mode: 0644]
tests/boolean/cells_test/I1 [new file with mode: 0644]
tests/boolean/cells_test/I2 [new file with mode: 0644]
tests/boolean/cells_test/begin [new file with mode: 0644]