31 #include <QTextStream> 
   40 bool CsvExporter::Export(shared_ptr<SimPT_Sim::SimInterface> sim, 
string const& file_path, 
bool overwrite)
 
   42         if (ifstream(file_path).good()) {
 
   45                         QFile::remove(QString::fromStdString(file_path));
 
   52         QFile file(QString::fromStdString(file_path));
 
   53         if (file.open(QIODevice::WriteOnly)) {
 
   54                 const auto mesh = sim->GetCoreData().m_mesh.get();
 
   55                 QTextStream stream(&file);
 
   56                 StreamCellData(mesh, stream);
 
   57                 StreamWallData(mesh, stream);
 
   58                 StreamMeshData(mesh, stream);
 
   70 void CsvExporter::StreamCellData(
const Mesh* mesh, QTextStream& csv_stream)
 
   72         csv_stream << 
"\"Cell Index\",\"Center of mass (x)\",\"Center of mass (y)\",\"Cell length\",\"CK/AUX\"";
 
   74         const unsigned int num_chem = mesh->GetNumChemicals();
 
   76         for (
unsigned int c = 0; c < num_chem; c++) {
 
   77                 csv_stream << 
",\"[Chemical " << c << 
"]" << 
"\"";
 
   80         for (
auto const& cell : mesh->
GetCells()) {
 
   81                 auto centroid = cell->GetCentroid();
 
   82                 csv_stream << cell->GetIndex() << 
", " << centroid[0] << 
", " << centroid[1] << 
", " 
   83                                 << cell->GetArea() / 16 
 
   85                 for (
unsigned int c = 0; c < num_chem; c++) {
 
   86                         csv_stream << 
", " << (cell->GetChemical(c)) / (cell->GetArea());
 
   92 void CsvExporter::StreamMeshData(
const Mesh* mesh, QTextStream& csv_stream)
 
   94         csv_stream << 
"\"Morph area\",\"Number of cells\",\"Number of nodes\",\"Compactness\",\"Hull area\",\"Morph circumference\",\"Hull circumference\"" 
   98         const double res_compactness      = get<0>(res_tuple);
 
   99         const double res_area             = get<1>(res_tuple);
 
  100         const double hull_circumference   = get<2>(res_tuple);
 
  104         csv_stream << mesh_area << 
", " << mesh->
GetCells().size() << 
", " << mesh->
GetNodes().size()
 
  105                         << 
", " << res_compactness << 
", " << res_area << 
", " 
  106                         << morph_circumference << 
", " << hull_circumference << endl;
 
  109 void CsvExporter::StreamWallData(
const Mesh* mesh, QTextStream& csv_stream)
 
  111         csv_stream << 
"\"Wall Index\",\"Cell A\",\"Cell B\",\"Length\"";
 
  113         const unsigned int num_chem = mesh->GetNumChemicals();
 
  115         for (
unsigned int c = 0; c < num_chem; c++) {
 
  116                 csv_stream << 
",\"Transporter A:" << c << 
"\"";
 
  118         for (
unsigned int c = 0; c < num_chem; c++) {
 
  119                 csv_stream << 
",\"Transporter B:" << c << 
"\"";
 
  122         for (
auto const& wall : mesh->
GetWalls()) {
 
  123                 csv_stream << wall->GetIndex() << 
"," << wall->GetC1()->GetIndex() << 
"," 
  124                                 << wall->GetC2()->GetIndex() << 
"," << wall->GetLength();
 
  125                 for (
unsigned int c = 0; c < num_chem; c++) {
 
  126                         csv_stream << 
"," << wall->GetTransporters1(c);
 
  128                 for (
unsigned int c = 0; c < num_chem; c++) {
 
  129                         csv_stream << 
"," << wall->GetTransporters2(c);
 
Core data used during model execution. 
 
Interface for MeshGeometry. 
 
static std::tuple< double, double, double > Compactness(const Mesh *mesh)
Calculate the convex hull of the cells in the mesh and returns respectively the ratio of the areas of...
 
Namespace for SimPT shell package. 
 
static bool Export(std::shared_ptr< SimPT_Sim::SimInterface > sim, std::string const &file_path, bool overwrite=true)
Export mesh state to csv format. 
 
const std::vector< Cell * > & GetCells() const 
The cells of this mesh, EXCLUDING the boundary polygon. 
 
Namespace for the core simulator. 
 
double GetCircumference() const 
Return the circumference along the edges. 
 
Cell * GetBoundaryPolygon() const 
Get the boundary polygon of the mesh. 
 
Interface for Csv Exporter. 
 
const std::vector< Node * > & GetNodes() const 
The nodes of the mesh. 
 
Structure of cells; key data structure. 
 
const std::vector< Wall * > & GetWalls() const 
The walls of this mesh. 
 
static std::string GetFileExtension()
File extension associated with this export format. 
 
double GetArea() const 
Return the area of the cell.