function varargout = decc_plot_bathy(varargin)
%DECC_PLOT_BATHY  plot bathymetry of curved coastline model
%
%   More detailed description goes here.
%
%   Syntax:
%   varargout = decc_plot_bathy(varargin)
%
%   Input:
%   varargin  =
%
%   Output:
%   varargout =
%
%   Example
%   decc_plot_bathy
%
%   See also

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2011 Delft University of Technology
%       Kees den Heijer
%
%       C.denHeijer@TUDelft.nl
%
%       Faculty of Civil Engineering and Geosciences
%       P.O. Box 5048
%       2600 GA Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation, either version 3 of the License, or
%   (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this library.  If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tool is part of <a href="http://www.OpenEarth.eu">OpenEarthTools</a>.
% OpenEarthTools is an online collaboration to share and manage data and
% programming tools in an open source, version controlled environment.
% Sign up to recieve regular updates of this function, and to contribute
% your own tools.

%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% Created: 16 Nov 2011
% Created with Matlab version: 7.12.0.635 (R2011a)

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

%%
OPT = struct(...
    'id', 0,...
    'irun', 0,...
    'maindir', fullfile(fileparts(which(mfilename)), '..', 'simulations'),...
    'radius', 1900,...
    'parent', gca,...
    'shading', 'interp',...
    'axislabels', {{{@xlabel, 'x-coordinate [m]'},...
    {@ylabel, 'y-coordinate [m]'},...
    {@zlabel, 'altitude [m]'}}});

OPT = setproperty(OPT, varargin{:});

%%
basepath = fullfile(OPT.maindir, sprintf('%08i', OPT.id), 'xbeach', sprintf('run%02i', OPT.irun));

calcdir = fullfile(basepath, sprintf('radius%05i', OPT.radius));
gridxy = wlgrid_da('read', fullfile(calcdir, 'xy.grd'));
z = ddb_wldep('read', fullfile(calcdir, 'bed.dep'), gridxy);
ph = surf(gridxy.X, gridxy.Y, z(1:end-1,1:end-1),...
    'parent', OPT.parent);
if OPT.shading
    feval(@shading, OPT.shading)
end
if iscell(OPT.axislabels)
    for ff = OPT.axislabels
        feval(ff{1}{:})
    end
end

%%
if nargout > 0
    varargout = {ph};
else
    axis tight
    figureStyle(@styleThesis)
    set(gcf, 'tag', '')
    fpath = fileparts(which(mfilename));
    fname = sprintf('decc_initial_bathy_radius_%05i', OPT.radius);
    figurepath = fullfile(fpath, '..', 'figures');
    set(gcf, 'tag', sprintf('radius %i m; $HeadURL$ $Revision$', OPT.radius))
    print(gcf, '-depsc2', fullfile(figurepath, [fname '.eps']))
    if ispc
        saveas(gcf, fullfile(figurepath, [fname '.emf']))
    end
    saveas(gcf, fullfile(figurepath, [fname '.fig']))
end