How can I calculate the surface area of a stl file with a cutting plane?

54 views (last 30 days)
Hi everybody,
I need hepl for this task: I opened a stl file in matlab, but I would like to make calculations such as surface, volume ecc.
In particular, my goal is to calculate the surface area of the stl shown below from the top to a depth of 0,1 mm.
To date, I could basically highligth part of my stl but the code needs improvements. Could you help me?
Thank you very much!
fv = stlread('G05.stl');
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
view([-135 35]);
x1 = -10;
x2 = 10;
y1 = -10;
y2 = 10;
%pks = findpeaks(G05.stl)
%zmax= max(G05.stl);
z1 = 0.2286;
[r] = find((fv.vertices(:,1)>=x1 & fv.vertices(:,1)<=x2) & (fv.vertices(:,2)>=y1 & fv.vertices(:,2)<=y2) & (fv.vertices(:,3)>=z1));
for i = 1:size(r,1)
interest.vertices(i,:) = fv.vertices(r(i,1),:);
% interest.faces(i,:) = fv.faces(r(i,1),:);
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;
patch(interest,'FaceColor', [1 0 0], 'EdgeColor','none', 'FaceLighting', 'gouraud', 'AmbientStrength', 0.15);
%[x,y,z] = peaks;
%[area,cellAreas,centroid] = surfarea(x,y,z);
Flavia Lerra
Flavia Lerra on 26 Feb 2020
actually, I would like to automatically highlight the stl zone between the maximum point and a defined depth (like 0,1 mm from the maximum point downward) and calculate that surface.
In the code that I posted I entered the cordinates below but they were found by trials.
x1 = -10;
x2 = 10;
y1 = -10;
y2 = 10;
z1 = 0.2286

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!