Merge isocap and isosurf to get one surface
7 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
采纳的回答
Paulo GOMES
2018-12-18
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 个评论
Jesus Barney
2020-3-10
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?
更多回答(1 个)
Oraib Al-Ketan
2019-8-23
编辑:Oraib Al-Ketan
2019-8-23
Thank you very much Palo, your answer solved my problem perfectly.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!