cutprofile

PURPOSE ^

CUTPROFILE - cut a profile

SYNOPSIS ^

function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);

DESCRIPTION ^

CUTPROFILE - cut a profile

   this script is used by expmaster as an elementary operation
   on an ARGUS profile

   Usage:
      [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);
0002 %CUTPROFILE - cut a profile
0003 %
0004 %   this script is used by expmaster as an elementary operation
0005 %   on an ARGUS profile
0006 %
0007 %   Usage:
0008 %      [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root)
0009         
0010     %some checks
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     %plot squares
0023     for i=1:numprofiles
0024         plot(A(i).x,A(i).y,'-rs','MarkerSize',10);
0025     end
0026 
0027     while loop
0028 
0029         %select a segment
0030         title('click the segment to cut, RETURN to exit','FontSize',14)
0031         [xi,yi] = ginput(1);
0032 
0033         if ~isempty(xi)
0034 
0035             %get the closest segment
0036             [profsel indsel]=closestsegment(A,numprofiles,xi,yi);
0037 
0038             %check that at least one segment exists
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                 %cut A
0048                 if closed(profsel)
0049                     %open the contour
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                     %cut the contour in 2 profiles
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                 %plot new profile
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             %RETURN->exit
0074             loop=0;
0075         end
0076     end
0077 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003