Commit a60b78291db5bb4cee0e9d1d7fe4ada7f8c3fea8

Authored by David Mayerich
2 parents 1657f19c 6deb168a

Merge branch 'cellset_save' into 'master'

add save to cellset.h

See merge request !5
Showing 1 changed file with 20 additions and 0 deletions   Show diff stats
stim/biomodels/cellset.h
... ... @@ -167,6 +167,26 @@ public:
167 167 cells.push_back(newcell); //push the new memory entry into the cell array
168 168 }
169 169  
  170 +void save(std::string filename){
  171 +
  172 +
  173 + size_t ncells = cells.size(); // get the number of cells
  174 + std::ofstream file(filename); //open a file to store the cell's coordinates
  175 + if (file.is_open()) {
  176 +
  177 + file << "x y z radius\n"; //write the file header
  178 + for (size_t c=0; c < ncells; c++){ //for each cell
  179 + if (cells[c][ip[3]] != NULL) //check if for the current cell, radius has been assigned
  180 + file << cells[c][ip[0]] << delim << cells[c][ip[1]] << delim << cells[c][ip[2]] << delim << cells[c][ip[3]] << '\n' ;
  181 + else //check if for the current cell, radius has not been assigned, set radius to zero
  182 + file << cells[c][ip[0]] << delim << cells[c][ip[1]] << delim << cells[c][ip[2]] << delim << 0 << '\n' ;
  183 + }
  184 +
  185 + }
  186 + file.close();
  187 +
  188 + }
  189 +
170 190  
171 191 }; //end class cellset
172 192 }; //end namespace stim
... ...