Home > vbmeg > external > iso2mesh > meshcylinders.m

meshcylinders

PURPOSE ^

SYNOPSIS ^

function [node,face,elem]=meshcylinders(c0, v, len, varargin)

DESCRIPTION ^

 [node,face]=meshcylinders(c0, v, len, r,tsize,maxvol,ndiv)
    or
 [node,face,elem]=meshacylinder(c0, v, len, r, tsize,maxvol,ndiv)
 [nplc,fplc]=meshacylinder(c0, v, len,r,0,0,ndiv);

 create the surface and (optionally) tetrahedral mesh of a 3D cylinder

 author: Qianqian Fang, <q.fang at neu.edu>

 input: 
   c0, cylinder list axis's starting point
   v: directional vector of the cylinder
   len: a scalar or a vector denoting the length of each 
        cylinder segment along the direction of v
   tsize, maxvol, ndiv: please see the help for meshacylinder for details

 output:
   node, face, elem: please see the help for meshacylinder for details

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [node,face,elem]=meshcylinders(c0, v, len, varargin)
0002 %
0003 % [node,face]=meshcylinders(c0, v, len, r,tsize,maxvol,ndiv)
0004 %    or
0005 % [node,face,elem]=meshacylinder(c0, v, len, r, tsize,maxvol,ndiv)
0006 % [nplc,fplc]=meshacylinder(c0, v, len,r,0,0,ndiv);
0007 %
0008 % create the surface and (optionally) tetrahedral mesh of a 3D cylinder
0009 %
0010 % author: Qianqian Fang, <q.fang at neu.edu>
0011 %
0012 % input:
0013 %   c0, cylinder list axis's starting point
0014 %   v: directional vector of the cylinder
0015 %   len: a scalar or a vector denoting the length of each
0016 %        cylinder segment along the direction of v
0017 %   tsize, maxvol, ndiv: please see the help for meshacylinder for details
0018 %
0019 % output:
0020 %   node, face, elem: please see the help for meshacylinder for details
0021 %
0022 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0023 %
0024 
0025 len=cumsum(len);
0026 [ncyl,fcyl]=meshacylinder(c0,c0+v*len(1),varargin{:});
0027 
0028 for i=2:length(len)
0029    [ncyl1,fcyl1]=meshacylinder(c0+v*len(i-1),c0+v*len(i),varargin{:});
0030    fcyl1=cellfun(@(x) {x{1}+size(ncyl,1),x{2}}, fcyl1, 'UniformOutput', false);
0031    ncyl=[ncyl; ncyl1];
0032    if(i==1)
0033        fcyl1=fcyl1(1:end-1);
0034    else
0035        fcyl1={fcyl1{1:end-2},fcyl1{end}};
0036    end
0037    fcyl={fcyl{:}, fcyl1{:}};
0038 end
0039 
0040 [ncyl,I,J]=unique(round(ncyl*1e10),'rows');
0041 ncyl=ncyl*1e-10;
0042 fcyl=cellfun(@(x) {J(x{1})',x{2}}, fcyl, 'UniformOutput', false);
0043 
0044 tsize=varargin{2};
0045 maxvol=varargin{3};
0046 
0047 if(nargout==2 && tsize==0.0 && maxvol==0.0)
0048     node=ncyl;
0049     face=fcyl;
0050     return;
0051 end
0052 if(nargin==3)
0053     tsize=len/10;
0054 end
0055 if(nargin<5)
0056     maxvol=tsize*tsize*tsize;
0057 end
0058 
0059 centroid=cumsum([0 len(1:end-1)])+len/2;   % define the centroids of each cylinder segment
0060 seeds=repmat(c0(:)',length(len),1)+repmat(v(:)',length(len),1).*repmat(centroid(:),1,3);
0061 [node,elem,face]=surf2mesh(no,fc,min(no),max(no),1,maxvol,seeds,[],0);

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