Changeset 2269
- Timestamp:
- 09/22/09 09:50:19 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/extrude.m
r2252 r2269 1 function md=extrude(md, numlayers,extrusionexponent)1 function md=extrude(md,varargin) 2 2 %EXTRUDE - vertically extrude a 2d mesh 3 3 % 4 % vertically extrude a 2d mesh and create corresponding 3d mesh following the extrusionexponent, 5 % the vertical distribution follows a polynomial law:'); 6 % extrusionexponent>1 refinement at the base'); 7 % 0<extrusionexponent<1 refinement at the surface'); 8 % extrusionexponent=1 linear extrusion'); 4 % vertically extrude a 2d mesh and create corresponding 3d mesh. 5 % The vertical distribution can: 6 % - follow a polynomial law 7 % - follow two polynomial laws, one for the lower part and one for the upper part of the mesh 8 % - be discribed by a list of coefficients (between 0 and 1) 9 % 9 10 % 10 11 % Usage: 11 12 % md=extrude(md,numlayers,extrusionexponent); 13 % md=extrude(md,numlayers,lowerexponent,upperexponent); 14 % md=extrude(md,listofcoefficients); 12 15 % 13 16 % Example: 14 17 % md=extrude(md,8,3); 18 % md=extrude(md,8,3,2); 19 % md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]); 15 20 % 16 21 % See also: MODELEXTRACT, COLLAPSE 17 22 18 23 %some checks on list of arguments 19 if ((nargin ~=3) | (nargout~=1)),24 if ((nargin>4) | (nargin<2) | (nargout~=1)), 20 25 help extrude; 21 26 error('extrude error message'); … … 31 36 end 32 37 38 %Extrude the mesh 39 if nargin==2, %list of coefficients 40 list=varargin{1}; 41 if any(list<0) | any(list>1), 42 error('extrusioncoefficients must be between 0 and 1'); 43 end 44 extrusionlist=sort(unique([list(:);0;1])); 45 numlayers=length(extrusionlist); 46 elseif nargin==3, %one polynomial law 47 if varargin{2}<=0, 48 help extrude; 49 error('extrusionexponent must be >=0'); 50 end 51 numlayers=varargin{1}; 52 extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2}; 53 elseif nargin==4, %two polynomial laws 54 numlayers=varargin{1}; 55 lowerexp=varargin{2}; 56 upperexp=varargin{3}; 57 58 if varargin{2}<=0 | varargin{3}<=0, 59 help extrude; 60 error('lower and upper extrusionexponents must be >=0'); 61 end 62 63 lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2; 64 upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2; 65 extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist])); 66 67 end 68 33 69 if numlayers<2, 34 70 disp('number of layers should be at least 2. returning initial model...'); … … 36 72 end 37 73 38 if extrusionexponent<=0,39 help extrude;40 error('extrusionexponent must be >=0');41 end42 43 %Extrude the mesh44 74 %Initialize with the 2d mesh 45 x3d= md.x;46 y3d= md.y;47 z3d= md.bed; %the lower grid is on the bed75 x3d=[]; 76 y3d=[]; 77 z3d=[]; %the lower grid is on the bed 48 78 thickness3d=md.thickness; %thickness and bed for these grids 49 79 bed3d=md.bed; 50 80 51 81 %Create the new layers 52 for i=1:numlayers -1,82 for i=1:numlayers, 53 83 x3d=[x3d; md.x]; 54 84 y3d=[y3d; md.y]; 55 85 %grids are distributed between bed and surface accordingly to the given exponent 56 z3d=[z3d; bed3d+thickness3d* (i/(numlayers-1))^extrusionexponent];86 z3d=[z3d; bed3d+thickness3d*extrusionlist(i)]; 57 87 end 58 88 number_grids3d=size(x3d,1); %number of 3d grids for the non extruded part of the mesh
Note:
See TracChangeset
for help on using the changeset viewer.