CTL  0.6.1
Computed Tomography Library
projectiondataview.h
1 #ifndef CTL_PROJECTIONDATAVIEW_H
2 #define CTL_PROJECTIONDATAVIEW_H
3 
4 #include <limits>
5 #include <vector>
6 
7 #include "projectiondata.h"
8 
9 namespace CTL {
10 
52 {
53 public:
54  ProjectionDataView(const ProjectionData& projections, std::vector<uint> viewIds);
55  ProjectionDataView(const ProjectionData& projections);
57  ProjectionDataView(ProjectionData&& projections) = delete;
58  ProjectionDataView(ProjectionData&& projections, std::vector<uint> viewIds) = delete;
59 
60  // setter
61  void resetData(const ProjectionData& projections, std::vector<uint> viewIds);
62  void resetData(ProjectionData&& projections, std::vector<uint> viewIds) = delete;
63 
64  // factory for invalid (empty) view, which does not refer to any data
66  // factory for dangling view, for direct use of the view by another function (single expression)
67  static ProjectionDataView dangling(ProjectionData&& projections);
68  static ProjectionDataView dangling(ProjectionData&& projections, std::vector<uint> viewIds);
69 
70  // data access
71  const SingleViewData& first() const;
72  const SingleViewData& view(uint i) const;
75 
76  // other methods
77  ProjectionData combined(const ModuleLayout& layout = ModuleLayout()) const;
78  bool isValid() const;
79  float max() const;
80  float min() const;
81  uint nbViews() const;
82  std::vector<float> toVector() const;
83 
84  // extended interface
85  bool containsView(uint viewId) const;
86  void shuffle();
87  void shuffle(uint seed);
89  ProjectionDataView shuffled(uint seed) const;
90  ProjectionDataView subset(const std::vector<uint>& idsInView) const;
91  ProjectionDataView subset(uint pos = 0, uint count = std::numeric_limits<uint>::max()) const;
92  const std::vector<uint>& viewIds() const;
93 
94  // conversion operations
95  explicit operator ProjectionData() const;
96  ProjectionData dataCopy() const;
97 
98  // comparison operators
99  bool operator==(const ProjectionDataView& other) const;
100  bool operator!=(const ProjectionDataView& other) const;
101 
102  // arithmetic operators
103  ProjectionData operator+(const ProjectionDataView& other) const;
104  ProjectionData operator-(const ProjectionDataView& other) const;
105  ProjectionData operator*(float factor) const;
106  ProjectionData operator/(float divisor) const;
107 
108 private:
109  template <class Function>
110  void parallelExecution(const Function& f) const;
111 
112  const ProjectionData* _dataPtr = nullptr;
113  std::vector<uint> _viewIds;
114 };
115 
116 } // namespace CTL
117 
118 #endif // CTL_PROJECTIONDATAVIEW_H
Simple class that holds the layout of a multi module detector.
Definition: modulelayout.h:32
const std::vector< uint > & viewIds() const
Returns the view ids of the views that are referenced by this instance.
Definition: projectiondataview.cpp:386
ProjectionDataView subset(const std::vector< uint > &idsInView) const
Returns a ProjectionDataView that references the subset with indices idsInView of the data referenced...
Definition: projectiondataview.cpp:333
ProjectionData dataCopy() const
Returns a copy of the data referenced by this instance as ProjectionData.
Definition: projectiondataview.cpp:399
static ProjectionDataView invalidView()
Creates a ProjectionDataView that does not reference any data.
Definition: projectiondataview.cpp:60
void parallelExecution(const Function &f) const
Definition: projectiondataview.cpp:611
ProjectionDataView shuffled() const
Returns a ProjectionDataView that references the same data but with a list of view ids whose order ha...
Definition: projectiondataview.cpp:289
uint nbViews() const
Returns the number of views referenced by this instance.
Definition: projectiondataview.cpp:605
float max() const
Returns the maximum value that appears in all views that are referenced by this instance.
Definition: projectiondataview.cpp:175
void shuffle()
Randomly shuffles the order in which the view ids referenced by this instance appear.
Definition: projectiondataview.cpp:265
bool isValid() const
Returns true if this instance references data.
Definition: projectiondataview.cpp:597
float min() const
Returns the minimum value that appears in all views that are referenced by this instance.
Definition: projectiondataview.cpp:201
void resetData(const ProjectionData &projections, std::vector< uint > viewIds)
Resets the data that is referenced by this instance to projections and the corresponding referenced v...
Definition: projectiondataview.cpp:119
The ProjectionDataView class is a read-only wrapper for a reference to ProjectionData.
Definition: projectiondataview.h:51
ProjectionData combined(const ModuleLayout &layout=ModuleLayout()) const
Returns a ProjectionData copy of the data referenced by this instance that has been combined accordin...
Definition: projectiondataview.cpp:566
std::vector< float > toVector() const
Returns a concatenated vector of all pixel values in the referenced data.
Definition: projectiondataview.cpp:229
ProjectionData operator *(float factor) const
Multiplies data referenced by this instance with factor and returns the result as ProjectionData.
Definition: projectiondataview.cpp:509
The ProjectionData class is the container class used to store all projections from all views.
Definition: projectiondata.h:19
const SingleViewData & first() const
Returns a reference-to-const to the first view referenced by this instance.
Definition: projectiondataview.cpp:142
ProjectionData operator/(float divisor) const
Divides data referenced by this instance by divisor and returns the result as ProjectionData.
Definition: projectiondataview.cpp:523
ProjectionData::Dimensions dimensions() const
Returns the dimensions of the referenced data under consideration that only a subset of views may be ...
Definition: projectiondataview.cpp:133
bool operator==(const ProjectionDataView &other) const
Returns true if this instance and other are equal.
Definition: projectiondataview.cpp:425
bool containsView(uint viewId) const
Returns true if this instance references the view with id viewId from the original dataset.
Definition: projectiondataview.cpp:254
Struct that holds the dimensions of a ProjectionData object.
Definition: projectiondata.h:118
static ProjectionDataView dangling(ProjectionData &&projections)
Creates a ProjectionDataView on temporary (r-value) projections.
Definition: projectiondataview.cpp:94
const SingleViewData & view(uint i) const
Returns a reference-to-const to i-th view referenced by this instance.
Definition: projectiondataview.cpp:152
Struct that holds the dimensions, namely number of channels, rows and modules, of a SingleViewData ob...
Definition: singleviewdata.h:114
unsigned int uint
Qt style alias for unsigned int.
Definition: modulelayout.h:6
ProjectionData operator+(const ProjectionDataView &other) const
Computes the sum of this instance and other and returns the result as ProjectionData.
Definition: projectiondataview.cpp:455
bool operator!=(const ProjectionDataView &other) const
Returns true if this instance and other are not equal.
Definition: projectiondataview.cpp:447
ProjectionDataView()
Creates a ProjectionDataView that does not reference any data.
Definition: projectiondataview.cpp:47
ProjectionData operator-(const ProjectionDataView &other) const
Computes the difference between this instance and other and returns the result as ProjectionData.
Definition: projectiondataview.cpp:482
SingleViewData::Dimensions viewDimensions() const
Returns the view dimensions (i.e. number of channels, rows, and modules) of the data referenced by th...
Definition: projectiondataview.cpp:163
The SingleViewData class is the container class used to store all projections from one particular vie...
Definition: singleviewdata.h:19