Home > vbmeg > external > iso2mesh > meshresample.m

meshresample

PURPOSE ^

SYNOPSIS ^

function [node,elem]=meshresample(v,f,keepratio)

DESCRIPTION ^

 [node,elem]=meshresample(v,f,keepratio)

 resample mesh using CGAL mesh simplification utility

 author: Qianqian Fang, <q.fang at neu.edu>
 date: 2007/11/12

 input:
    v: list of nodes
    f: list of surface elements (each row for each triangle)
    keepratio: decimation rate, a number less than 1, as the percentage
               of the elements after the sampling

 output:
    node: the node coordinates of the sampled surface mesh
    elem: the element list of the sampled surface mesh

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [node,elem]=meshresample(v,f,keepratio)
0002 %
0003 % [node,elem]=meshresample(v,f,keepratio)
0004 %
0005 % resample mesh using CGAL mesh simplification utility
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 % date: 2007/11/12
0009 %
0010 % input:
0011 %    v: list of nodes
0012 %    f: list of surface elements (each row for each triangle)
0013 %    keepratio: decimation rate, a number less than 1, as the percentage
0014 %               of the elements after the sampling
0015 %
0016 % output:
0017 %    node: the node coordinates of the sampled surface mesh
0018 %    elem: the element list of the sampled surface mesh
0019 %
0020 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
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 % function to perform the actual resampling
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

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005