Home > fvcom_prepro > add_river_nodes_graphic.m

add_river_nodes_graphic

PURPOSE ^

Add a set of river nodes comprising a single river to Mesh structure

SYNOPSIS ^

function [Mobj] = add_river_nodes(Mobj,RiverName)

DESCRIPTION ^

 Add a set of river nodes comprising a single river to Mesh structure  

 [Mobj] = add_river_nodes(Mobj)

 DESCRIPTION:
    Select using ginput the set of nodes comprising a river

 INPUT
    Mobj = Matlab mesh object
    RiverName = Name of the River

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

 EXAMPLE USAGE
    Mobj = add_river_nodes(Mobj,'Potomac')

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

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

Generated on Tue 18-Dec-2012 12:37:31 by m2html © 2005