| 1 | function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
|
|---|
| 2 | %CUTPROFILE - cut a profile
|
|---|
| 3 | %
|
|---|
| 4 | % this script is used by exptool as an elementary operation
|
|---|
| 5 | % on an ARGUS profile
|
|---|
| 6 | %
|
|---|
| 7 | % Usage:
|
|---|
| 8 | % [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
|
|---|
| 9 |
|
|---|
| 10 | %some checks
|
|---|
| 11 | if numprofiles==0
|
|---|
| 12 | disp('no profile present, exiting...')
|
|---|
| 13 | return
|
|---|
| 14 | end
|
|---|
| 15 | if numpoints<2
|
|---|
| 16 | disp('at least two points are needed')
|
|---|
| 17 | return
|
|---|
| 18 | end
|
|---|
| 19 | hold on
|
|---|
| 20 |
|
|---|
| 21 | %plot squares
|
|---|
| 22 | for i=1:numprofiles
|
|---|
| 23 | plot(A(i).x,A(i).y,'color',getfieldvalue(options,'color'),'LineStyle',getfieldvalue(options,'LineStyle'),'LineWidth',getfieldvalue(options,'LineWidth'),...
|
|---|
| 24 | 'MarkerEdgeColor',getfieldvalue(options,'MarkerEdgeColor'),'MarkerSize',getfieldvalue(options,'MarkerSize'),'Marker',getfieldvalue(options,'Marker'));
|
|---|
| 25 | end
|
|---|
| 26 |
|
|---|
| 27 | loop=1;
|
|---|
| 28 | while loop
|
|---|
| 29 |
|
|---|
| 30 | %select a segment
|
|---|
| 31 | title('click the segment to cut, RETURN to exit','FontSize',14)
|
|---|
| 32 | [xi,yi] = ginput(1);
|
|---|
| 33 |
|
|---|
| 34 | if ~isempty(xi)
|
|---|
| 35 |
|
|---|
| 36 | %get the closest segment
|
|---|
| 37 | [profsel indsel]=closestsegment(A,numprofiles,xi,yi);
|
|---|
| 38 |
|
|---|
| 39 | %check that at least one segment exists
|
|---|
| 40 | if indsel==0
|
|---|
| 41 | disp('at least 2 points are required');
|
|---|
| 42 | return,
|
|---|
| 43 | end
|
|---|
| 44 |
|
|---|
| 45 | if ((closed(profsel) & length(A(profsel).x)<3) | (~closed(profsel) & length(A(profsel).x)<2))
|
|---|
| 46 | disp('at least 2 points are required, make another selection');
|
|---|
| 47 | else
|
|---|
| 48 | %cut A
|
|---|
| 49 | if closed(profsel)
|
|---|
| 50 | %open the contour
|
|---|
| 51 | A(profsel).x=[A(profsel).x(indsel+1:end-1,1);A(profsel).x(1:indsel,1)];
|
|---|
| 52 | A(profsel).y=[A(profsel).y(indsel+1:end-1,1);A(profsel).y(1:indsel,1)];
|
|---|
| 53 | numpoints=numpoints-1;
|
|---|
| 54 | closed(profsel)=0;
|
|---|
| 55 | else
|
|---|
| 56 | %cut the contour in 2 profiles
|
|---|
| 57 | A(end+1).x=A(profsel).x(indsel+1:end,1);
|
|---|
| 58 | A(end).y=A(profsel).y(indsel+1:end,1);
|
|---|
| 59 | A(end).name=root;
|
|---|
| 60 | A(end).density=1;
|
|---|
| 61 | A(profsel).x=A(profsel).x(1:indsel,1);
|
|---|
| 62 | A(profsel).y=A(profsel).y(1:indsel,1);
|
|---|
| 63 | numprofiles=numprofiles+1;
|
|---|
| 64 | closed(end+1)=0;
|
|---|
| 65 | end
|
|---|
| 66 |
|
|---|
| 67 | %plot new profile
|
|---|
| 68 | undoplots(prevplot);
|
|---|
| 69 | for i=1:numprofiles
|
|---|
| 70 | plot(A(i).x,A(i).y,'color',getfieldvalue(options,'color'),'LineStyle',getfieldvalue(options,'LineStyle'),'LineWidth',getfieldvalue(options,'LineWidth'),...
|
|---|
| 71 | 'MarkerEdgeColor',getfieldvalue(options,'MarkerEdgeColor'),'MarkerSize',getfieldvalue(options,'MarkerSize'),'Marker',getfieldvalue(options,'Marker'));
|
|---|
| 72 | end
|
|---|
| 73 | end
|
|---|
| 74 | else
|
|---|
| 75 | %RETURN->exit
|
|---|
| 76 | loop=0;
|
|---|
| 77 | end
|
|---|
| 78 | end
|
|---|
| 79 | end
|
|---|