function dessineSoma(A,ks)
% reprŽsente un cube Soma dŽcrit par A et dont la solution se trouve dans
% KS

% Sommets et faces du cube
S =[0 0 0
    1 0 0
    1 1 0
    0 1 0
    0 0 1
    1 0 1
    1 1 1
    0 1 1];
F =[5 1 2 3 4 1
    5 1 2 6 5 1
    5 2 3 7 6 2
    5 3 4 8 7 3
    5 4 1 5 8 4
    5 5 6 7 8 5];

% matrice de couleur
C(:,:,1)=[1 0 0
    1 0 0
    1 0 0
    1 0 0
    1 0 0
    1 0 0];
C(:,:,7)=[0 1 0
    0 1 0
    0 1 0
    0 1 0
    0 1 0
    0 1 0];
C(:,:,3)=[0 0 1
    0 0 1
    0 0 1
    0 0 1
    0 0 1
    0 0 1];
C(:,:,4)=[1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0];
C(:,:,5)=[1 0 1
    1 0 1
    1 0 1
    1 0 1
    1 0 1
    1 0 1];
C(:,:,6)=[0 1 1
    0 1 1
    0 1 1
    0 1 1
    0 1 1
    0 1 1];
C(:,:,2)=[.5 .5 .5
    .5 .5 .5 
    .5 .5 .5
    .5 .5 .5
    .5 .5 .5
    .5 .5 .5];

% reprŽsentation graphique
[nbl,nbc,nbt]=size(A);
ks=reshape(ks,4,7)';
for pce=1:7
    for cub=1:4
        if ks(pce,cub)
            tr=1;
            [li,co]=find(A(:,:,tr)==ks(pce,cub));
            while isempty(li)
                tr=tr+1;
                [li,co]=find(A(:,:,tr)==ks(pce,cub));
            end
            T=S;
            T(:,1)=T(:,1)+li;
            T(:,2)=T(:,2)+co;
            T(:,3)=T(:,3)+tr;
            plot3d(T,F,-45,30,C(:,:,pce),'r')
            hold on
        end
    end
end

set(gcf,'renderer','opengl')
rotate3d on
axis equal
axis off
hold off
