Thu, 02/12/2015 - 13:16
1. Introduction
Next version of OCCT will feature new mode of Boolean Operation Algorithm (BOA), called "Fuzzy". Fuzzy Boolean operations are the type of Boolean operations in which additional user-specified tolerance is used. This mode allows Boolean operations to handle robustly cases of touching and near-coincident entities of the argument shapes.
2. Use of Fuzzy Boolean operations
The Fuzzy Boolean Operations are useful on the shapes with gaps or embeddings between the entities of these shapes which are not covered by the tolerance values of these entities. Such shapes can be the result of modeling mistakes, or translating process, or import from other systems with loss of precision, or errors in some algorithms. Most likely, the standard Boolean operations will give unsatisfactory results on such models. The result may contain unexpected and unwanted small entities, faulty entities (in terms of BRepCheck_Analyzer), or there can be no result at all. With the Fuzzy Boolean operations it is possible to get the expected result - it is just necessary to define the appropriate fuzzy tolerance for the operation. To define that value it is necessary to measure the value of the gap (or the value of embedding depth) between the entities of the models, slightly increase it (to make the shifted entities coincident in terms of their tolerance plus the additional one) and pass it to the algorithm.
3. Implementation
Fuzzy Boolean operations are integrated in the current development version of OCCT (6.8.1.dev). The class BRepAlgoAPI_BooleanOperation contains the corresponding API for its usage: new method SetFuzzyValue(const Standard_Real theFuzz) allows to set the fuzzy tolerance value. Default is zero, that is, no fuzzy treatment.
4. Examples
The following examples demonstrate the advantages of Fuzzy Boolean operations over the standard ones in typical situations.
4.1. Example 1
In this example the cylinder (shown in yellow and transparent) is subtracted from the box (shown in red). The cylinder is shifted on the 5.e-5 value relatively to the box along its axis (the distance between rear faces of the box and cylinder is 5.e-5).
The results obtained using standard Boolean operations and the Fuzzy ones with the fuzzy value 5.e-5 are:
Result of CUT operation obtained with standard BO | Result of CUT operation obtained with Fuzzy BO |
Here Fuzzy option allowed eliminating very thin part of the result shape produced by standard algorithm due to misalignment of rear faces of the box and the cylinder.
4.2. Example 2
In this example two boxes are fused. One of them has dimensions 10*10*10, and the other is 10*10.000001*10.000001 and adjacent to the first one. There is no gap in this case as the surfaces of the neighboring faces coincide, but one box is slightly grater than the other.
The results obtained using standard Boolean operations and the Fuzzy ones with the fuzzy value 1.e-6 are:
Result of CUT operation obtained with standard BO | Result of CUT operation obtained with Fuzzy BO |
Here Fuzzy option allowed to get rid of extremely narrow face in the result produced by standard operation.
4.3. Example 3
In this example the small planar face (shown in orange) is subtracted from the big one (shown in yellow). There is a gap 1.e-5 between the edges of these faces.
The results obtained using standard Boolean operations and the Fuzzy ones with the fuzzy value 1.e-5 are:
Result of CUT operation obtained with standard BO | Result of CUT operation obtained with Fuzzy BO |
Here Fuzzy options eliminated pin-like protrusion resulting from the gap between edges of the argument faces.
4.4. Example 4
In this example the small edge is subtracted from the big one. The edges are overlapping not precisely, with max deviation between them equal to 5.28004e-05. We will use 6.e-5 value for Fuzzy Boolean operations.
The results obtained using standard Boolean operations and the Fuzzy ones with the fuzzy value 6.e-5 are:
Result of CUT operation obtained with standard BO | Result of CUT operation obtained with Fuzzy BO |
This example stresses not only the validity, but also the performance issue. The fuzzy Boolean operations with the appropriate value work much faster than the standard ones. To measure the performance of Boolean operations on this case the following environment is used:
Processor | Intel(R) Core(TM) i5-3450 CPU @ 3.10 GHz |
System type | 64-bit Operating System |
Installed memory (RAM) | 16GB |
Operating System | Windows 7 Professional Copyright 2009 Microsoft Corporation. Service Pack1 |
Compiler | Microsoft Visual Studio Professional 2012, Version 11.0.61030.00 Update 4 |
Open CASCADE | 6.8.1 development, optimized mode |
The following results have been obtained:
Standard Boolean Operations, sec | Fuzzy Boolean Operations, sec | Gain, times | |
CPU user time, sec | 2.09 | 0.047 | 44.47 |
5.Conclusion
Fuzzy Boolean operations provide a way to perform operations on the shapes with near-coincidence between their entities robustly, filling gaps and eliminating small entities resulting from misalignment of input shapes. Fuzzy Boolean operations are able to produce the correct result while the standard ones are not.
Mon, 02/16/2015 - 16:11
Is there any existing example code that shows how to migrate from the BRepAlgoAPI_Fuse aFuse(S1,S2) constructor? I'm currently getting strange errors.
Mon, 02/16/2015 - 16:28
The following should work:
BRepAlgoAPI_Fuse aFuse;
TopTools_ListOfShape L1, L2;
L1.Append(S1);
L2.Append(S2);
aFuse.SetArguments(L1);
aFuse.SetTools(L2);
aFuse.SetFuzzyValue(Fuz);
aFuse.Build();
Mon, 02/16/2015 - 21:23
Thank you very much. I did exactly the above. But my problem persists.
If i set the FuzzyValue to high, i get a damaged Shape returned. This is fine.
But when I run a new boolean operation with an appropriate FuzzValue (or without setting it) I still get a damaged result or sometimes isDone() returns false.
It seems that the shared Shapes got corrupted.
One of the input shapes (a cylinder primitive) fails the bopcheck due to self intersecting vertexes.
Comparing dumps of the input shape differs only in the tolerances. But i was not able to reproduce this in DRAWEXE.
Mon, 02/16/2015 - 23:42
The following draw script is to reproduce the operation in draw. The command maxtolerance shows the tolerances of the shape.
It is a known problem that the operation modifies the input shape. We have in plan to overcome this. Now the workaround is to copy shapes before operation (tcopy command in draw).
box a 10 10 10
pcylinder c 10 30
ttranslate c 0 0 1e-5
puts [maxtolerance a]
puts [maxtolerance c]
bclearobjects; bcleartools
baddobjects a
baddtools c
bfuzzyvalue 1e-5
brunparallel 1
bapibop r 2
puts [maxtolerance a]
puts [maxtolerance c]
Tue, 12/13/2016 - 12:02
Since OCCT 7.0, Boolean operations acquired new option SetNonDestructive, which allows safe treatment of the input shapes. With it turned on, the algorithm must not modify the arguments. However, this option did not work properly in collaboration with Fuzzy option.
In preparation to OCCT 7.1, a tremendous work has been done to improve functioning of Fuzzy option. Now these two options work fine and produce good result, without modification of input shapes thanks to NonDestructive option, and resolve touch cases thanks to Fuzzy option. Now using Fuzzy option does not increase tolerance of the output shape without actual need, i.e. tolerance is increased only in the place of an intersection when it occurs due to Fuzzy value.