You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: thickenbinvol.m
    path of file: ./repos/iso2mesh
    
    the code of the file until where you have to start completion: function vol=thickenbinvol(vol,layer)
%
% vol=thickenbinvol(vol,layer)
%
% thickening a binary volume by a given pixel width
% this is similar to bwmorph(vol,'thicken',3) except 
% this does it in 3d and only does thickening for 
% non-zero elements (and hopefully faster)
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
%     vol: a volumetric binary image
%     layer: number of iterations for the thickenining
%
% output:
%     vol: the volume image after the thickening
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

dim=size(vol);
dxy=dim(1)*dim(2);
fulllen=prod(dim);

    
function vol=thickenbinvol(vol,layer)
%
% vol=thickenbinvol(vol,layer)
%
% thickening a binary volume by a given pixel width
% this is similar to bwmorph(vol,'thicken',3) except 
% this does it in 3d and only does thickening for 
% non-zero elements (and hopefully faster)
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
%     vol: a volumetric binary image
%     layer: number of iterations for the thickenining
%
% output:
%     vol: the volume image after the thickening
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

dim=size(vol);
dxy=dim(1)*dim(2);
fulllen=prod(dim);

offs=[1,-1,dim(1),-dim(1),dxy,-dxy];
for i=1:layer
	idx=find(vol);
    for j=1:6
    	idxnew=idx+offs(j);
        idxnew=idxnew(find(idxnew>0 & idxnew<fulllen));
    	vol(idxnew)=1;
    end