[new feature] Bspline knots

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

[new feature] Bspline knots

Post by abdullah »

As from today, Bsplines have knots and you can change the multiplicity of the knots:
bspline_knots_and_multiplicity.png
bspline_knots_and_multiplicity.png (45.7 KiB) Viewed 5420 times
Those points on the line are the knots, and you have a couple of controls in the bspline bar to increase and decrease the multiplicity of a knot.

So yes, now if you want to make a sharp edge within a bspline you can :)
MMSN
Posts: 68
Joined: Wed May 28, 2014 7:36 pm

Re: [new feature] Bspline knots

Post by MMSN »

abdullah ,
Thank you very much for your contribution in improving the design capacity of the program, I just wish that you would like to develop the parametric Bspline that I mentioned months ago in the following link:
viewtopic.php?f=8&t=16081
Tanks again.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [new feature] Bspline knots

Post by abdullah »

MMSN wrote:abdullah ,
Thank you very much for your contribution in improving the design capacity of the program, I just wish that you would like to develop the parametric Bspline that I mentioned months ago in the following link:
viewtopic.php?f=8&t=16081
Tanks again.
What you refer to apparently requires point on B-Spline. That is not within my short-term goals.

It might happen sooner to have the ability of approximate a bspline to points in the sketcher (outside the sketcher there is already such functionality). In fact, I think it is possible to create a bspline in the sketcher that approximates some points ATM from python (look at the ways to generate a bspline from python and add the result to the sketch). However, this is a one time approximation, if you move the points or you move the bspline it won't follow.

I do not know if it suites your application, but if instead of linking points on the bspline, you would link the bspline poles with the spreedsheet, then you could have some degree of parametric control.

If you are good with Python (I am not), you may be able to combine both, so somehow, you read the location of your points in a sketcher, you approximate a bspline using these points, the you update the bspline in the sketcher with the poles used for the approximation... I might just have come to a very weird alternative way of implementing a one-way point on object... :lol:
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: [new feature] Bspline knots

Post by microelly2 »

abdullah wrote:As from today, Bsplines have knots and you can change the multiplicity of the knots:

Those points on the line are the knots, and you have a couple of controls in the bspline bar to increase and decrease the multiplicity of a knot.

So yes, now if you want to make a sharp edge within a bspline you can :)
This is really the last great step forward (for me). Thank you for your work.
Now once more we can simplify the models.

We have a method to get a Skecher Bspline from a Draft Bspline (from a point cloud)
https://www.youtube.com/watch?v=Dh5jUAdPp5I
At the end the parameters should not be points because there will be some DOG when you approximate/interpolate
Having poles with weights and knots with multiplicities is the best parametric solution.

https://www.youtube.com/watch?v=7gU2jaKNYUI
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [new feature] Bspline knots

Post by abdullah »

microelly2 wrote:This is really the last great step forward (for me). Thank you for your work.
Now once more we can simplify the models.
I think I will make a break on B-Spline coding. There are still some ideas I would like to see implemented, but I have other things I would like to have in FC first. I will probably try to improve the external geometry import (DeepSOIC's teaser in carbon copy thread). I would like to see some kind of offset curve implementation in the Sketcher. I would like to see an automatic working plane generation in Part Design. I want to revisit the deletion of geometry in the sketcher now that we have unique identifiers in the geometry... I will be using FC for a while, so I will probably see more shortcomings.

However, if you see bugs or features, feel free to post in the "Bezier" (sic) thread ;)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: [new feature] Bspline knots

Post by triplus »

abdullah wrote:As from today, Bsplines have knots and you can change the multiplicity of the knots...
Thanks!
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [new feature] Bspline knots

Post by NormandC »

Great work Abdullah.

I think I found a bug. I created a B-spline, selected a knot then raised its multiplicity from (1) to (2). Then I tried to decrease the same knot multiplicity from (2) to (1) but I get this error:
Error wrote:Unknown C++ exception
I have a question: there's a tool to increase the degree of a B-spline: it increases the number of control points. But I haven't found a way to decrease the degree of a B-spline? That is, to decrease the number of control points.

Thanks for your work!

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10792 (Git)
Build type: None
Branch: master
Hash: 3b50a786f351339dd0c791b4e0e0e403f86033f0
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [new feature] Bspline knots

Post by wmayer »

There are further bugs:
  • when increasing the degree it doesn't add the new control points
  • when selecting a knot to decrease it the SW always complained that a knot was not selected (but can't reproduce this behaviour any more)
Fortunately, I saved the project.
Attachments
sketch_spline_test.FCStd
(9.56 KiB) Downloaded 110 times
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: [new feature] Bspline knots

Post by Chris_G »

Hi Normand,
I have a question: there's a tool to increase the degree of a B-spline: it increases the number of control points. But I haven't found a way to decrease the degree of a B-spline? That is, to decrease the number of control points.
Unfortunately, that's not that easy ...
It is always possible to increase the degree of a BSpline curve, while keeping its exact shape.
The algorithm will ( usually ? always ? I'm not sure ) add 1 control point for each degree increase step.
On the other hand, in the general case, there is no way to decrease the degree of the curve AND keep the original shape.
The general approach would be to approximate the curve with a lower degree one. And this (lower degree) approximating curve will most probably have MORE control points that the original one.
There are only special cases where it is possible : when you increase the degree of a curve, then, if you don't manipulate it, you can go back to a "simpler" (lower degree, fewer control points) curve.
So, modifying the degree of a curve while keeping its exact shape is a kind of "one way road".
Below is a degree increase sequence ( the exact shape of the curve is preserved ):
degree-increase.jpeg
degree-increase.jpeg (27.78 KiB) Viewed 5134 times
And here is the degree decrease sequence, by approximating ( the exact shape of the curve is NOT preserved ):
degree-decrease.jpeg
degree-decrease.jpeg (26.41 KiB) Viewed 5134 times
In the end, we are pretty lucky because the algorithm found a simple degree-3, 4-poles curve, but it is most probably not exactly the original one ...
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [new feature] Bspline knots

Post by abdullah »

NormandC wrote:Great work Abdullah.

I think I found a bug. I created a B-spline, selected a knot then raised its multiplicity from (1) to (2). Then I tried to decrease the same knot multiplicity from (2) to (1) but I get this error:
Error wrote:Unknown C++ exception
I have a question: there's a tool to increase the degree of a B-spline: it increases the number of control points. But I haven't found a way to decrease the degree of a B-spline? That is, to decrease the number of control points.

Thanks for your work!

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10792 (Git)
Build type: None
Branch: master
Hash: 3b50a786f351339dd0c791b4e0e0e403f86033f0
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Thanks Normand!! :)

Now, I had one sketch where I was having this problem. I wanted to recreate the issue with OCC only code, but I failed. Then I forgot about it. So far, it only happens in some bsplines having exactly 5 poles. I will look into it. Thanks for reporting!!

EDIT: I stand corrected. I was mixing degrees and multiplicities... No tools for degree reduction.
Last edited by abdullah on Wed Apr 12, 2017 12:03 pm, edited 2 times in total.
Post Reply