LCOV - code coverage report
Current view: top level - elsa/projectors - BoundingBox.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 26 52 50.0 %
Date: 2024-05-16 04:22:26 Functions: 8 16 50.0 %

          Line data    Source code
       1             : #include "BoundingBox.h"
       2             : 
       3             : #include <stdexcept>
       4             : 
       5             : #include "Error.h"
       6             : 
       7             : namespace elsa
       8             : {
       9             :     BoundingBox::BoundingBox(const IndexVector_t& volDims)
      10             :         : _dim(volDims.size()),
      11             :           _min(RealVector_t::Zero(_dim)),
      12             :           _max(volDims.template cast<real_t>())
      13        8665 :     {
      14        8665 :     }
      15             : 
      16             :     BoundingBox::BoundingBox(const RealVector_t& min, const RealVector_t& max)
      17             :         : _dim(min.size()), _min(min), _max(max)
      18           0 :     {
      19           0 :     }
      20             : 
      21             :     index_t BoundingBox::dim() const
      22         382 :     {
      23         382 :         return _dim;
      24         382 :     }
      25             : 
      26             :     RealVector_t BoundingBox::center() const
      27          14 :     {
      28          14 :         return (_max - _min).array() / 2;
      29          14 :     }
      30             : 
      31             :     RealVector_t& BoundingBox::min()
      32       18435 :     {
      33       18435 :         return _min;
      34       18435 :     }
      35             : 
      36             :     const RealVector_t& BoundingBox::min() const
      37     1185825 :     {
      38     1185825 :         return _min;
      39     1185825 :     }
      40             : 
      41             :     RealVector_t& BoundingBox::max()
      42       19681 :     {
      43       19681 :         return _max;
      44       19681 :     }
      45             : 
      46             :     const RealVector_t& BoundingBox::max() const
      47      705435 :     {
      48      705435 :         return _max;
      49      705435 :     }
      50             : 
      51             :     void BoundingBox::translateMin(const real_t& t)
      52           0 :     {
      53           0 :         this->min().array() += t;
      54           0 :     }
      55             : 
      56             :     void BoundingBox::translateMin(const RealVector_t& t)
      57           0 :     {
      58           0 :         this->min() += t;
      59           0 :     }
      60             : 
      61             :     void BoundingBox::translateMax(const real_t& t)
      62           0 :     {
      63           0 :         this->max().array() += t;
      64           0 :     }
      65             : 
      66             :     void BoundingBox::translateMax(const RealVector_t& t)
      67           0 :     {
      68           0 :         this->max() += t;
      69           0 :     }
      70             : 
      71             :     void BoundingBox::recomputeBounds()
      72        1683 :     {
      73        1683 :         RealVector_t min = _min.cwiseMin(_max);
      74        1683 :         RealVector_t max = _min.cwiseMax(_max);
      75             : 
      76        1683 :         _min = min;
      77        1683 :         _max = max;
      78        1683 :     }
      79             : 
      80             :     bool operator==(const BoundingBox& box1, const BoundingBox& box2)
      81           0 :     {
      82           0 :         return box1._min == box2._min && box1._max == box2._max;
      83           0 :     }
      84             : 
      85             :     bool operator!=(const BoundingBox& box1, const BoundingBox& box2)
      86           0 :     {
      87           0 :         return !(box1 == box2);
      88           0 :     }
      89             : 
      90             :     std::ostream& operator<<(std::ostream& stream, const BoundingBox& aabb)
      91           0 :     {
      92           0 :         Eigen::IOFormat fmt(4, 0, ", ", ", ", "", "", "[", "]");
      93           0 :         stream << "AABB { min = " << aabb._min.format(fmt) << ", max = " << aabb._max.format(fmt)
      94           0 :                << " }";
      95             : 
      96           0 :         return stream;
      97           0 :     }
      98             : 
      99             : } // namespace elsa

Generated by: LCOV version 1.14