


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)
Pierre Cazenave (Plymouth Marine Laboratory)
Note:
Uses ginput2 which allows zooming before selecting points and displays
clicked points realtime
Revision history
2014-05-20 Set boolean flag to true to indicate rivers.
==============================================================================

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 % Pierre Cazenave (Plymouth Marine Laboratory) 0023 % 0024 % Note: 0025 % Uses ginput2 which allows zooming before selecting points and displays 0026 % clicked points realtime 0027 % 0028 % Revision history 0029 % 2014-05-20 Set boolean flag to true to indicate rivers. 0030 % 0031 %============================================================================== 0032 subname = 'add_river_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 fprintf('click the river nodes in the model\n') 0060 fprintf('left click: zoom\n'); 0061 fprintf('delete: delete last point\n'); 0062 fprintf('drag mouse: pan\n'); 0063 fprintf('right click: select point\n'); 0064 fprintf('enter (return): finished selecting points\n'); 0065 [xselect] = ginput2(true,'r+'); 0066 0067 0068 [npts,jnk] = size(xselect); 0069 0070 if(npts == 0) 0071 fprintf('you didn''t select any points') 0072 fprintf(['end : ' subname '\n']) 0073 return 0074 end; 0075 fprintf('you selected %d points\n',npts) 0076 0077 % snap to the closest vertices 0078 for i=1:npts 0079 [ipt(i),dist] = find_nearest_pt(xselect(i,1),xselect(i,2),Mobj); 0080 end; 0081 0082 % replot domain with snapped vertices 0083 plot(x(ipt),y(ipt),'ro'); 0084 0085 % add to mesh object 0086 Mobj.nRivers = Mobj.nRivers + 1; 0087 Mobj.nRivNodes(Mobj.nRivers) = npts; 0088 Mobj.riv_nodes(Mobj.nRivers,1:npts) = ipt; 0089 Mobj.riv_name{Mobj.nRivers} = RiverName; 0090 0091 Mobj.have_rivers = true; 0092 0093 if(ftbverbose) 0094 fprintf(['end : ' subname '\n']) 0095 end; 0096