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