Merge isocap and isosurf to get one surface

조회 수: 17 (최근 30일)
oraib alketan
oraib alketan 2018년 1월 18일
댓글: Ryan 2020년 3월 18일
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);

채택된 답변

Paulo GOMES
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
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?
Ryan
Ryan 2020년 3월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Oraib Al-Ketan
Oraib Al-Ketan 2019년 8월 23일
편집: Oraib Al-Ketan 2019년 8월 23일
Thank you very much Palo, your answer solved my problem perfectly.

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by