LCOV - code coverage report
Current view: top level - elsa/generators - TrajectoryGenerator.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 22 24 91.7 %
Date: 2024-12-29 07:37:43 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "TrajectoryGenerator.h"
       2             : #include "VolumeDescriptor.h"
       3             : 
       4             : #include <optional>
       5             : 
       6             : namespace elsa
       7             : {
       8             : 
       9             :     std::pair<IndexVector_t, RealVector_t> TrajectoryGenerator::calculateSizeAndSpacingPerGeometry(
      10             :         const DataDescriptor& volDescr, index_t numberOfPoses,
      11             :         std::optional<IndexVector_t> detectorSize, std::optional<RealVector_t> detectorSpacing)
      12          48 :     {
      13          48 :         const auto dim = volDescr.getNumberOfDimensions();
      14             : 
      15          48 :         IndexVector_t coeffs(dim);
      16          48 :         RealVector_t spacing(dim);
      17             : 
      18          48 :         if (detectorSize) {
      19           0 :             coeffs.head(dim - 1) = detectorSize.value();
      20          48 :         } else {
      21             :             // Scale coeffsPerDim by sqrt(2), this reduces undersampling of the corners, as the
      22             :             // detector is larger than the volume. Cast back and forthe to reduce warnings...
      23             :             // This has to be a RealVector_t, most likely that the cast happens, anyway we get
      24             :             // errors down the line see #86 in Gitlab
      25          48 :             const RealVector_t coeffsPerDim =
      26          48 :                 volDescr.getNumberOfCoefficientsPerDimension().template cast<real_t>();
      27          48 :             const real_t sqrt2 = std::sqrt(2.f);
      28          48 :             const auto coeffsPerDimScaled = (coeffsPerDim * sqrt2).template cast<index_t>();
      29          48 :             coeffs.head(dim - 1) = coeffsPerDimScaled.head(dim - 1);
      30          48 :         }
      31             : 
      32          48 :         RealVector_t spacingPerDim(dim);
      33             : 
      34          48 :         if (detectorSpacing) {
      35           0 :             spacingPerDim.head(dim - 1) = detectorSpacing.value();
      36          48 :         } else {
      37          48 :             spacingPerDim = volDescr.getSpacingPerDimension();
      38          48 :         }
      39             : 
      40          48 :         coeffs[dim - 1] = numberOfPoses; // TODO: with eigen 3.4: `coeffs(Eigen::last) = 1`
      41             : 
      42          48 :         spacing.head(dim - 1) = spacingPerDim.head(dim - 1);
      43          48 :         spacing[dim - 1] = 1; // TODO: same as coeffs
      44             : 
      45             :         // return a pair, then split it using structured bindings
      46          48 :         return std::pair{coeffs, spacing};
      47          48 :     }
      48             : } // namespace elsa

Generated by: LCOV version 1.14