chbergmann / CurvedShapesWorkbench

FreeCAD Workbench for creating 3D shapes from 2D curves
GNU Lesser General Public License v3.0
58 stars 10 forks source link

Fix CurvedSegment edge case when bsplines have different num of poles #24

Closed andir closed 7 months ago

andir commented 8 months ago

In one of my recent FreeCAD adventures I tried to create a curved segment between a sketch, a downscaled version of the sketch and a simple hullcurve. The CurvedShapeWB would always fail with an IndexError from within the makeRibsSameShape function. This was caused by a mismatch in poles between the two shapes. Something that should have been caught by the code in CurvedSegmentWorker::makeRibs.

It turned out that the actual code for the (non-interpolated) ribs passed the FirstParameter and LastParameter to the toBSpline function which the check in the Worker class didn't. Passing those parameters to the checking code ensured that my curve ended up in the interpolation code path and thus stopped throwing exceptions and produced the correct objects in FreeCAD.

andir commented 7 months ago

Doh! You are right. It might have worked by accident in my case. That shouldn't be mixed up. I inteded for it to be the same as is done further down in the code. Otherwise this is again a wrong "precondition check" :-)