Problems with BRepAlgoAPI_Fuse when uniting multiple bodies

Hi,

I have OCCT 7.5.0 on my MacOS Big Sur, installed using homebrew. I am trying to generate a solid in STEP format made up of cylinders and spheres using an app based on OCCT. Pic of the desired solid (Pic 1) is below:

1. It has 4 primitive cylinders arranged at 4 body diagonals of a cube.
2. A small sphere at the center of the cube (also where all cylinders intersect).
3. All cylinders in 1 and sphere at 2 are to be united to generate a single solid.

1 and 2 and created using BRepPrimAPI_MakeCylinder and BRepPrimAPI_MakeSphere

Problem:
I am having issues when I try to perform step 3 - uniting all primitives. All methods resulted in a failed union. I verified the union by writing it as a STEP file using STEPControl_Writer and opening in it in a 3D CAD software FreeCAD. The result appeared nonsensical or gibberish with missing cylinders, open or partial solids .
I have tried multiple ways to unite by specifying TopTools_ListOfShape arguments and TopTools_ListOfShape tools Here are the different options that didn't work and I have tried:

List of Shape(s) for arguments List of Shape(s) for tools
1 Cylinder 3 Cylinders
1 Sphere All Cylinders
1 Cylinder 3 Cylinders and 1 Sphere

After this, I thought maybe it's the intersection of all cylinders before union, that might be causing the problem. So I split my cylinders in halves such that any half doesn't touch any other half. If all of these half cylinders are taken a union with an overlapping sphere at the center, then the resulting solid will be the same as what I want to generate, as shown in the Pic 1 above.
pic of the half cylinders here

pic of the desired solid with sphere

List of Shape(s) for arguments List of Shape(s) for tools
1 Sphere All Cylinders halves
All cylinder halves 1 Sphere

In all trials, I got bad results, one of the examples:
bad union

Apart from using list of arguments and tools, I also tried to unite cylinders iteratively and even that was behaving in a very funny way, it will need another post to explain the behavior.

Could you please suggest what if this is an OCCT bug or there is something else that I can try to fix this union issue for this case?

Archak Goel's picture

Hi Tech team. Please let me know if you'd like me to post a smaller version of this post with just basic details. If possible, please comment about, what details will be helpful for you to understand the problem better.

Mikhail Sazonov's picture

Hi Archak,

None of the links in your message are working.

If Boolean operation does not work as expected then please register a bug in the bugtracker.

Regards,

Mikhail

Eugene Zaliznyak's picture

Hi Archak, please send me your primitives and I will test the union operation on my side.
Thanks.
With respects, Eugene.

Archak Goel's picture

Hi @Eugene Zliznyak, I have uploaded two zip folders containing separate primitives and their union (incorrect) for the two cases: 1. Using full cylinders 2. Using half cylinders.

@Mikhail Sazonov I have also corrected the links to the pictures above. I was using Google Photos shared links earlier, I have changed it to imgur links and tested them, they are working fine.

Archak Goel's picture

Hi OCCT team, did you get a chance to look at this yet?

Mikhail Sazonov's picture

Hi Archak, please create a bug in the bug tracker. It will be processed according to established priorities.

Archak Goel's picture

Hi OCCT team, I am unable to see any option to submit a bug report in the Mantis bug tracker https://tracker.dev.opencascade.org/bug_report_page.php. I am getting a message (screenshot attached). Could you please suggest what is an alternative way or if there is something needs to be fixed with my profile?

Archak Goel's picture

@Mikhail and @Eugene I think I am able to submit bug now, had to change the projects to "Community". Who should I assign it to though?

Eugene Zaliznyak's picture

Hi Archak,
I do not think the problem is in Fuse operation.
Your sphere looks strange.
How has this sphere been created ? Really simply by BRepPrimAPI_MakeSphere() and exported to STEP ?
With respects, Eugene.

Attachments: 
Archak Goel's picture

That's a weird PNG image, I re-downloaded the files I attached to this post and opened the "sphere.step" in FreeCAD, and it looks perfectly okay. Even looked in high transparency and wireframe mode, looks okay. Attached Snapshot. What software you are using to view it?

yes, I did following commands to create it -

 BRepPrimAPI_MakeSphere sphereObject(center, radius);
    sphereObject.Build();
    setShape(sphereObject.Shape());

setShape is a simple set function that stores the sphere's shape as a separate TopoDS_Shape member variable in my custom class to create Sphere. When writing, this is the code I use to write:


    IFSelect_ReturnStatus writeSTEP(const TopoDS_Shape& shape,
                                    const std::string& filename) {

        std::stringstream ss1;
        std::streambuf* ob1 = std::cout.rdbuf(ss1.rdbuf());

        STEPControl_Controller::Init();
        STEPControl_Writer SCW;
        SCW.Transfer(shape, STEPControl_AsIs);
        IFSelect_ReturnStatus result = SCW.Write(filename.c_str());
        std::cout.rdbuf(ob1);
        return result;
    }

However, even if you exclude the sphere and just try to fuse the cylinders - they don't unite properly. I have mentioned this in the table of my original post as well.

Attachments: