Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
microelly2
Posts: 2441
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher: Bezier curves

Postby microelly2 » Thu Feb 09, 2017 9:04 am

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
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 09, 2017 11:23 am

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
Site Admin
Posts: 11342
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher: Bezier curves

Postby wmayer » Thu Feb 09, 2017 12:07 pm

- 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
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 09, 2017 7:44 pm

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
Site Admin
Posts: 11342
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher: Bezier curves

Postby wmayer » Thu Feb 09, 2017 9:33 pm

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
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 09, 2017 10:13 pm

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
Posts: 4993
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Fri Feb 10, 2017 12:09 pm

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
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Fri Feb 10, 2017 4:50 pm

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
Posts: 4993
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Fri Feb 10, 2017 5:40 pm

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
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Sun Feb 12, 2017 8:43 pm

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 162 times