Home > fvcom_prepro > add_obc_nodes_graphic.m

add_obc_nodes_graphic

PURPOSE ^

Add a set of obc nodes comprising a single obc boundary to Mesh structure

SYNOPSIS ^

function [Mobj] = add_obc_nodes_graphic(Mobj,ObcName,ObcType)

DESCRIPTION ^

 Add a set of obc nodes comprising a single obc boundary to Mesh structure  
 By clicking on points on the screen

 [Mobj] = add_obc_nodes(Mobj)

 DESCRIPTION:
    Select using ginput the set of nodes comprising an obc

 INPUT
    Mobj = Matlab mesh object
    ObcName = Name of the Open Boundary
    ObcType = FVCOM Flag for OBC Type

 OUTPUT:
    Mobj = Matlab mesh object with an additional obc nodelist

 EXAMPLE USAGE
    Mobj = add_obc_nodes(Mobj,'OpenOcean')

 Author(s):  
    Geoff Cowles (University of Massachusetts Dartmouth)

 Note:
    Uses ginput2 which allows zoom/pan before selecting points and displays
    clicked points realtime

 Revision history
   
==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Mobj]  = add_obc_nodes_graphic(Mobj,ObcName,ObcType)
0002 
0003 % Add a set of obc nodes comprising a single obc boundary to Mesh structure
0004 % By clicking on points on the screen
0005 %
0006 % [Mobj] = add_obc_nodes(Mobj)
0007 %
0008 % DESCRIPTION:
0009 %    Select using ginput the set of nodes comprising an obc
0010 %
0011 % INPUT
0012 %    Mobj = Matlab mesh object
0013 %    ObcName = Name of the Open Boundary
0014 %    ObcType = FVCOM Flag for OBC Type
0015 %
0016 % OUTPUT:
0017 %    Mobj = Matlab mesh object with an additional obc nodelist
0018 %
0019 % EXAMPLE USAGE
0020 %    Mobj = add_obc_nodes(Mobj,'OpenOcean')
0021 %
0022 % Author(s):
0023 %    Geoff Cowles (University of Massachusetts Dartmouth)
0024 %
0025 % Note:
0026 %    Uses ginput2 which allows zoom/pan before selecting points and displays
0027 %    clicked points realtime
0028 %
0029 % Revision history
0030 %
0031 %==============================================================================
0032 subname = 'add_obc_nodes';
0033 global ftbverbose
0034 if(ftbverbose)
0035   fprintf('\n')
0036   fprintf(['begin : ' subname '\n'])
0037 end;
0038 
0039 
0040 %------------------------------------------------------------------------------
0041 % Plot the mesh
0042 %------------------------------------------------------------------------------
0043 
0044 if(lower(Mobj.nativeCoords(1:3)) == 'car')
0045     x = Mobj.x;
0046     y = Mobj.y;
0047 else
0048     x = Mobj.lon;
0049     y = Mobj.lat;
0050 end;
0051 
0052 figure
0053 patch('Vertices',[x,y],'Faces',Mobj.tri,...
0054         'Cdata',Mobj.h,'edgecolor','k','facecolor','interp');
0055 hold on;
0056 
0057 % use ginput2 (which allows zooming and plots points as they are clicked) to let
0058 % user select the boundary points
0059 [xselect] = ginput2(true,'k+')
0060 
0061 
0062 [npts,jnk] = size(xselect);
0063 
0064 if(npts == 0)
0065     fprintf('you didn''t select any points')
0066     fprintf(['end   : ' subname '\n'])
0067     return
0068 end;
0069 fprintf('you selected %d points\n',npts)
0070 
0071 % snap to the closest vertices
0072 for i=1:npts
0073     [ipt(i),dist] = find_nearest_pt(xselect(i,1),xselect(i,2),Mobj);
0074 end;
0075 
0076 % replot domain with snapped vertices
0077 plot(x(ipt),y(ipt),'ro');
0078 
0079 % add to mesh object
0080 Mobj.nObs = Mobj.nObs + 1;
0081 Mobj.nObcNodes(Mobj.nObs) = npts;
0082 Mobj.obc_nodes(Mobj.nObs,1:npts) = ipt;
0083 Mobj.obc_name{Mobj.nObs} = ObcName;
0084 Mobj.obc_type(Mobj.nObs) = ObcType;
0085 
0086 
0087 if(ftbverbose)
0088   fprintf(['end   : ' subname '\n'])
0089 end;
0090

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005