Nurbs editor

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Nurbs editor

Post by triplus »

Hi @microelly2.

Today i had little free time and i have spent it on doing some BOA test. Will give you more feedback tomorrow.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Nurbs editor

Post by microelly2 »

some more useful editor commands
https://youtu.be/rf9NWJkkkbk
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Nurbs editor

Post by triplus »

I looked at the video and likely a lot of the things you are exploring will allow you to provide special purpose tools/algorithms in the future. To for example select curve and do some pre-defined operation on it. As most end users would likely get lost if exposed to such detailed control over the curve directly. ;)

As for the example to control points of Draft BSpline from spreadsheet. I will play with that over the weekend. As for the Draft BSpline symmetry. The issue is i guess related to the way it works ATM. For perfect symmetry this i guess would need to work:

Code: Select all

import FreeCAD,Draft
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(0,2,0)
p4 = FreeCAD.Vector(-1,1,0)
Draft.makeBSpline([p1,p2,p3,p4,p1])
But it doesn't as it instead force close the curve in a way the result is not symmetric. What i am guessing we are observing is seam edge would be made at p1 if the result would be extruded and the above example would work without force close.

Anyway if i do something like:

Code: Select all

import FreeCAD,Draft
p1 = FreeCAD.Vector(0.1,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(0,2,0)
p4 = FreeCAD.Vector(-1,1,0)
p5 = FreeCAD.Vector(-0.1,0,0)
Draft.makeBSpline([p1,p2,p3,p4,p5])
Symmetry.png
Symmetry.png (4.1 KiB) Viewed 1935 times
Result is much closer to what i would expect.
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Nurbs editor

Post by Chris_G »

Using Part.BSplineCurve, however, gives a symetric result :

Code: Select all

bs = Part.BSplineCurve()
bs.interpolate(Points = [p1,p2,p3,p4,p1])
Part.show(bs.toShape())
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Nurbs editor

Post by triplus »

Indeed. As for the result:

I guess we achieved G0 continuity at p1 with Part.BSplineCurve? And the Draft.makeBSpline goes after G1 continuity at p1? Now from user point of view i guess i would need to have some sort of continuity tool available to achieve G1 continuity at p1 after i used Part.BSplineCurve and for the Symmetry not to be lost. Like when i use Draft.makeBSpline. :D

P.S. And from engineering point of view i guess after the G1 continuity at p1 would be achieved p2, p3 and p4 points should stay the same. Therefore i would "sacrifice" precise position of p1 (as closed BSpline with continuity G1 can't be made with such input values) to get G1 continuity at p1 and the rest would stay the same.
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Nurbs editor

Post by Chris_G »

You can also control the tangents at each point :

Code: Select all

t1 = FreeCAD.Vector(1,0,0)
t2 = FreeCAD.Vector(0,1,0)
t3 = FreeCAD.Vector(-1,0,0)
t4 = FreeCAD.Vector(0,-1,0)
bs.interpolate(Points = [p1,p2,p3,p4,p1], Tangents = [t1,t2,t3,t4,t0], TangentFlags = [True,True,True,True,True])
... but you loose symmetry
Wouldn't it be easier to get the symmetry by creating a parametric "symmetric closed curve" composed of a half curve that mirrors itself around its StartPoint-to-EndPoind axis ?
Setting its StartPoint and EndPoint tangents perpendicular to axis, you get not only G1 but Gn continuity ...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Nurbs editor

Post by triplus »

Will go over it and do more tests tomorrow as for today i don't have the time any more.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Nurbs editor

Post by microelly2 »

Chris_G wrote:Using Part.BSplineCurve, however, gives a symetric result :

Code: Select all

bs = Part.BSplineCurve()
bs.interpolate(Points = [p1,p2,p3,p4,p1])
Part.show(bs.toShape())
In this case the result is not a periodic bspline
to get tangential continuity there is a trick
if there are 3 poles colinear the tangent to the inner pole is the same line.
For interpolation we use a pair of points very close to p1

I have done this (it's not exactly the same but if the tangent vector t is small (under the production tolerenace) it works.)

Code: Select all

p1 = FreeCAD.Vector(0.1,0,0)
p2 = FreeCAD.Vector(1,1,0)
p3 = FreeCAD.Vector(0,2,0)
p4 = FreeCAD.Vector(-1,1,0)
p5 = FreeCAD.Vector(-0.1,0,0)

bs = Part.BSplineCurve()
t=FreeCAD.Vector(0.01,0,0)
bs.interpolate(Points = [p1,p1+t,p2,p3,p4,p1-t,p1])
Part.show(bs.toShape())

triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Nurbs editor

Post by triplus »

Chris_G wrote:Wouldn't it be easier to get the symmetry by creating a parametric "symmetric closed curve" composed of a half curve that mirrors itself around its StartPoint-to-EndPoind axis ?
Setting its StartPoint and EndPoint tangents perpendicular to axis, you get not only G1 but Gn continuity ...
I wanted to try it but likely it would take me few hours of thinking what exactly was the proposition. Therefore if i would have in-depth knowledge likely yes it could be easier but from the casual FreeCAD user point of view it sounds more like science fiction. ;)

Hi @microelly2.

The result is not symmetric. And i finally tested the BSpline/Spreadsheet "macro". When i try to update the values back to the BSpline the result is:

Code: Select all

TypeError: Either three floats, tuple or Vector expected
Therefore i guess the macro needs more work and i rather did this manually:
Frame.png
Frame.png (8.86 KiB) Viewed 1870 times
By reusing some Points of Draft BSpline. As you can see i don't have to have the same rib geometry and the procedure is straightforward and fast (but it is available only form Python). And if i could have points in spreadsheet i would be able to make 2 points of different BSplines equal and the shape on the image would therefore become fully parametric.
Surface.png
Surface.png (16.62 KiB) Viewed 1870 times
Do you plan to offer any tools that would enable me to achieve better results when applying surfaces?
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Nurbs editor

Post by microelly2 »

triplus wrote: The result is not symmetric.
Have you tested this my script?

Code: Select all

p1 = FreeCAD.Vector(0.1,0,0)
p2 = FreeCAD.Vector(2,1,0)
p3 = FreeCAD.Vector(0,5,0)
p4 = FreeCAD.Vector(-2,1,0)
p5 = FreeCAD.Vector(-0.1,0,0)

bs = Part.BSplineCurve()
t=FreeCAD.Vector(0.01,0,0)
bs.interpolate(Points = [p1,p1+t,p2,p3,p4,p1-t,p1])
Part.show(bs.toShape())

bs2 = Part.BSplineCurve()
t=FreeCAD.Vector(0.01,0,0)
bs2.interpolate(Points = [p1,p1-t,p4,p3,p2,p1+t,p1])
Part.show(bs2.toShape())


p2=bs2.getPoles()
p2.reverse()
for i,p in enumerate(bs.getPoles()):
	print (i,p-p2[i])
My output is symmetric:
..
(0, Vector (0.0, 0.0, 0.0))
(1, Vector (0.0, -4.79420648145934e-19, 0.0))
(2, Vector (-1.4876988529977098e-14, 4.33138767907959e-17, 0.0))
(3, Vector (1.4210854715202004e-14, 0.0, 0.0))
(4, Vector (-7.559437017329307e-15, 2.6645352591003757e-15, 0.0))
(5, Vector (8.43769498715119e-15, 3.3306690738754696e-16, 0.0))
(6, Vector (-7.993605777301127e-15, -5.071355661800947e-17, 0.0))
(7, Vector (0.0, 6.581446000165914e-19, -0.0))
(8, Vector (0.0, 0.0, 0.0))
>>>

And i finally tested the BSpline/Spreadsheet "macro". When i try to update the values back to the BSpline the result is:

Code: Select all

TypeError: Either three floats, tuple or Vector expected
where does this error raise?

OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9542 (Git)
Build type: None
Branch: master
Hash: 96dc57c06861922b9dde830e3bcc07e43ed11cf7
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Do you plan to offer any tools that would enable me to achieve better results when applying surfaces?
Yes, when we can modify single surfaces in a acceptabel manner then moving, connecting of multiple surfaces should be the next.

This was my testcase
https://freecadbuch.de/doku.php?id=blog ... rmflaechen
So i'm sure that we have methods to bring the pieces together.
Post Reply