function [ v_xy, v_l, e_v, e_l, t_v, t_l ] = freefem_msh_io_2d_data_read ( ...
  ffmsh_filename, v_num, e_num, t_num )

%*****************************************************************************80
%
%% freefem_msh_io_2d_data_read() reads data from an FFMSH file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 December 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string FFMSH_FILENAME, the FFMSH filename.
%
%    integer V_NUM, the number of vertices.
%
%    integer E_NUM, the number of boundary edges.
%
%    integer T_NUM, the number of triangles.
%
%  Output:
%
%    real V_XY(2,V_NUM), vertex coordinates.
%
%    integer V_L(V_NUM), vertex labels.
%
%    integer E_V(2,E_NUM), edge vertices.
%
%    integer E_L(E_NUM), vertex labels.
%
%    integer T_V(3,T_NUM), triangle vertices.
%
%    integer T_L(T_NUM), triangle labels.
%
  ffmsh_unit = fopen ( ffmsh_filename, 'rt' );

  if ( ffmsh_unit < 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'FREEFEM_MSH_IO_2D_DATA_READ - Error!\n' );
    fprintf ( 1, '  Could not open the input file "%s".\n', ffmsh_filename );
    error ( 'FREEFEM_MSH_IO_2D_DATA_READ - Error!' );
  end

  [ values, count ] = fscanf ( ffmsh_unit, '%d%d%d', 3 );

  if ( count < 3 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'FREEFEM_MSH_IO_2D_DATA_READ - Error!\n' );
    fprintf ( 1, '  Could not read 3 values from line 1 of "%s".\n', ffmsh_filename );
    error ( 'FREEFEM_MSH_IO_2D_DATA_READ - Error!' );
  end

  v_num2 = values(1);
  t_num2 = values(2);
  e_num2 = values(3);
%
%  Read Vertex X, Y, Label
%
  for j = 1 : v_num
    [ values, count ] = fscanf ( ffmsh_unit, '%g%g%d', 3 );
    v_xy(1,j) = values(1);
    v_xy(2,j) = values(2);
    v_l(j) = values(3);
  end
%
%  Read Triangle V1, V2, V3, Label
%
  for j = 1 : t_num
    [ values, count ] = fscanf ( ffmsh_unit, '%d%d%d%d', 4 );
    t_v(1,j) = values(1);
    t_v(2,j) = values(2);
    t_v(3,j) = values(3);
    t_l(j) = values(4);
  end
%
%  Read Edge V1, V2, Label
%
  for j = 1 : e_num
    [ values, count ] = fscanf ( ffmsh_unit, '%d%d%d', 3 );
    e_v(1,j) = values(1);
    e_v(2,j) = values(2);
    e_l(j) = values(3);
  end

  fclose ( ffmsh_unit );

  return
end
