From 6deb168a8182fbe105f21635422ee353d487725a Mon Sep 17 00:00:00 2001 From: laila Saadatifard Date: Fri, 16 Sep 2016 18:10:57 -0500 Subject: [PATCH] add save to cellset.h --- stim/biomodels/cellset.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+), 0 deletions(-) diff --git a/stim/biomodels/cellset.h b/stim/biomodels/cellset.h index b7117f0..bbf258b 100644 --- a/stim/biomodels/cellset.h +++ b/stim/biomodels/cellset.h @@ -167,6 +167,26 @@ public: cells.push_back(newcell); //push the new memory entry into the cell array } +void save(std::string filename){ + + + size_t ncells = cells.size(); // get the number of cells + std::ofstream file(filename); //open a file to store the cell's coordinates + if (file.is_open()) { + + file << "x y z radius\n"; //write the file header + for (size_t c=0; c < ncells; c++){ //for each cell + if (cells[c][ip[3]] != NULL) //check if for the current cell, radius has been assigned + file << cells[c][ip[0]] << delim << cells[c][ip[1]] << delim << cells[c][ip[2]] << delim << cells[c][ip[3]] << '\n' ; + else //check if for the current cell, radius has not been assigned, set radius to zero + file << cells[c][ip[0]] << delim << cells[c][ip[1]] << delim << cells[c][ip[2]] << delim << 0 << '\n' ; + } + + } + file.close(); + + } + }; //end class cellset }; //end namespace stim -- libgit2 0.21.4