0001 function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if numprofiles==0
0012 disp('no profile present')
0013 return
0014 end
0015 if numpoints<2
0016 disp('at least two points are needed')
0017 return
0018 end
0019 hold on
0020 loop=1;
0021
0022
0023 for i=1:numprofiles
0024 plot(A(i).x,A(i).y,'-rs','MarkerSize',10);
0025 end
0026
0027 while loop
0028
0029
0030 title('click the segment to cut, RETURN to exit','FontSize',14)
0031 [xi,yi] = ginput(1);
0032
0033 if ~isempty(xi)
0034
0035
0036 [profsel indsel]=closestsegment(A,numprofiles,xi,yi);
0037
0038
0039 if indsel==0
0040 disp('at least 2 points are required');
0041 return,
0042 end
0043
0044 if ((closed(profsel) & length(A(profsel).x)<3) | (~closed(profsel) & length(A(profsel).x)<2))
0045 disp('at least 2 points are required, make another selection');
0046 else
0047
0048 if closed(profsel)
0049
0050 A(profsel).x=[A(profsel).x(indsel+1:end-1,1);A(profsel).x(1:indsel,1)];
0051 A(profsel).y=[A(profsel).y(indsel+1:end-1,1);A(profsel).y(1:indsel,1)];
0052 numpoints=numpoints-1;
0053 closed(profsel)=0;
0054 else
0055
0056 A(end+1).x=A(profsel).x(indsel+1:end,1);
0057 A(end).y=A(profsel).y(indsel+1:end,1);
0058 A(end).name=root;
0059 A(end).density=1;
0060 A(profsel).x=A(profsel).x(1:indsel,1);
0061 A(profsel).y=A(profsel).y(1:indsel,1);
0062 numprofiles=numprofiles+1;
0063 closed(end+1)=0;
0064 end
0065
0066
0067 undoplots(prevplot);
0068 for i=1:numprofiles
0069 plot(A(i).x,A(i).y,'-rs','MarkerSize',10);
0070 end
0071 end
0072 else
0073
0074 loop=0;
0075 end
0076 end
0077 end