0001 function [XY, Pindx, FLR, VLR, XYLR, IDLR] = ...
0002 vb_inflate_to_flat_func(V,F,Xdim,xcenter)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 F3R = F.F3R;
0025 F3L = F.F3L;
0026 Nleft = F.NdipoleL;
0027
0028
0029 if nargin<4, xcenter = 0.1; end;
0030
0031 Xrate = xcenter*[ 1 -1 1 -1 ];
0032
0033
0034 switch Xdim,
0035 case 1,
0036 prj_mode = { 'x' ; '-x' ; 'x' ; '-x'};
0037 case 2,
0038 prj_mode = { 'y' ; '-y' ; 'y' ; '-y'};
0039 case 3,
0040 prj_mode = { 'z' ; '-z' ; 'z' ; '-z'};
0041 end;
0042
0043 Npoint = size(V,1);
0044 Nright = Npoint - Nleft;
0045
0046 XY = zeros(Npoint,3);
0047 Pindx = zeros(Npoint,1);
0048
0049
0050 VL = V(1:Nleft,:);
0051 VR = V((Nleft+1):Npoint,:);
0052
0053 if Nleft==0,
0054 VLmean = zeros(1,3);
0055 else
0056 VLmean = sum(VL)/Nleft;
0057 end;
0058
0059 if Nright==0,
0060 VRmean = zeros(1,3);
0061 else
0062 VRmean = sum(VR)/Nright;
0063 end;
0064
0065
0066 VL = VL - repmat(VLmean ,[ Nleft 1]);
0067 VR = VR - repmat(VRmean ,[ Nright 1]);
0068
0069
0070 LU = find( VL(:,Xdim) >= 0 );
0071 LD = find( VL(:,Xdim) < 0 );
0072 RU = find( VR(:,Xdim) >= 0 );
0073 RD = find( VR(:,Xdim) < 0 );
0074
0075 VLU = VL(LU,:);
0076 VLD = VL(LD,:);
0077 VRU = VR(RU,:);
0078 VRD = VR(RD,:);
0079
0080 RU = RU+Nleft;
0081 RD = RD+Nleft;
0082
0083 IDLR = { LU; LD; RU; RD };
0084 VLR = {VLU; VLD; VRU; VRD };
0085 XYLR = cell(4,1);
0086
0087
0088 for j=1:4,
0089 VLRj = VLR{j};
0090 IDj = IDLR{j};
0091 NID = size(VLRj,1);
0092
0093
0094 Xzero = (max(VLRj(:,Xdim)) -min(VLRj(:,Xdim)))*Xrate(j);
0095
0096 VLRj(:,Xdim) = VLRj(:,Xdim) - repmat(Xzero,NID,1);
0097
0098
0099 [ Xj , Yj ] = vb_cart2theta_phi( VLRj , prj_mode{j} );
0100
0101 VLR{j} = VLRj;
0102 Pindx(IDj) = j;
0103 XY(IDj,1) = Xj;
0104 XY(IDj,2) = Yj;
0105 XYLR{j} = [Xj , Yj];
0106 end;
0107
0108
0109 FLU = [];
0110 FLD = [];
0111 FRU = [];
0112 FRD = [];
0113
0114 Lface=length(F3L);
0115 Rface=length(F3R);
0116
0117 for n=1:Lface,
0118 ix=F3L(n,:);
0119 pix=Pindx(ix);
0120
0121 if (pix(1)==1)&(pix(2)==1)&(pix(3)==1),
0122 FLU = [ FLU; ix];
0123 end;
0124
0125 if (pix(1)==2)&(pix(2)==2)&(pix(3)==2),
0126 FLD = [ FLD; ix];
0127 end;
0128
0129 end;
0130
0131 for n=1:Rface,
0132 ix=F3R(n,:);
0133 pix=Pindx(ix);
0134
0135 if (pix(1)==3)&(pix(2)==3)&(pix(3)==3),
0136 FRU = [ FRU; ix];
0137 end;
0138
0139 if (pix(1)==4)&(pix(2)==4)&(pix(3)==4),
0140 FRD = [ FRD; ix];
0141 end;
0142
0143 end;
0144
0145 FLR = { FLU; FLD; FRU; FRD };