Creating and exporting surface from points

Hello
I have created a scilab file where I put in different layer points coordinate.
now I’d like to create a surface from all this layer and then export it.

How can I do?

thnaks
sergio

Hello Sergio,

Is the distribution of points structured in some way, or completely unstructured ?

S.

I’ve created a matrix of points
Each row have coordinates x,y,z of the points
each row same points number

it’s enough for you?

Can you be more precise ? Is the matrix of size n by 3 ? What do you mean by “each row same points number” ? Can you share your file here ?

S.

Hi
I can send you in a private way or put here only a part of it (where the matrix is created)
esempio.sod (9.8 KB)

Edit your previous post : you can save the matrix in a sod file, i.e. save data.sod A and drag and drop the file in the editing window.

S.

I meant only the resulting matrix. You sent the whole Scilab script (which doesn’t run because some matrices are not defined). So, please save the matrix you were talking about in a .sod file.

S.

Hi
Ok is easier if I give you the all file because I don’t have only the matrix.
You need also the txt file in the same folder
test_surf.sod (21.1 KB)
Import_Mat_Rad_Chord_Gam_Camb_thick_P.sod (650 Bytes)

Hello,

What do you want to do exactly ? Your script already draws a (very folded) surface. Would a STL format export be OK for you ? What is the RA_X2P_Imp2_TraslRot1.ibl file ?

Hello
I’d like to have a iges or step surface. STL is bad for me bacause I have to use the file in a cad,
The .ibl file is a file that I inport in the CAD and create a array of points that I had to use for creating a surface
tanks

Sorry, Scilab has no IGES or STEP converter. Maybe NURBS conversion can be done by other software. However, STL conversion of a Scilab Fac3d object is quite easy to do, if you can convert STL to another format afterwards it may be the way to go for your problem.

S.

Thanks
OK maybe I can try with STL and check for a conversion
S

Here is a script to do the conversion to STL:

// find object
h = findobj("type","Fac3d");
X = [h.data.x;mean(h.data.x,1)]
Y = [h.data.y;mean(h.data.y,1)];
Z = [h.data.z;mean(h.data.z,1)];
// add center vertex and form triangles
X=[X([5 1 2],:) X([5 2 3],:) X([5 3 4],:) X([5 4 1],:)];
Y=[Y([5 1 2],:) Y([5 2 3],:) Y([5 3 4],:) Y([5 4 1],:)];
Z=[Z([5 1 2],:) Z([5 2 3],:) Z([5 3 4],:) Z([5 4 1],:)];
// sides vectors
U=[X(2,:)-X(1,:); Y(2,:)-Y(1,:); Z(2,:)-Z(1,:)];
V=[X(3,:)-X(1,:); Y(3,:)-Y(1,:); Z(3,:)-Z(1,:)];
// normals computation
NX=U(2,:).*V(3,:)-U(3,:).*V(2,:);
NY=U(3,:).*V(1,:)-U(1,:).*V(3,:);
NZ=U(1,:).*V(2,:)-U(2,:).*V(1,:);
// write STL file
n = size(X,2);
fd = mopen('object.stl','wt');
mfprintf(fd,"solid object\n");
for i = 1:n
    mfprintf(fd,"facet normal %f %f %f\n",NX(i),NY(i),NZ(i));
    mfprintf(fd,"  outer loop\n");
    mfprintf(fd,"    vertex %f %f %f\n",X(1,i),Y(1,i),Z(1,i));
    mfprintf(fd,"    vertex %f %f %f\n",X(2,i),Y(2,i),Z(2,i));
    mfprintf(fd,"    vertex %f %f %f\n",X(3,i),Y(3,i),Z(3,i));
    mfprintf(fd,"   endloop\n");
    mfprintf(fd,"endfacet\n");
end
mfprintf(fd,"endsolid object");
mclose(fd);

resulting geometry looks good in online STL viewers:
Capture d’écran 2023-07-13 à 12.07.47

thanks
I’ll check it

Sorry
the code is a generic one?
It isn’t the same you put in my scilab file in order to obtain this stl file.
I’ve tryed but it doesn’t work

Ok now it works
I need something smother!
do you thinck that scilab could connect to open library for nurbs generator?
s

You can arbitrarily (by changing the two 100 occurences below) refine the original surface given by your 3 matrices x3,y3,z3 by spline interpolation with splin2d and interp2d with the following code. Insert it before STL export.

[N,M]=size(x3);
cx=splin2d(1:N,1:M,x3);
cy=splin2d(1:N,1:M,y3);
cz=splin2d(1:N,1:M,z3);
[I,J]=ndgrid(linspace(1,N,100),linspace(1,M,100));
X3=interp2d(I,J,1:N,1:M,cx);
Y3=interp2d(I,J,1:N,1:M,cy);
Z3=interp2d(I,J,1:N,1:M,cz);

mesh(X3,Y3,Z3)

Thank you very much!

Another thing
i have another version of the code where I create a series of surfaces with different sweep (see add)
sfalsatura.sod (1.5 KB)
I have tryed do add the STL part at the end (after “// Scrittura file IBL con tutte le catene
// Superficie Unica Pala”) but I have only the last geometry.
thanks
s

I think you can adapt the code yourself: insert the exporting code in your loop and clear the figure between each surface plot, and also change the STL file name.

S.

Hi
I’ve tryed but I’m too low in scilab programming.
Can you haelp me?