-
Notifications
You must be signed in to change notification settings - Fork 73
/
finddisconnsurf.m
39 lines (38 loc) · 936 Bytes
/
finddisconnsurf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function facecell = finddisconnsurf(f)
%
% facecell=finddisconnsurf(f)
%
% subroutine to extract disconnected surfaces from a
% cluster of surfaces
%
% author: Qianqian Fang (q.fang at neu.edu)
% Date: 2008/03/06
%
% input:
% f: faces defined by node indices for all surface triangles
%
% output:
% facecell: separated disconnected surface node indices
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
facecell = {};
subset = [];
while (~isempty(f))
idx = reshape(ismember(f, f(1, :)), size(f));
ii = find(sum(idx, 2));
while (~isempty(ii))
if (isempty(ii))
break
end
% ii=unique(ii);
subset(end + 1:end + length(ii), :) = f(ii, :);
f(ii, :) = [];
idx = reshape(ismember(f, subset), size(f));
ii = find(sum(idx, 2));
end
if (~isempty(subset))
facecell{end + 1} = subset;
subset = [];
end
end