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!
jean.thil
Posts: 209
Joined: Tue Jul 28, 2015 7:28 am

Re: Sketcher: Bezier curves

Post by jean.thil »

why do these people take such a hard work to apply approximations to specific shapes (conics) instead of the exact NURBS representation, that is existing?
It would be interesting to have an answer directly from the OCC team.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

wmayer wrote: I don't know why they do it this way but maybe other algorithms have problems with rational splines. For example with boolean operations you often run into problems just with normal B-spline surfaces and maybe this becomes worse with real NURBS.
Thanks for sharing this thought. It actually is the only thing that makes sense so far.
jean.thil wrote: why do these people take such a hard work to apply approximations to specific shapes (conics) instead of the exact NURBS representation, that is existing?

It would be interesting to have an answer directly from the OCC team.
Definitely! Feel free to ask them and let us know ;)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

Today I have rebased to master and changed the convert-to-NURBS functionality to use Werner's newly commited functionality. Funny enough, the approximation was indeed different (Top are the approx I used yesterday, bottom the approx by wmayer):
ConicsAsNURBS.png
ConicsAsNURBS.png (27.86 KiB) Viewed 2136 times
Ok, for circle we know why it is different, it is Werner's own implementation ;), but for example for the Ellipse, the OCC approx I used is substantially different from the OCC approx Werner uses (6 poles vs 14 poles). I think that the algo I used produces at least rational bsplines, while the algo Werner uses produces polynomic bsplines (at least for the Ellipse). Why I say that? Well I tried to show the poles:
ConicsAsNURBS_showingpoles.png
ConicsAsNURBS_showingpoles.png (81.07 KiB) Viewed 2136 times
The ellipse nurbs-ized by Werner's OCC does not deform when enforcing equal weights, whereas the one nurbs-ized using my OCC algo deforms at enforcing equal weights...


STREAMLINING:

To close this deliverable I need to:
1. Fix normal calculation of Nurbs containing straight segments (OCC's Normal fails miserably when the curvature is zero), or at least the effect (crash).
2. Include the icons Alex is doing for the Sketcher... I have to ask him one for the NURBS-ize a shape.

Next one has to do in principle with knots...

EDIT: The branch
https://github.com/abdullahtahiriyo/Fre ... iverable_2
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Post by looo »

I like this new feature a lot! Very impressive and very useful.

Just wondering if this should work with occt7.0.0. With python3 and occt7 I always get an exception on right click:
<class 'Part.BSplineCurve'> returned a result with an error set
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

looo wrote:I like this new feature a lot! Very impressive and very useful.

Just wondering if this should work with occt7.0.0. With python3 and occt7 I always get an exception on right click:
<class 'Part.BSplineCurve'> returned a result with an error set
Could you specify where are you right-clicking so as to get that?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Post by looo »

abdullah wrote:Could you specify where are you right-clicking so as to get that?
It's with two day old build of master + python3 branch:
sketcher wb -> new sketch -> create bspline -> some left click for pole creation -> right click to finish bspline. If your implementation should work with occt7 this is most likely a problem with the python3 branch I am using.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

looo wrote:
abdullah wrote:Could you specify where are you right-clicking so as to get that?
It's with two day old build of master + python3 branch:
sketcher wb -> new sketch -> create bspline -> some left click for pole creation -> right click to finish bspline. If your implementation should work with occt7 this is most likely a problem with the python3 branch I am using.
Ah! That right-clicking! Well, I do not have OCCT7 installed, so I cannot compile against it, but I would not expect that to be the problem (but you never know). That "returning a result with an error set" sounds to me like Python speaking, but I cannot know if OCCT7 returned some error that python simply complains about... If you happen to compile main+OCCT7-python3 and the error is still there, we might come closer to a diagnosis... :)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

Today's take, is the functionality for increasing the degree of the bspline. I have currently a button that when triggered increases by one the degree of the polynom. The code, even if it works, it is not yet of my liking and I won't be publishing this commit today. However, you get to have your daily teaser:
IncreaseDegree.png
IncreaseDegree.png (86.47 KiB) Viewed 2009 times
So basically I created one bspline, I made copies and increased their degree.

So now yes, to close this deliverable I need to:
1. Fix normal calculation of Nurbs containing straight segments (OCC's Normal fails miserably when the curvature is zero), or at least the effect (crash).
2. Include the icons Alex is doing for the Sketcher... I have to ask him one for the NURBS-ize a shape.
3. Make the increase degree code of my liking.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Post by looo »

If you happen to compile main+OCCT7-python3 and the error is still there, we might come closer to a diagnosis...

no problems with occt7 and python2...good job :D
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

looo wrote:no problems with occt7 and python2...good job
Thanks! Good to know. You may want to report the issue to the one doing the python3 integration...
Post Reply