1 #ifndef _parameteric_curves_utils_file_io_hpp
2 #define _parameteric_curves_utils_file_io_hpp
7 #define MAXBUFSIZE ((int)1000000)
13 int cols = 0, rows = 0;
18 infile.open(filename.c_str());
19 while (!infile.eof()) {
21 getline(infile, line);
25 std::stringstream stream(line);
26 while (!stream.eof()) stream >> buff[cols * rows + temp_cols++];
28 if (temp_cols == 0)
continue;
32 else if (temp_cols != cols && !infile.eof()) {
33 std::cout <<
"Error while reading matrix from file, line " << rows
34 <<
" has " << temp_cols
35 <<
" columnds, while preceding lines had " << cols
37 std::cout << line <<
"\n";
43 std::cout <<
"Max buffer size exceeded (" << rows <<
" rows, " << cols
52 Eigen::MatrixXd result(rows, cols);
53 for (
int i = 0; i < rows; i++)
54 for (
int j = 0; j < cols; j++) result(i, j) = buff[cols * i + j];
#define MAXBUFSIZE
to read text file
Definition: file-io.hpp:7
const Eigen::MatrixXd readMatrixFromFile(const std::string &filename)
Definition: file-io.hpp:12
Definition: abstract-curve.hpp:16