%% setup
%    this function will loop through all the cells in both the left
%    grid and the top grid, once we reach a leaf cell for both
%    grids, if there does not exist an RCell in the RGrid for both
%    these leaf cells then we need to create one.
% inputs:
%   object:RGrid - reference to current RGrid
%   g1:Grid - reference to the top grid
%   g2:Grid - reference to the left grid.
% outputs;
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = setup(object,g1,g2)
for i=1:size(g2.cells,2)
    if (~isempty(g2.cells(i).subgrid))
        object.setup(g1,g2.cells(i).subgrid);
    else
        for j=1:size(g1.cells,2)
            if(~isempty(g1.cells(j).subgrid))
                object.setup(g1.cells(j).subgrid,g2);
            else
                if (object.search(g1.cells(j),g2.cells(i)) == 0)
                    rcell = RCell(g1.cells(j),g2.cells(i));
                    object.Cells = [object.Cells rcell];
                end
            end
        end
    end
end
end