-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmaxloop.m
More file actions
31 lines (28 loc) · 771 Bytes
/
Copy pathmaxloop.m
File metadata and controls
31 lines (28 loc) · 771 Bytes
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
function newloop = maxloop(curveloop)
%
% newloop = maxloop(curveloop)
%
% return the curve segment that has the largest number of nodes
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
% curveloop: curves defined by node indices, separated by nan
%
% output:
% newloop: the node indices defining the longest segment
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
newloop = curveloop;
if (~isnan(curveloop(end)))
curveloop(end + 1) = nan;
end
loopend = find(isnan(curveloop));
if (length(loopend) > 1)
seglen = [loopend(1), diff(loopend)];
[maxlen, maxloc] = max(seglen);
loopend = [0 loopend];
newloop = curveloop((loopend(maxloc) + 1):(loopend(maxloc + 1) - maxloc));
end
newloop(isnan(newloop)) = [];