LCOV - code coverage report
Current view: top level - elsa/generators/tests - test_SphereTrajectoryGenerator.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 37 37 100.0 %
Date: 2022-08-25 03:05:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file test_SphereTrajectoryGenerator.cpp
       3             :  *
       4             :  * @brief Test for SphereTrajectoryGenerator class
       5             :  *
       6             :  * @author Michael Loipführer - initial code
       7             :  */
       8             : 
       9             : #include "doctest/doctest.h"
      10             : 
      11             : #include "SphereTrajectoryGenerator.h"
      12             : 
      13             : #include "Logger.h"
      14             : #include "VolumeDescriptor.h"
      15             : 
      16             : using namespace elsa;
      17             : using namespace doctest;
      18             : 
      19             : TEST_CASE("SphereTrajectoryGenerator: Create a Spherical Trajectory")
      20           2 : {
      21           2 :     using namespace geometry;
      22             : 
      23           2 :     const index_t s = 64;
      24             : 
      25             :     // Detector size is the volume size scalled by the square root of 2
      26           2 :     const auto expectedDetectorSize = static_cast<index_t>(s * std::sqrt(2));
      27             : 
      28           2 :     GIVEN("A 2D descriptor and 256 poses")
      29           2 :     {
      30           1 :         index_t numberOfPoses = 256;
      31           1 :         IndexVector_t volSize(2);
      32           1 :         volSize << s, s;
      33           1 :         VolumeDescriptor desc{volSize};
      34             : 
      35           1 :         WHEN("Trying to create a 2D spherical trajectory")
      36           1 :         {
      37           1 :             geometry::SourceToCenterOfRotation diffCenterSource(s * 100);
      38           1 :             geometry::CenterOfRotationToDetector diffCenterDetector(s);
      39             : 
      40           1 :             REQUIRE_THROWS_AS(SphereTrajectoryGenerator::createTrajectory(
      41           1 :                                   numberOfPoses, desc, 5, diffCenterSource, diffCenterDetector),
      42           1 :                               InvalidArgumentError);
      43           1 :         }
      44           1 :     }
      45             : 
      46           2 :     GIVEN("A 3D descriptor and 256 poses")
      47           2 :     {
      48           1 :         index_t numberOfPoses = 256;
      49           1 :         IndexVector_t volSize(3);
      50           1 :         volSize << s, s, s;
      51           1 :         VolumeDescriptor desc{volSize};
      52             : 
      53           1 :         WHEN("We create a spherical trajectory with 3 circular trajectories and 256 poses for this "
      54           1 :              "scenario")
      55           1 :         {
      56           1 :             geometry::SourceToCenterOfRotation diffCenterSource(s * 100);
      57           1 :             geometry::CenterOfRotationToDetector diffCenterDetector(s);
      58             : 
      59           1 :             auto sdesc = SphereTrajectoryGenerator::createTrajectory(
      60           1 :                 numberOfPoses, desc, 5, diffCenterSource, diffCenterDetector);
      61             : 
      62             :             // Check that the detector size is correct
      63           1 :             REQUIRE_EQ(sdesc->getNumberOfCoefficientsPerDimension()[0], expectedDetectorSize);
      64           1 :             REQUIRE_EQ(sdesc->getNumberOfCoefficientsPerDimension()[1], expectedDetectorSize);
      65           1 :         }
      66           1 :     }
      67           2 : }

Generated by: LCOV version 1.14