Continuum Membrane 719025a62b1e384a6ff80e2f2a223ef4012153dc
Loading...
Searching...
No Matches
Functions
io.hpp File Reference

Manage io of continuum membrane model, including parameter files, vertices and faces, and scaffolding structure files. More...

#include <fstream>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <stdexcept>
#include <sys/stat.h>
#include "mesh/Mesh.hpp"
#include "model/Record.hpp"
#include "model/Model.hpp"
#include "mesh/Vertex.hpp"
#include "Parameters.hpp"
#include "linalg/Linear_algebra.hpp"
#include "Dynamics.hpp"

Go to the source code of this file.

Functions

std::string pop_space (std::string rawString)
 Remove spaces from a string.
 
std::string trim_trailing_semicolon (std::string rawString)
 
bool import_kv_string (std::string variableNameStr, std::string variableValueStr, Param &param)
 Import key-value pairs from a string.
 
bool import_param_file (Param &param, std::string filepath)
 Import parameters from a file.
 
template<typename T >
std::vector< std::vector< T > > read_data_from_csv (const std::string &filepath, char separator=',')
 Read data from a CSV file and store it in a vector of vectors with the specified data type.
 
bool import_mesh_from_vertices_faces (Mesh &mesh, std::string verticesFilepath, std::string facesFilepath)
 Import a mesh from separate files containing vertices and faces.
 
std::vector< Matriximport_scaffolding_mesh (std::string filepath)
 Import scaffolding mesh from a file.
 

Detailed Description

Manage io of continuum membrane model, including parameter files, vertices and faces, and scaffolding structure files.

Author
Y Ying (yying.nosp@m.7@jh.nosp@m..edu)
Date
2023-03-29

Function Documentation

◆ import_kv_string()

bool import_kv_string ( std::string  variableNameStr,
std::string  variableValueStr,
Param param 
)

Import key-value pairs from a string.

This function takes two strings, variableNameStr and variableValueStr, which are expected to contain name-value pairs separated by an "=" sign. It then parses these variables and uses them to update a Param struct object's variables, which is passed as reference. If parsing and updating are successful, returns true, else returns false.

Parameters
variableNameStrthe string containing names of the variables
variableValueStrthe string containing values of the variables
paramthe Param object to be updated
Returns
true if parsing and updating was successful, else false.

◆ import_mesh_from_vertices_faces()

bool import_mesh_from_vertices_faces ( Mesh mesh,
std::string  verticesFilepath,
std::string  facesFilepath 
)

Import a mesh from separate files containing vertices and faces.

This function reads vertices and faces from specified files and constructs a mesh.

Parameters
meshThe Mesh object to write vertices and faces data.
verticesFilepathThe file path of the vertices file.
facesFilepathThe file path of the faces file.
Returns
True if the mesh is successfully imported, false otherwise.

◆ import_param_file()

bool import_param_file ( Param param,
std::string  filepath 
)

Import parameters from a file.

This function reads a parameter file specified by filepath and updates a Param struct object's variables using the information present in the file. The updated Param object is passed as reference. If file reading and updating are successful, returns true, else false.

Parameters
paramthe Param object to be updated
filepaththe path of the parameter file to be read
Returns
true if file reading and updating was successful, else false.

◆ import_scaffolding_mesh()

std::vector< Matrix > import_scaffolding_mesh ( std::string  filepath)

Import scaffolding mesh from a file.

This function reads a mesh file specified by filepath and returns a vector of matrices containing the vertices' coordinates of all triangular faces.

Parameters
filepaththe path of the mesh file to be read
Returns
A vector of matrices containing the vertices' coordinates of all triangular faces.

◆ pop_space()

std::string pop_space ( std::string  rawString)

Remove spaces from a string.

This function takes a raw string and removes any whitespace characters present in it. The modified string with no spaces is returned.

Parameters
rawStringthe original string to be processed
Returns
The string with spaces removed.

◆ read_data_from_csv()

template<typename T >
std::vector< std::vector< T > > read_data_from_csv ( const std::string &  filepath,
char  separator = ',' 
)

Read data from a CSV file and store it in a vector of vectors with the specified data type.

This function reads data from a CSV file, where each line represents a row of data, and each value within a line is separated by the specified character.

Generated by GPT 3.5.

Template Parameters
TThe data type (int, float, or double) to store in the resulting vector.
Parameters
filepathThe file path of the CSV file.
separatorThe character used as a separator in the CSV file (default is comma ',' for typical CSV files).
Returns
A vector of vectors containing the read data.
Exceptions
std::invalid_argumentIf the data cannot be converted to the specified data type.

◆ trim_trailing_semicolon()

std::string trim_trailing_semicolon ( std::string  rawString)