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

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

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

Initial import of Stark code.

Line 
1 function [ho,hb]=contour3d(Q,Z,mesh,qlev,slev)
2
3 % [H,HB]=contour3d(Q,Z,MESH,QLEV,SLEV)
4 %
5 % Generates a wireframe of the isosurface of Q at value QLEV, with the
6 % interval between frames being described by SLEV
7 %
8 %     Q = Scalar field (nnv x nn)
9 %     Z = Z locations of scalar field (nnv x nn)
10 %     mesh = Structure loaded by MESHSTR (with E,X,Y fields)
11 %     qlev = isosurface value of Q to be plotted
12 %     slev = intervals between x, y and z wireframes (3 x 1)
13
14
15 nnv=size(Z,1);
16 xint=slev(1);
17 yint=slev(2);
18 zint=slev(3);
19 h=[];
20 hb=[];
21
22 hold on
23
24 % CONSTANT Z
25
26 if ~isnan(zint)
27         zrange= zint*ceil(min(Z(1,:))/zint+0.5):...
28                 abs(zint):0;
29 for zin=zrange
30         disp([zin max(Q(:)) min(Q(:))])
31         x=mesh.X;
32         y=mesh.Y;
33         e=mesh.E;
34         if zin<0
35                 l=hslice(Z',Q',zin);
36                 save testprob x y l e qlev
37                 c=contourctri([x y],l,e,qlev,1);
38         else
39                 c=contourctri([mesh.X mesh.Y],Q(nnv,:)',mesh.E,qlev,1);
40         end
41         while ~isempty(c)
42                 np=c(2,1);
43                 z=ones(1,np)*zin;
44                 x=c(1,2:np+1);
45                 y=c(2,2:np+1);
46                 h=[h;plot3(x,y,z,'c-')];
47                 c=c(:,np+2:size(c,2));
48         end
49 end
50 end
51
52 % BATHYMETRY
53
54 c=contoursurf([mesh.X mesh.Y],mesh.E',-mesh.H,zrange);
55 while ~isempty(c)
56         np=c(2,1);
57         z=ones(1,np)*c(1,1);
58         x=c(1,2:np+1);
59         y=c(2,2:np+1);
60         hb=[hb;plot3(x,y,z,'-',...
61                 'color',[0.3 0.3 0.3])];
62         c=c(:,np+2:size(c,2));
63 end
64
65 % CONSTANT X
66
67 if ~isnan(xint)
68         xrange=xint*ceil(min(mesh.X)/xint):...
69                 xint:...
70                 xint*floor(max(mesh.X)/xint);
71 for xin=xrange
72         [l,z,d,xl,yl]=vslice(Q,Z,xin,[],100,mesh);
73         hb=[hb;plot3(xl(1,:),yl(1,:),z(1,:),'-',...
74                 'color',[0.3 0.3 0.3])];
75        
76         c=contours(yl,z,l,[qlev qlev]);
77         while ~isempty(c)
78                 np=c(2,1);
79                 x=ones(1,np)*xin;
80                 y=c(1,2:np+1);
81                 z=c(2,2:np+1);
82                 h=[h;plot3(x,y,z,'c-')];
83                 c=c(:,np+2:size(c,2));
84         end
85 end
86 end
87
88 % CONSTANT Y
89
90 if ~isnan(yint)
91         yrange=yint*ceil(min(mesh.Y)/yint):...
92                 yint:...
93                 yint*floor(max(mesh.Y)/yint);
94 for yin=yrange
95         [l,z,d,xl,yl]=vslice(Q,Z,[],yin,150,mesh);
96         hb=[hb;plot3(xl(1,:),yl(1,:),z(1,:),'-',...
97                 'color',[0.3 0.3 0.3])];
98
99         c=contours(xl,z,l,[qlev qlev]);
100         while ~isempty(c)
101                 np=c(2,1);
102                 y=ones(1,np)*yin;
103                 x=c(1,2:np+1);
104                 z=c(2,2:np+1);
105                 h=[h;plot3(x,y,z,'c-')];
106                 c=c(:,np+2:size(c,2));
107         end
108 end
109 end
110
111 if nargout
112         ho=h;
113 end
Note: See TracBrowser for help on using the browser.