function viewDinoSaur(Shat, tri, inPath)
% inPath is the path of images containing bmps of the datasets

F = size(Shat,1)/3;
x1 = min(min(Shat(1:3:end, :)));
y1 = min(min(Shat(2:3:end, :)));
z1 = min(min(Shat(3:3:end, :)));
x2 = max(max(Shat(1:3:end, :)));
y2 = max(max(Shat(2:3:end, :)));
z2 = max(max(Shat(3:3:end, :)));


if exist('inPath')
    
    for i=1: F
        im = imread(sprintf('%s\\%03d.bmp', inPath, i));
        
        subplot('position', [0, 0, 0.3, 1])
        imagesc(im);
%         imagesc(flipdim(im(Y1:Y2, X1:X2, :),1));
        hold on
        plot(W(2*i-1,:)-X1+1, W(2*i,:)-Y1+1, 'b.', 'MarkerSize', 10)
        h = trimesh(tri, W(2*i-1,:)-X1+1, W(2*i,:)-Y1+1); set(h,'Color','r');
        hold off
        axis image
%         axis([1 X2-X1 1 Y2-Y1-100]);
        axis off

        Si = [-Shat(3*i-2, :); Shat(3*i-1, :); -Shat(3*i, :)];
        subplot('position', [0.3, 0, 0.36, 1])
%         subplot(1,3,2)
        plot3(Si(1,:), Si(2,:), Si(3,:), 'b.');
        hold on
        h = trimesh(tri, Si(1,:), Si(2,:), Si(3,:));
        hold off;
%         shading interp
%         light
%         lighting gouraud
%         colormap white
        axis equal
        axis([-x2 -x1 y1 y2 -z2 -z1])
%         axis([x1 x2 y1 y2 z1 z2])
        axis off
        view(150.8674, -49)
        grid on
        
%         subplot(1,3,3)
        subplot('position', [0.67, 0, 0.33, 1])
        Si = [Shat(3*i-2, :); Shat(3*i-1, :); Shat(3*i, :)];
        plot3(Si(1,:), Si(2,:), Si(3,:), 'b.');
        hold on
        h = trimesh(tri, Si(1,:), Si(2,:), Si(3,:));
        hold off;
%         shading interp
%         light
%         lighting gouraud
%         colormap copper
        axis equal
        axis([x1 x2 y1 y2 -z2 -z1])
        axis off
        view(-132.0102, -23.8485)
        grid on
        
%         print(gcf, '-deps', sprintf('%s//eps//%03d', path, i));
        pause(0.1)
%         img = frame2im(getframe(gcf));
%         imwrite(img, sprintf('%s//%03d.bmp', path, i))
    end;
else
    for i=1: F
        plot3(Shat(3*i-2, :), Shat(3*i-1, :), Shat(3*i, :), 'rO');
        drawLines(Shat(3*i-2:3*i, :));
        axis equal
        axis([x1 x2 y1 y2 z1 z2])
        view(-70.5, -54)
        title('Reconstructed Structure');
        grid on

        pause(0.1)
%         img = frame2im(getframe(gcf));
%         imwrite(img, sprintf('%s//%03d.bmp', path, i))
    end;
end;