// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include "JFJochReader.h" #include "MiniCBF.h" // Reads a rotation sweep straight from a directory of PILATUS miniCBF files - the form most // facilities still archive - with no conversion step and no libcbf. // // The sweep's geometry comes from the first file's header; the rotation angle of each image comes // from its own header, which costs only the bytes up to the binary separator. Images are decoded on // demand, one per call, so any number of workers can read at once - there is no global lock as there // is on the HDF5 path, HDF5 not being thread-safe. // // A raw CBF carries no analysis results, so this reader has no spots, no reflections and no snapshots; // the dataset it builds is the geometry, the mask and nothing else, exactly as a plain DECTRIS file // with no /entry/MX would give. class JFJochCBFReader : public JFJochReader { std::vector files_; std::shared_ptr dataset_; minicbf::Header header0_; bool LoadImage_i(std::shared_ptr &dataset, DataMessage &message, std::vector &buffer, int64_t image_number, bool update_dataset) override; // Decodes one image into the caller's byte buffer (RawByteBuffer or std::vector) and // returns the image that points at it. template CompressedImage DecodeInto(int64_t image_number, Buffer &buffer) const; public: ~JFJochCBFReader() override = default; // True if the path names something this reader can open: a miniCBF file, or a directory holding // at least one. Cheap - it reads a few kB at most. static bool CanRead(const std::string &path); // path is a directory of *.cbf, or one *.cbf inside the sweep to take the whole directory from. void ReadFiles(const std::string &path); [[nodiscard]] uint64_t GetNumberOfImages() const override; void Close() override; std::shared_ptr GetRawImage(int64_t image_number) override; [[nodiscard]] std::vector ReadSpots(int64_t image) const override; };