%
% Plots the isosurface
%
% if zvlevel=vector then plot several slices with different transparency


function [lhandle,p]=plotsiosurface(X,Y,Z,U,zlevel,isocolor)

%figure(2)
%clf
%[X Y Z] = meshgrid(allx,ally,allz);
%
%lx=length(allx);
%ly=length(ally);
%lz=length(allz);
%it = 1;
%
%up = reshape(allu(it,:,:,:),lx,ly,lz);
%up=abs(up).^2;

ll=length(zlevel);
zlevel=sort(zlevel);
zlevel=fliplr(zlevel);
if(ll>1)
 transp=linspace(1,0.3,ll).^2;
else
 transp=1;
end

for ii=1:ll
 p=patch(isosurface(X, Y, Z, U, zlevel(ii)));
 isonormals(X,Y,Z,U,p)
 set(p, 'FaceColor', isocolor, 'EdgeColor', 'none','AmbientStrength',0.5);
 set(p, 'FaceAlpha', transp(ii))
 %%reducepatch(p,0.5);
 %daspect([1 1 1])
 view(3)
 lhandle=camlight; 
 lighting phong

end

