LCOV - code coverage report
Current view: top level - core/Descriptors - IdenticalBlocksDescriptor.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 0 37 0.0 %
Date: 2022-08-04 03:43:28 Functions: 0 7 0.0 %

          Line data    Source code
       1             : #include "IdenticalBlocksDescriptor.h"
       2             : #include "VolumeDescriptor.h"
       3             : #include "Error.h"
       4             : 
       5             : namespace elsa
       6             : {
       7           0 :     IdenticalBlocksDescriptor::IdenticalBlocksDescriptor(index_t numberOfBlocks,
       8           0 :                                                          const DataDescriptor& dataDescriptor)
       9           0 :         : BlockDescriptor{initBase(numberOfBlocks, dataDescriptor)},
      10           0 :           _blockDescriptor{dataDescriptor.clone()},
      11           0 :           _numberOfBlocks{numberOfBlocks}
      12             : 
      13             :     {
      14           0 :     }
      15             : 
      16           0 :     index_t IdenticalBlocksDescriptor::getNumberOfBlocks() const { return _numberOfBlocks; }
      17             : 
      18           0 :     const DataDescriptor& IdenticalBlocksDescriptor::getDescriptorOfBlock(index_t i) const
      19             :     {
      20           0 :         if (i < 0 || i >= _numberOfBlocks)
      21           0 :             throw InvalidArgumentError("BlockDescriptor: index i is out of bounds");
      22             : 
      23           0 :         return *_blockDescriptor;
      24             :     }
      25             : 
      26           0 :     index_t IdenticalBlocksDescriptor::getOffsetOfBlock(index_t i) const
      27             :     {
      28           0 :         if (i < 0 || i >= _numberOfBlocks)
      29           0 :             throw InvalidArgumentError("BlockDescriptor: index i is out of bounds");
      30             : 
      31           0 :         return i * _blockDescriptor->getNumberOfCoefficients();
      32             :     }
      33             : 
      34           0 :     IdenticalBlocksDescriptor* IdenticalBlocksDescriptor::cloneImpl() const
      35             :     {
      36           0 :         return new IdenticalBlocksDescriptor(_numberOfBlocks, *_blockDescriptor);
      37             :     }
      38             : 
      39           0 :     bool IdenticalBlocksDescriptor::isEqual(const DataDescriptor& other) const
      40             :     {
      41           0 :         if (!BlockDescriptor::isEqual(other))
      42           0 :             return false;
      43             : 
      44             :         // static cast as type checked in base comparison
      45           0 :         auto otherBlock = static_cast<const IdenticalBlocksDescriptor*>(&other);
      46             : 
      47           0 :         if (*_blockDescriptor != *otherBlock->_blockDescriptor)
      48           0 :             return false;
      49             : 
      50           0 :         return true;
      51             :     }
      52             : 
      53           0 :     VolumeDescriptor IdenticalBlocksDescriptor::initBase(index_t numberOfBlocks,
      54             :                                                          const DataDescriptor& dataDescriptor)
      55             :     {
      56           0 :         if (numberOfBlocks < 1)
      57           0 :             throw InvalidArgumentError(
      58           0 :                 "IdenticalBlockDescriptor: number of blocks has to be positive");
      59             : 
      60           0 :         auto numberOfCoeffs = dataDescriptor.getNumberOfCoefficientsPerDimension();
      61           0 :         index_t numDim = numberOfCoeffs.size() + 1;
      62           0 :         auto spacingOfCoeffs = dataDescriptor.getSpacingPerDimension();
      63           0 :         numberOfCoeffs.conservativeResize(numDim);
      64           0 :         spacingOfCoeffs.conservativeResize(numDim);
      65           0 :         numberOfCoeffs[numDim - 1] = numberOfBlocks;
      66           0 :         spacingOfCoeffs[numDim - 1] = 1;
      67             : 
      68           0 :         return VolumeDescriptor(numberOfCoeffs, spacingOfCoeffs);
      69           0 :     }
      70             : } // namespace elsa

Generated by: LCOV version 1.14