Bug #2509: Sweep using bezier curve bug

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

issue #2509: Sweep using bezier curve bug
Description
Create a pipe using bezier curve. Depending on geometric point placement, the sweep bugs.
-------------------------------------
OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.Unknown
Build type: Release
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1

Steps To Reproduce
Simple case:
1) Create a bezier curve using 4 points aligned (2 vertex, 2 geometric).
2) Create 2 disks placed to the curve extremities.
3) Create a sweep with the two disks along the bezier curve.

Additional Information
See the joint example in the FreeCAD file and a screenshot
screen.jpeg
screen.jpeg (148.46 KiB) Viewed 3432 times
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

normandc wrote:summoning NormandC
If and when you get around to it. Thanks in advance!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Bug #2509: Sweep using bezier curve bug

Post by chrisb »

There is an additional problem with the example given which crashes FreeCAD:
- Open file bug1.fcstd
- select Sweep
- in the Data Tab change Frenet to true
- FreeCAD crashes on recompute

Output of console:

Code: Select all

Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Part::Part2DObjectPython: Overread data for property Support of type App::PropertyLinkSubList, expected type is App::PropertyLinkSub
Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x36cb0) [0x7f92d9ffacb0]
#1  0x7f92a107b24e in BRepFill_Sweep::BuildShell(BRepFill_TransitionStyle, int, int, TopTools_MapOfShape&, BRepFill_DataMapOfShapeHArray2OfShape&, BRepFill_DataMapOfShapeHArray2OfShape&, double, double) from /usr/lib/x86_64-linux-gnu/libTKBool.so.10+0x1ece
#2  0x7f92a107ebac in BRepFill_Sweep::Build(TopTools_MapOfShape&, BRepFill_DataMapOfShapeHArray2OfShape&, BRepFill_DataMapOfShapeHArray2OfShape&, BRepFill_TransitionStyle, GeomAbs_Shape, GeomFill_ApproxStyle, int, int) from /usr/lib/x86_64-linux-gnu/libTKBool.so.10+0x3cc
#3  0x7f92a10648e6 in BRepFill_PipeShell::Build() from /usr/lib/x86_64-linux-gnu/libTKBool.so.10+0x3a6
#4  0x7f929f276632 in BRepOffsetAPI_MakePipeShell::Build() from /usr/lib/x86_64-linux-gnu/libTKOffset.so.10+0x12
#5  0x7f92a3bb9f21 in Part::Sweep::execute() from /usr/lib/freecad-daily/lib/Part.so+0x761
#6  0x7f92dc3ff3a5 in App::DocumentObject::recompute() from /usr/lib/freecad-daily/lib/libFreeCADApp.so+0x15
#7  0x7f92a3bbdaaf in Part::Feature::recompute() from /usr/lib/freecad-daily/lib/Part.so+0xf
#8  0x7f92dc3cf72c in App::Document::_recomputeFeature(App::DocumentObject*) from /usr/lib/freecad-daily/lib/libFreeCADApp.so+0x9c
#9  0x7f92dc3d55b2 in App::Document::recompute() from /usr/lib/freecad-daily/lib/libFreeCADApp.so+0x362
#10  0x7f92dcc34de3 in Gui::PropertyEditor::PropertyEditor::closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x63
#11  0x7f92daa3487a in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x2da
#12  0x7f92db5a7230 in QAbstractItemDelegate::closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x40
#13  0x7f92db49495c in QItemDelegate::eventFilter(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x31c
#14  0x7f92daa20646 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x86
#15  0x7f92daf51e0c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x6c
#16  0x7f92daf584a0 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x270
#17  0x7f92dcabced1 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x41
#18  0x7f92daa204dd in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x6d
#19  0x7f92daf56542 in QApplicationPrivate::setFocusWidget(QWidget*, Qt::FocusReason) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x182
#20  0x7f92daf9c68b in QWidget::setFocus(Qt::FocusReason) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x1bb
#21  0x7f92daf584ef in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2bf
#22  0x7f92dcabced1 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x41
#23  0x7f92daa204dd in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x6d
#24  0x7f92daf57d93 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x153
#25  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x2449eb) [0x7f92dafcc9eb]
#26  0x7f92dafcc289 in QApplication::x11ProcessEvent(_XEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x1559
#27  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bb32) [0x7f92daff3b32]
#28  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x254) [0x7f92d387de04]
#29  /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x49048) [0x7f92d387e048]
#30  /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7f92d387e0ec]
#31  0x7f92daa4d7a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x71
#32  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bbe6) [0x7f92daff3be6]
#33  0x7f92daa1f0af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x2f
#34  0x7f92daa1f3a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x175
#35  0x7f92daa24b79 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x89
#36  0x7f92dca7ae11 in Gui::Application::runApplication() from /usr/lib/freecad-daily/lib/libFreeCADGui.so+0x1371
#37  freecad-daily(main+0x6ad) [0x4032cd]
#38  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f92d9fe5f45]
#39  freecad-daily() [0x4040f2]
OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10101 (Git)
Build type: None
Branch: master
Hash: 99fa203f323927b0dd027420d4421b577b7420c3
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Bug #2509: Sweep using bezier curve bug

Post by NormandC »

I confirm the issue, but...

The shapes are extremely small, in the micron range. I wonder if it's relevant.

What thing I find puzzling: why a BezCurve with all points aligned, which amounts to a straight line? Maybe sweep doesn't like that.

Someone needs to test this with OCC 7.1.0. I still haven't found the time to compile it. Rebuilt my whole system earlier this week.

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6707 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 5465bc47c95db45e0be85dc0e2872419efadce0f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Bug #2509: Sweep using bezier curve bug

Post by NormandC »

NormandC wrote:What thing I find puzzling: why a BezCurve with all points aligned, which amounts to a straight line? Maybe sweep doesn't like that.
Just tested with abdullah's new Sketcher B-Spline. A B-spline is not a Bézier curve, but they're close relatives.

I made a B-spline with poles all lying on the vertical sketch axis, producing a straight path:
FC017_Sweep_Straight_B-spline_path_01.png
FC017_Sweep_Straight_B-spline_path_01.png (13.42 KiB) Viewed 3388 times
And here's the result:
FC017_Sweep_Straight_B-spline_path_02.png
FC017_Sweep_Straight_B-spline_path_02.png (25.03 KiB) Viewed 3388 times
If I don't force the B-Spline to be straight, the sweep is nice and smooth:
FC017_Sweep_Straight_B-spline_path_03.png
FC017_Sweep_Straight_B-spline_path_03.png (18 KiB) Viewed 3388 times
If I create a Sketcher B-spline with only 2 poles, it also produces a straight segment that is still a B-spline - and the Sweep succeeds.

So the question here is this:

Does a 4-point Bézier or B-spline curve constrained to be straight make any sense at all??? Note that when creating a BezCurve with only two points, a Draft Line is automatically created instead. Which makes sense to me.

Either it's an inappropriate use of the BezCurve (toward which I tend but I am not a developer), or an issue with the OCC kernel...
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Bug #2509: Sweep using bezier curve bug

Post by Chris_G »

Hi,
I think this bug may be similar to this one : Unusable Wire from Section
In both cases, the sweep path has some straight segments, that have a normal plane, but no unique normal vector ( which is needed for Frenet ).
IMHO, this is an OCC bug. A nurbs or Bezier curve with poles aligned is perfectly valid.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

Chris_G wrote:Hi,
I think this bug may be similar to this one : Unusable Wire from Section
In both cases, the sweep path has some straight segments, that have a normal plane, but no unique normal vector ( which is needed for Frenet ).
IMHO, this is an OCC bug. A nurbs or Bezier curve with poles aligned is perfectly valid.
So a relationship between issue #2509 & issue #2187?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

bump
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

another soft bump to stimulate conversation
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2509: Sweep using bezier curve bug

Post by Kunda1 »

Kunda1 wrote: Fri Feb 17, 2017 1:46 pm
Chris_G wrote:Hi,
I think this bug may be similar to this one : Unusable Wire from Section
In both cases, the sweep path has some straight segments, that have a normal plane, but no unique normal vector ( which is needed for Frenet ).
IMHO, this is an OCC bug. A nurbs or Bezier curve with poles aligned is perfectly valid.
So a relationship between issue #2509 & issue #2187?
Is there an upstream open ticket for this issue we can link to or should we create one?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply