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!
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher: Bezier curves

Post by microelly2 »

abdullah wrote:
microelly2 wrote:what if you take the opposite direction of the curvature vector?
Then it is mainly outside the closed curve and only in concave regions it points to the inner area.
I do not know if that would be useful for people using this. What do you think, people usually using this?
I don't know how people will use it but you can see the curvature as the centrifugal force when you run along the curve :roll:
microelly2 wrote:the other idea to scale it is nice too but which factor to use.
As I had calculated the center of mass for putting the degree, I have thought of reusing it. This is normalizing the max curvature to 0.5 * max(distance(centerofmass,point at edge of the curve)):
Looks good.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

Ok guys, here ends up a new develppment cycle.

If you want to check code or functionality, it is here:
https://github.com/abdullahtahiriyo/Fre ... eliverable

To switch the different geometry information layer nodes on/off by type, use the "X" drop-down "icons" in the new BSpline toolbar (lots to come in this toolbar). By default the button shows/hides the control polygon. The first X after drop-down is the degree, the last X is the curvature comb. It remember your setting, so it will continue offering the selected nodes over different sessions (this way, those who love the curvature comb and those who may hate it as not leaving a clean space can live with the same solution :))

No icons yet, but they will come soon...:
https://forum.freecadweb.org/viewtopic. ... 6&start=40
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher: Bezier curves

Post by wmayer »

- Implementing Chris_G's comb
This looks all nice but IMO implementing all this inside the sketcher module is the wrong place. We better should move this to a separate workbench so that it can be used for arbitrary shapes.

In the past two people were working independently on a surface workbench but stopped very soon. Some time ago I saved the code and moved it to my github repo. So, after doing some clean-up work it could be integrated into master and I think the curvature function should be moved there.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

wmayer wrote: In the past two people were working independently on a surface workbench but stopped very soon. Some time ago I saved the code and moved it to my github repo. So, after doing some clean-up work it could be integrated into master and I think the curvature function should be moved there.
My question: If that function were integrated in that surface WB in the future, would it appear while editing a BSpline in the Sketcher (and would do it so without a high computational cost / reasonable speed)?
wmayer wrote:This looks all nice but IMO implementing all this inside the sketcher module is the wrong place. We better should move this to a separate workbench so that it can be used for arbitrary shapes.
I do see the merit of having it for arbitrary shapes. However I also see a specific tool ready to be used (it is already implemented), integrated in the Sketcher and apparently wanted by the users (useful). Of course yours is the last word, so if you want to see it excised, I will.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher: Bezier curves

Post by wmayer »

My question: If that function were integrated in that surface WB in the future, would it appear while editing a BSpline in the Sketcher (and would do it so without a high computational cost / reasonable speed)?
Well, it depends on how flexible it is implemented. All the algorithmic stuff should stay in this surface module and then sketcher gui can link against this module or if a hard dependency is not desired use its Python interface.
I do see the merit of having it for arbitrary shapes. However I also see a specific tool ready to be used (it is already implemented), integrated in the Sketcher and apparently wanted by the users (useful). Of course yours is the last word, so if you want to see it excised, I will.
Since it's obviously already done it can stay there until the surface WB is ready. And it can still take a while until it's done.

But my actual point is that we should avoid to implement too specific functions in different modules which are also useful in a wider context. Because then we end up with dozens of slightly different functions and code duplications distributed all over the place.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

wmayer wrote: But my actual point is that we should avoid to implement too specific functions in different modules which are also useful in a wider context. Because then we end up with dozens of slightly different functions and code duplications distributed all over the place.
Point taken.

Probably, when the functionality is implemented in the surface WB, it will be more general and complete and it will just feel natural to modify the sketcher so as to make use of it.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Post by triplus »

I checked for some reference and for example SolidWorks provides curvature combs for sketcher entities:

http://help.solidworks.com/2016/English ... _Combs.htm

P.S. Abdullah give it all you got as when you will stop likely for year(s) nobody will add anything new anyway to the sketcher splines. I for one am hoping the spline toolbar in Sketcher ends up being long when you finish your work!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

triplus wrote:I checked for some reference and for example SolidWorks provides curvature combs for sketcher entities:

http://help.solidworks.com/2016/English ... _Combs.htm
And interesting is that in closed shapes the comb is external as per microElly's suggestion. Thanks!!
triplus wrote:P.S. Abdullah give it all you got as when you will stop likely for year(s) nobody will add anything new anyway to the sketcher splines. I for one am hoping the spline toolbar in Sketcher ends up being long when you finish your work!
Well there is no need to be catastrophic. Sketcher will have improvements. I am not the only one working in the Sketcher. The idea is to make the BSpline tool as meaningful as possible... Let's hope for a toolbar full of meaningful tools to work with B-Splines...:)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Post by triplus »

abdullah wrote:Well there is no need to be catastrophic. Sketcher will have improvements. I am not the only one working in the Sketcher. The idea is to make the BSpline tool as meaningful as possible... Let's hope for a toolbar full of meaningful tools to work with B-Splines...:)
OK i am reassured. ;)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

jean.thil wrote: I don't want to behave like a spoilt kid but to be able to use your code at its full value, it would be nice that someone fix the code
./src/Mod/Sketcher/App/SketchObject.cpp:4315 :oops:
https://github.com/abdullahtahiriyo/Fre ... 91fac1b898
bspline_external.png
bspline_external.png (16.53 KiB) Viewed 1585 times
Post Reply