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

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/contourfill3d.m

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

Initial import of Stark code.

Line 
1 function [ho,hb]=contourfill3d(Q,Z,mesh,qlev,slev)
2
3 % [H,HB]=contour3d(Q,Z,MESH,QLEV,SLEV)
4
5 nnv=size(Z,1);
6 xint=slev(1);
7 yint=slev(2);
8 zint=slev(3);
9 h=[];
10 hb=[];
11
12 hold on
13
14 % CONSTANT Z
15
16 zrange= zint*ceil(min(Z(1,:))/zint+0.5):...
17         abs(zint):0;
18
19 if ~isnan(zint)
20 for zin=zrange
21         if zin<0
22                 l=horzslicefem(Z',Q',zin);
23                 c=contourctri([mesh.X mesh.Y],l,mesh.E,qlev,1);
24         else
25                 c=contourctri([mesh.X mesh.Y],Q(nnv,:)',mesh.E,qlev,1);
26         end
27         while ~isempty(c)
28                 np=c(2,1);
29                 z=ones(1,np)*zin;
30                 x=c(1,2:np+1);
31                 y=c(2,2:np+1);
32                 h=[h;patch(x,y,z,'w',...
33                         'facecolor','none',...
34                         'edgecolor','c')];
35                 c=c(:,np+2:size(c,2));
36         end
37 end
38 end
39
40 % BATHYMETRY
41
42 c=contoursurf([mesh.X mesh.Y],mesh.E',-mesh.H,zrange);
43 while ~isempty(c)
44         np=c(2,1);
45         z=ones(1,np)*c(1,1);
46         x=c(1,2:np+1);
47         y=c(2,2:np+1);
48         hb=[hb;plot3(x,y,z,'-',...
49                 'color',[0.3 0.3 0.3])];
50         c=c(:,np+2:size(c,2));
51 end
52
53 % CONSTANT X
54
55 xrange=xint*ceil(min(mesh.X)/xint):xint:xint*floor(max(mesh.X)/xint);
56
57 if ~isnan(xint)
58 for xin=xrange
59         [l,z,d,xl,yl]=vslice(Q,Z,xin,[],60,mesh);
60         hb=[hb;plot3(xl(1,:),yl(1,:),z(1,:),'-',...
61                 'color',[0.3 0.3 0.3])];
62        
63         [c,ht]=contourf(yl,z,l,[qlev qlev]);
64         h=[h;ht];
65         for in=ht(:)'
66                 z=get(in,'ydata');
67                 y=get(in,'xdata');
68                 x=ones(size(y))*xin;
69                 set(in,'xdata',x,...
70                         'ydata',y,...
71                         'zdata',z,...
72                         'facecolor','none',...
73                         'edgecolor','c')
74         end
75 end
76 end
77
78 % CONSTANT Y
79
80 yrange=yint*ceil(min(mesh.Y)/yint):yint:yint*floor(max(mesh.Y)/yint);
81
82 if ~isnan(yint)
83 for yin=yrange
84         [l,z,d,xl,yl]=vslice(Q,Z,[],yin,100,mesh);
85         hb=[hb;plot3(xl(1,:),yl(1,:),z(1,:),'-',...
86                 'color',[0.3 0.3 0.3])];
87
88         [c,ht]=contourf(xl,z,l,[qlev qlev]);
89         h=[h;ht];
90         for in=ht(:)'
91                 z=get(in,'ydata');
92                 x=get(in,'xdata');
93                 y=ones(size(x))*yin;
94                 set(in,'xdata',x,...
95                         'ydata',y,...
96                         'zdata',z,...
97                         'facecolor','none',...
98                         'edgecolor','c')
99         end
100 end
101 end
102
103 if nargout
104         ho=h;
105 end
Note: See TracBrowser for help on using the browser.