LCOV - code coverage report
Current view: top level - elsa/generators - EllipCylinder.h (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 20 20 100.0 %
Date: 2024-05-16 04:22:26 Functions: 10 12 83.3 %

          Line data    Source code
       1             : #pragma once
       2             : #include "PhantomDefines.h"
       3             : 
       4             : namespace elsa::phantoms
       5             : {
       6             : 
       7             :     // Fix 2d vector
       8             :     template <typename data_t = double,
       9             :               typename = std::enable_if_t<std::is_floating_point<data_t>::value>>
      10             :     using Vec2X = Eigen::Matrix<data_t, 2, 1>;
      11             : 
      12             :     template <typename data_t = double>
      13             :     class EllipCylinder
      14             :     {
      15             : 
      16             :     private:
      17             :         data_t aSqr;
      18             :         data_t bSqr;
      19             :         data_t aSqrbSqr;
      20             : 
      21             :         Orientation _orientation;
      22             :         data_t _amplit;
      23             :         Vec3i _center;
      24             :         /* halfAxis for the ellipse always in the order of {dx,dy,dz} - e.g. for
      25             :          * ORIENTATION X_AXIS  => {dy,dz}, for ORIENTATION Y_AXIS  => {dx,dz}*/
      26             :         Vec2X<data_t> _halfAxis;
      27             :         data_t _length;
      28             : 
      29             :     public:
      30             :         /**
      31             :          * @param amlpit amplitude wich is added to the voxel on rasterization
      32             :          * @param center center of the object
      33             :          * @param halfAxis halfAxis for the ellipse always in the order of {dx,dy,dz} - e.g. for
      34             :          * ORIENTATION X_AXIS {dy,dz}
      35             :          * @param length the length from one side throught the center to the other side
      36             :          *
      37             :          */
      38             :         EllipCylinder(Orientation o, data_t amplit, Vec3i center, Vec2X<data_t> halfAxis,
      39             :                       data_t length);
      40             : 
      41             :         /**
      42             :          * @brief returns the orientation
      43             :          */
      44         122 :         Orientation getOrientation() const { return _orientation; };
      45             :         /**
      46             :          * @brief returns the amplitude to color the voxel
      47             :          */
      48          65 :         const data_t getAmplitude() const { return _amplit; };
      49             :         /**
      50             :          * @brief returns the center of the EllipCylinder
      51             :          */
      52          65 :         const Vec3i& getCenter() const { return _center; };
      53             :         /**
      54             :          * @brief returns the center of the EllipCylinder
      55             :          */
      56           4 :         const Vec2X<data_t>& getHalfAxis() const { return _halfAxis; };
      57             :         /**
      58             :          * @brief returns the length of the EllipCylinder
      59             :          */
      60          65 :         const data_t getLength() const { return _length; };
      61             : 
      62             :         bool isInEllipCylinder(const Vec3i& idx) const;
      63             :     };
      64             : 
      65             :     /**
      66             :      * @brief Rasterizes the given EllipCylinder in the given data container.
      67             :      */
      68             :     template <Blending b, typename data_t>
      69             :     void rasterize(EllipCylinder<data_t>& el, VolumeDescriptor& dd, DataContainer<data_t>& dc);
      70             : 
      71             : } // namespace elsa::phantoms
      72             : 
      73             : /**
      74             :  * @brief EllipCylinder formatter to use the Logger.h functions
      75             :  */
      76             : template <typename data_t>
      77             : struct fmt::formatter<elsa::phantoms::EllipCylinder<data_t>> : fmt::formatter<std::string> {
      78             :     auto format(elsa::phantoms::EllipCylinder<data_t> ell, format_context& ctx)
      79             :         -> decltype(ctx.out())
      80           4 :     {
      81           4 :         auto _center = ell.getCenter();
      82           4 :         auto _amplit = ell.getAmplitude();
      83           4 :         auto _halfAxis = ell.getHalfAxis();
      84           4 :         auto _length = ell.getLength();
      85           4 :         auto _orientation = ell.getOrientation();
      86             : 
      87           4 :         return format_to(ctx.out(),
      88           4 :                          "EllipCylinder with amplitude {}, Center ({},{},{}) , half axis ({},{}), "
      89           4 :                          "length "
      90           4 :                          "{} along orientation {} ",
      91           4 :                          _amplit, _center[elsa::phantoms::INDEX_X],
      92           4 :                          _center[elsa::phantoms::INDEX_Y], _center[elsa::phantoms::INDEX_Z],
      93           4 :                          _halfAxis[elsa::phantoms::INDEX_X], _halfAxis[elsa::phantoms::INDEX_Y],
      94           4 :                          _length, getString(_orientation));
      95           4 :     }
      96             : };

Generated by: LCOV version 1.14