void Mesh_File_Reader::load( Meshes & final_meshes, const Cell_Target & cells, const URI & circuit_source, bool load_vertices, bool load_triangles, bool load_mapping, bool load_triangle_strips) { Meshes meshes; boost::filesystem::path mvd_file = uri_to_filename(circuit_source); if (mvd_file == "" || boost::filesystem::extension(mvd_file) != ".mvd2") { throw_exception(Bad_Data_Source("Loading meshes: circuit_source '" + circuit_source + "' "), FATAL_LEVEL, __FILE__, __LINE__); } MVD_File_Parser mvd_parser(mvd_file); mvd_parser.parse_file(cells); for (Cell_Target::iterator cell_gid = cells.begin(); cell_gid != cells.end(); ++cell_gid) { MVD_Cell_Index index = mvd_parser.cell_index(*cell_gid); if (index == UNDEFINED_MVD_CELL_INDEX) { std::stringstream msg; msg << "Loading meshes: bad cell target, neuron gid " << *cell_gid << " not in mvd file '" << mvd_file << "'"; throw_exception(Bad_Data(msg.str()), FATAL_LEVEL, __FILE__, __LINE__); } const Label & label = mvd_parser.morphology_names()[index]; if (meshes.find(label) == meshes.end()) { insert_new_or_updated(label, final_meshes, meshes, load_vertices, load_triangles, load_triangle_strips, load_mapping); } } // Final insertion from local container to result for (Meshes::iterator i = meshes.begin(); i != meshes.end(); ++i) { // This insertion replaces old existing meshes with its updated // version also final_meshes.insert(i.label(), i.ptr()); } }
Compartment_Report_Binary_File_Reader::Compartment_Report_Binary_File_Reader (const Report_Specification & specs) : _sequence_start_frame(0), _frame_counter(0), _frame_skip(1.0f), _current_frame(UNDEFINED_FRAME_NUMBER) { static Report_Specialization_Register< Compartment_Report_Binary_File_Reader, float > register_float_buffer; namespace fs = boost::filesystem; Filepath path = uri_to_filename(specs.data_source()); Filepath filename; enum Binary_Type { Multi_Split, Unknown }; Binary_Type binary_type = Unknown; // Checking which type of file if (fs::is_directory(path)) { if (fs::exists((filename = path / (specs.label() + ".rep")))) { binary_type = Multi_Split; } else if (fs::exists((filename = path / (specs.label() + ".bbp")))) { binary_type = Multi_Split; } } else if (fs::exists(path)) { filename = path; if (fs::extension(path) == ".rep") { binary_type = Multi_Split; } else if (fs::extension(path) == ".bbp") { binary_type = Multi_Split; } } if (binary_type == Multi_Split) { _parser.open(filename.string()); } else { throw_exception(Bad_Data("Compartment_Binary_File_Report_Reader: " "no proper binary file for " + specs.data_source() + " found"), FATAL_LEVEL, __FILE__, __LINE__); } }
Compartment_Report_HDF5_File_Reader::Compartment_Report_HDF5_File_Reader (const Report_Specification & specs) : _path(uri_to_filename(specs.data_source())), _report_name(specs.label()), _sequence_start_frame(0), _frame_counter(0), _frame_skip(1.0), _current_framestamp(UNDEFINED_FRAME_NUMBER) { namespace fs = boost::filesystem; static Report_Specialization_Register< Compartment_Report_HDF5_File_Reader, float > register_float_buffer; // Finding a suitable cell name from which has a h5 inside the search path. bool h5_file_found = false; if (!fs::is_directory(_path)) { throw_exception( IO_Error("Compartment_Report_HDF5_File_Reader: data source " "is not a directory: " + specs.data_source()), FATAL_LEVEL, __FILE__, __LINE__); } fs::directory_iterator entry(_path), end_entry; Cell_GID cell_GID = UNDEFINED_CELL_GID; while (cell_GID == UNDEFINED_CELL_GID && entry != end_entry) { fs::path filename = entry->path(); std::string cell_name = fs::basename(filename); char * endptr; if (fs::is_regular(entry->status()) && fs::extension(filename) == ".h5" && // Checking if name matches a[0-9]+ pattern and storing the GID cell_name.size() > 1 && cell_name[0] == 'a' && (cell_GID = strtol(&cell_name[1], &endptr, 10)) > 0 && *endptr == '\0') h5_file_found = true; ++entry; } if (cell_GID == UNDEFINED_CELL_GID) { throw_exception( Bad_Data("Compartment_Report_HDF5_File_Reader: source path " "doesn't contain any valid .h5 file" + specs.data_source()), FATAL_LEVEL, __FILE__, __LINE__); } // Not catching any exception here H5ID file, dataset; open_data_set(cell_GID, "data", file, dataset); float start_time, end_time, delta_time; if (// Trying to read attributes !read_attribute("tstart", dataset, start_time) || !read_attribute("tstop", dataset, end_time) || !read_attribute("Dt", dataset, delta_time) || // And checking them start_time != specs.start_time() || end_time != specs.end_time() || delta_time != specs.timestep()) { /*! \todo Exception commented because the forward_skip is not taken into account in the HDF5. SL - 24.07.08 throw_exception( Bad_Data("Compartment_Report_HDF5_File_Reader: inconsistent" " report metadata found for '" + specs.label() + "' in path " + specs.data_source()), FATAL_LEVEL, __FILE__, __LINE__); */ } }