#include <cstdlib>
#include <iostream>
#include "stg.h"
#include "fromfile.h"
#include "sg.h"
#include "makesg.h"
#include <vector>    
#include "structregion.h"
#include "region.h"    
#include "celem.h"
#include "expanse.h"
#include "deleteStruct.h"

using namespace std;


int main(int argc, char *argv[])
{
    string name;
    cout << "Jmeno souboru: ";
    cin >> name;
    
    
    Stg* stg = new Stg;
    SG* sg = new SG;
    
    for(int i =0; i < 2000; i++)
    sg->sg.push_back(0);
    
    for(int i =0; i < 100; i++)
    stg->tran.push_back(0);
    
    for(int i =0; i < 200; i++)
    stg->place.push_back(0); 
   
    stg->vyP = 0;
    stg->pocetVyP = 0;
    
    FromFile f( name.c_str(),stg);       

    MakeSG* m = new MakeSG(stg,sg);
    
    cout << "Pocet prechodu v STG: " << stg->pocetTran <<endl;
    cout << "Pocet mist v STG: " << stg->pocetPlace << endl;
    
    m->find_SG();
   
    cout << "Pocet stavu v SG: " << sg->pocet << endl;
   
    RegStavBuf rs;
    rs.pocet = strlen(sg->sg[0]->code);
    rs.rs = new RegStav[rs.pocet];
    
    Region re(sg,&rs);
    re.makeRegion();
    
    Cbuffer* cb = new Cbuffer ;
    
    KMap k(&rs,stg->vyP ,stg->pocetVyP,cb);
    
    MakeCorLog(cb, stg);
    
    DelSturct d;

    d.deleteSG(sg);
    d.deleteRegion(&rs);
    
    cout << "Dokonceno, vystupni soubor je: " << stg->nameFile <<  endl;
    d.deleteSTG(stg);
    system("PAUSE");
    return EXIT_SUCCESS;
}
