0001 function [node,elem]=meshresample(v,f,keepratio)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 [node,elem]=domeshsimplify(v,f,keepratio);
0024
0025 if(length(node)==0)
0026 warning(['Your input mesh contains topological defects, and the ',...
0027 'mesh resampling utility aborted during processing. Now iso2mesh ',...
0028 'is trying to repair your mesh with meshcheckrepair. ',...
0029 'You can also call this manually before passing your mesh to meshresample.'] );
0030 [vnew,fnew]=meshcheckrepair(v,f);
0031 [node,elem]=domeshsimplify(vnew,fnew,keepratio);
0032 end
0033 [node,I,J]=unique(node,'rows');
0034 elem=J(elem);
0035 saveoff(node,elem,mwpath('post_remesh.off'));
0036
0037 end
0038
0039
0040 function [node,elem]=domeshsimplify(v,f,keepratio)
0041 exesuff=getexeext;
0042 exesuff=fallbackexeext(exesuff,'cgalsimp2');
0043
0044 saveoff(v,f,mwpath('pre_remesh.off'));
0045 deletemeshfile(mwpath('post_remesh.off'));
0046 system([' "' mcpath('cgalsimp2') exesuff '" "' mwpath('pre_remesh.off') '" ' num2str(keepratio) ' "' mwpath('post_remesh.off') '"']);
0047 [node,elem]=readoff(mwpath('post_remesh.off'));
0048 end