function region_test ( )

%*****************************************************************************80
%
%% region_test() plots data computed by FreeFem++.
%
%  Licensing:
%
%    Copyright (C) 2018 Chloros2 <chloros2@gmx.de>
%
%    This program 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 program 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 program.  If not, see
%    <https://www.gnu.org/licenses/>.
%
%  Modified:
%
%    2018-05-13
%
%  Author:
%
%    Chloros2 <chloros2@gmx.de>
%    Modifications by John Burkardt.
%
  addpath ( '../ffmatlib' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'region_test():\n' );
  fprintf ( 1, '  Plot data computed by FreeFem++\n' );

  clear ( 'all' );
%
%  Read the data from the FreeFem++ computation.
%
  [ p, b, t, nv, nbe, nt, labels, regions ] = ffreadmesh ( 'region.msh' );
  [ vh ] = ffreaddata ( 'region_vh.txt' );
  [ u ] = ffreaddata ( 'region_data.txt' );

  figure ( );
  ffpdeplot ( p, b, t, ...
    'Mesh','on', ...
    'Boundary','on' );
  filename = 'region_mesh.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );

  figure ( );
  ffpdeplot ( p, b, t, ...
    'Mesh','on', ...
    'Boundary','off', ...
    'RLabels',regions(1) );
  filename = 'region_blank.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );

  plotcols = rand ( numel(regions), 3 );

  figure ( );
  ffpdeplot ( p, b, t, ...
    'Mesh','on', ...
    'Boundary','off', ...
    'RLabels',regions, ...
    'RColors',plotcols );
  filename = 'region_colors.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );

  figure ( );
    ffpdeplot ( p, b, t, ...
    'VhSeq',vh, ...
    'XYData',u, ...
    'ZStyle','continuous', ...
    'Mesh','on', ...
    'MColor','k' );
  filename = 'region_surface.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'region_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../ffmatlib' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

