Simple sphere cut from cylinder fails

This code produces invalid shape. Input shapes are both valid of course.

auto shape1 = BRepPrimAPI_MakeSphere(gp_Pnt(1, 1, 1), 1).Shape();
auto shape2 = BRepPrimAPI_MakeCylinder(1, 1).Shape();

auto op = BRepAlgoAPI_Cut(shape2, shape1);
op.Build();
auto shape3 = op.Shape();

BRepAlgoAPI_Check analyzer;
analyzer.SetData(shape3);
analyzer.Perform();
printf("valid: %d\n", analyzer.IsValid());

occt is the recent 7.7.0.

I found two ways to make this code work:

1. Use occt 7.4.0
2. change
auto shape1 = BRepPrimAPI_MakeSphere(gp_Pnt(1, 1, 1), 1).Shape();
to
auto shape1 = BRepPrimAPI_MakeSphere(gp_Pnt(1, 1, 0.99), 1).Shape();

So this definitely is a bug.

Mikhail Sazonov's picture

There is another way of it to work, it is to incline the coordinate system of the sphere, so that the apex was not in touch with the cylinder shell.

auto shape1 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(1, 1, 1), gp_Dir(0, 1, 1), gp_Dir(1, 1, 0)), 1).Shape();

And I confirm that this is definitely a bug. You are welcome to register it in the bug tracker.