Elaboradar  0.1

◆ 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.

483 {
484  LOG_INFO("Opening %s %s", desc, fname.c_str());
485  FILE* in = fopen_checked(fname.c_str(), "rb", desc);
486 
487  // Read the file size
488  fseek(in, 0,SEEK_END);
489  long fsize = ftell(in);
490  rewind(in);
491 
492  // Check that the file size is consistent with what we want
493  if ((unsigned)fsize != matrix.size() * sizeof(T))
494  {
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");
498  }
499  LOG_INFO ("DIMENSIONE MAPPA STATICA %ld %ld", matrix.rows(), matrix.cols());
500 
501  for (unsigned i = 0; i < matrix.rows(); ++i)
502  if (fread(matrix.data() + i * matrix.cols(), matrix.cols(), 1, in) != 1)
503  {
504  std::string errmsg("Error reading ");
505  errmsg += fname;
506  errmsg += ": ";
507  errmsg += strerror(errno);
508  fclose(in);
509  throw std::runtime_error(errmsg);
510  }
511 
512  fclose(in);
513 }
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.
Definition: utils.cpp:144

Referenzia radarelab::fopen_checked().

Referenziato da load_first_level(), load_first_level_bb_bloc(), e load_first_level_bb_el().