create face from point value

Hi there!:o
I have import some 3d data whar i want to do now is to obtain a mesh…(have you suggestion?)
I read some treats use extende.face() (How function these command?
can someone help me?
thanks for your helps
:):slight_smile:

Are they like in a point cloud? Or could you linearly go and join edge between them? There is a script to skin a point cloud, but i have no idea how it works, and whether it works.

For a basic example of how to use mesh.extend.face() see http://fake.yolasite.com/airfoilplotter
It also shows how to create vertices as well.

thabks for your answer…I have 512 point and I not able to made by hand…

@ jarod81 - can you sibmit sample data of what you have to process so that somebody who knows how, to point you in the right direction or provide a complete solution?

@ Fake - the plotter.zip reports to be corrupted :eek:

thanks, this is example of data…(I can’t put all the data in paste all… crash my computer):spin:

1 0 1.00931e-06
2 0 1.01e-06
3 0 1.01078e-06
4 0 1.01285e-06
5 0 1.01379e-06
6 0 1.01413e-06
7 0 1.01446e-06
8 0 1.01245e-06
9 0 1.01164e-06

this is the program… but I have (512*512) vertex… with a loop is nott so FAST…

:confused:
THANKS :eek:

Well, try to replace

    for line in open(filename):     #Per ogni linea del file memorizzo i 3 dati
        line=line.rstrip("
")
        line=line.rstrip("\r")
        temp=line.split()
        data.append((float(temp[0]),float(temp[1]),float(temp[2])))

with

    fr = open(filename, "r")
    lines = fr.readlines()
    for line in lines:
        line=line.rstrip("
")
        line=line.rstrip("\r")
        temp=line.split()
        data.append((float(temp[0]),float(temp[1]),float(temp[2])))

With a testing file of 900 x 3 coordinates like yours, this proves to run 6-10 times faster :wink:

thanks… it fantastic…:eyebrowlift:

but for made the face how can do?

Is there any order in your data?

I mean something like this:

N_vertex_coords
===============================
1,2,3,4            = face_1
3,4,5,6            = face_2
5,6,7,8            = face_3
............

or

N_vertex_coords
===============================================
1,2,3,4,5,6,..........,34,35,36    = row_of_verts_1 = begin row_of_faces_1
37,38,39,..........,70,71,72    = row_of_verts_2 = closes row_of_faces_1
73,74,75.........106,107,108    = row_of_verts_3 = closes row_of_faces_2
.......................

If ‘Yes’ - it can be programmed to the reading proc to follow that order. If ‘No’ - you should use a script the analyses the point cloud but the result will be to some extend unpredictable.

Regards,

3 things. First, the data needs to be moved and scaled to fit within the Blender space, which is 1e5 to 1e-5. So, if all your data is in the range of 1e-6, then add 1e6 to it all to move it closer to origin.
Second, data points are either 2D or 3D, so there needs to be pairs or triples representing (x,y) or (x,y,z).
Third, once you have those two issues resolved, look up the skinning script, it will intelligently make faces out of every three 3D points.

Thank for your helps…
Data have this order:
have 512 colunm of 512 row this means I have 512*512 vertices the order is 1…to 512…


1,2,3,4,5,6....60...512
513,514...............

I have tried this form but I Have some errors and computer are not fast…


for i in data:
  face= [[i,i+512,i+513,i+2]]
  me.faces.extend(face)

any other suggestions?

I’ve been working a little with loading coordinates data from a file. Also I am interested to make this more effective for future purposes… So that I’ll try today to re-work what I have here in the form suitable to your case.

From your postings I assume that after constricting the “data” list with a size of 262144 (=512*512) triples, you need to put them into a more or less 2D net… I mean, it is similar to a rectangular net with some bumps… Well, lets say that the bumps will come from the Z value, an really deviations can be significant but the point is that it will not be a mesh like a cylinder in which you have the first and the last row of verts the same, i.e. the surface is closed in the 3D space… Your surface is not closed in such a way, right?

Thinking in the frame above, your formula for the “i”-face = [[i,i+512,i+513,i+2]] is principally incorrect cause it will form faces like [0,512,513,2], [1,513,514,3], etc… while you would need [0,513,514,1], [1,514,515,2], and so on…

Regards,

Thanks for your efforts…!!!

My data is a single picture single mesh. What I need to obtain a imple mesh… My data come use a every single colun I have only z data (512 colunm with 512 row). After that I create a file follow the formation a single plane. The data create plane. what i want to create a face betwen colunm


abcde..512
b............
512...............

I have difficult to use the loop for made a face because give me a error _(tuple can concatenate)
any suggestion?
thanks again

OK, here is what I have…

The general suggestion is (as before) try do the things in groups, as larger as possible :wink:

When you have your object created and data loaded in “data” list and you ensure that data contains n*n coordinates (“n” points in “n” rows), then you may process it in a cycle, similar to your, which is like this (called Cycle_1):

    for j in range(n-1):  # to (n-1) cause N_faces_rows = N_verts_rows-1
        for i in range(n-1):
            k = i+j*n
            face = [k,k+n,k+n+1,k+1]
            me.faces.extend(face)
    Redraw()

A much better solution is what I call Cycle_2:

    faces = []
    for j in range(n-1):  # to (n-1) cause N_faces_rows = N_verts_rows-1
        for i in range(n-1):
            k = i+j*n
            face = [k,k+n,k+n+1,k+1]
            faces.append(face)
    me.faces.extend(faces)
    Redraw()

They both go first on j, then on i in order the coordinates match X,Y,Z axes correctly.

At my comp (Dual core, 2,10 MHz, 4 GB RAM), I,ve got the following timings:

 n      t0        t1        t2
==========================================
 10    0.0480    0.0029    0.0078
100    0.1222   24.2703    0.0654
500    1.5207              1.3489
512    1.5204              1.4235
==========================================

where:
n - number of points in data
t0 - time for loading the data from a file (the effective proc discussed earlier)
t1 - timing of running the Cycle_1
t2 - timing of running the Cycle_2

All times reported are in seconds.

At n = 100, Cycle_1 runs dramatically slooooow… Due to this, at n = 500 and more, I measured only the performance of Cycle_2…

I’ve noticed that Cycle_1 is a bit faster than Cycle_2 at n = 10 or similar. Apparently, Cycle_2 can be optimised a little but I usually dont put efforts to improve efficiency by 1% or less :wink:

Regards,

:no:
I use your suggestion but I not was able to form face…<What I made wrong?
Here you can take one file with 3 colunms…

http://www.scienziofilia.altervista.org//cipo/Blender/nico3.txt

here the script…

http://www.scienziofilia.altervista.org//cipo/Blender/file.py

thanks for your efforts and kind help…:o

http://blenderartists.org/forum/showthread.php?t=144504

@ jarod81 - Well, you dont ensure that the total number of coords gives you a square mesh! I.e. n should be a square root of numbvert and in the same time an integer. Basically, you were trying to implement 262144*262144 faces which is a huuuuuge number and you dont have the data for that :wink:

So that I made some modification to the code to work properly with such cases:

import Blender
from Blender import Scene, Mesh
import math
filename="C:\Blender_Input\Test_coords_2.txt" #Apre il file con i dati
data=[]   #Creo una matrice che conterra` tutti i vertici
fr = open(filename, "r")
lines = fr.readlines()
for line in lines:
    line=line.rstrip("
")
    line=line.rstrip("\r")
    temp=line.split()
        data.append((float(temp[0]),float(temp[1]),float(temp[2])))                    
me = Mesh.New('point cloud') #Creo una mesh con nome Point cloudob
me.verts.extend(data)
Scene.GetCurrent().objects.new(me,"pointcloudob")
numbvert = len(data)
print numbvert
n = int(math.sqrt(numbvert))
if (numbvert &lt;&gt; n*n):  # just to be sure...
    print "Data is NOT OK........ --&gt; numbvert &lt;&gt; n*n   "+str(numbvert)+" &lt;&gt; "+str(n)+"*"+str(n)
else:
    print "Data is OK........ --&gt; n = "+str(n)
    faces = []
    for j in range(n-1):  # to (n-1) cause N_faces_rows = N_verts_rows-1
        for i in range(n-1):
            k = i+j*n
              face = [k,k+n,k+n+1,k+1]
            faces.append(face)
    me.faces.extend(faces)
Blender.Redraw()

To ensure additional calculation needed, the math module should be imported too!

The above should work for you… Just change the filename @ row 4 to yours :slight_smile:

@ rdo3 - The script you point works fine but as I raised the issue in the same thread (your reference) it may not work correctly in some cases… and as soon as it is unknown what shape is to be expected from the data you give to that script, one should be careful or expect surprises :cool: