Line data Source code
1 : #pragma once 2 : 3 : #include "BlockDescriptor.h" 4 : #include "VolumeDescriptor.h" 5 : 6 : namespace elsa 7 : { 8 : /** 9 : * @brief Class representing a series of identical descriptors concatenated along a new 10 : * dimension (the last dimension of the full descriptor). 11 : * 12 : * @author Nikola Dinev 13 : * 14 : * The blocks are, essentially, slices (though not necessarily two-dimensional) of the full 15 : * descriptor along its last dimension. The last dimension of the full descriptor serves solely 16 : * for the indexing of the different blocks, and will always have a spacing of one and a number 17 : * of coefficients corresponding to the number of blocks. 18 : * 19 : * This descriptor should be the preferred choice when dealing with vector fields. 20 : */ 21 : class IdenticalBlocksDescriptor : public BlockDescriptor 22 : { 23 : public: 24 : /** 25 : * @brief Create a new descriptor, replicating the dataDescriptor numberOfBlocks times 26 : * along a new dimension 27 : * 28 : * @param[in] numberOfBlocks is the desired number of blocks 29 : * @param[in] dataDescriptor is the descriptor that will be replicated numberOfBlocks 30 : * times 31 : * along a new dimension 32 : * 33 : * @throw InvalidArgumentError if numberOfBlocks is non-positive 34 : */ 35 : IdenticalBlocksDescriptor(index_t numberOfBlocks, const DataDescriptor& dataDescriptor); 36 : 37 : /// make copy constructor deletion explicit 38 : IdenticalBlocksDescriptor(const IdenticalBlocksDescriptor&) = delete; 39 : 40 : /// default destructor 41 1680 : ~IdenticalBlocksDescriptor() override = default; 42 : 43 : /// return the number of blocks 44 : index_t getNumberOfBlocks() const override; 45 : 46 : /// return the DataDescriptor of the i-th block 47 : const DataDescriptor& getDescriptorOfBlock(index_t i) const override; 48 : 49 : /// return the offset to access the data of the i-th block 50 : index_t getOffsetOfBlock(index_t i) const override; 51 : 52 : protected: 53 : /// descriptor of a single block 54 : std::unique_ptr<DataDescriptor> _blockDescriptor; 55 : 56 : /// the total number of identical blocks 57 : index_t _numberOfBlocks; 58 : 59 : /// implement the polymorphic clone operation 60 : IdenticalBlocksDescriptor* cloneImpl() const override; 61 : 62 : /// implement the polymorphic comparison operation 63 : bool isEqual(const DataDescriptor& other) const override; 64 : 65 : private: 66 : /// generates the 67 : VolumeDescriptor initBase(index_t numberOfBlocks, const DataDescriptor& dataDescriptor); 68 : }; 69 : } // namespace elsa