Skip to content
Snippets Groups Projects
gtReadBoundariesStructure.m 4.76 KiB
Newer Older
Andrew King's avatar
Andrew King committed
function [output, output2] = gtReadBoundariesStructure(boundaries_structure, boundaries_structure_test, bridges)


%boundaries_structure is a .mat file used to store boundary data.
%it contains: boundaries_structure(i).
% grain1
% grain2
% count
% crack1_count
% crack2_count
% crack5_count
% gb_norm
% gb_norm_confidence
% gb_centre
% misorientation_angle
% misorientation_axis
% gb_norm_grain1
% gb_norm_grain2
% sigma
% grain1_R_vector
% grain2_R_vector

%therefore, can pull out the poles for a pole figure according to different
%criteria, as well as producing symmetry equivelent (for xtallographic
%things) if required.

% add - in a crude way - the stuff to read from the the
% boundaries_structure_test - the pole figure density for each boundary
% after dealing with curved boundaries.

%output is either poles or density - either way then used in gtMakePoleFigure
%output2 is valid poles weight, not used for poles case
%should be able to combine boundaries_structure and
%boundaries_structure_test.  Keep separate for the moment while testing.

poles=[];
count=1;
load parameters
spacegroup=parameters.acq.spacegroup;
Andrew King's avatar
Andrew King committed

if spacegroup==225 | spacegroup==229
    sym = gtGetCubicSymOp;
elseif spacegroup==167 || spacegroup==663 || spacegroup==194
    sym= gtGetHexagonalSymOp_sab;
else
    disp('spacegroup not supported! cant do symmetry operations!')
end
    
Andrew King's avatar
Andrew King committed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if 1 % if using boundaries_structure
Andrew King's avatar
Andrew King committed
%loop through structure
for i=1:length(boundaries_structure)
Andrew King's avatar
Andrew King committed
%for i=bridges
    %criteria
  if  boundaries_structure(i).grain1~=0 & boundaries_structure(i).grain2~=0 & ~isempty(boundaries_structure(i).gb_norm)
  

%      if  boundaries_structure(i).grain1<500 & boundaries_structure(i).grain2<500 & boundaries_structure(i).count>200
       if  boundaries_structure(i).count>1000
Andrew King's avatar
Andrew King committed
   %if 1 %no test
%    if boundaries_structure(i).crack5_count>100
   % if isempty(boundaries_structure(i).sigma) | boundaries_structure(i).sigma~=3
%    if isempty(boundaries_structure(i).sigma)
Andrew King's avatar
Andrew King committed
  %if boundaries_structure(i).sigma==3
  %    poles(end+1,:)=boundaries_structure(i).gb_norm;
%

    poles(end+1,:)=boundaries_structure(i).gb_norm_grain1;
    poles(end+1,:)=boundaries_structure(i).gb_norm_grain2;

    end   % criteria 2
Andrew King's avatar
Andrew King committed
  end%criteria
    end
    
    if 0
    % alternative structure for specific grain poles
    for a=1:20;
    if  boundaries_structure(i).grain1==a & boundaries_structure(i).grain2~=0 
        poles(end+1,:)=boundaries_structure(i).gb_norm_grain1;
    end
    if  boundaries_structure(i).grain2==a & boundaries_structure(i).grain1~=0 
        poles(end+1,:)=boundaries_structure(i).gb_norm_grain2;
    end
    end
    end
  
Andrew King's avatar
Andrew King committed
end%loop

if 1
    %apply the symmetry operators
    poles2=[];
    for i=1:length(sym)
        if spacegroup==225 | spacegroup==229
            poles2=[poles2; poles*sym(i).g];
        elseif spacegroup==167 || spacegroup==663 || spacegroup==194
            poles2=[poles2; poles*sym(i).g3];
        end
    end
    poles=poles2;
Andrew King's avatar
Andrew King committed
end
Andrew King's avatar
Andrew King committed
%add this to correspond to line in gtMakePoleFigure
poles=[poles; -poles];
Andrew King's avatar
Andrew King committed
output=poles;
output2=[];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Andrew King's avatar
Andrew King committed
    %find a non-empty density map to preallocate
    i=1;
    density=[];
    count=0;
    vpw=0;%valid poles_weight for normalising
    while isempty(density)
        density=zeros(size(boundaries_structure_test(i).grain1_pole_density));
        i=i+1;
    end

    %for i=1:length(boundaries_structure_test)
for i=bridges
        %criteria
        %if  boundaries_structure(i).grain1~=0 & boundaries_structure(i).grain2~=0 & ~isempty(boundaries_structure(i).gb_norm)

        if 1 %no test
        %    if boundaries_structure(i).crack5_count>100
%        if isempty(boundaries_structure(i).sigma) | boundaries_structure(i).sigma~=3
%if (isempty(boundaries_structure(i).sigma) | boundaries_structure(i).sigma~=3) & boundaries_structure(i).grain1~=0 & boundaries_structure(i).grain2~=0
        %  if isempty(boundaries_structure(i).sigma)
   %  if boundaries_structure(i).sigma==3
%     if boundaries_structure(i).sigma==9
%  if boundaries_structure(i).misorientation_angle>15
   %
            if ~isempty(boundaries_structure_test(i).grain1_pole_density)
            density=density+boundaries_structure_test(i).grain1_pole_density;
            vpw=vpw+boundaries_structure_test(i).grain1_valid_poles_weight;
            end
            if ~isempty(boundaries_structure_test(i).grain2_pole_density)
            density=density+boundaries_structure_test(i).grain2_pole_density;
            vpw=vpw+boundaries_structure_test(i).grain2_valid_poles_weight;
            end
count=count+1;
        end%criteria
    end%loop
    output=density;
    output2=vpw;
    count
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%