void Host::RestoreHost(const string& sline)
{
	stringstream ssline(sline);

	ssline >> lociKIR;
	ssline >> lociMHC;
	ssline >>age;
	ssline >> tuning;
	ssline >> dead;
	ssline >> mutationRateHost;
	ssline >> inhibitoryKIRs;
	ssline >> activatingKIRs;
	int totalInfections;
	ssline >> totalInfections;

	/*use the streamstring from the position after "totalInfections"
	 *for that I copy the rest of the line into a string, and then reassign the streamstring with the content of
	 *for "restLine. For it to work, I have to clear the string first!
	 */
	string restLine;
	getline(ssline,restLine);
	ssline.clear();
	ssline.str(restLine);
	string infectionString;
	int type; double inf_time; double immune_time; double clearance_time;
	for(int i=0; i<totalInfections; i++)
	{
		Infection dummyInfection;
		infectionString = dummyInfection.RestoreInfection(ssline);
		infections.push_back(dummyInfection);
		ssline.clear();
		ssline.str(infectionString);
	}

	string geneString;
	//cout <<"mhc string>>>>>"<<ssline.str() <<endl;
	for(int i=0; i<lociMHC*TWO; i++)
	{
		Gene mhc;
		geneString = mhc.RestoreGenes(ssline);
		mhcGenes.push_back(mhc);
		ssline.clear();
		ssline.str(geneString);
	}

	string kirString;
	for(int i=0; i<lociKIR*TWO; i++)
	{
		//cout <<"kir string>>>>>"<<ssline.str() <<endl;
		KIRGene kir;
		kirString = kir.RestoreGenes(ssline);
		kirGenes.push_back(kir);
		ssline.clear();
		ssline.str(kirString);

	}
}
void MainWindow::readCharactersFromFile(const std::string &fileName)
{
    std::string line;
    std::ifstream ifs(fileName, std::ifstream::in);

    std::shared_ptr<Character> currentChar;
    while (std::getline(ifs, line))
    {
       if (line == "[hero]")
       {
           currentChar = hero;
       }
       else if (line == "[enemy]")
       {
           currentChar = enemy;
       }
       else
       {
           std::stringstream ssline(line);
           std::string parametr;
           int value;
           ssline >> parametr >> value;
           if (parametr == "maxHp")
           {
               currentChar->setMaxHp(value);
           }
           else if (parametr == "hp")
           {
               currentChar->setHp(value);
           }
           else if (parametr == "att")
           {
               currentChar->setAtt(value);
           }
           else if (parametr == "def")
           {
               currentChar->setDef(value);
           }
       }
    }
}
Beispiel #3
0
void Model3d::LoadOBJ(std::string ModelPath, std::string TexPath)
{
	std::cout << "Loading " << ModelPath << "..." << std::endl;

	m_numFace = 0;
	m_numVerts = 0;
	m_numVertsTex = 0;
	m_numFaceTex = 0;

	//Alloue les tableaux 
	m_vertex = new V3<float>[30000];
	m_vertexTexture = new V3<float>[30000];
	m_face = new V3<int>[30000];
	m_faceTexture = new V3<int>[30000];

	// Open file
	std::ifstream file;
	file.open(ModelPath.c_str());

	//Read All file
	std::string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
	std::stringstream ss(str);

	//Close it
	file.close();

	//Read
	while (ss)
	{
		std::string line;
		std::getline(ss, line, '\n');
		std::stringstream ssline(line);

		std::string type = "";
		ssline >> type;
		if (type == "v")
		{
			ssline >> m_vertex[m_numVerts].x >> m_vertex[m_numVerts].y >> m_vertex[m_numVerts].z;
			m_numVerts++;
		}
		else if (type == "vt")