LCOV - code coverage report
Current view: top level - elsa/generators - EllipCylinderFree.h (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 22 22 100.0 %
Date: 2024-12-21 07:37:52 Functions: 12 14 85.7 %

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

Generated by: LCOV version 1.14