function [xfp,yfp,DI,xlist,ylist] = dof2list(DOFvec,Nodes,pltvec)
%
%  Name:   dof2list
%
%  Usage:  [xfp,yfp,DI,xlist,ylist] = dof2list(DOFvec,Nodes,pltvec)
%
%  Converts vector of indicator variables 'pltvec' to matrix 'DI'
%	according to list of DOF in 'DOFvec' and list of nodal locations
%	in 'Nodes'. 'xlist' and 'ylist' are sorted lists of nodal x and y locations,
%	'xfp' and 'yfp' are corresponding plaid matrices.
%  

%  Version SWD970117
%
%  Author(s): Scott W. Doebling, doebling@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%               ESA-EA
%
%  Copyright (c) 1997, The Regents of the University
%       of California. (See top level of code for
%       full copyright statement.)
%

%  Generate xfp,yfp,DI
%

xlist = [];
ylist = [];

for i = 1:length(DOFvec),

	nnode = find( Nodes(:,1) == DOFvec(i,1));

       	if isempty(find(xlist == Nodes(nnode,2))),
		xlist = [xlist;Nodes(nnode,2)];
	end

	if isempty(find(ylist == Nodes(nnode,3))),
		ylist = [ylist;Nodes(nnode,3)];
	end

end

xlist = sort(xlist);
ylist = sort(ylist);

[xfp,yfp] = meshgrid(xlist,ylist);
DI = zeros(size(xfp));


for i = 1:size(xfp,1),
	for j = 1:size(xfp,2),
		nnode = find(Nodes(:,2) == xfp(i,j) & Nodes(:,3) == yfp(i,j));
		DI(i,j) = pltvec(nnode);
	end
end

