function human_mesh2d ( )

%*****************************************************************************80
%
%% human_mesh2d() uses mesh2d() to triangulate human data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 May 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../mesh2d' )
%
%  Suppress the warnings about the soon-to-be-obsolete function "tsearch".
%
  warning ( 'off' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'human_mesh2d():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test mesh2d() on the outline of a human.\n' );
%
%  Load the vertex data.
%
  v = load ( 'human_points.txt' );
  x = v(:,1);
  y = v(:,2);
%
%  Display the vertices.
%
  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( [ x; x(1) ], [ y; y(1) ], 'b-' );
    plot ( x, y, 'r.', 'markersize', 25 );
  hold ( 'off' );
  title ( '  Vertices for the human' );
  axis ( 'equal' );
  filename = 'human_mesh2d_vertices.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  v = [ x, y ];
  v_num = length ( x );
%
%  Set up the edge array.
%
  e = zeros ( v_num, 2 );
  e(1:v_num,1) = ( 1 : v_num )';
  e(1:v_num-1,2) = ( 2 : v_num )';
  e(v_num,2) = 1;
%
%  Create the HDATA structure.
%
%  Set the HMAX field to specify the maximum element size.
%
  hdata = [];
  hdata.hmax = 0.25;
%
%  Call MESH2D to determine the triangulation.
%
  [ p, t ] = mesh2d ( v, e, hdata );
  filename = 'human_mesh2d_mesh.png';
  print ( '-dpng', filename );
% filename = 'human_mesh2d_mesh.jpg';
% print ( '-djpeg', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Count and report the vertices, nodes and elements.
%
  nv = size ( v, 1 );
  np = size ( p, 1 );
  nt = size ( t, 1 );
  fprintf ( 1, ...
    '  %d boundary vertices input, %d nodes and %d triangles created\n', ...
    nv, np, nt );
%
%  Write the node and element data to files.
%
  node_filename = 'human_mesh2d_nodes.txt';
  save ( node_filename, 'p', '-ascii' );
  fprintf ( 1, '  Nodes saved as "%s"\n', node_filename );

  element_filename = 'human_mesh2d_elements.txt';
  save ( element_filename, 't', '-ascii' );
  fprintf ( 1, '  Elements saved as "%s"\n', element_filename );
%
%  Clear the MATLAB path.
%
  rmpath ( '../mesh2d' )
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'human_mesh2d():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
 
  return
end
