How can I cut(crop) patch(3d,stl file) object?

조회 수: 21 (최근 30일)
pty0220
pty0220 2017년 5월 19일
댓글: naomy_yf 2022년 12월 19일
Hi I want to know how can I crop 3D patch in matlab
I have a Data 'skull' it is from .STL file ( It is from stl file and I read stl file from my matlab)
skull = stlread('Skull.stl')
patch(skull,'FaceColor', [0.8 0.8 1], 'EdgeColor','none', 'FaceLighting', 'gouraud', 'AmbientStrength', 0.15);
camlight('headlight');
material('dull');
(( skull data is struct like this))
And then I make a patch about skull (like this)
But that skull data quite large So I want to crop some region which is I interested (Like this)
((this picture just specify the plot range. like below ))
axis ([0,100,0,100,0,100])
But I want to save plot(patch) which is cropped as a Data like 'skull'
So I try it like below (I interest in range that is bigger than(0,0,0))
x = 0;
y = 0;
z = 0;
[r] = find((skull.vertices(:,1)>=x) & (skull.vertices(:,2)>=y) & (skull.vertices(:,3)>=z));
for i = 1:size(r,1)
interest.vertices(i,:) = skull.vertices(r(i,1),:);
% interest.faces(i,:) = skull.faces(r(i,1),:);
end
for i = 1:size(r,1)/3
interest.faces(i,3) = 3*i;
interest.faces(i,2) = 3*i-1;
interest.faces(i,1) =3*i-2;
end
And then I patched Data interest
patch(interest,'FaceColor', [1 0 0], 'EdgeColor','none', 'FaceLighting', 'gouraud', 'AmbientStrength', 0.15);
camlight('headlight');
material('dull');
So I got a patch(plot) like this
The overall shape exists but there is a lot of hole in the middle. How can I solve this problem? and What did I do wrong?
  댓글 수: 4
Rawan
Rawan 2022년 12월 7일
Where is the model please?
naomy_yf
naomy_yf 2022년 12월 19일
i'm using the face and ver files to reindex the face and ver I need then creat the patch again.

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

답변 (1개)

Mitchell Carlson
Mitchell Carlson 2020년 3월 6일
I had a similar problem and found that using the xlim, ylim, and zlim functions worked. In this case you could do something like this:
xlim = ([0 100]) % This only displays values with x between 0 and 100
ylim = ([0 100]) % Same thing for y
zlim = ([0 100])

제품

Community Treasure Hunt

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

Start Hunting!