LCOV - code coverage report
Current view: top level - projectors - BoundingBox.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 16 25 64.0 %
Date: 2022-05-27 02:48:28 Functions: 3 6 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       18538 :     BoundingBox::BoundingBox(const IndexVector_t& volumeDimensions) : _dim(volumeDimensions.size())
      10             :     {
      11             :         // sanity check
      12       18538 :         if (volumeDimensions.size() < 2 || volumeDimensions.size() > 3)
      13           0 :             throw InvalidArgumentError("BoundingBox: can only deal with the 2d/3d cases");
      14             : 
      15       18538 :         _min.setZero();
      16       18538 :         _max = volumeDimensions.template cast<real_t>();
      17             : 
      18       18538 :         _voxelCoordToIndexVector[0] = 1;
      19       18538 :         _voxelCoordToIndexVector[1] = volumeDimensions[1];
      20       18538 :         if (_dim == 3)
      21       12217 :             _voxelCoordToIndexVector[2] = volumeDimensions[2] * volumeDimensions[2];
      22       18538 :     }
      23             : 
      24          14 :     RealVector_t BoundingBox::center() const { return (_max - _min).array() / 2; }
      25             : 
      26       10180 :     void BoundingBox::recomputeBounds()
      27             :     {
      28       20360 :         RealVector_t min = _min.cwiseMin(_max);
      29       20360 :         RealVector_t max = _min.cwiseMax(_max);
      30             : 
      31       10180 :         _min = min;
      32       10180 :         _max = max;
      33       10180 :     }
      34             : 
      35           0 :     bool operator==(const BoundingBox& box1, const BoundingBox& box2)
      36             :     {
      37           0 :         return box1._min == box2._min && box1._max == box2._max;
      38             :     }
      39             : 
      40           0 :     bool operator!=(const BoundingBox& box1, const BoundingBox& box2) { return !(box1 == box2); }
      41             : 
      42           0 :     std::ostream& operator<<(std::ostream& stream, const BoundingBox& aabb)
      43             :     {
      44           0 :         Eigen::IOFormat fmt(4, 0, ", ", ", ", "", "", "[", "]");
      45           0 :         stream << "AABB { min = " << aabb._min.format(fmt) << ", max = " << aabb._max.format(fmt)
      46           0 :                << " }";
      47             : 
      48           0 :         return stream;
      49             :     }
      50             : 
      51             : } // namespace elsa

Generated by: LCOV version 1.15