NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FDCONT/lndfill.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function h=lndfill(fem_grid_struct,color)
2 %LNDFILL draw land polygons for FEM domain
3 %   LNDFILL draws the land polygons generated by LNDMAKE
4 %   for a given FEM domain.  This is the "masking" routine
5 %   for the finite-difference based filled contouring package
6 %   FDCONT. The necessary fem_grid_struct fields for LNDFILL
7 %   are generated by LNDMAKE, and are contained in the
8 %   fem_grid_struct returned by LOADGRID, if the appropriate
9 %   files are located.
10 %
11 %   Input: fem_grid_struct - FEM domain grid structure (see LOADGRID)
12 %          color    - polygon face color
13 %
14 %   Output : h - handle to patch objects drawn
15 %
16 %   Call as: h=lndfill(fem_grid_struct,color);
17 %
18 %   Written by: Chris E. Naimie
19 %   Modified by: Brian O. Blanton for more general usage. (Jan 99)
20
21 if nargin<1 | nargin>2
22    error('Incorrect number of input arguments to LNDFILL')
23 end
24 if nargout>1 
25    error('Incorrect number of output arguments to LNDFILL')
26 end
27
28 % Verify incoming structure
29 if ~is_valid_struct(fem_grid_struct)
30    error('    Argument to LNDFILL must be a valid fem_grid_struct.')
31 end
32
33 % Check to see if the .lnd and .lbe fields of fem_grid_struct
34 % exist and are not empty.
35 if ~isfield(fem_grid_struct,'lnd')
36    error('    Land Node field not part of fem_grid_struct')
37 elseif ~isfield(fem_grid_struct,'lbe')
38    error('    Land Element field not part of fem_grid_struct')
39 end
40 lnd=fem_grid_struct.lnd;
41 lbe=fem_grid_struct.lbe;
42 if isempty(lnd)
43    error('    Land Node field in fem_grid_struct is EMPTY')
44 elseif isempty(lbe)
45    error('    Land Element field in fem_grid_struct is EMPTY')
46 end
47
48 % If color is not passed in, set the color to
49 % draw the land polys to be the same as the gca
50 % background color.
51 if nargin == 1
52    color=get(gca,'Color');
53 end
54
55 %
56 % Load data from .lnd and .lbe files
57 x=lnd(:,1);y=lnd(:,2);
58
59 %
60 % colorfill land and islands
61 i2=0;
62 count=0;
63 while i2 < length(lbe)
64 %
65    i1=i2+1;
66    i2=find(lbe(:,3)==lbe(i1,2));
67    polygon=lbe(i1:i2,2);
68    xp=x(polygon);yp=y(polygon);
69    count=count+1;
70    hf(count)=patch(xp,yp,color);
71    set(hf(count),'EdgeColor','none')
72 end
73 if nargout==1
74    h=hf;
75 end
76
Note: See TracBrowser for help on using the browser.