I have encountered an issue with Open Cascade 7.5.0 while trying to fuse two solid shapes and exporting the result to the STEP format.
I create a box and two cylinders that I would assume should be equal. Both cylinders share the same height, radius and orientation, except that one of them was created at the position (-4, 5.5, 0), while the other is a located instance at the same position of a cylinder originally created at the origin. I would expect the results of fusing operations with either cylinders and the box to be equal. However, when exporting the resulting shapes to STEP files, the result of fusing the box and the located cylinder instance seems broken. Oddly enough, this does not happen when exporting the same shapes to the IGES format.
// Create a box. auto box = TopoDS_Shape( BRepPrimAPI_MakeBox( gp_Pnt(-10.0, -5.0, 0.0), gp_Pnt( 10.0, 5.0, 5.0))); // Create a cylinder. auto cylinder = TopoDS_Shape( BRepPrimAPI_MakeCylinder( gp_Ax2( gp_Pnt(-4.0, -5.5, 0.0), gp_Dir( 0.0, 0.0, 1.0)), 2.0, 5.0)); // Create another cylinder that should be equal to the one above, except that it's a located instance of a cylinder created in the origin. auto trsfCylinder = gp_Trsf(); trsfCylinder.SetTranslation(gp_Vec(-4.0, -5.5, 0.0)); auto cylinderLocated = TopoDS_Shape( BRepPrimAPI_MakeCylinder( gp_Ax2( gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0)), 2.0, 5.0)).Located(trsfCylinder); // Perform two boolean fuse operations where the box is fused with both cylinders respectively. auto fusedShape = BRepAlgoAPI_Fuse(box, cylinder); auto fusedShapeLocated = BRepAlgoAPI_Fuse(box, cylinderLocated); // Export the resulting shapes of the fuse operations to STEP files. auto app = XCAFApp_Application::GetApplication(); auto doc0 = opencascade::handle<TDocStd_Document>(); app->NewDocument("doc0", doc0); XCAFDoc_DocumentTool::ShapeTool(doc0->Main())->AddShape(fusedShape); auto writer0 = STEPCAFControl_Writer(); writer0.Perform(doc0, "fusedShape.stp"); app->Close(doc0); auto doc1 = opencascade::handle<TDocStd_Document>(); app->NewDocument("doc1", doc1); XCAFDoc_DocumentTool::ShapeTool(doc1->Main())->AddShape(fusedShapeLocated); auto writer1 = STEPCAFControl_Writer(); writer1.Perform(doc1, "fusedShapeLocated.stp"); app->Close(doc1);
I have attached the exported step files; they can be found in the zip-archive ("fused_shapes.zip"). The attached png-image ("fused_shapes.png") shows the broken shape resulting from the fusing operation of the box and the located cylinder on the right while the left shows the intact variant resulting from fusing the box with the non-located cylinder.
Is this a bug or am I doing something fundamentally wrong here?