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: remeshsurf.m
    path of file: ./repos/iso2mesh
    
    the code of the file until where you have to start completion: function [newno,newfc]=remeshsurf(node,face,opt)
%
% [newno,newfc]=remeshsurf(node,face,opt)
%
% remesh a triangular surface and the output is guaranteed to be
% free of self-intersecting element. This function is similar to 
% meshresample, but it can both downsample or upsample a mesh
%
% author: Qianqian Fang (q.fang at neu.edu)
%
% input:
%	 node: list of nodes on the input suface mesh, 3 columns for x,y,z
%	 face: list of trianglular elements on the surface, [n1,n2,n3,region_id]
%	 opt: function parameters
%	   opt.gridsize:  resolution for the voxelization of the mesh
%	   opt.closesize: if there are openings, set the closing diameter
%	   opt.elemsize:  the size of the element of the output surface
%	   if opt is a scalar, it defines the elemsize and gridsize=opt/4
%
% output:
%	 newno:  list of nodes on the resulting suface mesh, 3 columns for x,y,z
%	 newfc:  list of trianglular elements on the surface, [n1,n2,n3,region_id]
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%


    
function [newno,newfc]=remeshsurf(node,face,opt)
%
% [newno,newfc]=remeshsurf(node,face,opt)
%
% remesh a triangular surface and the output is guaranteed to be
% free of self-intersecting element. This function is similar to 
% meshresample, but it can both downsample or upsample a mesh
%
% author: Qianqian Fang (q.fang at neu.edu)
%
% input:
%	 node: list of nodes on the input suface mesh, 3 columns for x,y,z
%	 face: list of trianglular elements on the surface, [n1,n2,n3,region_id]
%	 opt: function parameters
%	   opt.gridsize:  resolution for the voxelization of the mesh
%	   opt.closesize: if there are openings, set the closing diameter
%	   opt.elemsize:  the size of the element of the output surface
%	   if opt is a scalar, it defines the elemsize and gridsize=opt/4
%
% output:
%	 newno:  list of nodes on the resulting suface mesh, 3 columns for x,y,z
%	 newfc:  list of trianglular elements on the surface, [n1,n2,n3,region_id]
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

p0=min(node);
p1=max(node);

if(isstruct(opt))
   if(isfield(opt,'gridsize'))
      dx=opt.gridsize;
   end