cp readslice.R ts_readslice.R
[wrf-fire-matlab.git] / quicwind / plot_mesh.m
blob4368581c388d6fc9028c6a7ece1eff84667324f9
1 function plot_mesh(X,bbox)
2 check_mesh(X);
3 if exist('bbox','var')
4     for i=1:3
5         X{i}=X{i}(bbox(1):bbox(2),bbox(3):bbox(4),bbox(5):bbox(6));
6     end
7 end
8 [nx,ny,nz]=size(X{1});
9 nx=nx-1; ny=ny-1; nz=nz-1;
10 x=X{1};
11 y=X{2};
12 z=X{3};
13 clf
14 hold on
15 properties={'FaceColor', 'b', 'FaceAlpha', 0.05, 'EdgeColor','k','EdgeAlpha',1};
16 for ivar=1:3
17     ivar
18     for i=1:nx+(ivar==1)
19         %i
20         for j=1:ny+(ivar==2)
21             %j
22             for k=1:nz+(ivar==3)
23                 xx = vpatch3(x,i,j,k,ivar);
24                 yy = vpatch3(y,i,j,k,ivar);
25                 zz = vpatch3(z,i,j,k,ivar);
26                 % i,j,k,xx,yy,zz
27                 patch('Xdata', xx, 'YData', yy, 'ZData', zz, properties{:});
28             end
29         end
30         drawnow
31     end
32 end
33 hold off
34 end
36 function v=vpatch3(a,i,j,k,ivar)
37 switch ivar
38     case 1
39         v=[a(i,j,k),a(i,j+1,k),a(i,j+1,k+1),a(i,j,k+1)];
40     case 2
41         v=[a(i,j,k),a(i+1,j,k),a(i+1,j,k+1),a(i,j,k+1)];
42     case 3
43         v=[a(i,j,k),a(i+1,j,k),a(i+1,j+1,k),a(i,j+1,k)];
44 end
45 end