function tri_surface_to_ply_test01 ( )

%*****************************************************************************80
%
%% tri_surface_to_ply_test01() tests TRI_SURFACE_TO_PLY and PLY_WRITE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 March 2007
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'tri_surface_to_ply_test01():\n' );
  fprintf ( 1, '  TRI_SURFACE_TO_PLY converts a pair of arrays\n' );
  fprintf ( 1, '  describing a triangular mesh into a data\n' );
  fprintf ( 1, '  structure suitable for a PLY file.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  PLY_WRITE writes PLY data to a file.\n' );
%
%  Define the surface of a pyramid:
%
  node_xyz = [ 0,0,0; 1,0,0; 1,1,0; 0,1,0; 0.5,0.5,1.6 ]';
  triangle_node = [ 2,1,4; 2,4,3; 1,2,5; 1,5,4; 4,5,3; 2,3,5 ]';
%
%  Print (some of) the data.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The node coordinates\n' );

  node_num = size ( node_xyz, 2 );

  disp ( node_xyz )

  triangle_num = size ( triangle_node, 2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The triangle indices\n' );

  disp ( triangle_node )
%
%  View the pyramid.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Display the TRI_SURFACE data:\n' );

  trisurf ( triangle_node', node_xyz(1,:), node_xyz(2,:), node_xyz(3,:) );
  axis ( 'equal' );
  filename = 'pyramid.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  The data can be converted to PLY format, and written to a PLY file:
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Convert the TRI_SURFACE data to PLY data.\n' );

  ply_data = tri_surface_data_to_ply_data ( node_xyz, triangle_node );

  ply_file = 'pyramid.ply';

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Write the PLY data to the file "%s".\n', ply_file );

  ply_write ( ply_data, ply_file, 'ascii' );

  return
end
