-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathsurfedge.m
65 lines (61 loc) · 1.63 KB
/
surfedge.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [openedge, elemid] = surfedge(f, varargin)
%
% [openedge,elemid]=surfedge(f)
%
% find the edge of an open surface or surface of a volume
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2007/11/21
%
% input:
% f: input, surface face element list, dimension (be,3)
%
% output:
% openedge: list of edges of the specified surface
% elemid (optional): the corresponding index of the
% tetrahedron of an open-edge or triangle,
% elemid has the same length as openedge.
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
if (isempty(f))
openedge = [];
return
end
opt = varargin2struct(varargin{:});
findjunc = jsonopt('Junction', 0, opt);
if (size(f, 2) == 3)
edges = [f(:, [1, 2])
f(:, [2, 3])
f(:, [3, 1])]; % create all the edges
elseif (size(f, 2) == 4)
edges = [f(:, [1, 2, 3])
f(:, [2, 1, 4])
f(:, [1, 3, 4])
f(:, [2, 4, 3])]; % create all the edges
else
error('surfedge only supports 2D and 3D elements');
end
% node4=[f(:,3);f(:,2);f(:,1)]; % node idx concatinated
edgesort = sort(edges, 2);
[foo, ix, jx] = unique(edgesort, 'rows');
if (isoctavemesh)
u = unique(jx);
if (size(f, 2) == 3 && findjunc)
qx = u(hist(jx, u) > 2);
else
qx = u(hist(jx, u) == 1);
end
else
vec = histc(jx, 1:max(jx));
if (size(f, 2) == 3 && findjunc)
qx = find(vec > 2);
else
qx = find(vec == 1);
end
end
openedge = edges(ix(qx), :);
if (nargout >= 2)
[elemid, iy] = ind2sub(size(f), ix(qx));
end
% node4=node4(ix(qx));