Generating voxels for stl files

Hi All,
I have a stl file of the surfaces of some complex geometries. The stl file contains the coordinates for the vertices on the surfaces of the geometries. However, I am now interested in filling the volume of each geometries with vertices so that the bigger the gometry is, the higher amount of vertices it should get.
Till now, the only idea that came to my mind is to mesh the stl files with volume elements and then extract the centroid of each volume elements. This way I can fill each geometries with specific number of vertices based on their volumes. However, since the geometries are highly complex, this process, meshing them with CAE software, can be very time consuming. I am now wondering if there is a function in matlab that can fill the volume of each geometry with a network of vertices so that the bigger geometries have more vertices in them compared to the smaller ones.
I will be really thankful if someone can help me with this problem.
Many thanks in advance,

2 件のコメント

darova
darova 2020 年 5 月 13 日
Can you show sample geomtry?
Memo Remo
Memo Remo 2020 年 5 月 13 日
Hi Darova,
Sure. Attached is the sample geometry. Please consider that there are many of these small geometries in the final file.
Best,
M

サインインしてコメントする。

回答 (2 件)

darova
darova 2020 年 5 月 13 日

0 投票

First you need to separate each region of interest (try clusterdata or kmeans)
Once you separate each blob generate pointcloud
Use alphaShape with inShape option to identificate points inside

4 件のコメント

Memo Remo
Memo Remo 2020 年 5 月 13 日
Thank you so much for your help.
I will give it a try and will let you know if it works.
Best,
M
Memo Remo
Memo Remo 2020 年 6 月 5 日
Hi darova,
Thanks for letting me know about this very genius method.
I followed your instructions but there is a problem with the run time.
What I did was actually to fill a cubic volume space around each geometries with points and then try to determine which of them are located inside the alphashape using inShape command.
The dimensions of this cubic volume is determined by the minimum and maximum coordinates of each geometry in each directions (X,Y and Z).
In some cases this can create an unnecessary huge number of points that can increase the run time exceedingly specially when the geometry looks like a curved disc. Is there any way to fill a more limited space around the geometries rather than considering the cubic volume?
Thanks.
darova
darova 2020 年 6 月 11 日
What abou this?
clc,clear
ff = stlread('sample.stl');
ind = clusterdata(ff.vertices,10); % group data in 10 regions
cmap = rand(10,3); % generate 10 random colors
cla
f1 = ind(ff.faces); % find faces of groups
ff1.vertices = ff.vertices;
for i = 1:10
ix = find(f1(:,1)==i); % find group
ff1.faces = ff.faces(ix,:); % faces of group
ff1.facecolor= rand(1,3); % random color
patch(ff1) % display region
end
axis vis3d
result
Do you the number of separate regions?
Memo Remo
Memo Remo 2020 年 6 月 13 日
Thanks a lot for your help. I need to give it a try. Will let you know if it works. By the way, it seems a brilliant idea!

サインインしてコメントする。

質問済み:

2020 年 5 月 13 日

回答済み:

DGM
2025 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by