function polygonal_surface_display ( node_file_name, face_file_name ) %% POLYGONAL_SURFACE_DISPLAY displays a polygonal surface file. % % Modified: % % 18 January 2007 % % Author: % % John Burkardt % % Parameters: % % Input, string NODE_FILE_NAME, the name of the node file. % % Input, string FACE_FILE_NAME, the name of the face file. % timestamp; fprintf ( 1, '\n' ); fprintf ( 1, 'POLYGONAL_SURFACE_DISPLAY\n' ); fprintf ( 1, ' MATLAB version\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Read the nodes and faces defining\n' ); fprintf ( 1, ' a polygonal surface and display the object\n' ); fprintf ( 1, ' as a MATLAB shape.\n' ); % % If at least one command line argument, it's the node file name. % if ( nargin < 1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'POLYGONAL_SURFACE_DISPLAY:\n' ); node_file_name = input ( 'Enter the name of the node file:' ); end % % If at least two command line arguments, it's the face file name. % if ( nargin < 2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'POLYGONAL_SURFACE_DISPLAY:\n' ); face_file_name = input ( 'Enter the name of the face file:' ); end [ node_num, node_xyz ] = polygonal_surface_node_file_read ( node_file_name ); fprintf ( 1, '\n' ); fprintf ( 1, ' Number of nodes = %d\n', node_num ); r8mat_transpose_print_some ( 3, node_num, node_xyz, 1, 1, 3, 5, ... ' First five nodes:' ); [ face_order, face_num, face_node ] = ... polygonal_surface_face_file_read ( face_file_name ); fprintf ( 1, '\n' ); fprintf ( 1, ' Face order = %d\n', face_order ); fprintf ( 1, ' Number of faces = %d\n', face_num ); i4mat_transpose_print_some ( face_order, face_num, face_node, ... 1, 1, face_order, 5, ' First five faces:' ); % % Display the image as a collection of polygons. % handle = patch ( 'Vertices', node_xyz', 'Faces', face_node' ); set ( handle, 'FaceColor', [0.5, 0.6, 0.8], 'EdgeColor', 'Black' ); axis equal; grid on; xlabel ( '--X axis--' ) ylabel ( '--Y axis--' ) zlabel ( '--Z axis--' ) % % The TITLE function will interpret underscores in the title. % We need to unescape such escape sequences! % title_string = s_escape_tex ( face_file_name ); title ( title_string ) fprintf ( 1, '\n' ); fprintf ( 1, 'POLYGONAL_SURFACE_DISPLAY:\n' ); fprintf ( 1, ' Normal end of execution.\n' ); fprintf ( 1, '\n' ); timestamp;