필터 지우기
필터 지우기

How could I separate the geometry data from single stl file contains multiple objects by stlread?

조회 수: 6 (최근 30일)
Dear all, I have a question about stlread!
The scenario is that I have a stl file with two non-overlap ellipses in it as attached.
But when I using stlread function in Matlab.
I obtain the points coordinates and connectivity list of faces of both ellipses TOGETHER.
I wondering is there any method to separate the information of two ellipses?
For regular shapes this might not be a big problem, however, If I have 100 irregular objects with eac of them has different number of faces and vertices, it will be difficult to use since it's very hard to specify the information of each object.
I just try to start to separate them, but then I have no further idea.
Attached are my codes, with stl file in zip format.
F=stlread('research_stl_read.stl')
con_list=F.ConnectivityList
face_num=length(con_list(:,1))
Could anyone give me a hand?
I appreciate for your patience
Sincerely yours~!
Daniel
  댓글 수: 1
KSSV
KSSV 2021년 2월 4일
It can be seperated.....you need to have a look on the data to do this. Attach your stl file. And the lines of code which you tried to plot the attached.

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2021년 2월 4일
편집: Bruno Luong 2021년 2월 4일
You can use conncomp of the triangulation graph
data=stlread('research_stl_read.stl');
s=data.ConnectivityList(:,[1 2]);
t=data.ConnectivityList(:,[2 3]);
G=graph(s(:),t(:));
I=G.conncomp;
u=unique(I);
P = data.Points;
T = data.ConnectivityList;
clear Obj
for i=1:length(u)
j = find(I==i);
Pi = P(j,:);
[b,Ti] = ismember(T,j);
Ti = Ti(all(b,2),:);
Obj{i} = triangulation(Ti,Pi);
end
figure();
subplot(2,2,[1 2]);
trimesh(data);
for i=1:length(Obj)
subplot(2,2,i+2);
trimesh(Obj{i} );
end
  댓글 수: 2
Daniel Chou
Daniel Chou 2021년 2월 4일
편집: Daniel Chou 2021년 2월 4일
Dear Bruno Luong,
Please accept my kneeling.
I believe this is what I need.
I will try it.
Really appreciate for this, wish you have a nice day :)
Sincerely
Daniel
Daniel Chou
Daniel Chou 2021년 2월 4일
편집: Daniel Chou 2021년 2월 4일
Dear Bruno Luong,
May I ask for a question?
Your codes are amazing, It complete the works of the complex geometry in only 5 secs (as attached).
But I wish I could know more about the mechanism of it.
I don't quite understand that why you design these three lines:
s=data.ConnectivityList(:,[1 2]);
t=data.ConnectivityList(:,[2 3]);
G=graph(s(:),t(:));
I checked the illustration of graph object and conncomp.
But I couldn't understand yet.
You could answer this only if oyu have time.
Thank you very much again!
Sincerely
Daniel

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by