Sketcher: Bezier curves

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!
Post Reply
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

Dear all,

This is to say that I have started the coding. Here:
https://github.com/abdullahtahiriyo/Fre ... pline_2017

Currently there is very little coded, but it is possible to see an amovable bspline created in the sketcher from python:
bspline.png
bspline.png (2.98 KiB) Viewed 2209 times
it corresponds to these poles:
viewtopic.php?t=9312

Because BSpline is still missing serialization, FreeCAD will crash as soon as the autosave feature starts :)

There is a loooooooooooooooooooooooooong way to go and it is not usable yet. But it will get better with time... I hope ;)

I want to thank everybody that helped me understand, provided resources (Werner's on continuity were very much welcome), contributed to the discussion... You are kind nice people (you even offered to send me a book, amazing!).

Now, I won't be coding for a couple of weeks as the "coding wind" is being overcome by a tornado of busy-ness... :?

EDIT: App.ActiveDocument.Sketch.addGeometry(Part.BSplineCurve([App.Vector(0,0),App.Vector(0.5,1),App.Vector(1,0)]),False)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

I have added a creation method, so now it can be constructed by clicking in the poles, double-click for last pole. Jim's icons from 3 years ago are in. Still amovable and crash on autosave, so not usable and no testing required, just a follow up post:
bspline1.png
bspline1.png (10.39 KiB) Viewed 2156 times
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Sketcher: Bezier curves

Post by Chris_G »

Hi Abdullah,
It's great to see your progress.
Keep up the good work !
Chris
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

Chris_G wrote:Hi Abdullah,
It's great to see your progress.
Keep up the good work !
Chris
I have just pushed to my branch basic BSpline serialization, so now it does not crash when autosave. It still needs some work (to support periodic BSplines)... for the next coding slot...
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher: Bezier curves

Post by wmayer »

Thanks for your work Abdullah. Please see my comments I added to your branch on github.

Will you be able to do the recommended code change before you leave? Otherwise I can make the changes and merge the branch into master.
It still needs some work (to support periodic BSplines)... for the next coding slot...
There isn't much to do I think. All what you need is to store whether it's periodic or not. The actual information is put inside the knot sequence and the multiplicities.
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Sketcher: Bezier curves

Post by yorik »

This was one of the old daunting tasks nobody would dare to undertake... Thanks a lot for this Abdullah!
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher: Bezier curves

Post by microelly2 »

Great,
I'm waiting to design my first car with profiles from sketcher :D
viewtopic.php?f=13&t=17970&p=152321#p152321
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

wmayer wrote:Thanks for your work Abdullah. Please see my comments I added to your branch on github.

Will you be able to do the recommended code change before you leave? Otherwise I can make the changes and merge the branch into master.
It still needs some work (to support periodic BSplines)... for the next coding slot...
There isn't much to do I think. All what you need is to store whether it's periodic or not. The actual information is put inside the knot sequence and the multiplicities.
Werner, this can not be merged. It is not there yet by far. It is not usable ATM (Compile and try to use it and you will see what I mean).

While I accept that BSpline support may be added in chunks of increasing functionality, we do not currently meet any reasonable minimum requirements. For that, IMO the bspline has at least to be movable and constrainable on its endpoints. I would like to have the poles available in addition. Given my current workload I will try to reach there within a month. Sorry if it gave the impression it was more advanced.

I will take a look to your comments and also integrate your reply to my question in the other thread. Yes I am missing storing isperiodic. I ran out if coding time and had to commit to github as I was using a borrowed PC that I had to return...
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher: Bezier curves

Post by wmayer »

Werner, this can not be merged. It is not there yet by far. It is not usable ATM (Compile and try to use it and you will see what I mean).
Of course everything that affects the GUI or Python interface of the sketcher will be commented out. My idea was to avoid to duplicate effort when we wait again a couple of months because then too many things may have changed and a merge doesn't work properly any more.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

wmayer wrote:
Werner, this can not be merged. It is not there yet by far. It is not usable ATM (Compile and try to use it and you will see what I mean).
Of course everything that affects the GUI or Python interface of the sketcher will be commented out. My idea was to avoid to duplicate effort when we wait again a couple of months because then too many things may have changed and a merge doesn't work properly any more.
Ok. I do understand your point.

Let's do it like this if it is ok for you: let's see first how much I can handle within the next week. If progress is made, then we wait to have something usable, if it stalls, then I we disable the features a merge it.

With respect to the comments on GitHub, I must repeat myself: What a wonderful eye for detail you have! I have just fixed the issues.
microelly2 wrote:Great,
I'm waiting to design my first car with profiles from sketcher
Beautiful project!
yorik wrote:This was one of the old daunting tasks nobody would dare to undertake... Thanks a lot for this Abdullah!
wmayer wrote:Thanks for your work Abdullah
You are welcome! (although it is really not there yet) Hopefully I will manage to make it useful soon...:)
Post Reply