Line data Source code
1 : #pragma once 2 : 3 : #include "elsaDefines.h" 4 : #include "DataDescriptor.h" 5 : #include "Geometry.h" 6 : #include "TypeCasts.hpp" 7 : 8 : #include <optional> 9 : #include "Eigen/Geometry" 10 : 11 : namespace elsa 12 : { 13 : /** 14 : * @brief Class representing metadata for linearized n-dimensional signal stored in memory. It 15 : * is a base class for different type signals captured by some kind of detectors (i.e. a planar 16 : * detector, curved or some other shaped detector). It additionally stores information about the 17 : * different poses of a trajectory. 18 : */ 19 : class DetectorDescriptor : public DataDescriptor 20 : { 21 : public: 22 : /// There is not default signal 23 : DetectorDescriptor() = delete; 24 : 25 : /// Default destructor 26 57312 : ~DetectorDescriptor() override = default; 27 : 28 : /** 29 : * @brief Construct a DetectorDescriptor with a number of coefficients for each dimension 30 : * and a list of geometry poses 31 : */ 32 : DetectorDescriptor(const IndexVector_t& numOfCoeffsPerDim, 33 : const std::vector<Geometry>& geometryList); 34 : /** 35 : * @brief Construct a DetectorDescriptor with a number of coefficients and spacing for each 36 : * dimension and a list of geometry poses 37 : */ 38 : DetectorDescriptor(const IndexVector_t& numOfCoeffsPerDim, 39 : const RealVector_t& spacingPerDim, 40 : const std::vector<Geometry>& geometryList); 41 : 42 : /** 43 : * @brief Overload of computeRayToDetector with a single detectorIndex. Compute the pose and 44 : * coord index using getCoordinateFromIndex and call overload 45 : */ 46 : RealRay_t computeRayFromDetectorCoord(const index_t detectorIndex) const; 47 : 48 : /** 49 : * @brief Overload of computeRayToDetector with a single coord vector. This vector encodes 50 : * the pose index and the detector coordinate. So for a 1D detector, this will be 2D and the 51 : * second dimension, will reference the pose index 52 : */ 53 : RealRay_t computeRayFromDetectorCoord(const IndexVector_t coord) const; 54 : 55 : /** 56 : * @brief Compute a ray from the source from a pose to the given detector coordinate 57 : * 58 : * @param[in] detectorCoord Vector of size dim - 1, specifying the coordinate the ray should 59 : * hit 60 : * @param[in] poseIndex index into geometryList array, which pose to use for ray computation 61 : * 62 : */ 63 : virtual RealRay_t computeRayFromDetectorCoord(const RealVector_t& detectorCoord, 64 : const index_t poseIndex) const = 0; 65 : 66 : /** 67 : * @brief Computes the projection of the center of a voxel to the detector and its scaling 68 : * !!be aware that this function is not optimized, as it uses dynamic sized arrays!! 69 : * 70 : * @param[in] voxelCoord coordinate of the voxel to be projected in volume coordinates 71 : * @param[in] poseIndex index into geometryList array, which pose to use for projection 72 : * @return std::pair<RealVector_t, real_t> detector coordinate and scaling on detector 73 : */ 74 : virtual std::pair<RealVector_t, real_t> 75 : projectAndScaleVoxelOnDetector(const RealVector_t& voxelCoord, 76 : const index_t poseIndex) const; 77 : 78 : /// Get the number of poses used in the geometry 79 : index_t getNumberOfGeometryPoses() const; 80 : 81 : /// Get the list of geometry poses 82 : const std::vector<Geometry>& getGeometry() const; 83 : 84 : /// Get the i-th geometry in the trajectory. 85 : Geometry getGeometryAt(const index_t index) const; 86 : 87 : /// Create another DetectorDescriptor of same type sharing all parameters except geometries 88 : /// Useful to split datasets for stochastic methods 89 : virtual std::unique_ptr<DetectorDescriptor> 90 : cloneWithGeometry(std::vector<Geometry> geometries) const = 0; 91 : 92 : protected: 93 : /// implement the polymorphic comparison operation 94 : bool isEqual(const DataDescriptor& other) const override; 95 : 96 : /// List of geometry poses 97 : std::vector<Geometry> _geometry; 98 : }; 99 : } // namespace elsa