Home > functions > common > boundary > vb_boundary_edge.m

vb_boundary_edge

PURPOSE ^

extract boundary edge from surface patch index

SYNOPSIS ^

function [Vlist] = vb_boundary_edge(F,V)

DESCRIPTION ^

  extract boundary edge from surface patch index
 [Vlist] = vb_boundary_edge(F,V)
 --- Input 
  V    : surface vertex [Nvertex x 3]
  F    : triangle patch index for surface [Npatch x 3]
 --- Output
 Vlist : boundary vertex list [cell array]

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [Vlist] = vb_boundary_edge(F,V)
0002 %  extract boundary edge from surface patch index
0003 % [Vlist] = vb_boundary_edge(F,V)
0004 % --- Input
0005 %  V    : surface vertex [Nvertex x 3]
0006 %  F    : triangle patch index for surface [Npatch x 3]
0007 % --- Output
0008 % Vlist : boundary vertex list [cell array]
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 DEBUG = 0;
0014 %Jedge = [9 2; 9 1; 1 10; 1 2 ; 2 9; 3 4; 2 1];
0015 
0016 % Edge index
0017 Jedge = [F(:,1), F(:,2); F(:,2), F(:,3);F(:,3), F(:,1)];
0018 
0019 % Jedge(:,1) <= Jedge(:,2)
0020 jx = find(Jedge(:,1) > Jedge(:,2));
0021 jj = Jedge(jx,1);
0022 Jedge(jx,1) = Jedge(jx,2);
0023 Jedge(jx,2) = jj;
0024 
0025 % Sort rows
0026 Jedge = sortrows(Jedge);
0027 Nedge = size(Jedge,1);
0028 Jdiff = Jedge(1:Nedge-1,:) - Jedge(2:Nedge,:);
0029 
0030 % find duplicate edge : Jedge(ix,:) = Jedge(ix+1,:)
0031 ix = find( sum(abs(Jdiff),2) == 0 );
0032 
0033 % Boundary edge appeares once in edge list 'Jedge'
0034 % Exclude duplicate edges
0035 Id = ones(Nedge,1);
0036 Id(ix)   = 0;
0037 Id(ix+1) = 0;
0038 
0039 jx = find(Id > 0);
0040 
0041 % index list for boudary edge
0042 Fedge = Jedge(jx,:);
0043 
0044 if DEBUG == 1
0045     NL = size(Fedge,1);
0046     
0047     for n=1:NL
0048         plot3(V(Fedge(n,:),1),V(Fedge(n,:),2),V(Fedge(n,:),3),'r-')
0049         hold on
0050     end
0051 end
0052 
0053 Vlist = [];
0054 Flist = [];
0055 Nline = 0;
0056 
0057 % Make vertex index list for boundary closed loop
0058 % and triangle index to close surface
0059 while ~isempty(Fedge)
0060     % make closed loop index list
0061     [ID, Fedge] = vb_close_line(Fedge);
0062     Nline = Nline + 1;
0063     Vlist{Nline} = ID;
0064 end
0065 
0066 if DEBUG == 1
0067     for n=1:Nline
0068         ID = Vlist{n};
0069         plot3(V(ID,1),V(ID,2),V(ID,3),'r-')
0070         hold on
0071         plot3(V([ID(1) ID(n)],1),V([ID(1) ID(n)],2),V([ID(1) ID(n)],3),'r-')
0072     end
0073 end
0074 
0075 return
0076 
0077 
0078 return

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005