function hand_mesh2d ( )

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

  fprintf ( 1, '\n' );
  fprintf ( 1, 'hand_mesh2d():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  mesh2d() can triangulate the outline of a hand.\n' );
%
%  Load the vertex data.
%
  v = load ( 'hand_vertices.txt' );
%
%  Display the vertices.
%
  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( v(:,1), v(:,2), 'r-' );
    plot ( v(:,1), v(:,2), 'b.', 'markersize', 25 );
  hold ( 'off' );
  title ( '  Vertices for the hand' );
  axis ( 'equal' );
  filename = 'hand_mesh2d_vertices.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  v_num = length ( v );
%
%  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.01;
  hdata.hmax = 0.025;
%
%  Call MESH2D to determine the triangulation.
%
  [ p, t ] = mesh2d ( v, e, hdata );
  filename = 'hand_mesh2d_mesh.png';
  print ( '-dpng', 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 = 'hand_nodes.txt';
  save ( node_filename, 'p', '-ASCII' );
  fprintf ( 1, '  Nodes saved as "%s"\n', node_filename );

  element_filename = 'hand_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, 'hand_mesh2d():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
 
  return
end
