problems with BRepAlgoAPI_Cut: lost control of surface complexity after the cut

Forums: 

Dear all,
I'm finding several difficulties in a very simple tool that creates a box.
All the surfaces of the box are defined starting from simple curves, by means of the BRepOffsetAPI_ThruSections function.
Each curve is built from a list of points (by means of GeomAPI_PointsToBSpline) provided as input.
All surfaces extend more than necessary, and then all the "extended" surfaces are cut (by means of BRepAlgoAPI_Cut) in order to have the desired box.
In particular, the bottom and top surfaces should be planar surfaces created starting from some linear segments.
After cutting them with sidewalls, the top and bottom surfaces appear too complex: with some wiggles in some specific regions where sharp angles are encountered (please see attached pictures).
I wonder why it happens: I can not understand if the problem arises from the way I choose for creating the surfaces or from the cut operation. I tried to export the "extended" surfaces and perform the cut operations in a commercial CAD and it works, so I suppose that I'm missing something in the cut. In any case, any suggestion of how to improve the tool is really welcome.
I hope the problem will be more clear looking at the specific application: to this end, I prepared a test case to replicate the problem.
Attached you can find the simple source code as well as my input files in the zip file and two images showing the issues I'm referring to.
I look forward to any suggestions,
Thanks,
Matteo

Attachments: