How can I cut(crop) patch(3d,stl file) object?
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
naomy_yf
le 19 Déc 2022
i'm using the face and ver files to reindex the face and ver I need then creat the patch again.
Réponses (1)
Mitchell Carlson
le 6 Mar 2020
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])
0 commentaires
Voir également
Catégories
En savoir plus sur STL (STereoLithography) dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!