(Solved) Draft Edit: issues caused by loss of precision in gui_trackers

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
alafr
Posts: 45
Joined: Sat Jan 18, 2020 8:40 pm

(Solved) Draft Edit: issues caused by loss of precision in gui_trackers

Post by alafr »

Hi,
I experienced some issues with Draft Edit on Draft Wires:

(1) A perfectly planar wire often becomes slightly non planar when editing it's vertexes.
Planar edited Draft wire problem.png
Planar edited Draft wire problem.png (53.55 KiB) Viewed 627 times
  • Select a non XY face and set it as Working Plane
  • Activate Snap Working Plane
  • Draw a closed Draft Wire
  • A face is automatically created
  • Double-click in the tree view to edit wire
  • Click on a vertex and move it
  • Notice while moving the vertex that Local Dz is not exactly 0.000000
  • Click again the set new vertex position
  • The face disappears (not always, repeat if necessary)
  • Open the Points property dialog and notice that the edited vertexes have z not exactly 0.000000

(2) A wire snapped on another shape during its creation works better in Part Boolean operations than a wire snapped later during its edition
Boolean from edited Draft wire problem.png
Boolean from edited Draft wire problem.png (42.86 KiB) Viewed 627 times
  • Create a Draft polygon, Sides = 6, Radius = 1000 mm
  • Extrude the polygon, Length = 1000 mm, Direction = Normal (this creates a prism)
  • Select the top face of the prism and set it as Working Plane
  • Draw a Wire that covers approximately (no snap) half the top face of the prism
  • Double-click in the tree view to edit wire
  • Activate snap EndPoint and move the wire's Vertexes exactly on the points of the prism
  • Extrude the Wire, Length = 500 mm, Direction = Normal, Reversed
  • Run a Part Cut on the two extrusions
  • Notice that the resulting shape is bad
I investigated those two issues are apparently they are caused by a significant precision loss in https://github.com/FreeCAD/FreeCAD/blob ... rs.py#L826
EditTracker.get doesn't give back the exact value set by EditTracker.set. Specifically it's coin.SoCoordinate3() that is the culprit...

I tried modifying the gui_trackers.py file like that https://github.com/FreeCAD/FreeCAD/pull/9202 and it indeed appears to partially solve the issue (there is still the problem that the wire becomes non planar when inserting a new Vertex).

I would like to have the opinion of Draft developers or users before opening an issue or PR.
There are probably better ways to solve the issue in gui_edit.py or SoCoordinate3 ? Also I dit not find were the precision is lost when inserting a new vertex...

Draft users can try the proposed fix and check if it breaks anything else...

Thanks
Attachments
Draft Edit Problems.FCStd
(26.77 KiB) Downloaded 29 times
Last edited by alafr on Wed Apr 12, 2023 4:46 pm, edited 1 time in total.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Edit: issues caused by loss of precision in gui_trackers

Post by Roy_043 »

Thanks and good catch! A bit worrying that coin.SoCoordinate3() has a limited accuracy. AFAICT the modified code fixes both issues. Please remove the Draft status so that the PR can be merged.
alafr
Posts: 45
Joined: Sat Jan 18, 2020 8:40 pm

Re: Draft Edit: issues caused by loss of precision in gui_trackers

Post by alafr »

Thanks for merging

Roy_043 wrote: Wed Apr 12, 2023 8:39 amA bit worrying that coin.SoCoordinate3() has a limited accuracy.
I don't think it's worrying, after all coin is used for 3D rendering and it's in most cases precise enough for this purpose.
In the contrary it's relieving to find out that Booleans in Freecad are not broken as I thought initially :) !
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: (Solved) Draft Edit: issues caused by loss of precision in gui_trackers

Post by yorik »

Excellent find and solution! This had bugged everything for some time I think
Post Reply