STL to PointCloud : the pointcloud doesn't cover all of the STL parts.

2 views (last 30 days)
Hi,
I tried to change the stl data to point cloud but there are some parts that are still not filled with point cloud.
Can anyone help me?
Basis_Resolution = 0.0014;
STL_Mesh = true;
show_Punktewolke = true;
show_Punktewolke_interpoliert = true;
[filename, pathname] = uigetfile ('*.stl','Select your file','MultiSelect','on');
arr_filename = string(filename).';
for file = 1:size(arr_filename,1)
[filepath,name,ext] = fileparts(arr_filename(file));
new_name = strrep(name,'_','\_');
STL = stlread(string(pathname).'+arr_filename(file));
Punktewolke = STL.Points;
x = Punktewolke_rot(:,1);
y = Punktewolke_rot(:,2);
z = Punktewolke_rot(:,3);
Resolution = Basis_Resolution.*((abs(min(x) - max(x)) + abs(min(y)-max(y)))/2);
[X,Y] = meshgrid(min(x): Resolution :max(x), min(y) :Resolution:max(y));
Z = griddata(x,y,z,X,Y,"linear");
if STL_Mesh == true
figure
trisurf(STL.ConnectivityList, Punktewolke(:,1), Punktewolke(:,2), Punktewolke(:,3),'FaceColor','none','EdgeColor','k');
xlabel('x'); ylabel('y'); zlabel('z');
title("STL-Mesh"); view([135 25]) ; axis equal
%grid off
%set (gca,'XColor','none','YColor','none','ZColor','none')
end
if show_Punktewolke == true
figure
plot3(x,y,z,'.r','markersize',10)
xlabel('x'); ylabel('y'); zlabel('z') ;title("Punktewolke")
view ([135 25]); axis equal
%grid off
end
if show_Punktewolke_interpoliert == true
figure
plot3 (X,Y,Z, '.r', 'markersize', 10)
xlabel('x'); ylabel('y'); zlabel('z'); title("Punktewolke(interpoliert)")
view ([135 25]) ; axis equal
%grid off
end
end

Answers (1)

Vidip
Vidip on 26 Oct 2023
I understand you're trying to read an STL file, convert it into a point cloud, and then interpolate that point cloud. However, you've encountered an issue where some parts of the STL data are not filled with a point cloud. This might be due to the specific characteristics of the STL file you're working with. To address this issue, consider the following suggestions:
  1. Check STL Data: Verify that the STL file you're working with contains data in the regions you expect to see in the point cloud. It's possible that the STL file itself has gaps or missing data in those areas.
  2. Mesh Refinement: Increase the mesh resolution or refine the mesh if you suspect that the gaps are due to the mesh's coarseness.
  3. Smoothing: Apply a smoothing or filtering step to the point cloud data. This can help in filling small gaps and reducing noise in the point cloud.
For further information, refer to the documentation links below:

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!