Effacer les filtres
Effacer les filtres

Merge isocap and isosurf to get one surface

13 vues (au cours des 30 derniers jours)
oraib alketan
oraib alketan le 18 Jan 2018
Commenté : Ryan le 18 Mar 2020
Dear Colleagues,
I having an issue with merging surfaces. I have a function f defined below for which I want to generate a volume enclosed by the isosurface and the isocap. I wish to merge these two surfaces into one surface that I want to extract later as stl file using stlwrite.
is there a way to do so ?
f = @(x,y,z) cos(2.*pi.*y).*sin(2.*pi.*x)+cos(2.*pi.*z);
O = 0:.05:1;
[x,y,z] = meshgrid(O);
v = f(x,y,z);
p1 = isosurface(x,y,z,v,0.2);
p2 = isocaps(x,y,z,v,0.2);

Réponse acceptée

Paulo GOMES
Paulo GOMES le 18 Déc 2018
I found that this is a convinient solution.
for example you have the faces and vertices of an isosurface:
[f,v] = isosurface(x,y,z,Gyroid);
and the faces and vertices of an isocaps
[f2,v2,c] = isocaps(x,y,z,Gyroid);
then you can merge the faces and vertices together. Careful on how to merge the faces together, you need to send the vector pointer to the correct position of the vertices, otherwise you will send the pointer to the wrong vertice pointer - for this reason +length(v(:,1)) is added.
f3 = [f ; f2+length(v(:,1))];
v3 = [v ; v2];
face f3 and vertice v3 have the merged geometry!
Now if you want to save the file as stl you can write the following line
stlwrite('file_name.stl',f3,v3);
If you understant the example I gave, it is pretty straight forward to solve your problem!
Source:
min 26~29
  2 commentaires
Jesus Barney
Jesus Barney le 10 Mar 2020
Hello Paulo,
I tried exactly the above code:
f = @(x,y,z) cos(2.*pi.*y).*sin(2.*pi.*x)+cos(2.*pi.*z);
O = 0:.05:1;
[x,y,z] = meshgrid(O);
v = f(x,y,z);
[f,v] = isosurface(x,y,z,v,0.2);
stlwrite('file_name.stl',f,v);
and I get the error "Input argument must be a triangulation object." What am I doing wrong?
Ryan
Ryan le 18 Mar 2020
I have experienced this error also. My solution was to download the version of stlwrite written by Sven (avaliable here) and place it into the working directory or Matlab path.

Connectez-vous pour commenter.

Plus de réponses (1)

Oraib Al-Ketan
Oraib Al-Ketan le 23 Août 2019
Modifié(e) : Oraib Al-Ketan le 23 Août 2019
Thank you very much Palo, your answer solved my problem perfectly.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by