Boolean operation fails, but succeeds when I/O TopoDS_Shape as BREP before

Hi everyone,

I'm using BRepAlgoAPI_Common to compute the common part of two TopoDS_Solids, which consists of some B-Spline-, planar and cylindrical surfaces created at runtime.

In a specific case, the Boolean operation fails although the geometries are well prepared (as in other cases which work well).

I tried to analyze it in DRAW with bop and bopcommon commands, but the Boolean operation doesn't fail there. So I tried the code of bop and bopcommon (they use BOPAlgo_PaveFiller and BOPAlgo_BOP) in my application, ending again in a failing Boolean operation (resulting shape is an empty TopoDS_Compound).

Now the strange part comes. When I save and load one of the TopoDS_Solids (using BRepTools::Write and BRepTools::Read) before the Boolean operation, the computation works as expected.

Why does it work after I/O the shape into/from a BREP-file?

My suggestion is, that some shape parameters are slightly different after I/O causing the Boolean operation not to fail anymore.

Does anybody has some thoughts on that?

liuhuiwei's picture

Use BOPAlgo_CheckerSI to check the shape has self intersection sub tem

Eugeny's picture

Hello Matthias,

Your suggestion is correct, this is caused by the loss of precision during writing/reading the shape. Try saving the shape with BinTools::Write method, which saves the shape into binary format without loss of precision. Use binrestore to load the shape in Draw.

Regards, Eugeny.

Matthias K.'s picture

Hi liuhuiwei, Eugeny,

I could reproduce the failing Boolean Operation in DRAW when transfering the shapes with BinTools.

Neither of the input shapes has a self-intersection, but the Boolean Operation leads to creation of small edges and self-intersections.

Thank you both!

Eugeny's picture

Hello Matthias, you can create an issue in attaching the dumped shapes.

Matthias K.'s picture

I have to come back to this topic again.

I perform a boolean operation resulting in an empty compound.

If I save and load one particular input shape with BinTools::Write and BinTools::Read before the boolean operation the result is okay.

How is this possible, if BinTools saves/loads shapes without loss of precision?