LCOV - code coverage report
Current view: top level - generators/tests - test_SphereTrajectoryGenerator.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 24 24 100.0 %
Date: 2022-02-28 03:37:41 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           2 : TEST_CASE("SphereTrajectoryGenerator: Create a Spherical Trajectory")
      20             : {
      21             :     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           3 :     GIVEN("A 2D descriptor and 256 poses")
      29             :     {
      30           1 :         index_t numberOfPoses = 256;
      31           2 :         IndexVector_t volSize(2);
      32           1 :         volSize << s, s;
      33           2 :         VolumeDescriptor desc{volSize};
      34             : 
      35           2 :         WHEN("Trying to create a 2D spherical trajectory")
      36             :         {
      37           1 :             geometry::SourceToCenterOfRotation diffCenterSource(s * 100);
      38           1 :             geometry::CenterOfRotationToDetector diffCenterDetector(s);
      39             : 
      40           2 :             REQUIRE_THROWS_AS(SphereTrajectoryGenerator::createTrajectory(
      41             :                                   numberOfPoses, desc, 5, diffCenterSource, diffCenterDetector),
      42             :                               InvalidArgumentError);
      43             :         }
      44             :     }
      45             : 
      46           3 :     GIVEN("A 3D descriptor and 256 poses")
      47             :     {
      48           1 :         index_t numberOfPoses = 256;
      49           2 :         IndexVector_t volSize(3);
      50           1 :         volSize << s, s, s;
      51           2 :         VolumeDescriptor desc{volSize};
      52             : 
      53           2 :         WHEN("We create a spherical trajectory with 3 circular trajectories and 256 poses for this "
      54             :              "scenario")
      55             :         {
      56           1 :             geometry::SourceToCenterOfRotation diffCenterSource(s * 100);
      57           1 :             geometry::CenterOfRotationToDetector diffCenterDetector(s);
      58             : 
      59             :             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             :         }
      66             :     }
      67           2 : }

Generated by: LCOV version 1.15