Calling polyr from MATLAB
function [faces,vertices] = polyr(volume,numpolygons, ...
eval(['!polyr -r ' num2str(numpolygons) ...
' -o /tmp/polyr -raw ' num2str(size(volume)) ...
' -d ' num2str(downsample) ' /tmp/polyr.bin ’ ...
fid = fopen('/tmp/polyr.off','r');
fscanf(fid,'%s',1); %skip the OFF on first line
counts = fscanf(fid,'%d',3);
vertices = fscanf(fid,'%f',3*numvertices);
vertices = reshape(vertices,3,numvertices)';
faces = fscanf(fid,'%f',4*numfaces);
faces = reshape(faces,4,numfaces)';
faces(:,1)=[]; %remove count of vertices in each face.
faces = faces+1; %start indexing at 1, not 0