% ex11.m % % Example 1: graphics of the triangular mesh % with triangle labels % without rectangular boxes % % Jiangguo (James) Liu % ColoState, Dec. 2005 clear all; close all; pderect([-1 1 -1 1]); disp('Export mesh data, then continue...'); pause; NumElts = size(t,2); NumNds = size(p,2); figure(1); hold on; x = zeros(3,1); y = zeros(3,1); for j=1:NumElts for i=1:3 x(i) = p(1,t(i,j)); y(i) = p(2,t(i,j)); end fill(x,y,'w'); xc = (x(1)+x(2)+x(3))/3; yc = (y(1)+y(2)+y(3))/3; % This is funny if j<=9 xc = xc-0.00625; end if j>=10 & j<=99 xc = xc-0.0125; end if j>=100 & j<=999 xc = xc-0.035; end text(xc,yc,num2str(j)); end print -f1 -depsc2 ex11.eps; % Write the triangular mesh data to a file fp = fopen('TrigMesh.dat','wt'); fprintf(fp,'%4d %4d\n',NumElts, NumNds); for i=1:NumElts fprintf(fp,'%4d %4d %4d\n',t(1:3,i)); end for i=1:NumNds fprintf(fp,'%8.4f %8.4f\n',p(:,i)); end fclose(fp); disp('Press any key to close all windows...'); pause; close all; return;