@@ -92,7 +92,23 @@ BundleHistory readH5BundleHistory(const std::filesystem::path& filepath) {
9292 return raySoAToBundleHistory (rays);
9393}
9494
95- void writeH5RaySoA (const std::filesystem::path& filepath, const RaySoA& rays, const RayAttrFlag attr) {
95+ std::vector<std::string> readH5ElementNames (const std::filesystem::path& filepath) {
96+ RAYX_VERB << " reading element names from '" << filepath;
97+
98+ auto element_names = std::vector<std::string>();
99+
100+ try {
101+ auto file = HighFive::File (filepath.string (), HighFive::File::ReadOnly);
102+
103+ file.getDataSet (" /rayx/element_names" ).read (element_names);
104+ } catch (const std::exception& e) {
105+ RAYX_EXIT << " exception caught while attempting to read h5 file: " << e.what ();
106+ }
107+
108+ return element_names;
109+ }
110+
111+ void writeH5RaySoA (const std::filesystem::path& filepath, const std::vector<std::string>& element_names, const RaySoA& rays, const RayAttrFlag attr) {
96112 RAYX_PROFILE_FUNCTION_STDOUT ();
97113 RAYX_VERB << " writing rays to '" << filepath << " ' with attribute flags: "
98114 << std::bitset<static_cast <RayAttrFlagType>(RayAttrFlag::RayAttrFlagCount)>(static_cast <RayAttrFlagType>(attr));
@@ -108,14 +124,16 @@ void writeH5RaySoA(const std::filesystem::path& filepath, const RaySoA& rays, co
108124#undef X
109125
110126 file.createDataSet (" rayx/num_paths" , rays.num_paths );
127+ file.createDataSet (" rayx/element_names" , element_names);
111128 } catch (const std::exception& e) {
112129 RAYX_EXIT << " exception caught while attempting to write h5 file: " << e.what ();
113130 }
114131}
115132
116- void writeH5BundleHistory (const std::filesystem::path& filepath, const BundleHistory& bundle, const RayAttrFlag attr) {
133+ void writeH5BundleHistory (const std::filesystem::path& filepath, const std::vector<std::string>& element_names, const BundleHistory& bundle,
134+ const RayAttrFlag attr) {
117135 const auto rays = bundleHistoryToRaySoA (bundle);
118- writeH5RaySoA (filepath, rays, attr);
136+ writeH5RaySoA (filepath, element_names, rays, attr);
119137}
120138
121139} // namespace RAYX
0 commit comments