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

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

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

Initial import of Stark code.

Line 
1 function [ho,hb]=slice3d(Q,Z,mesh,slev)
2
3 % [H,HB]=slice3d(Q,Z,MESH,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 %     slev = intervals between x, y and z wireframes (3 x 1)
12
13 % OPNML COMPLIANT 3-18-99
14
15 nnv=size(Z,1);
16 xint=slev(1);
17 yint=slev(2);
18 zint=slev(3);
19 h=[];
20
21 if ~isnan(xint)
22         xrange=xint*ceil(min(mesh.x)/xint):...
23                 xint:...
24                 xint*floor(max(mesh.x)/xint);
25 else
26         xrange=[];
27 end
28 if ~isnan(zint)
29         zrange= zint*ceil(min(Z(1,:))/zint+0.5):...
30                 abs(zint):-5;
31 else
32         zrange=[];
33 end
34 if ~isnan(yint)
35         yrange=yint*ceil(min(mesh.y)/yint):...
36                 yint:...
37                 yint*floor(max(mesh.y)/yint);
38 else
39         yrange=[];
40 end
41 hold on
42
43 % CONSTANT Z
44
45 for zin=zrange
46         x=mesh.x;
47         y=mesh.y;
48         e=mesh.e;
49         if zin<0
50                 l=horzslicefem(Z,Q,zin);
51                 ht=colormesh2d(mesh,l);
52         else
53                 ht=colormesh2d(mesh,Q(nnv,:)');
54         end
55         set(ht,'zdata',get(ht,'xdata')*0+zin)
56         h=[h;ht];
57 end
58
59 % CONSTANT X
60
61 for xin=xrange
62         [l,z,d,xl,yl]=vslice(Q,Z,xin,[],100,mesh);
63         ht=surf(xl,yl,z,l);
64         shading('interp')
65         h=[h;ht];
66         plot3(xl(:,1),yl(:,1),z(:,1),'k')
67         plot3(xl(:,size(xl,2)),yl(:,size(xl,2)),z(:,size(xl,2)),'k')
68         plot3(xl(size(xl,1),:),yl(size(xl,1),:),z(size(xl,1),:),'k')
69         plot3(xl(1,:),yl(1,:),z(1,:),'k')
70 end
71
72 % CONSTANT Y
73
74 for yin=yrange
75         [l,z,d,xl,yl]=vslice(Q,Z,[],yin,150,mesh);
76         ht=surf(xl,yl,z,l);
77         shading('interp')
78         h=[h;ht];
79         plot3(xl(:,1),yl(:,1),z(:,1),'k')
80         plot3(xl(:,size(xl,2)),yl(:,size(xl,2)),z(:,size(xl,2)),'k')
81         plot3(xl(size(xl,1),:),yl(size(xl,1),:),z(size(xl,1),:),'k')
82         plot3(xl(1,:),yl(1,:),z(1,:),'k')
83 end
84
85 if nargout
86         ho=h;
87 end
88
89 for xin=xrange
90 for yin=yrange
91         plot3(  xin*ones(2,1),...
92                 yin*ones(2,1),...
93                 [min(Z(:)) max(Z(:))],...
94                 'k-');
95 end
96 end
97
98 axis([-inf inf -inf inf min(Z(:)) max(Z(:))]);
Note: See TracBrowser for help on using the browser.