BRepAlgoAPI_Common produces empty compound

I am using to compare shapes as they come from different sources and IsEqual cannot be used. For some faces common returns empty compound. Here is a code to reproduce, as well as the brep file of the shape:

        BRep_Builder reader1, reader2;
        TopoDS_Shape face1, face2;
        BRepTools::Read(face1, "D:/test/faulty_face.brep", reader1);
        BRepTools::Read(face2, "D:/test/faulty_face.brep", reader2);

        BRepAlgoAPI_Common common_builder;
        TopTools_ListOfShape s1_list, s2_list;
        s1_list.Append(face1);
        s2_list.Append(face2);
        common_builder.SetArguments(s1_list);
        common_builder.SetTools(s2_list);
        common_builder.Build();

        common_builder.DumpWarnings(std::cout);
        common_builder.DumpErrors(std::cout);

        if (common_builder.Shape().IsNull())
            std::cout << "Shape is null!" << std::endl;
        ShapeAlgorithms::writeBrepFile(common_builder.Shape(), "D:/test/compared.brep");

As a result, no warnings or errors are dumped to cout, shape is not null, and the compared.brep is an empty compound. So, what is causing the problem? Is this a bug in algorithm? Or is the shape wrong? What could be the workaround?

Thank you!

Attachments: 
Mikhail Sazonov's picture

Hi,

I cannot reproduce the problem for me, the result is not empty. Here is the snapshot of a session in DRAW:

Draw[21]> restore faulty_face.brep a
a
Draw[22]> restore faulty_face.brep b
b
Draw[23]> bcommon r a b
Draw[24]> nbshapes a
Number of shapes in a
 VERTEX    : 146
 EDGE      : 147
 WIRE      : 1
 FACE      : 1
 SHELL     : 0
 SOLID     : 0
 COMPSOLID : 0
 COMPOUND  : 0
 SHAPE     : 295

Draw[25]> nbshapes b
Number of shapes in b
 VERTEX    : 146
 EDGE      : 147
 WIRE      : 1
 FACE      : 1
 SHELL     : 0
 SOLID     : 0
 COMPSOLID : 0
 COMPOUND  : 0
 SHAPE     : 295

Draw[26]> nbshapes r
Number of shapes in r
 VERTEX    : 146
 EDGE      : 147
 WIRE      : 1
 FACE      : 1
 SHELL     : 0
 SOLID     : 0
 COMPSOLID : 0
 COMPOUND  : 1
 SHAPE     : 296
Vadims Geza's picture

Apparently, I mixed up some results. Now two files are attached, which seem to be identical visually, but even test harness returns wrong results for common operation.

Mikhail Sazonov's picture

Everything works with the new shapes, too. You should use the actual BO, which are run by the command 'bcommon', rather than 'common', in Draw. The command 'common' runs obsolete version of BO.

Vadims Geza's picture

I apologize for uploading non-reproducible problems!
Now I double-checked everything, installed the latest binary (7.5.0), and still got problems with simple geometry (attached).
Used 'bcommon', but the result of boolean is still empty shape. I hope this time it is reproducible!
Thank you for your time!

Attachments: 
Mikhail Sazonov's picture

Now the problem is reproducible with conical_ring.brep. You are appreciated to register a bug in the bug tracker.

Eugene Zaliznyak's picture

As for me it happens for any case where shapes do not have common geometry (at least 7.4).
TopoDS_Shape box1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 10, 10, 10);
TopoDS_Shape box2 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 20), 10, 10, 10);

Here common operation returns non-null compound.
I would advise to check the result by enumerating any vertex:
TopExp_Explorer ex(resShape, TopAbs_VERTEX);
if (!ex.More())
{
return false;
}

With respects, Eugene.