Generating voxels for stl files

6 views (last 30 days)
Memo Remo
Memo Remo on 13 May 2020
Answered: DGM on 5 Apr 2025
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 Comments
darova
darova on 13 May 2020
Can you show sample geomtry?
Memo Remo
Memo Remo on 13 May 2020
Hi Darova,
Sure. Attached is the sample geometry. Please consider that there are many of these small geometries in the final file.
Best,
M

Sign in to comment.

Answers (2)

darova
darova on 13 May 2020
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 Comments
darova
darova on 11 Jun 2020
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 on 13 Jun 2020
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!

Sign in to comment.


DGM
DGM on 5 Apr 2025

Community Treasure Hunt

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

Start Hunting!