File: surfpart.m

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (43 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download
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
function elist = surfpart(f, loopedge)
%
% elist=surfpart(f,loopedge)
%
% partition a triangular surface using a closed loop defined by existing edges
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2012/02/09
%
% input:
%      f: input, surface face element list, dimension (be,3)
%      loopedge: a 2-column array, specifying a closed loop in CCW order
%
% output:
%      elist: list of triangles that is enclosed by the loop
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

elist = [];
if (isempty(f) || isempty(loopedge))
    return
end

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])
             f(:, [2, 3])
             f(:, [3, 4])
             f(:, [4, 1])];             % create all the edges
else
    error('surfpart only supports triangular and quadrilateral elements');
end

[elist, front] = advancefront(edges, loopedge);
while (~isempty(front))
    [elist0, front0] = advancefront(edges, front);
    elist = unique([elist; elist0]);
    front = front0;
end