function triangulation_quality ( input_node_filename, ... input_triangulation_filename ) %% MAIN is the main program for TRIANGULATION_QUALITY. % % Discussion: % % TRIANGULATION_QUALITY determines quality measures for a triangulation. % % The code has been modified to 'allow' 6-node triangulations. % However, no effort is made to actually process the midside nodes. % Only information from the vertices is used. % % The three quality measures are: % % ALPHA_MEASURE % AREA_MEASURE % Q_MEASURE % % In each case, the ideal value of the quality measure is 1, and % the worst possible value is 0. % % The program also prints out the geometric bandwidth, which is the % bandwidth of the adjacency matrix of the nodes. % % Modified: % % 30 December 2006 % % Author: % % John Burkardt % % Local parameters: % % Local, integer DIM_NUM, the spatial dimension. % % Local, integer NODE_NUM, the number of nodes. % % Local, real NODE_XY(DIM_NUM,NODE_NUM), the point set. % % Local, integer TRIANGLE_NODE(TRIANGLE_ORDER,TRIANGLE_NUM), % lists the nodes that make up each triangle. % % Local, integer TRIANGLE_NUM, the number of triangles. % % Local, integer TRIANGLE_ORDER, the order of the triangles, % either 3 or 6. % fprintf ( 1, '\n' ); timestamp; fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY:\n' ); fprintf ( 1, ' (MATLAB version):\n' ); fprintf ( 1, ' Compute triangulation quality measures.\n' ); % % If at least one command line argument, it's the node file name. % if ( nargin < 1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY:\n' ); input_node_filename = input ( ... 'Please enter the name of the node coordinate file ' ); end % % If at least two arguments, the second is the triangulation file. % if ( nargin < 2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY:\n' ); input_triangulation_filename = input ( ... ' Please enter the name of the triangulation file.' ); end % % Read the node data. % [ dim_num, node_num ] = dtable_header_read ( input_node_filename ); fprintf ( 1, '\n' ); fprintf ( 1, ' Read the header of "%s".', input_node_filename ); fprintf ( 1, '\n' ); fprintf ( 1, ' Spatial dimension DIM_NUM = %d\n', dim_num ); fprintf ( 1, ' Number of points NODE_NUM = %d\n', node_num ); if ( dim_num ~= 2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY - Fatal error!\n' ); fprintf ( 1, ' Dataset must have spatial dimension 2.\n' ); error ( 'TRIANGULATION_QUALITY - Fatal error!' ); end node_xy = dtable_data_read ( input_node_filename, dim_num, node_num ); fprintf ( 1, '\n' ); fprintf ( 1, ' Read the data in "%s".\n', input_node_filename ); r8mat_transpose_print_some ( dim_num, node_num, node_xy, 1, 1, 5, 5, ... ' 5 by 5 portion of data read from file:' ); % % Read the triangulation data. % [ triangle_order, triangle_num ] = itable_header_read ( ... input_triangulation_filename ); if ( triangle_order ~= 3 & triangle_order ~= 6 ) fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY - Fatal error!\n' ); fprintf ( 1, ' Data is not for a 3-node or 6-node triangulation.\n' ); error ( 'TRIANGULATION_QUALITY - Fatal error!' ); end fprintf ( 1, '\n' ); fprintf ( 1, ' Read the header of "%s".\n', ... input_triangulation_filename ); fprintf ( 1, '\n' ); fprintf ( 1, ' Triangle order = %d\n', triangle_order ); fprintf ( 1, ' Number of triangles TRIANGLE_NUM = %d\n', ... triangle_num ); triangle_node = itable_data_read ( input_triangulation_filename, ... triangle_order, triangle_num ); fprintf ( 1, '\n' ); fprintf ( 1, ' Read the data in "%s".\n', ... input_triangulation_filename ); i4mat_transpose_print_some ( triangle_order, triangle_num, ... triangle_node, 1, 1, triangle_order, 10, ... ' Portion of TRIANGLE_NODE:' ); value = alpha_measure ( node_num, node_xy, triangle_order, ... triangle_num, triangle_node ); fprintf ( 1, ' The minimum angle measure Alpha = %f\n', value ); value = area_measure ( node_num, node_xy, triangle_order, ... triangle_num, triangle_node ); fprintf ( 1, ' The area ratio measure A-Ratio = %f\n', value ); value = q_measure ( node_num, node_xy, triangle_order, triangle_num, ... triangle_node ); fprintf ( 1, ' The triangle uniformity measure Q = %f\n', value ); [ ml, mu, m ] = bandwidth_mesh ( triangle_order, triangle_num, ... triangle_node ); fprintf ( 1, ' The geometric bandwidth M = %d\n', m ); fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_QUALITY:\n' ); fprintf ( 1, ' Normal end of execution.\n' ); fprintf ( 1, '\n' ); timestamp;