Pocket operation distorts solid made from b-spline profiles

Report observations made with the new Toponaming branch.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
MediumCrab
Posts: 4
Joined: Thu Feb 24, 2022 9:47 pm

Pocket operation distorts solid made from b-spline profiles

Post by MediumCrab »

I'm relatively new to Freecad but have fairly good Solidworks experience. Enjoying the learning process and really grateful to the folks contributing to this software and all the support on the forums.

I'm currently trying to model a simple wing-like structure. It is a loft between two airfoil profiles, mirrored about the center and then a cut-out made with a pocket. I have also tried a simple Pad of a single airfoil profile with the same results as below.

The problem I am running into is that after I make the pocket, my nice smooth airfoil body turns crinkly. See the before/after screenshots: in the 'after', the leading edge has an irregular appearance. This is reflected in exported STLs from before/after; the 'after' STLs are very complicated and irregular on a micro scale, disrupting the slicing and resulting in a poor 3D printed part vs the 'before'.

I feel like the somehow boils down to the fact the loft profiles include b-splines. If I replace my profiles with simple polygons, I don't get this issue. But I want to use the b-spline profiles.

In the attached freecad file, make the 'Pocket' operation visible to see the effect.

Before:
before_pocket.png
before_pocket.png (78.54 KiB) Viewed 3362 times
After:
after_pocket.png
after_pocket.png (59.14 KiB) Viewed 3362 times
showing Stl in cura:
cura_stl.png
cura_stl.png (85.04 KiB) Viewed 3362 times
I've been using Freecad Link Branch as well as regular Freecad with the same results in both:
OS: Ubuntu 20.04.4 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 2022.430.26244 +4758 (Git) AppImage
Build type: Release
Branch: LinkDaily
Hash: b024b876480a533018fdc702145e9e38f8c54ba6
Python version: 3.9.12
Qt version: 5.12.9
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United Kingdom (en_GB)

Any guidance gratefully received!
Attachments
frontwing_foil_v2.FCStd
(463.71 KiB) Downloaded 59 times
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Pocket operation distorts solid made from b-spline profiles

Post by chrisb »

Moved from Help forum. Opened in master the last sketch shows an error.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Pocket operation distorts solid made from b-spline profiles

Post by adrianinsaval »

You need to reduce the tolerance for the mesh, on the property tab go to the view tab and reduce the deviation and angular deflection, note that this will increase the recomputation time. For the specific case of wing profiles I found that splitting the airfoil spline at the leading edge gave much better results. Have a look at the airplane design workbench, it's not very polished but the tool to make airfoils is pretty good
MediumCrab
Posts: 4
Joined: Thu Feb 24, 2022 9:47 pm

Re: Pocket operation distorts solid made from b-spline profiles

Post by MediumCrab »

Thank you for your suggestion. Reducing the 'deviation' property as you suggested did improve the appearance (although not perfect), and probably would be sufficient for what I want to do.

But I'm curious why this happens? Before the pocket, the leading edge was perfect, and afterwards it is distorted, even though the pocket didn't touch that area?
User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Pocket operation distorts solid made from b-spline profiles

Post by hammax »

... here is a variable "real smooth" BSpline approach to your NACA profile.
The External Link makes trouble.
And you get a "mesh free" leading edge.

Frontwing.PNG
Frontwing.PNG (35.3 KiB) Viewed 3211 times
Attachments
frontwing_foil_3.FCStd
FC.20
(413.6 KiB) Downloaded 55 times
MediumCrab
Posts: 4
Joined: Thu Feb 24, 2022 9:47 pm

Re: Pocket operation distorts solid made from b-spline profiles

Post by MediumCrab »

Thanks for this example. Looks like it completely solves the issue! I can see your profile is split at the leading edge and has a very thin thickness at the trailing edge. Are these details important? Did you create it from my "naca2412_" bspine or from something else?

This seems like a common issue: the wing profiles I create using the AirplaneDesign workbench (which is fantastic - thanks for the suggestion) all exhibit the problem. Would we have to manually tweak the generated profiles to have splits at leading edge and finite thickness trailing edges?
airfoildesign_crinkle.png
airfoildesign_crinkle.png (124.21 KiB) Viewed 3161 times
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Pocket operation distorts solid made from b-spline profiles

Post by adrianinsaval »

I think airplane design should have an option to split the edge and have a small gap at the trailing edge, at least the utility to make just wingribs does. My best guess is that OCC struggles to properly mesh that kind of bsplines.
User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Pocket operation distorts solid made from b-spline profiles

Post by hammax »

... I used your NACA profile to redraw a "flexible" airfoil.
The leading edge gets a (vertical) tangent, 2 coincident knots and 2 control points on Y-axis (movable and weight controlled).
The trailing edge is a vertical mirrored line with fixed length for the 2 end knots of the splines.
Convert the upper profile to spline, insert at least 2 control points - same procedure with lower profile.
Now you can pull the control points to adapt the profile form to the master profile.
And you are able to de-/increase the weight circles at your will.
( I think the profile authors did it in a similar, but mathematical way - BSpline does it also)
You get a smooth BSpline with no inner knots => they always generate a kink in the curvature comb, if you have more than 2 control points.

Frontwing_2.PNG
Frontwing_2.PNG (27.47 KiB) Viewed 3074 times
Attachments
frontwing_foil_4.FCStd
FC.20
(12.15 KiB) Downloaded 56 times
MediumCrab
Posts: 4
Joined: Thu Feb 24, 2022 9:47 pm

Re: Pocket operation distorts solid made from b-spline profiles

Post by MediumCrab »

Thanks hammax. That is a neat trick! There is so much depth to Freecad.

I have noticed that even with the 'mesh' appearing perfect in Freecad, it still has minor crinkles when exported as STL. However, the magnitude is dramatically reduced with the approaches shown in this thread, and I'm happy now that I can do what I want to do. Thanks for the assistance!
Jon557
Posts: 4
Joined: Wed Nov 09, 2022 12:26 am

Re: Pocket operation distorts solid made from b-spline profiles

Post by Jon557 »

Hi,

New here, I have been having what looks like the same issue, it has been plaguing me for many weeks, I have done many 10's of hours testing and testing to narrow down the issue. After reading this post I found I was having the same issue but with different shapes. I originally created a B-Spline with several points, forming a kind of 'm', sometimes it looked fine but certainly after a union it started to suffer. I have been playing with a new B-Spline with just 2 control points as mentioned above, it looks perfect in FreeCAD and CURA, but...

> I have unionised a square (touching and overlapping), no issues, looks great.
> I have unionised a cylinder (just touching), no issues, looks great.
> But when I unionise a cylinder that overlaps, all hell breaks loose.

Is this meant to happen? Have I done something wrong to the cylinder? Ideally I don't want to have to cut all the cylinders so they don't overlap other shapes.

Here is my sketch (2 shapes also visible), I've not bothered about a lot of constraints at this stage...
pic1.png
pic1.png (17.04 KiB) Viewed 2376 times
I have noticed I can see the mesh issue when I show all the shapes and the union together (this issue translates into CURA and to my 3D printer).
pic2.png
pic2.png (47.97 KiB) Viewed 2376 times
Here is an image when I detatch the cylinder from the sketch main body
pic3.png
pic3.png (37.79 KiB) Viewed 2376 times
Finally here is an image with the cylinder simply touching the side of the sketch main body, there are lines but I think they are just the resolution lines, no issues when printed etc.
pic4.png
pic4.png (55.44 KiB) Viewed 2376 times
I am using version 20.1 but I was also having the issue in version 18 a few weeks back.

Any help or direction much appreciated!

Thanks,
Jon
Attachments
Mesh Test 1.FCStd
(29.09 KiB) Downloaded 50 times
Post Reply