How to divide a triangulation
    15 views (last 30 days)
  
       Show older comments
    
    Wang Jack
 on 16 Aug 2020
  
    
    
    
    
    Answered: Jun Matsubayashi
 on 8 Apr 2022
            There is a triangulation, which is two parts that are not connected, how to distinguish them?
For example, a triangulation TR, which connection matrix is TR.ConnectivityList
[3 4 5;
4 6 3;
5 3 6;
8 9 2;
9 8 2]
As we can see that 3 4 5 6 are connected and 2 8 9 are connected, how to distinguish them to two triangulations, Tr1 and TR2
I tried to use dual  for loop or dual while. Although the function can be realized, but the efficiency is very low, and the actual data is thousands of points, (3D point)
Now I use undirected graph to deal with them, it is faster than for or while, but the process is very complicated,,,
Is there a simpler way? or some matlab build-in function/statement?
connection=[TR.ConnectivityList(:,[1 2]);TR.ConnectivityList(:,[2 3]);TR.ConnectivityList(:,[1 3])];
connection=unique(sort(connection,2),'rows');
G=graph(connection(:,1),connection(:,2));%node connectivity, has lot of noise points
%plot(G)
bins = conncomp(G);
for i=1:max(bins)
    p_index=find(bins==i);
    m=ismember(TR.ConnectivityList,p_index);
    t_ind=sum(m,2)>0;
    TR_sorted{i,:}=triangulation(TR.ConnectivityList(t_ind,:),TR.Points);
end
0 Comments
Accepted Answer
  Jun Matsubayashi
 on 8 Apr 2022
        I am facing the same problem as you. It may be too late to reply, but I suggest one solution. This code does not involve any for loop.
tmp=TR.ConnectivityList;
groupnumber=1;
subTR=cell(1,1);
while ~isempty(tmp)
    fprintf('Finding group #%d', groupnumber);
    poolvec=tmp(1,:);
    poolvecsize=3;
    while length(poolvecsize)==1 || poolvecsize(end)>poolvecsize(end-1)
        ind=any(ismember(tmp,poolvec),2);
        poolvec=unique([reshape(tmp(ind,:),1,[]) poolvec]);
        poolvecsize=[poolvecsize length(poolvec)];
        fprintf('.');
    end
    fprintf('\nCumulative number of faces: %d\n', sum(ind));
    subTR{groupnumber}=tmp(ind,:);
    tmp=tmp(~ind,:);
    groupnumber=groupnumber+1;
end
0 Comments
More Answers (0)
See Also
Categories
				Find more on Interpolation in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
