Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Post by -alex- »

Hi, here I would like to talk and describe some behaviors of Part_RuledSurface, Par_Loft and Part_Sweep.
As you know those features usually produces twisted faces when start and end profiles are rotated from each other.
But, in sometimes the start and the end profiles are parallel, segments are parallel as well, however in such situation the above features produce Bspline elements (faces n edges) although said elements should be flat or linear.
Such behavior produces too much complex elements for no reason, it's overkill. I don't know if it's related to FreeCAD or OCC, I'm not a developer.

First example:
Part_RuledSurface_should_be_a_planar_face.gif
Part_RuledSurface_should_be_a_planar_face.gif (126.81 KiB) Viewed 1740 times
Part_RuledSuraface.FCStd
(5.29 KiB) Downloaded 47 times

This ruled surface is totaly flat, however face and edges are Bsplines, the same if the shape is rectangular.

Second example:
Loft_plane-faces_n_Bezier-edges_to_Bspline_faces_n_edges_behaviour.gif
Loft_plane-faces_n_Bezier-edges_to_Bspline_faces_n_edges_behaviour.gif (251.24 KiB) Viewed 1740 times
Loft_plane_to_Bspline_faces_behaviour.FCStd
(7.95 KiB) Downloaded 47 times

Here it's worst, when the shape is totaly rectangular shaped faces are planes and edges are Bezier edges. But when the shape is stretched the faces become Bsplines and the edges Bsplines also. This is a source of instability (Xref for eg.).

Third exemple, draft option of PartDesign Pad in Linkstage3 with draft option:
realthunder wrote:ping
Linkstage3_PD_Pad_with_draft_option_leads_to_Bspline_edges.gif
Linkstage3_PD_Pad_with_draft_option_leads_to_Bspline_edges.gif (257.51 KiB) Viewed 1740 times
File: -> see next post.

Here we've got flat and linear elements, then with draft option faces remain flat but edges turns to Bsplines.

Last example with Sweep, the behavior is better:
https://forum.freecadweb.org/viewtopic. ... 50#p470924
Image

Here faces are planes, but edges are still Bsplines.

AFAIK such behavior make shapes which are impossible to unfold in sheetmetal workbench, it also involves errors with Xref because of the change of elements nature when the shape's dimension vary.
IMO get flat faces and linear edges when start and end profiles are flat and parallel would be far more reliable.

What is the underlying mechanism which controls such behavior in source code?
Is it possible to trigger a special behavior in order to get flat and linear elements from OCC for non twisted shapes?
(It could be a new property "avoid Bspline elements for non twisted shapes". Set to False by default in PartWB preferences for backward compatibility)
Power users of FreeCAD and devs, what's your opinion about such behavior?

Thanks for your attention.

OS: Debian GNU/Linux 10 (buster) (LXDE/LXDE-pi)
Word size of FreeCAD: 64-bit
Version: 0.20.25893 (Git)
Build type: Unknown
Branch: master
Hash: b8c1877133c814cd801309fd0b0266a6d1e0b75e
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
Last edited by -alex- on Tue Oct 26, 2021 7:44 am, edited 3 times in total.
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Enhancement request: flat and linear edges with Part Ruled Loft Sweep

Post by -alex- »

Here the missing file (Linkstage3 branch):
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Post by realthunder »

Here is the commit I added in my branch to 'linearize' the bspline face. And here is the function to do so. I managed to replace the bspline surface geometry of the face with a planar one, but didn't get the same working for edges. Considering the edge geometry are often generated on demand from surface, we probably need to recreate the entire face, or even shell and solid. Need further investigation. Anyone interested can try.

Maybe you can post some sample file showing unfolding failure with Bspline edge produced in my branch. I'll see if it can be fixed in sheetmetal, which would be easier as the sheetmetal are meant to generate shapes by itself. It's probably just a matter of improving linear edge detection method.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Post by -alex- »

realthunder wrote: Wed Oct 27, 2021 12:04 am Here is the commit I added in my branch to 'linearize' the bspline face. And here is the function to do so.
Sounds great! Thanks for your quick reply, much appreciated. I'm compiling your branch ATM, I'll report tomorrow with a sheetmetal test file.
I hope bspline edges could be linearised as well in futur. However maybe you're right, it could be more convenient to improve sheetmetal unfold behaviour, as a workaround. AFAIK the unfold algorithm of Ulrich Brammer does unfold shapes with only planar and cylindrical faces. If you have a plan to replace Bspline elements by planar and linear ones in unfold feature I'm excited to see that.

Offtopic: I've seen 3 days ago you added Diligent engine to renderer modul in Linkdaily branch :P
Does it mean your Linkdaily branch now would support Vulkan API?
I assume that would be great for RPI4 users of FreeCAD because https://www.raspberrypi.com/news/vulkan ... erry-pi-4/ :roll:
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Post by realthunder »

-alex- wrote: Wed Oct 27, 2021 11:12 pm Offtopic: I've seen 3 days ago you added Diligent engine to renderer modul in Linkdaily branch :P
Does it mean your Linkdaily branch now would support Vulkan API?
I assume that would be great for RPI4 users of FreeCAD because https://www.raspberrypi.com/news/vulkan ... erry-pi-4/ :roll:
I actually added both bgfx and Diligent engine. And I got bgfx OpenGL backend working already (just for rendering their examples, not FC objects yet), but not Diligent, as it demands OpenGL 4 which my current machine don't have. For a smoother transition, we have to support older OpenGL, and also legacy code that renders using their own OpenGL code. What I am trying to do is to write my renderer using those libraries to render into a framebuffer/texture, and then copy into FC OpenGL framebuffer. So if the machine supports extensions for sharing between Vulkan and OpenGL, then yes, we can have Vulkan rendering there. The same goes for D3D rendering on Windows, and Metal on MacOSX.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Enhancement request: planar faces and linear edges with Part Ruled Loft Sweep

Post by -alex- »

realthunder wrote: Wed Oct 27, 2021 12:04 am I managed to replace the bspline surface geometry of the face with a planar one
Works great indeed:
Linkstage3_PD_Pad_with_draft_option_with_sheetmetal_shell.gif
Linkstage3_PD_Pad_with_draft_option_with_sheetmetal_shell.gif (457.09 KiB) Viewed 1356 times

Thanks! Would be great if this linearize property were extended to Loft and Sweep in PD and Part WB (PD for the very least).

but didn't get the same working for edges. Need further investigation. Anyone interested can try.
I really hope a fix could be found here.
Edit 2022/01/11: Because B-spline edges leads to B-spline bends then sheetmetal unfolder still fails (as you can see in the above gif screencast).

Maybe you can post some sample file showing unfolding failure with Bspline edge produced in my branch. I'll see if it can be fixed in sheetmetal, which would be easier as the sheetmetal are meant to generate shapes by itself. It's probably just a matter of improving linear edge detection method.
Please find here the file displayed above:
OS: Debian GNU/Linux 10 (buster) (LXDE/LXDE-pi)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.28611 (Git)
Build type: Unknown
Branch: LinkDaily
Hash: ac2ddd51131ec6a05d42b151be71d26fd39c5973
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)


Offtopic: as you can see in screencast above, there is a clipping artefact on Navcube now, I assume that's related with the changes you made recently.
I actually added both bgfx and Diligent engine. And I got bgfx OpenGL backend working already ...
Lets continue this topic here: https://forum.freecadweb.org/viewtopic. ... 63#p542863
Post Reply