Radial Nurbs
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Radial Nurbs
i know you made this for radial basis functions, but i hope you realize the boring old u,v basis function surfaces don't have any kind of interface this cool in FreeCAD right now.
I write macros that generate grids based on sketches, and if i could parametrically tie my grids/sketches to a realtime surface display tool like you made...that would kick some major ass.
I write macros that generate grids based on sketches, and if i could parametrically tie my grids/sketches to a realtime surface display tool like you made...that would kick some major ass.
Re: Radial Nurbs
Yes, I think it is activated by pressing shift x to drag in the dx = 0 plane. Blender has so many useful hidden key events:-) But once you know them blender is simple the best ui.Chris_G wrote:Another blender feature ? I didn't know it ...
I follow your work, but for me it's hard to get into this bspline stuff. We have made some really nice working bezier and bspline curves (not surfaces) written in python for the glider workbench (it is used for airfoils, merging-curves, shape,...) and can be found here. This works really good for us. And the theory behind this is really nice. But surfaces are a bit harder. And OCC-naming confuses. So I can't help with applying this interaction to OCC splines.emills2 wrote:i know you made this for radial basis functions, but i hope you realize the boring old u,v basis function surfaces don't have any kind of interface this cool in FreeCAD right now.
I write macros that generate grids based on sketches, and if i could parametrically tie my grids/sketches to a realtime surface display tool like you made...that would kick some major ass.
But if you have access to the controllpoints, it shouldn't be that hard to make them visible and apply some eventhandlers to it.
Attached is a picture comparing the pinning of radial and orthogonal spline surfaces: Maybe a better choose of base function would give a better output.
Re: Radial Nurbs
Hi Edward,
The curve was automatically updated. It used a Part.BezierCurve on each change of a point coordinate.
Then I tried to do it with a Bezier surface, but the display was horribly laggy.
As looo's python code opens highly interesting perspectives, I searched for some code example to display a bezier surface directly with coin ( without going through a Part.BezierSurface ).
You can try this directly in the python console ( create a new document before ) :
Then you can play with the surface display complexity (value between 0 and 1) with :
Maybe displaying the surface this way would be fast enough to use it realtime ?
Chris
I made a macro, some time ago, that created a parametric bezier curve : the 4 point coordinates being editable in the data tab.emills2 wrote:i know you made this for radial basis functions, but i hope you realize the boring old u,v basis function surfaces don't have any kind of interface this cool in FreeCAD right now.
I write macros that generate grids based on sketches, and if i could parametrically tie my grids/sketches to a realtime surface display tool like you made...that would kick some major ass.
The curve was automatically updated. It used a Part.BezierCurve on each change of a point coordinate.
Then I tried to do it with a Bezier surface, but the display was horribly laggy.
As looo's python code opens highly interesting perspectives, I searched for some code example to display a bezier surface directly with coin ( without going through a Part.BezierSurface ).
You can try this directly in the python console ( create a new document before ) :
Code: Select all
from pivy import coin
import FreeCADGui
# The control points for this surface
pts = (
(-4.5, -2.0, 8.0),
(-2.0, 1.0, 8.0),
( 2.0, -3.0, 6.0),
( 5.0, -1.0, 8.0),
(-3.0, 3.0, 4.0),
( 0.0, -1.0, 4.0),
( 1.0, -1.0, 4.0),
( 3.0, 2.0, 4.0),
(-5.0, -2.0, -2.0),
(-2.0, -4.0, -2.0),
( 2.0, -1.0, -2.0),
( 5.0, 0.0, -2.0),
(-4.5, 2.0, -6.0),
(-2.0, -4.0, -5.0),
( 2.0, 3.0, -5.0),
( 4.5, -2.0, -6.0))
# The knot vector
knots = (0, 0, 0, 0, 1, 1, 1, 1)
# Create the nodes needed for the Bezier surface.
def makeSurface(com):
surfSep = coin.SoSeparator()
# Define the Bezier surface including the control
# points and a complexity.
complexity = coin.SoComplexity()
controlPts = coin.SoCoordinate3()
surface = coin.SoNurbsSurface()
complexity.value = com
controlPts.point.setValues(0, 16, pts)
surface.numUControlPoints = 4
surface.numVControlPoints = 4
surface.uKnotVector.setValues(0, 8, knots)
surface.vKnotVector.setValues(0, 8, knots)
surfSep.addChild(complexity)
surfSep.addChild(controlPts)
surfSep.addChild(surface)
return surfSep
carpet = coin.SoSeparator()
surf = makeSurface(0.8)
carpet.addChild(surf)
view = FreeCADGui.ActiveDocument.ActiveView
view.getSceneGraph().addChild(carpet)
Code: Select all
surf.getChild(0).value = 0.1
Chris
Re: Radial Nurbs
this is why i was so surprised by looo's realtime editing. Everytime i create a surface i wait almost a minute. Sure, i'm recalculating all the basis functions everytime, but i thought most of the work was in tessellating the surface.Then I tried to do it with a Bezier surface, but the display was horribly laggy.
Looo, your picture on the right is all i was asking for, it looks like a uv surface (you call it ortho basis functions). if that object is parametric and the control points can be set to sketch points, or assigned from a spreadsheet, that would be all that is needed.
I'm sure there are some obstacles that i can't see, but if understanding details of NURBS didn't stop you from making the radial basis version...
Re: Radial Nurbs
Hi Edward,
Here is a funny toy for you.
The zip file attached contains 2 files :
- loooMarkers.py ( a copy of looo's file here : https://github.com/looooo/freecad_glide ... new_new.py)
- SurfaceEdit.fcmacro
Copy the files in your macro folder. Create a new doc in FC and start "SurfaceEdit.fcmacro".
Select some points and grab them with 'g' key.
You can constraint the move to axis with 'x', 'y' and 'z' key during the mouse grab.
'q' to quit editing
If editing is laggy for you, you can try to reduce Surface Complexity on line 31of the macro.
Quick and dirty code, but a proof of concept ...
Bye
Chris
Here is a funny toy for you.
The zip file attached contains 2 files :
- loooMarkers.py ( a copy of looo's file here : https://github.com/looooo/freecad_glide ... new_new.py)
- SurfaceEdit.fcmacro
Copy the files in your macro folder. Create a new doc in FC and start "SurfaceEdit.fcmacro".
Select some points and grab them with 'g' key.
You can constraint the move to axis with 'x', 'y' and 'z' key during the mouse grab.
'q' to quit editing
If editing is laggy for you, you can try to reduce Surface Complexity on line 31of the macro.
Quick and dirty code, but a proof of concept ...
Bye
Chris
Re: Radial Nurbs
that is really fun! is there a way to stop the macro without killing FreeCAD?
i noticed that if i hit x before hitting g, it eats the selected markers and i can't get them back. editing speed is awesome even on an old machine. actually, if i hold the x key down during the grab, it does this weird high speed flicker that looks kinda cool
the free hand editing is great, but this also has value for faster surface previews.
Down the line i could see having a parametric surface object that derives from sketches, and when you edit a sketch, it does this live preview of the final surface.
now i need to learn all this GUI stuff too! if we could define groups of these surfaces and maintain some level of patch to patch continuity AND do live edits that propagate across neighbor surfaces, that would be pretty badass!
i noticed that if i hit x before hitting g, it eats the selected markers and i can't get them back. editing speed is awesome even on an old machine. actually, if i hold the x key down during the grab, it does this weird high speed flicker that looks kinda cool
the free hand editing is great, but this also has value for faster surface previews.
Down the line i could see having a parametric surface object that derives from sketches, and when you edit a sketch, it does this live preview of the final surface.
now i need to learn all this GUI stuff too! if we could define groups of these surfaces and maintain some level of patch to patch continuity AND do live edits that propagate across neighbor surfaces, that would be pretty badass!
Re: Radial Nurbs
This looks really smooth.
This toggles the "x-constrained". So the point jumps between constraint position and mouse position.emills2 wrote: if i hold the x key down during the grab, it does this weird high speed flicker that looks kinda cool
Re: Radial Nurbs
I added the 'q' key event to stop editingemills2 wrote:that is really fun! is there a way to stop the macro without killing FreeCAD?
The x key was already used for removing a point marker ...emills2 wrote:i noticed that if i hit x before hitting g, it eats the selected markers and i can't get them back.
looo, I suggest you to replace line 343 of your code from :
Code: Select all
if event.getKey() == ord("x"):
Code: Select all
if event.getKey() == ord(u"\uffff"):
Yeah, there are lots of possible interesting uses ... but I really need to untangle all these Coin, events and Gui things first.emills2 wrote:Down the line i could see having a parametric surface object that derives from sketches, and when you edit a sketch, it does this live preview of the final surface.
now i need to learn all this GUI stuff too! if we could define groups of these surfaces and maintain some level of patch to patch continuity AND do live edits that propagate across neighbor surfaces, that would be pretty badass!
My poor old brain is not made for this kind of non-linear programming (I learned programming with BASIC on Sinclair ZX-81 )
Re: Radial Nurbs
Thanks, I have changed this: commitChris_G wrote:The x key was already used for removing a point marker ...
looo, I suggest you to replace line 343 of your code from :
OT:
I am thinking about outsourcing this interactive stuff directly to pivy. I like the idea of a easy to use highlevel graphics api that simplify the pivy stuff and show how to use it.
maybe similar to matplotlib:
Code: Select all
from pivy import Graphics
Graphics.Line()
Graphics.Polygon()
....
Graphics.show()
Re: Radial Nurbs
Hi ChrisChris_G wrote: ↑Sat Feb 06, 2016 9:32 pm Hi Edward,
Here is a funny toy for you.
The zip file attached contains 2 files :
- loooMarkers.py ( a copy of looo's file here : https://github.com/looooo/freecad_glide ... new_new.py)
- SurfaceEdit.fcmacro
Copy the files in your macro folder. Create a new doc in FC and start "SurfaceEdit.fcmacro".
Select some points and grab them with 'g' key.
You can constraint the move to axis with 'x', 'y' and 'z' key during the mouse grab.
'q' to quit editing
If editing is laggy for you, you can try to reduce Surface Complexity on line 31of the macro.
Quick and dirty code, but a proof of concept ...
Bye
Chris
Surface-Edit.zip
I have tested your code, it's awesome and it is what I need.
By the way, currently I only can select multiple control points by pressing "ctrl" button.
If we could select those point with box selection, that would be much easier.
FreeCAD has box selection feature, but it is not specific for these control points.
Do you have any suggestions of creating a box selection to select those control points?
Many thanks.
Mea08kw