function plot_thickness3D_22808_r1

% Function works with Shim thickness GUI
% Performs Plots/Refreshes the Shim Thickness 3D plot.
% 
% created by Mark Smith
% 121207

% Revised 2/28/08: Changes to accomadate new shim labels.


% Check if data is available for plotting.
if evalin('base','thickness') == 0
    msgbox('Thickness Values Not Calculated');
    return
else % If the thickness are calculated perform the following.
    joint_type = evalin('base','joint_type');
    
% Revision 2/28/08 ******************************************** Revision 2/28/08 
    if strcmp(joint_type,'AB')
        % value placement adjustment
        dx1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2];
        dy1=[-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-7,-5,-5,-7,-5,-5,-7,...
            -5,-5,-5,-5,-5,-5,-7,-7,-5,-5,0];
        % label placement placement.        
        dx2=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        dy2=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

    end
    if strcmp(joint_type,'BC')
        % value placement adjustment
        dx1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,-3,1,-3,1,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        dy1=[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,3,1,3,2,2,-5,1,-5,-5,-5,-5,...
            -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5];
        % label placement placement.
        dx2=[0,0,0,0,0,0,0,0,0,0,0,0,0,2,-1,3,-1,3,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        dy2=[0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,3,2,2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    end
% *************************************************************************
    thickness  = evalin('base','thickness');
    shim_pts = evalin('base','shim_pts');
    shim_centers = evalin('base','shim_centers');
    labels = evalin('base','labels');
    scatter3(shim_pts(:,1),shim_pts(:,2),zeros(length(shim_pts),1),6,'r','o','filled')
    cp_array = zeros(4,3);
    shim_c=0;
    for mm=1:4:length(shim_pts)
        shim_c=shim_c+1;
        xx = shim_centers(shim_c,1);
        yy = shim_centers(shim_c,2);
        zz = shim_centers(shim_c,3);
        cp_array(:,(1:3))= shim_pts((mm:mm+3),(1:3));
        hold on
        % Create Shim Outline.
        patch(cp_array((1:4),1),cp_array((1:4),2),cp_array((1:4),3),'FaceColor','none','EdgeColor','r')
        hold on
        % Display thickness values located at shim centers.
        text(xx+dx1(shim_c),yy+dy1(shim_c),0,num2str(thickness(shim_c)),'Color','b','FontWeight','bold','fontsize',8);
        hold on
        % Display shim label located at shim centers
        text(xx+dx2(shim_c),yy+dy2(shim_c),0,labels{shim_c,1},'FontWeight','bold','fontsize',8);
        hold on
    end
    title_str = strcat(joint_type,' Joint: Shim Thicknesses 3D');
    title(title_str,'Fontweight','bold','fontsize',12)           
    xlabel('X (inches)','fontsize',8)
    ylabel('Y (inches)','fontsize',8)
    zlabel('Z (inches)','fontsize',8)
    hold off
            
end

