Error while fusing a sphere with a cylinder

Hello everyone,

I'm trying to fuse a cylinder with a sphere, where the sphere is offset by a certain amount. This seems to fail (produces a broken solid) when the sphere's offset is close to the cylinder's radius. It works better at other angles.

The code I'm using to do this is:

TopoDS_Shape ves = BRepPrimAPI_MakeSphere(500);
TopoDS_Shape noz = BRepPrimAPI_MakeCylinder(50, 580);
gp_Trsf transform;
transform.SetTranslation(gp_Vec(0, 50, 0));
TopoDS_Shape transformed = BRepBuilderAPI_Transform(ves, transform);
TopoDS_Shape fused = BRepAlgoAPI_Fuse(transformed, noz);
BRepTools::Write(fused, "fused.brep");

Can someone help me with this?

T.R.Shashwath's picture

More progress: If I rotate the sphere by 90 degrees on the X or Y axis, this problem goes away.

Still, I'd like to know what this is, and what causes it, if anyone here knows...

m-aronsson's picture

Open Cascade had terrible problems with booleans and spheres in the past (most of the time when one of the poles are inside the other shape),I guess what you see is the same thing.

T.R.Shashwath's picture

Thanks. This confirms my suspicions.

I'll just continue by rotating the sphere like I described above.