Пример #1
0
bool readCSV(std::string filename, std::vector< std::vector<cv::Point> >& content) {
	std::ifstream datafile(filename.c_str());
	if (datafile) {
		int counter = 0;
		int sizeof_point = 2;
		std::string line;
		while(std::getline(datafile,line)) {
			std::stringstream  lineStream(line);
			std::string        cell;
			std::vector<cv::Point> row_content;
			std::vector<int> set_content;
			counter = 0;
			cv::Point tmp;
			while(std::getline(lineStream,cell,',')) {
				set_content.push_back(atoi(cell.c_str()));
				counter += 1;
				if (counter == sizeof_point && set_content.size() != 0) {
					tmp.x = set_content[0];
					tmp.y = set_content[1];
					row_content.push_back(tmp);
					set_content.clear();
					counter = 0;
				}
			}
			content.push_back(row_content);
			row_content.clear();
		}
		datafile.close();
		return true;
	}
	else {
		datafile.close();
		return false;
	}
}
	Lights::Lights(string lightFilePath)
	{
		ifstream inputFile;
		inputFile.open(lightFilePath);
		if (inputFile)
		{
			string line;
			int lightIndex = 0;
			while (getline(inputFile, line))
			{
				istringstream lineStream(line);
				string word;
				lineStream >> word;
				if (word == "light")
				{
					Light* light = new Light();
					lights.push_back(light);
					
					light->lightIndex = lightIndex;
					lineStream >> light->position[0] >> light->position[1] >> light->position[2];
					light->position[3] = 1.0f;

					lineStream >> light->ambient[0] >> light->ambient[1] >> light->ambient[2];			
					lineStream >> light->diffuse[0] >> light->diffuse[1] >> light->diffuse[2];				
					lineStream >> light->specular[0] >> light->specular[1] >> light->specular[2];

					lightIndex++;
				}
				else if(word == "ambient")
				{
					if(ambientLight == nullptr)
						ambientLight = new AmbientLight();
					lineStream >> ambientLight->ambient[0] >> ambientLight->ambient[1] >> ambientLight->ambient[2];
				}
			}
Пример #3
0
bool readCSV(std::string filename, int x_ref, int y_ref) {
	std::ifstream datafile(filename.c_str());
	int x = 0;
	int y = 0;
	if (datafile) {
		std::string line;
		while(std::getline(datafile,line)) {
			std::stringstream  lineStream(line);
			std::string        cell;
			std::vector<int> row_content;
			x = 0;
			while(std::getline(lineStream,cell,',')) {
				x += 1;
			}
			y += 1;
		}
		datafile.close();
		if (x == x_ref && y == y_ref)
			return true;
		else
			return false;
	}
	else {
		datafile.close();
		return false;
	}
}
mitk::pa::PropertyCalculator::PropertyCalculator()
{
  us::ModuleResource resource = us::GetModuleContext()->GetModule()->GetResource("spectralLIB.dat");

  if (resource.IsValid())
  {
    us::ModuleResourceStream resourceStream(resource);
    std::string line;
    int wavelength = 300;
    int counter = 0;
    while (std::getline(resourceStream, line, '\t'))
    {
      int currentLineIdx = counter % 6;
      if (currentLineIdx == 0)
        wavelength = std::stoi(line);
      else
      {
        std::istringstream lineStream(line);
        double tempDouble;
        lineStream >> tempDouble;
        m_SpectralLibMap[currentLineIdx][wavelength] = tempDouble;
      }
      ++counter;
    }
  }
Пример #5
0
vector<int> Interface::CSVEntries(string name)
{
	vector<int>	result;

	if (ifstream(name))
	{

		//Variable to store the file holding the data
		fstream dataFile;
		//If the file does not exist it will be created
		dataFile.open(name);

		//Parse the file and collect a csv string
		string line;
		getline(dataFile, line);
		stringstream          lineStream(line);
		string                cell;


		//Break down the csv string. Each element in the vector represents a single number
		while (getline(lineStream, cell, ',')) {
			int convertion = atoi(cell.c_str());
			result.push_back(convertion);
		}

		dataFile.close();

		return result;
	}
	else {
		cout << "File does not exists" << endl;
		return result;
	}
}
Пример #6
0
void sceneParser(std::string fileName, Object*** objs, int* nObj, Object*** srcs, int* nSrc, Image** img, Vec3** eye)
{
  std::ifstream fs(fileName);
  std::string curLine;

  if (std::getline(fs, curLine))
  {
    std::cout << "Parsing scene: " << fileName << std::endl;
  }
  else
  {
    std::cout << "Error reading scene: " << fileName << std::endl;
    assert(0);
  }

  fs.clear();
  fs.seekg(0, std::ios::beg);

  /* Start by counting the number of objects, sources, etc. */
  while (std::getline(fs, curLine))
  {
    std::istringstream lineStream(curLine);
    std::string curWord;

    lineStream >> curWord;

    if (curWord == "I") /* Image: I locX locY locZ w h pixW pixH normX normY normZ */
    {
      float locX, locY, locZ, pixW, pixH, normX, normY, normZ;
      int w, h;
      lineStream >> locX >> locY >> locZ >> w >> h >> pixW >> pixH >> normX >> normY >> normZ;
      *img = new Image(Vec3(locX, locY, locZ), Vec3(normX, normY, normZ), w, h, pixW, pixH);
      std::cout << "Img initialized \n";
    }
    else if (curWord == "E") /* Eye: E locX locY locZ */
Пример #7
0
//Loads an OBJ file into this mesh
//Does not currently account for textures
void Mesh::loadOBJ(std::string fileName) {
	std::vector<glm::vec3> vertices;
	std::vector<glm::vec2> uvs;
	std::vector<glm::vec3> normals;

	std::ifstream objFile(fileName, std::ios::in);
	if (!objFile.is_open()) {
		std::cout << "Failed to open the file " << fileName << std::endl;
	}
	
	std::string line;
	
	while (getline(objFile,line)) {
		if (line.length() == 0) {	//Line was empty, for some reason
			continue;
		}

		std::stringstream lineStream(line);	//Possible performance issues
		std::string lineType;
		
		lineStream >> lineType;

		if (lineType == "v") {	//We're dealing with a vertex
			float x,y,z;
			lineStream >> x >> y >> z;
			vertices.push_back(glm::vec3(x,y,z));
		}
		else if (lineType == "vt") {	//"" UV
Пример #8
0
//------------------------------------------------------------------------------
int ClimateFile::GetColumnDataFromCSVFile(char* FileName,char* FieldName,double* vect)
{
  int pos=DeterminePositionFromCSVFile(FileName,FieldName);
  int cont;
  std::ifstream  data(FileName);
  int num;
  std::string line;
  std::getline(data,line); // la primera linea no debe contabilizarse ya que es cabecera
  int numelem=0;
  while(std::getline(data,line))
  {
    std::stringstream  lineStream(line);
    std::string        cell;
    numelem++;
    int cont=0;
    while(std::getline(lineStream,cell,','))
    {
      cont++;
      // Aqui obtenemos una celda
      num=strlen(cell.c_str());
      char* dato = new char[ num + 1 ];
      strcpy(dato,cell.c_str());
      if(cont==pos)
      {
        vect[numelem-1]=atof(dato);
      }
    }
  }
  data.close();
  return numelem;
}
Пример #9
0
Parser* ParserFactory::getParserForFile(const char *fileName)
{
	std::ifstream dataFile(fileName);
	if (dataFile.fail())
	{
		return NULL;
	}
	
	std::string line;
	std::getline(dataFile, line);
	std::stringstream lineStream(line);
	std::string cell;
	
	std::vector<std::string> lineData;
	while (std::getline(lineStream, cell, ','))
	{
		lineData.push_back(reduce(cell));
	}
	
	if (atoi(lineData[1].c_str()) == VERSION_ONE)
	{
		return new ParserV1(fileName);
	}

	return NULL;
}
Пример #10
0
void Model::load(std::istream& is)
{
    Mesh* currMesh = NULL;

    mMeshes.empty();
    mVertices.empty();
    mUVs.empty();
    mNormals.empty();

    while (is.good()) {
        std::string line;
        std::getline(is, line);
        if (line.empty() || line[0] == '#') {
            continue;
        }
        std::istringstream lineStream(line);

        std::string cmd;
        lineStream >> cmd;
        if (cmd == "o") {
            std::string name;
            lineStream >> std::ws;
            std::getline(lineStream, name);
            Mesh mesh(*this, name);
            mMeshes.push_back(mesh);
            currMesh = &(*--mMeshes.end());
        } else if (cmd == "v") {
Пример #11
0
void HeathrowRowData::fillFromLine(const std::string & line)
{
  std::stringstream lineStream(line); // use this stream for the whole line
  std::string valueString;

  // Year
  std::getline(lineStream, valueString, ' ');
  setData(myYear, valueString);

  // Month
  std::getline(lineStream, valueString, ' ');
  setData(myMonth, valueString);

  // T_max
  std::getline(lineStream, valueString, ' ');
  setData(myTMax, valueString);

  // T_max
  std::getline(lineStream, valueString, ' ');
  setData(myTMin, valueString);

  // Air frost
  std::getline(lineStream, valueString, ' ');
  setData(myAirFrost, valueString);

  // Rain
  std::getline(lineStream, valueString, ' ');
  setData(myRain, valueString);

  // Sun hours
  std::getline(lineStream, valueString, ' ');
  setData(mySunHours, valueString);
}
Пример #12
0
bool Level::readEntityData(std::ifstream& stream) {
    std::string line;
    std::string type;
    while (getline(stream, line)) {
        if (line == "") {
            break;
        }
        std::istringstream sStream(line);
        std::string key,value;
        getline(sStream, key, '=');
        getline(sStream, value);
        if (key == "type") {
            type = value;
        }
        else if (key == "location") {
            std::istringstream lineStream(value);
            std::string xPosition, yPosition;
            getline(lineStream, xPosition, ',');
            getline(lineStream, yPosition, ',');
            float placeX = atof(xPosition.c_str())/16*TILE_SIZE;
            float placeY = atof(yPosition.c_str())/16*-TILE_SIZE;
            placeEntity(type, placeX, placeY);
        }
    }
    return true;
}
Пример #13
0
bool Tilemap::readEntityData(std::ifstream &stream) {
    string line;
    string type;
    while(getline(stream, line)) {
        if(line == "") { break; }
        istringstream sStream(line);
        string key,value;
        getline(sStream, key, '=');
        getline(sStream, value);
        if(key == "type") {
            type = value; // it'll say "start", don't worry, me
        } else if(key == "location") {
            istringstream lineStream(value);
            string xPosition, yPosition;
            getline(lineStream, xPosition, ',');
            getline(lineStream, yPosition, ',');
            
//            playerX = atoi(xPosition.c_str());
//            playerY = atoi(yPosition.c_str());
//            placeEntity(type, placeX, placeY);
            
        }
    }
    return true;
}
Пример #14
0
void CSVRow::readNextRow(std::istream& str) 
/** @fn readNextRow
 *  @param std::istream& str - get the address of the 1st byte of memory used to store the string str
 *  */
{
	std::string	line;
			
	/** @details std::getline reads characters from an input stream and places them into a string 
	 *  @ref http://en.cppreference.com/w/cpp/string/basic_string/getline
	 *  @param str - input - the stream to get data from 
	 *  @param line - str - the string to put the data into
	 *  @param delim - the delimiter character
	 * */
	std::getline(str,line);
			
	/** @brief std::stringstream::stringstream - stream class to operate on strings
	 *  @details initialization constructor, (const string& str)
	 *  @param str constructs a stringstream object with a copy of str as content 
	 * 	@ref http://www.cplusplus.com/reference/sstream/stringstream/stringstream/
	 * */
	std::stringstream lineStream(line);
	std::string cell; 
			
	m_data.clear();
	while(std::getline(lineStream, cell, ','))
	{
		m_data.push_back(cell);
	}
	// This checks for a trailing comma with no data after it.
	if (!lineStream && cell.empty())
	{
		// If there was a trailing comma then add an empty element.
		m_data.push_back("");
	}
}		
Пример #15
0
Cloud::Cloud(char *filename)
  // Perlin::Perlin(int octaves,float freq,float amp,int seed)
  //next is a list of working values
	//: perlin(10, 0.3, 1, 2)
	//: perlin(10, 0.3, 1, 19191919)
  //: perlin(4, 0.3, 1.2, 19)
  : perlinCloud(10, 0.06, 1.0, 19) //definitely working values for cloud
  , perlinPuff(4, 0.01, 0.42, 19) //possible value for pyroclastic puff
{ 
  string line;
  ifstream myfile (filename);
  lightCount = 1;

  if (myfile.is_open())
    { 
      while ( getline (myfile,line) )
      {
        istringstream lineStream (line);
        
        string token;
        lineStream >> token;
        //cout << token;
        
        if (token == "DELT") {
          lineStream >> delt;
		    } else
        if (token == "STEP") {
          lineStream >> stepLength;
		    } else
Пример #16
0
int main(){
  Graph<int> graph;

  std::ifstream file("SCC.txt");
  std::string line;  

  std::cout<<"parsing file"<<std::endl;
  while(std::getline(file,line)){
    std::stringstream lineStream(line);
    int node, neighbor;
    lineStream >> node >> neighbor;
    graph.add_node(node);
    graph.add_node(neighbor);
    graph.add_directed_edge(node, neighbor);
  }

  auto sccs = scc(graph);

  std::multiset<size_t> scc_sizes;

  for(const auto& component: sccs){
    scc_sizes.insert(component->size());
  }

  std::cout<<"biggest sizes: ";
  for(auto it = scc_sizes.rbegin(); it!=std::next(scc_sizes.rbegin(), 5); ++it){
    std::cout<<*it<<',';
  }
  std::cout<<std::endl;

  return 0;
}
Пример #17
0
ClientInformationFile::ClientInformationFile(std::string fileName): File(fileName)
{
	std::string			csvPath = CLIENT_FILE_PATH + "client.csv";

	std::ifstream		data(csvPath);
	std::string			line;
	
	
	std::getline(data, line);

	while (std::getline(data, line))
	{
		std::stringstream			lineStream(line);
		std::string					cell;
		std::vector<std::string>	recordString;

		while (std::getline(lineStream, cell, ';'))
		{
			recordString.push_back(cell);
		}

		m_record.push_back(recordString);

		recordString.clear();
	}
};
Пример #18
0
bool ObjLoader::load(::QIODevice *ioDev)
{
    Q_CHECK_PTR(ioDev);
    if (!ioDev->isOpen()) {
        qCWarning(Render::Io) << "iodevice" << ioDev << "not open for reading";
        return false;
    }

    int faceCount = 0;

    // Parse faces taking into account each vertex in a face can index different indices
    // for the positions, normals and texture coords;
    // Generate unique vertices (in OpenGL parlance) and output to m_points, m_texCoords,
    // m_normals and calculate mapping from faces to unique indices
    QVector<QVector3D> positions;
    QVector<QVector3D> normals;
    QVector<QVector2D> texCoords;
    QHash<FaceIndices, unsigned int> faceIndexMap;
    QVector<FaceIndices> faceIndexVector;

    QTextStream stream(ioDev);
    while (!stream.atEnd()) {
        QString line = stream.readLine();
        line = line.simplified();

        if (line.length() > 0 && line.at(0) != QChar::fromLatin1('#')) {
            QTextStream lineStream(&line, QIODevice::ReadOnly);
            QString token;
            lineStream >> token;

            if (token == QStringLiteral("v")) {
                float x, y, z;
                lineStream >> x >> y >> z;
                positions.append(QVector3D( x, y, z ));
            } else if (token == QStringLiteral("vt") && m_loadTextureCoords) {
Пример #19
0
void loadSkillList(SkillList& l)
{
    std::ifstream file("rc/data/skilllist.csv");
    std::string line;
    std::string value;
    std::string* listValue;
    int index = 0;

    while(std::getline(file, line))
    {
        Skill skill;
        listValue = new std::string[6];
        std::stringstream lineStream(line);

        while(std::getline(lineStream, value, ','))
        {
            listValue[index] = value;
            index++;
        }

        skill.setName(listValue[0]);
        skill.setBasePower(atoi(listValue[1].c_str()));
        skill.setTargetNeeded((atoi(listValue[2].c_str()) == 1) ? true : false);
        skill.setTargetType(static_cast<TargetType>(atoi(listValue[3].c_str())));
        skill.setCooldown(atoi(listValue[4].c_str()));
        skill.setDescription(listValue[5]);

        l.push_back(skill);

        index = 0;
        delete [] listValue;
    }
}
Пример #20
0
void Config::LoadConfigs(const std::string& iFilename)
{
    std::ifstream configFile( iFilename.c_str(), std::fstream::in);
    
    std::string line;
    
    if ( !configFile.good() ) {
        std::cout << "Could not open settings file." << std::endl;
        return;
    }
    
    while ( !configFile.eof() ) {
        std::getline( configFile, line );
        
        std::stringstream lineStream(line);
        
        std::string tag;

        lineStream >> tag;

        if ( tag.compare("RSC_DIR") == 0 ) {
            lineStream >> Config::_resourcesPath;

            std::cout << "RSC_DIR = " << Config::ResourcesPath() << std::endl;
        }
    }
Пример #21
0
void ClassDemoApp::LoadLevel(std::string mapName) {
	std::ifstream infile(mapName);
	std::string line;
	while (std::getline(infile, line)) {
		if (line == "[layer]") {
			while (std::getline(infile, line)) {
				if (line == "") break;
				std::istringstream sStream(line);
				std::string key, value;
				std::getline(sStream, key, '=');
				std::getline(sStream, value);
				if (key == "data") {
					for (int y = 0; y < LEVEL_HEIGHT; y++) {
						std::getline(infile, line);
						std::istringstream lineStream(line);
						std::string tile;

						for (int x = 0; x < LEVEL_WIDTH; x++) {
							std::getline(lineStream, tile, ',');
							unsigned char val = (unsigned char)atoi(tile.c_str());
							if (val > 0) {
								levelData[y][x] = val - 1;
							}
							else {
								levelData[y][x] = NO_TILE;
							}
						}
					}
				}
			}
			break;
		}
	}
}
Пример #22
0
//Note: could possibly use Waffles arff parser
//http://waffles.sourceforge.net/docs/matrices.html
StructuredSampleCollection readArff(std::istream& in){
  unsigned lineNum = 0;
  
  std::string relationName;
  std::vector<std::string> contvarNames;
  std::vector<std::string> catvarNames;
  //std::vector<std::string> binvarNames;
  
  std::vector<Array<std::string> > catvarCatNames;
  //std::vector<Array<std::string> > binvarCatNames;
  
  std::vector<featurety_t> featureTypes; //Used to determine the order of the arff arguments.
  
  std::string line;
  while (1)
  {
    lineNum++;
    if(!std::getline(in, line)){
      parserError(lineNum) << "Blank or absent @DATA section." << std::endl;
      exit(1);
    }
    
    //Filter comments, blank lines
    if(line.length() == 0 || line[0] == '%') continue;
    std::istringstream lineStream(line);

    //Read from the line
    std::string token;
    lineStream >> token;

    tolower(token);
    if(token == "@relation"){
      lineStream >> relationName;
    }
    else if(token == "@attribute"){
Пример #23
0
KdTreeBB::Item* loadItems(char* file, KdTreeBB::Item* &items, int &size)
{
	std::ifstream in(file);
	std::string line;
	
	float left, right, top, bottom;
	int zipcode;

	std::getline(in, line);
	size = atoi(line.c_str()); //number of lines
	items = (KdTreeBB::Item*)malloc(sizeof(KdTreeBB::Item)*size);
	int *zipCodes = (int*)malloc(sizeof(int)*size);
	int index = 0;
	while(std::getline(in, line))
	{
		std::stringstream  lineStream(line);
		sscanf(line.c_str(), "%d %f %f %f %f", &zipcode, &left, &bottom, &right, &top);

		items[index].bbox[0][0] = left;
		items[index].bbox[0][1] = right;
		items[index].bbox[1][0] = bottom;
		items[index].bbox[1][1] = top;
		zipCodes[index] = zipcode;
		items[index].data = zipCodes+index;
		index ++;
	}
	return items;
}
Пример #24
0
//checks if a string stream is legal
bool is_legal_input_str_stream(std::string in_ss){
    bool result = true;
    if(in_ss == ""){
        result = false;
        //std::cout << "illegal input: (Empty Input)" << std::endl;
    }
    else{
        stringstream lineStream(in_ss);
        string song_title;
        while(std::getline(lineStream, song_title, ',')) {
            // if the input string does not exist in the valid
            // song tree it is not a valid string stream
            if(song_title[0] == ' '){
                song_title = song_title.substr(1, song_title.length()-1);
            }

            if(song_tree->check(song_title) == 0){
                result = 0;
                //std::cout << "illegal input: " << song_title << std::endl;
                break;
            }
        }
    }
    if(result)
        //std::cout << "legal input" << std::endl;

    return result;
}
void create_queryfile() {
    std::ifstream ifile(QUERYSOURCE);

    // Load the points from the file and dump to data.dat
    long long lineCount = 0;

    // Temp variables to read unwanted info
    int temp;

    for (std::string line; std::getline(ifile, line) && lineCount < querysize; ++lineCount) {
        std::istringstream lineStream(line);

        // Read the query number
        lineStream >> temp;

        // Read the query point
        for (int i = 0; i < D; ++i) {
            lineStream >> query[lineCount][i];
        }

        // Read the value of k
        lineStream >> temp;
    }

    ifile.close();

    // Write to disk
    io.diskwrite_float(QUERYTARGET, query[0], querysize * D);
}
Пример #26
0
 /**
  * This method inserts values into the specified value table
  * @param fileName the fileName of the csv file
  * @param valueTable the value table to insert into
  * @param keyIndex the column index to use as the match criteria
  */
 void FileController::insertValues(const string& fileName, ValueTable* valueTable, int keyIndex)
 {
     if (validateFileName(fileName))
     {
         ifstream input(fileName.c_str());
         if (input.good())
         {
             string line;
             getline(input, line);
             valueTable->setHeaders(getHeaders(line));
             while (getline(input, line))
             {
                 stringstream lineStream(line);
                 string cell;
                 vector<string> values;
                 while (getline(lineStream, cell, ','))
                 {
                     values.push_back(stripAll(cell));
                 }
                 valueTable->addValue(values[keyIndex], values);
             }
         } else {
             cout << "File Does Not Exist." << endl;
         }
     } else {
         cout << "Incorrect File Format." << endl;
     }
 }
Пример #27
0
bool SideScroller::readLayerData(ifstream& stream) {
	string line;
	while (getline(stream, line)) {
		if (line == "") { break; }
		istringstream sStream(line);
		string key, value;
		getline(sStream, key, '=');
		getline(sStream, value);
		if (key == "data") {
			for (int y = 0; y < mapHeight; y++) {
				getline(stream, line);
				istringstream lineStream(line);
				string tile;

				for (int x = 0; x < mapWidth; x++) {
					getline(lineStream, tile, ',');
					unsigned char val = (unsigned char)atoi(tile.c_str());
					if (val > 0) {
						levelData[y][x] = val;
					}
					else {
						levelData[y][x] = 0;
					}
				}

			}
		}
	}
	return true;
}
Пример #28
0
bool Tilemap::readLayerData(ifstream &stream) {
    string line;
    while(getline(stream, line)) {
        if(line == "") { break; }
        istringstream sStream(line);
        string key,value;
        getline(sStream, key, '=');
        getline(sStream, value);
        if(key == "data") {
            for(int y=0; y < LEVEL_HEIGHT; y++) {
                getline(stream, line);
                istringstream lineStream(line);
                string tile;
                for(int x=0; x < LEVEL_WIDTH; x++) {
                    getline(lineStream, tile, ',');
                    unsigned char val =  (unsigned char)atoi(tile.c_str());
                    if(val > 0) {
                        levelData[y][x] = val-1;
                    } else {
                        levelData[y][x] = 0;
                    }
                }
            } }
    }
    return true;
}
Пример #29
0
std::vector<long> splitCSV(std::string input,char delim){
    std::vector<long> output;
    std::stringstream lineStream(input);
    std::string temp;
	while(getline(lineStream,temp,delim)){output.push_back(atoi(temp.c_str()));}
    return output;
}
Пример #30
-1
bool Level::readLayerData(std::ifstream& stream) {
    std::string line;
    while (getline(stream, line)) {
        if(line == "") {
            break;
        }
        std::istringstream sStream(line);
        std::string key,value;
        getline(sStream, key, '=');
        getline(sStream, value);
        if (key == "data") {
            for(int y=0; y < mapHeight; y++) {
                getline(stream, line);
                std::istringstream lineStream(line);
                std::string tile;
                for (int x=0; x < mapWidth; x++) {
                    getline(lineStream, tile, ',');
                    unsigned char val =  (unsigned char)atoi(tile.c_str());
                    if (val > 0) {
                        // be careful, the tiles in this format are indexed from 1 not 0
                        levelData[y][x] = val-1;
                    }
                    else {
                        levelData[y][x] = 0;
                    }
                }
            }
        }
    }
    return true;
}