Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
jean.thil
Posts: 151
Joined: Tue Jul 28, 2015 7:28 am

Re: Sketcher: Bezier curves

Postby jean.thil » Tue Feb 14, 2017 1:27 pm

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

Re: Sketcher: Bezier curves

Postby abdullah » Tue Feb 14, 2017 9:07 pm

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

Re: Sketcher: Bezier curves

Postby abdullah » Tue Feb 14, 2017 10:35 pm

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 261 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 261 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
looo
Posts: 605
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Postby looo » Wed Feb 15, 2017 8:39 am

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

Re: Sketcher: Bezier curves

Postby abdullah » Wed Feb 15, 2017 5:07 pm

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?
looo
Posts: 605
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Postby looo » Wed Feb 15, 2017 8:30 pm

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

Re: Sketcher: Bezier curves

Postby abdullah » Wed Feb 15, 2017 9:05 pm

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

Re: Sketcher: Bezier curves

Postby abdullah » Wed Feb 15, 2017 10:39 pm

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 134 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.
looo
Posts: 605
Joined: Mon Nov 11, 2013 5:29 pm

Re: Sketcher: Bezier curves

Postby looo » Thu Feb 16, 2017 12:01 am

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

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 16, 2017 4:40 pm

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...