set_inho

PURPOSE ^

function [mat,grp] = set_inho(srf,simp,vtx,mat_ref,val);

SYNOPSIS ^

function [mat,grp] = set_inho(srf,simp,vtx,mat_ref,val);

DESCRIPTION ^

function [mat,grp] = set_inho(srf,simp,vtx,mat_ref,val);

Auxiliary functions used to set small local inhomogeneities 
near the boundary of the volume graphically.



srf     = The boundary (surface) faces
simp    = The simplices matrix
vtx     = The vertices matrix
mat_ref = The reference conductivity vector
val     = The value to be asigned to the selected inhomogeneity
mat     = The conductivity vector (updated) that contains the inhomogeneity
grp     = Subset of the simplices matrix, the tetrahedral that have been selected.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mat,grp] = set_inho(srf,simp,vtx,mat_ref,val);
0002 %function [mat,grp] = set_inho(srf,simp,vtx,mat_ref,val);
0003 %
0004 %Auxiliary functions used to set small local inhomogeneities
0005 %near the boundary of the volume graphically.
0006 %
0007 %
0008 %
0009 %srf     = The boundary (surface) faces
0010 %simp    = The simplices matrix
0011 %vtx     = The vertices matrix
0012 %mat_ref = The reference conductivity vector
0013 %val     = The value to be asigned to the selected inhomogeneity
0014 %mat     = The conductivity vector (updated) that contains the inhomogeneity
0015 %grp     = Subset of the simplices matrix, the tetrahedral that have been selected.
0016 
0017 
0018 
0019 %figure;
0020 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0021 axis image;
0022 set(gcf,'Colormap',[0 0 0]);
0023 hidden off;
0024 
0025 mat = mat_ref;
0026 
0027 shifter = 1;
0028 
0029 beg_wm = simp(1,:);
0030 
0031 
0032 for dd=1:size(simp,1)
0033    
0034     
0035    if simp(dd,:) ~= beg_wm
0036       
0037       shifter = shifter + 1;
0038    end
0039    
0040    if simp(dd,:) == beg_wm
0041       
0042       shifter = dd-1;
0043       
0044       break;
0045    end
0046 end
0047 
0048 
0049 cnts = []; 
0050 
0051 for i=1:size(srf,1)
0052    
0053    a = srf(i,1);
0054    b = srf(i,2);
0055    c = srf(i,3);
0056    
0057    ccnx = (vtx(a,1) + vtx(b,1) + vtx(c,1))/3;
0058    ccny = (vtx(a,2) + vtx(b,2) + vtx(c,2))/3;
0059    ccnz = (vtx(a,3) + vtx(b,3) + vtx(c,3))/3;
0060    
0061    ccn = [ccnx,ccny,ccnz];
0062    
0063    cnts = [cnts; ccn];
0064 end
0065 
0066 
0067 %Number of inho
0068    
0069 disp('Click on the figure to locate the inhomogeneity');
0070 pause;
0071 
0072    
0073    [sel] = laserbeam(vtx,srf,cnts); 
0074    
0075    %sel is the index of the triangular surface in the srf matrix
0076    %From that we extract the tet element.
0077    
0078    for rr=1:size(simp,1)
0079       
0080       if ismember(srf(sel,:),simp(rr,:)) == [1 1 1] 
0081          
0082          the_x = simp(rr+shifter,:);
0083          
0084          break;
0085          
0086       end
0087    
0088 end
0089 
0090   
0091    the_nd = setdiff(the_x, srf(sel,:)); %The forth node
0092    
0093    grp = [];
0094    Ssimp = [];
0095   
0096    
0097    for qq=1:size(simp,1)
0098       
0099       if sum(ismember(simp(qq,:),the_nd)) == 1
0100          
0101          grp = [grp; simp(qq+shifter,:)];
0102          
0103          Ssimp = [Ssimp; (qq+shifter)];
0104          
0105          mat(qq+shifter) = val;
0106       end
0107    end
0108    
0109    
0110     
0111    for cc=1:size(grp,1)
0112       
0113    this_x = grp(cc,:);
0114    
0115    
0116    hold on;
0117    
0118    if val > mat_ref(Ssimp(cc))
0119       
0120       %Patching f_a
0121       Xas = vtx(this_x(1:3),1);
0122       Yas = vtx(this_x(1:3),2);
0123       Zas = vtx(this_x(1:3),3);
0124       
0125       patch(Xas,Yas,Zas,'r','EdgeColor','none');
0126       
0127       Xbs = vtx(this_x([1,2,4]),1);
0128       Ybs = vtx(this_x([1,2,4]),2);
0129       Zbs = vtx(this_x([1,2,4]),3);
0130       patch(Xbs,Ybs,Zbs,'r','EdgeColor','none');
0131       
0132       
0133       Xcs = vtx(this_x([1,3,4]),1);
0134       Ycs = vtx(this_x([1,3,4]),2);
0135       Zcs = vtx(this_x([1,3,4]),3);
0136       patch(Xcs,Ycs,Zcs,'r','EdgeColor','none');
0137       
0138       
0139       Xds = vtx(this_x(2:4),1);
0140       Yds = vtx(this_x(2:4),2);
0141       Zds = vtx(this_x(2:4),3);
0142       patch(Xds,Yds,Zds,'r','EdgeColor','none');
0143    end
0144    
0145       if val < mat_ref(Ssimp(cc))
0146          
0147       Xas = vtx(this_x(1:3),1);
0148       Yas = vtx(this_x(1:3),2);
0149       Zas = vtx(this_x(1:3),3);
0150       patch(Xas,Yas,Zas,'b','EdgeColor','none');
0151       
0152       Xbs = vtx(this_x([1,2,4]),1);
0153       Ybs = vtx(this_x([1,2,4]),2);
0154       Zbs = vtx(this_x([1,2,4]),3);
0155       patch(Xbs,Ybs,Zbs,'b','EdgeColor','none');
0156       
0157       Xcs = vtx(this_x([1,3,4]),1);
0158       Ycs = vtx(this_x([1,3,4]),2);
0159       Zcs = vtx(this_x([1,3,4]),3);
0160       patch(Xcs,Ycs,Zcs,'b','EdgeColor','none');
0161       
0162       Xds = vtx(this_x(2:4),1);
0163       Yds = vtx(this_x(2:4),2);
0164       Zds = vtx(this_x(2:4),3);
0165       patch(Xds,Yds,Zds,'b','EdgeColor','none');
0166 
0167       end
0168       
0169 end
0170    
0171    
0172    view(3);
0173    camlight right; 
0174    lighting flat;
0175 
0176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0177 % This is part of the EIDORS suite.
0178 % Copyright (c) N. Polydorides 2003
0179 % Copying permitted under terms of GNU GPL
0180 % See enclosed file gpl.html for details.
0181 % EIDORS 3D version 2.0
0182 % MATLAB version 5.3 R11
0183 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005