31 #include <QTextStream>
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 CsvGzExporter::StreamCellData(
const Mesh* mesh, QTextStream& csv_stream)
72 csv_stream <<
"\"Cell Index\",\"Center of mass (x)\",\"Center of mass (y)\",\"Cell area\",\"Cell length\"";
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() <<
", " << get<0>(cell->GetGeoData().GetEllipseAxes());
84 for (
unsigned int c = 0; c < num_chem; c++) {
85 csv_stream <<
", " << cell->GetChemical(c);
91 void CsvGzExporter::StreamMeshData(
const Mesh* mesh, QTextStream& csv_stream)
93 csv_stream <<
"\"Morph area\",\"Number of cells\",\"Number of nodes\",\"Compactness\",\"Hull area\",\"Morph circumference\",\"Hull circumference\""
97 const double res_compactness = get<0>(res_tuple);
98 const double res_area = get<1>(res_tuple);
99 const double hull_circumference = get<2>(res_tuple);
103 csv_stream << mesh_area <<
", " << mesh->
GetCells().size() <<
", " << mesh->
GetNodes().size()
104 <<
", " << res_compactness <<
", " << res_area <<
", "
105 << morph_circumference <<
", " << hull_circumference << endl;
108 void CsvGzExporter::StreamWallData(
const Mesh* mesh, QTextStream& csv_stream)
110 csv_stream <<
"\"Wall Index\",\"Cell A\",\"Cell B\",\"Length\"";
112 const unsigned int num_chem = mesh->GetNumChemicals();
114 for (
unsigned int c = 0; c < num_chem; c++) {
115 csv_stream <<
",\"Transporter A:" << c <<
"\"";
117 for (
unsigned int c = 0; c < num_chem; c++) {
118 csv_stream <<
",\"Transporter B:" << c <<
"\"";
121 for (
auto const& wall : mesh->
GetWalls()) {
122 csv_stream << wall->GetIndex() <<
"," << wall->GetC1()->GetIndex() <<
","
123 << wall->GetC2()->GetIndex() <<
"," << wall->GetLength();
124 for (
unsigned int c = 0; c < num_chem; c++) {
125 csv_stream <<
"," << wall->GetTransporters1(c);
127 for (
unsigned int c = 0; c < num_chem; c++) {
128 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.
const std::vector< Cell * > & GetCells() const
The cells of this mesh, EXCLUDING the boundary polygon.
Namespace for the core simulator.
static bool Export(std::shared_ptr< SimPT_Sim::SimInterface > sim, std::string const &file_path, bool overwrite=true)
Export mesh state to csv format.
static std::string GetFileExtension()
File extension associated with this export format.
double GetCircumference() const
Return the circumference along the edges.
Cell * GetBoundaryPolygon() const
Get the boundary polygon of the mesh.
const std::vector< Node * > & GetNodes() const
The nodes of the mesh.
Interface for CsvGzExporter.
Structure of cells; key data structure.
const std::vector< Wall * > & GetWalls() const
The walls of this mesh.
double GetArea() const
Return the area of the cell.