File: orderloopedge.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 (36 lines) | stat: -rw-r--r-- 1,028 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
function newedge = orderloopedge(edge)
%
% [newedge]=orderloopedge(edge)
%
% order the node list of a simple loop based on connection sequence
%
% author: Qianqian Fang (q.fang at neu.edu)
% date:   2008/05
%
% input:
%        edge: a loop consisted by a sequence of edges, each row
%              is an edge with two integers: start/end node index
%
% output:
%        newedge: reordered edge node list
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

% this subroutine can not process bifercation

ne = size(edge, 1);
newedge = zeros(size(edge));
newedge(1, :) = edge(1, :);

for i = 2:ne
    [row, col] = find(edge(i:end, :) == newedge(i - 1, 2));
    if (length(row) == 1) % loop node
        newedge(i, :) = [newedge(i - 1, 2), edge(row + i - 1, 3 - col)];
        edge([i, row + i - 1], :) = edge([row + i - 1, i], :);
    elseif (length(row) >= 2)
        error('bifercation is found,exit');
    elseif (length(row) == 0)
        error(['open curve at ' num2str(edge(i - 1, 2))]);
    end
end