|
template<class T >
void elaboradar::Assets::load_raw |
( |
const std::string & |
fname, |
|
|
const char * |
desc, |
|
|
radarelab::Matrix2D< T > & |
matrix |
|
) |
| |
|
protected |
Load a Matrix2D, from packed row-major binary data.
Definizione alla linea 480 del file assets.cpp.
Referenzia radarelab::fopen_checked().
Referenziato da load_first_level(), load_first_level_bb_bloc(), e load_first_level_bb_el().
482 LOG_INFO( "Opening %s %s", desc, fname.c_str());
486 fseek(in, 0,SEEK_END);
487 long fsize = ftell(in);
491 if (( unsigned)fsize != matrix.size() * sizeof(T))
493 LOG_ERROR( "Il file %s è %ld byte ma dovrebbe invece essere %ld byte\n",
494 fname.c_str(), fsize, matrix.size() * sizeof(T));
495 throw std::runtime_error( "La dimensione della mappa statica non è quello che mi aspetto");
497 LOG_INFO ( "DIMENSIONE MAPPA STATICA %ld %ld", matrix.rows(), matrix.cols());
499 for ( unsigned i = 0; i < matrix.rows(); ++i)
500 if (fread(matrix.data() + i * matrix.cols(), matrix.cols(), 1, in) != 1)
502 std::string errmsg( "Error reading ");
505 errmsg += strerror(errno);
507 throw std::runtime_error(errmsg);
FILE * fopen_checked(const char *fname, const char *mode, const char *description) A wrapper of fopen that throws an exception if it cannot open the file.
|