Closed mich-j closed 1 year ago
This is a problem of splines. I will be working on this one.
Some background on the math part: Quadratic Spline Curve Length
We are using a dimensionless quadratic curve length function $$\int 2\sqrt{1+v^2}dv=v\sqrt{1+v^2}+ \ln(v+\sqrt{1+v^2})$$
The issue is due to negative v, when $v<-10^{10}$, $v$ and $\sqrt{1+v^2}$ are close in absolute values but of different signs, and direct adding $v + \sqrt{1+v^2}$ gets unstable numerically with loss significant digits due to floating point rounding up.
The fix, as usual, to avoid summation of floating points of different signs, for negative $v$, $$v+\sqrt{1+v^2} = \frac{1}{\sqrt{1+v^2}-v}$$ Therefore, for $v \ge 0$, $$\ln({v+\sqrt{1+v^2} })= \ln({v+\sqrt{1+v^2} }) $$ for $v<0$, $$\ln({v+\sqrt{1+v^2} }) = - \ln({\sqrt{1+v^2} - v}) $$
With your commits, on LibreCAD:
Version: 2.2.1_alpha-9-g8c2e3ce6
Compiler: GNU GCC 11.3.0
Compiled on: May 21 2023
Qt Version: 5.15.3
Boost Version: 1.74.0
System: Ubuntu 22.04.2 LTS
I observed no freezing on the sample file. Also I tested BancadaCozinha-Vistas.dxf.gz file from #1000 and it also turned out OK.
Unfortunately on file Transistors.dxf.zip from #891 freezing was still observed.
So @dxli, I think that this issue and #1000 can be closed. I leave this decision for you. If you need more testing, I can help out as much as I can.
Successfully tested.
Expected behavior
LibreCAD allows to zoom in and out to every part of a drawing.
Observed behavior
LibreCAD stops responding, when I zoom in and zoom out a few times to a specific zone in my drawing. File that I'm working on is a section cut from an assembly drawing, created in FreeCAD TechDraw Workbench and exported to .dxf. I deleted by "trial and error" lines which did not cause any freezing, which left me with a something like minimal working example, which is included in this issue ticket (
drawing.zip
). Unfortunately, I am not able to pinpoint which lines exactly caused this problem.I had an opportunity to import this file to GStarCAD on someone else's PC and it indeed prompted that some of the lines are broken. It said that it repaired them, but did not inform which ones were faulty. I imported this 'repaired' file to LibreCAD again, but it unfortunately did not help in the freezing issue.
Linking similar issues: #1000, #891
Steps to reproduce or sample file
drawing.zip
Operating System and LibreCAD version info
System: Ubuntu 22.04.2 LTS x86_64
FreeCAD: I tried two versions:
Both crashed in a similar manner.