0001 function [A,numprofiles,numpoints,closed]=removeseveralpoints(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<3
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 points=[];
0028
0029
0030 while loop
0031
0032
0033 if isempty(points)
0034 title('click on the first tip, RETURN to exit','FontSize',14)
0035 elseif length(points)==1
0036 title('click on the second tip, RETURN to exit','FontSize',14)
0037 else
0038 title('click in the middle of the area to be removed, RETURN to exit','FontSize',14)
0039 end
0040
0041 [xi,yi] = ginput(1);
0042
0043 if ~isempty(xi)
0044
0045
0046 if isempty(points)
0047 [profsel indsel]=closestpoint(A,numprofiles,xi,yi);
0048 if ((closed(profsel) & length(A(profsel).x)<4) | (~closed(profsel) & length(A(profsel).x)<3)),
0049 disp('the selected profile has less than 3 points, make another selection');
0050 else
0051 selection=profsel;
0052 points(end+1)=indsel;
0053 plot(A(selection).x,A(selection).y,'-b','MarkerSize',10);
0054 text(A(selection).x(indsel),A(selection).y(indsel),num2str(1),'FontSize',14,'background',[0.7 0.7 0.9]);
0055 end
0056 else
0057
0058 [profsel indsel]=closestpoint(A(selection),1,xi,yi);
0059 if ismember(indsel,points)
0060 disp('the selected points must be distinct')
0061 else
0062
0063 if length(points)==1,
0064 points(end+1)=indsel;
0065 text(A(selection).x(indsel),A(selection).y(indsel),num2str(2),'FontSize',14,'background',[0.7 0.7 0.9]);
0066
0067 else
0068 p1=points(1); p2=points(2); p3=indsel;
0069 if p1<p2
0070 if p3>p1 & p3<p2
0071 A(selection).x(p1+1:p2-1)=[];
0072 A(selection).y(p1+1:p2-1)=[];
0073 numpoints=numpoints-(p2-p1-1);
0074 loop=0;
0075 else
0076 A(selection).x=A(selection).x(p1:p2);
0077 A(selection).y=A(selection).y(p1:p2);
0078 numpoints=numpoints-(numpoints-1-p2)-(p1-1);
0079 if closed(selection)
0080
0081 A(selection).x(end+1)=A(selection).x(1);
0082 A(selection).y(end+1)=A(selection).y(1);
0083 numpoints=numpoints+1;
0084 end
0085 loop=0;
0086 end
0087 else
0088 if p3>p2 & p3<p1
0089 A(selection).x(p2+1:p1-1)=[];
0090 A(selection).y(p2+1:p1-1)=[];
0091 numpoints=numpoints-(p1-p2-1);
0092 loop=0;
0093
0094 else
0095 A(selection).x=A(selection).x(p2:p1);
0096 A(selection).y=A(selection).y(p2:p1);
0097 numpoints=numpoints-(numpoints-1-p1)-(p2-1);
0098 if closed(selection)
0099
0100 A(selection).x(end+1)=A(selection).x(1);
0101 A(selection).y(end+1)=A(selection).y(1);
0102 numpoints=numpoints+1;
0103 end
0104 loop=0;
0105 end
0106 end
0107 end
0108 end
0109 end
0110 else
0111
0112 loop=0;
0113 end
0114 end
0115 end