Peculiar results when fusing two shapes with BSpline surfaces

I was running some General Fuse Algorithm (henceforth simply "fuse") operations involving shapes with BSpline surfaces (henceforth "BSpline boxes"), and I observed the following peculiar results. 

  • The fuse between a BSpline box and a regular box (with 6 flat faces) results in a regular box plus parts of the BSpline box that are inside the regular box. The rest of the BSpline box disappears.
  • The fuse between two BSpline boxes results only in one BSpline box which is slightly deformed from the original inputs.

Here are a little bit more details on the tests.

1. The BSpline ​box is created using the following steps. (Please also see the attached CreateBSplineBox.cpp)

  • Create the top and bottom surfaces using GeomAPI_PointsToBSplineSurface
  • Convert these surfaces into faces using BRepBuilderAPI_MakeFace
  • Get the wires of these faces using TopExp_Explorer
  • Identify the vertices of the wires
  • Create vertical edges connecting vertices at the top and bottom
  • Create vertical wires, and subsequently faces
  • Add the top surface, the bottom surface, and all the vertical faces into a shell
  • Add this shell into a solid, and return it

2. Perform the fuse using​ BOPAlgo_Builder. (fuse-snippet.cpp)
In this snippet, one box's corner is at (0.8,0.8,0.8), and the other at (1,1,1). Both have the size of 2x2x2 units.

The attached images show the resulting shapes, visualised using CAD Assistant:

  • BSpline-and-regular.png --> The result of fusing a BSpline box and a regular box
  • two-BSplines-boxes.png --> The result of fusing two BSpline boxes

My expectation is the results should resemble the fuse results between two regular boxes. That is, the overlapping area inside both boxes is identified, while parts of the shapes outside this overlap are preserved. However, apparently I didn't get such results. May I just verify if these are intentional, or if I made a mistake somewhere?

I am using Open CASCADE 7.1.0 (64 bit), Visual Studio 2017, and Windows 8.1.

Thank you in advance for your help.

Best regards,
Nicholas

Forum supervisor's picture

Dear Nicholas,

You should use methods of the classes BRepAlgoAPI_Fuse or BOPAlgo_BOP.

The tests based on both these ways have produced the proper expected results for your test cases - fusing of "BSpline boxes" and “regular box”.

Please don’t hesitate to communicate us via Contact Form to exchange information about our expertise and services and general context and specific needs of your projects.

Best Regards,

Forum supervisor 

Nicholas MW's picture

Dear Forum supervisor,

Thank you for your reply. As you suggested, I tried BRepAlgoAPI_Fuse and BOPAlgo_BOP. Both generated the same results, and in some cases they preserved the input shapes as I would like them to be. However, the results did not seem to be consistent, so I wonder if I am doing things correctly. In some cases, one of the arguments disappeared.

You can see the results in the attached image (montage-BSpline-regular.png and montage-BSpline-BSpline.png). I shifted the BSpline box from (-1.5,-1.5,-1.5) to (3.5,3.5,3.5) by (0.1,0.1,0.1) in each iteration. The snippet for this is attached (fuse-snippet-2.cpp). I observed both cases underwent a few phases of disappearance and re-appearance of one BSpline box (or portions of it) as one of the boxes moves.

Another observation is that if applied to two regular boxes, these functions remove the overlapping part (please refer to the clipped shape in BOPAlgo_BOP-regular.png). There seems to be discrepancies with the above cases, as in here they unite only the outer boundaries of the mesh.

Also thank you for your offer. We will discuss about that among our team members.

Best regards,
Nicholas

Forum supervisor's picture

Dear Nicholas,

If the issue is reproduced for some input data, you can register the issue in OCCT Mantis BugTracker which is available via our Collaborative Development Portal with these certain data for issue reproducing.

Best Regards,

Forum supervisor 

dphil's picture

Hi Nicholas,

Your issue sounds surprisingly similar to one I had recently. I was trying to do a boolean cut with one box into another. This worked fine when both were normal boxes, but like you I then tried with a bspline box (made from Geom_BSplineSurface converted to a TopoDS_Face and swept with BRepPrimAPI_MakePrism). And I got very similar strange results as you that were hard to understand. I had the same issue of parts of my bspline box disappearing/reappearing as I moved it back and forth through the regular box that it was supposed to be cutting (it did not appear to be cutting it at all, in fact in some positions it appeared to be some sort of fuse - ie the opposite operation I intended - of the bspline box shell with the regular box).

After much headache, I finally discovered that the shape creation and boolean operation was all correct, it was my rendering of the boolean result that was wrong! So that's another thing to consider. Before questioning the correctness of your brep construction and boolean operation, make sure you are meshing and interpreting your mesh data correctly for rendering.

I wrote about my issue here: https://www.opencascade.com/content/boolean-cut-incorrect-mesh-result

Hope that helps, in case you are having the same problem.

David