Tolerance issues

In the application I am developing I decided to change the default tolerance value to 0.5 (for buildings 0.5 mm should be an adequate value). I used BRepBuilderAPI::Precision to set that value. The issues begin when I start using the Fuse operation (most likely all booleans cause the same problem). The new shapes produced by the Fuse operation have a higher tolerance than the one I specified initially (1.2 was the maximum I saw). In a short drawing session, one of the vertices became 1.9 mm off the Z direction from the value it should have had. As a result, the drawing ends up being useless because many operations that depend on that precision will reject the current shapes, as well as OpenCASCADE's own algorithms.

Is there anything I could do so the tolerances don't change that much?

Bearloga's picture

For big objects, it is better to use meter units instead of mm. Just scale down your shape 1000 times, so that all coordinates became measured in meters.

Paul Jimenez's picture

That sounds good. The big question is if scaling down everything by 1000 (including the tolerance) will give the expected results, or if the issue will just be the same. I will give it a try. Thanks.

Paul Jimenez's picture

It does not seem to be the solution. The same basic test caused one of the vertices to get its tolerance twice the one I specified initially, without it being necessary at all. That is exactly what happened when the tolerance was just 0.5. What the boolean operations should do is to work with a higher precision (0.05 in my case should be good enough) for all intersection points (of course the default precision should be used to check for equality). In other words, new points should be calculated more accurately to guarantee the minimum precision of the shapes involved is retained.

It is so easy to ask for something that should work to work, but it looks I will just have to look for a workaround... as usual.

Paul Jimenez's picture

The evil workaround that seems to be working is calculating the intersection points, and scheduling them for replacement. Checking and updating the tolerance during the process is helping also to keep everything in its place. That does not stop OpenCASCADE algorithms to change the tolerance sometimes (I got 0.75 in many cases), but the next operation should put everything back in its place.

Does anyone know of good algorithms to implement boolean operations that work on planar surfaces? I may consider re-writing them for that specific case sometime (I got some ideas already, but it is better to know different approaches before re-inventing the wheel).