Exemplo n.º 1
0
void ZoneSetLoader::load(std::string const& zoneSetFilePath, ZoneSetLoader::ZoneSet & zoneSet) const
{
    std::ifstream zoneSetFile(zoneSetFilePath);
    std::string line;

    /** @todo zone key MUST be unique */

    while(std::getline(zoneSetFile, line))
    {
        // Handling Windows edited files
        if ('\r' == *(line.cend()-1))
        {
            line.erase(line.end()-1);
        }

        std::istringstream streamLine(line);
        std::string cell;

        zoneSet.push_back(ZoneSetLoader::ZoneSetLine(0));
        while (std::getline(streamLine, cell, ';'))
        {
            zoneSet.rbegin()->push_back(cell);
        }
    }
}
Exemplo n.º 2
0
void DynamicWorld::m_bootScenario(std::string const& scenario)
{
    std::ifstream dataFile("data/" + scenario + "/boot.scn");
    std::string line;

    /** @todo All here is to secure */

    while(std::getline(dataFile, line))
    {
        /** @todo share */
        if ('\r' == *(line.cend()-1))
        {
            line.erase(line.end()-1);
        }

        std::stringstream streamLine(line);
        std::string word;

        streamLine >> word;
        if ("start" == word)
        {
            streamLine >> word;
            ZoneLinker* linker = new ZoneLinker("data/" + scenario + "/" + word + "/zone.links");
            const ZoneLinker::ZoneLink* startLink = linker->find("start");
            if (NULL != startLink)
            {
                /** @todo check for coherence */

                m_loadSet(scenario, word);

                m_currentSet = word;
                m_partyZone = startLink->zone;
                m_partyTile = startLink->tile;
                m_zoneLinker = linker;

                m_scenario = scenario;
            }
            else
            {
                /** @todo throw exception */
            }
        }
        else
        {
            /** @todo throw exception */
        }
    }
Exemplo n.º 3
0
vector<Snap*>* makeJobListFromFile(string filePath, int interpMethod, bool doSortPoint, int innPoints,float voxtabsize[3],float stepLength)
{
    vector<Snap*>* ret = new vector<Snap*>();
    Snap* current;
    Snap* previous = NULL;
    ifstream infile(filePath.c_str());
    string line;
    int i = 0;
    int sizeCp = 0;
    double x,y,z;
    int nPoints = innPoints;

    getline(infile, line);
    istringstream streamLine(line);
    streamLine >> sizeCp;
    Point* tabControl = new Point[sizeCp];
    while (getline(infile, line))
    {
        istringstream streamLine(line);
        if(!(streamLine >> x>> y>> z))
        {
            break;
        }
        tabControl[i].SetX(x);
        tabControl[i].SetY(y);
        tabControl[i].SetZ(z);
        i++;
    }
    infile.close();
    if(doSortPoint)
        sortPoints(tabControl,sizeCp);
    if(stepLength != 0.0)
    {
        float pathLength = estimatePathLength(tabControl,sizeCp);
        nPoints = (int)(pathLength / stepLength);
    }
    switch(interpMethod){
    case INTERP_DIRECT:
        {
            ret = direct(tabControl,ret,sizeCp);
            break;
        }
    case INTERP_BEZIER:
        {
            ret = BezierCurveByBernstein(tabControl,ret,sizeCp,nPoints);
            break;
        }
    case INTERP_HERMIT:
        {
            ret = hermit(tabControl,ret,sizeCp,nPoints);
            break;
        }
    }
   
   
    for(int j = 0 ; j < ret->size()-1 ; j++)
    {
        for(int i = 0 ; i < 3 ; i++)
        {
            ret->at(j)->direction[i] = ret->at(j+1)->position[i] - ret->at(j)->position[i];
        }
        ret->at(j)->normalize(ret->at(j)->direction);
    }
    for(int i = 0 ; i < 3 ; i++)
    {
        ret->back()->direction[i] = ret->at(ret->size()-2)->direction[i];
    }
    ret->at(0)->up[0] = -1.0;
    ret->at(0)->up[0] = 1.0;
    ret->at(0)->up[0] = 1.0;
    ret->at(0)->initFirstSnap();
    for(int j = 0 ; j < ret->size()-1 ; j++)
    {
        doubleReflectionAlgorithm(ret->at(j),ret->at(j+1));
    }
    for(int i = 0 ; i < 3 ; i++)
    {
        ret->back()->up[i] = ret->at(ret->size()-2)->up[i];
        ret->back()->cross[i] = ret->at(ret->size()-2)->cross[i];
    }
    return ret;
}