function ShowMesh(nodes,elem);
%ShowMesh(...)
%  shows a graph of the mesh
%
%ShowMesh(nodes,elem);
%nodes, elem contain information about the mesh
%         see ReadMesh() for the description of the format
%
%see also ReadMesh, FEMEquation, FEMSolve, ShowSolution, FEMValue")

if (nargin!=2) 
  help("ShowMesh");
  usage("ShowMesh(nodes,elem)");
endif


[fid,msg]=fopen("/tmp/meshdata.gnu","w");

% coordinate axes
%fprintf(fid,"%g %g %g\n",  0,0,0 );
%fprintf(fid,"%g %g %g\n\n", 0,0,1 );
%fprintf(fid,"%g %g %g\n",  0,0,0 );
%fprintf(fid,"%g %g %g\n\n", 0,1,0 );
%fprintf(fid,"%g %g %g\n",  0,0,0 );
%fprintf(fid,"%g %g %g\n\n", 1,0,0 );

% the mesh
for k=1:length(elem);
  fprintf(fid,"%g %g %g\n",nodes(elem(k,1),1:2), 0.0 );
  fprintf(fid,"%g %g %g\n",nodes(elem(k,2),1:2), 0.0 );
  fprintf(fid,"%g %g %g\n",nodes(elem(k,3),1:2), 0.0 );
  fprintf(fid,"%g %g %g\n\n",nodes(elem(k,1),1:2), 0.0 );
endfor
fclose(fid);

gset nokey
gset title 
gset view 30, 10
% gsplot  "/tmp/meshdata.gnu" with lines 3 ,"/tmp/meshdata.gnu" with points 12
gplot  "/tmp/meshdata.gnu" with lines 3 using 1:2
endfunction
