## from set of points to surface?

Need help, or want to share a macro? Post here!
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

### from set of points to surface?

Hello,
i am looking to a function (or piece of python) to transform a set of 3d points into a surface (mesh)
The set of points were generated by parametric surface (u,v).

Any python function to do that (or oop function)?

Thank you for any kind of help.

Rentlau_64
r-frank
Posts: 2181
Joined: Thu Jan 24, 2013 6:26 pm
Location: Möckmühl, Germany
Contact:

### Re: from set of points to surface?

Hello.

I remember this thread in the german sub-forum about his subject.

As mentioned in the last post there i remember user microelly2 did a lot of work based on that in his
- reconstruction workbench ... discussion here
- NURBS Editor ... discussion here

Hope this is useful for a start ...

Roland
Deutsche FreeCAD Tutorials auf Youtube
My GrabCAD FreeCAD-Projects
FreeCAD lessons for beginners in english

Native german speaker - so apologies for my english, no offense intended
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: from set of points to surface?

I think this is a good way to start playing
http://freecadbuch.de/doku.php?id=story ... _mass_data

write your own version to generate the data
example:

Code: Select all

``````x = np.arange(-5.00, 5.00, 0.5)
y = np.arange(-5.00, 5.00, 0.5)
xx, yy = np.meshgrid(x, y)
z = np.sin(xx**2+yy**2)

setSpreadsheet(ss1,x,y,z)
table2Nurbs(ss1,"waves")
``````
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

### Re: from set of points to surface?

Roland and microelly2,
thank a lot, i will look carefuly at these information.

Have a good day
Rentlau_64
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

### Re: from set of points to surface?

microelly2,

I have an error message regarding the test :
ns.table2Nurbs(ss1,"simpe gen data")
>>> ns.table2Nurbs(ss1,"simpe gen data")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/laurent/.FreeCAD/Mod/nurbs/nurbswb/spreadsheet_lib.py", line 234, in table2Nurbs
,3,3)
TypeError: PyCXX: Error creating object of type N2Py6VectorE from array([ 0. , 0. , 565.71704008])
The code I typed in the FreeCad python Console:

Code: Select all

``````import nurbswb.spreadsheet_lib as ns
ss1=ns.createSpreadsheet(label='MySpreadsheet')
ns.gendata(ss1)
ns.table2Nurbs(ss1,"simpe gen data")
``````
I suspect it is my release of Ubuntu...what do you think?
OS: Ubuntu 15.04
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6692 (Git)
Build type: None
Branch: master
Hash: 87293fac9bb85c5f5e0ebf563374e27d565116ae
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Thank you

Rentlau_64
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: from set of points to surface?

rentlau_64 wrote: TypeError: PyCXX: Error creating object of type N2Py6VectorE from array([ 0. , 0. , 565.71704008])

Version: 0.16.6692 (Git)
There was an improvement to handle numpy arrays in 0.17
Maybe I can make it backward compatible by converting the array to a array of Vectors

starting line 221 insert these lines should help for the first.

Code: Select all

``````
ps=np.array(ps).reshape(NbVPoles,NbUPoles,3)

#-hack for 0.16
ps=[]
for v in range(NbVPoles):
psl=[]
for u in range(NbUPoles):
p=(x[u],y[v],z[v*NbUPoles+u])
psl.append(FreeCAD.Vector(p))
ps.append(psl)
#- end hack
``````
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

### Re: from set of points to surface?

Microelly2,
Thank you for your help i will test your fix this evening.
And will also upgrade my system during Christmas holydays.
Have a nice day.
Rentlau_64
rentlau_64
Posts: 181
Joined: Tue Oct 21, 2014 9:47 am
Location: Pau (France)

### Re: from set of points to surface?

Microelly2,

Thank you it worked perfectly!
Nurbs1.jpg (159.78 KiB) Viewed 2056 times
Have a nice evening!

Rentlau_64