|
◆ load_raw()
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 482 del file assets.cpp.
484 LOG_INFO( "Opening %s %s", desc, fname.c_str());
488 fseek(in, 0,SEEK_END);
489 long fsize = ftell(in);
493 if (( unsigned)fsize != matrix.size() * sizeof(T))
495 LOG_ERROR( "Il file %s è %ld byte ma dovrebbe invece essere %ld byte\n",
496 fname.c_str(), fsize, matrix.size() * sizeof(T));
497 throw std::runtime_error( "La dimensione della mappa statica non è quello che mi aspetto");
499 LOG_INFO ( "DIMENSIONE MAPPA STATICA %ld %ld", matrix.rows(), matrix.cols());
501 for ( unsigned i = 0; i < matrix.rows(); ++i)
502 if (fread(matrix.data() + i * matrix.cols(), matrix.cols(), 1, in) != 1)
504 std::string errmsg( "Error reading ");
507 errmsg += strerror(errno);
509 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.
Referenzia radarelab::fopen_checked().
Referenziato da load_first_level(), load_first_level_bb_bloc(), e load_first_level_bb_el().
|