1 #ifndef CTL_VOXELVOLUME_H     2 #define CTL_VOXELVOLUME_H     9 struct VoxelCoordinates;
    22     std::string 
info() 
const;
    40     std::string 
info() 
const;
    54     std::string 
info() 
const;
    82     template <
class IteratorType>
    92     using reverse_iterator       = std::reverse_iterator<iterator>;
    93     using const_reverse_iterator = std::reverse_iterator<const_iterator>;
   101     reverse_iterator rbegin();
   102     reverse_iterator rend();
   103     const_reverse_iterator rbegin() 
const;
   104     const_reverse_iterator rend() 
const;
   105     const_reverse_iterator crbegin() 
const;
   106     const_reverse_iterator crend() 
const;
   124                 std::vector<T> 
data);
   145     const std::vector<T>& 
data() 
const;
   146     std::vector<T>& 
data();
   162     void setVoxelSize(
float xSize, 
float ySize, 
float zSize);
   174     void fill(
const T& fillValue);
   216     template <
class Function>
   222     using Generic3DCoord::Generic3DCoord;
   224     float& x() { 
return coord1(); }
   225     float& y() { 
return coord2(); }
   226     float& z() { 
return coord3(); }
   227     const float& x()
 const { 
return coord1(); }
   228     const float& y()
 const { 
return coord2(); }
   229     const float& z()
 const { 
return coord3(); }
   234     using Generic3DIndex::Generic3DIndex;
   236     uint& x() { 
return idx1(); }
   237     uint& y() { 
return idx2(); }
   238     uint& z() { 
return idx3(); }
   239     const uint& x()
 const { 
return idx1(); }
   240     const uint& y()
 const { 
return idx2(); }
   241     const uint& z()
 const { 
return idx3(); }
   246 template <
class IteratorType>
   250     using iterator_category = std::bidirectional_iterator_tag;
   251     using value_type        = 
typename IteratorType::value_type;
   252     using difference_type   = 
typename IteratorType::difference_type;
   253     using pointer           = 
typename IteratorType::pointer;
   254     using reference         = 
typename IteratorType::reference;
   256     VoxelIterator(IteratorType voxel = {}, 
const VoxelVolume<T>* ptrToVol = 
nullptr);
   258     friend bool operator==(
const VoxelIterator& left, 
const VoxelIterator& right)
   260         return left._dataItr == right._dataItr;
   262     friend bool operator!=(
const VoxelIterator& left, 
const VoxelIterator& right)
   264         return left._dataItr != right._dataItr;
   267     VoxelIterator& operator++();
   268     VoxelIterator  operator++(
int);
   269     VoxelIterator& operator--();
   270     VoxelIterator  operator--(
int);
   272     reference 
operator*()
 const { 
return *_dataItr; }
   273     pointer   operator->()
 const { 
return _dataItr.operator->(); }
   275     operator VoxelIterator<typename std::vector<T>::const_iterator>() 
const;
   277     reference value() 
const;
   278     VoxelIndex voxelIndex() 
const;
   281     IteratorType _dataItr;
   282     const VoxelVolume<T>* _ptrToVol;
   287 template <
typename ToType, 
typename FromType, 
typename ConversionFun = ToType (*)(const FromType&)>
   288 VoxelVolume<ToType> 
convertTo(
const VoxelVolume<FromType>& volume,
   289                               ConversionFun f = [](
const FromType& val) { 
return static_cast<ToType>(val); });
   290 float interpolate3D(
const VoxelVolume<float>& volume, 
const mat::Matrix<3, 1>& position);
   291 float interpolate3D(
const VoxelVolume<float>& volume, 
double x, 
double y, 
double z);
   295 using assist::convertTo;
   299 #include "voxelvolume.tpp"   303 #endif // CTL_VOXELVOLUME_H void setData(std::vector< T > &&data)
Definition: voxelvolume.tpp:1130
bool operator!=(const VoxelVolumeDimensions &other) const
Definition: voxelvolume.tpp:812
bool operator==(const VoxelVolumeVoxelSize &other) const
Definition: voxelvolume.tpp:836
static VoxelVolume< T > cube(uint nbVoxel, float voxelSize, const T &fillValue)
Definition: voxelvolume.tpp:182
Definition: voxelvolume.h:220
VoxelVolume< T > & operator-=(const VoxelVolume< T > &other)
Definition: voxelvolume.tpp:624
std::string info() const
Definition: voxelvolume.tpp:820
VoxelVolume< T > operator-(const VoxelVolume< T > &other) const
Definition: voxelvolume.tpp:746
void setVolumeOffset(const Offset &offset)
Definition: voxelvolume.tpp:1080
std::vector< T > _data
The internal data of the volume.
Definition: voxelvolume.h:211
Definition: coordinates.h:24
Chunk2D< T > sliceY(uint slice) const
Definition: voxelvolume.tpp:454
Definition: voxelvolume.h:15
void allocateMemory()
Definition: voxelvolume.tpp:925
const Dimensions & dimensions() const
Definition: voxelvolume.tpp:1120
static VoxelVolume< T > ball(float radius, float voxelSize, const T &fillValue)
Definition: voxelvolume.tpp:199
const Dimensions & nbVoxels() const
Definition: voxelvolume.tpp:1012
bool operator==(const VoxelVolumeDimensions &other) const
Definition: voxelvolume.tpp:804
T min() const
Definition: voxelvolume.tpp:580
void parallelExecution(const Function &f) const
Definition: voxelvolume.tpp:1165
std::vector< T >::reference operator()(uint x, uint y, uint z)
Definition: voxelvolume.tpp:382
T max() const
Definition: voxelvolume.tpp:568
The VoxelVolume class provides a simple container for storage of voxelized 3D volume data.
Definition: ctsystemview.h:14
Definition: voxelvolume.h:83
size_t totalNbElements() const
Definition: voxelvolume.tpp:828
Definition: voxelvolume.h:30
static VoxelVolume< T > cylinderX(float radius, float height, float voxelSize, const T &fillValue)
Definition: voxelvolume.tpp:222
Dimensions _dim
The dimensions of the volume.
Definition: voxelvolume.h:207
void fill(const T &fillValue)
Definition: voxelvolume.tpp:948
The Chunk2D class provides a simple container for storage of 2D image data.
Definition: chunk2d.h:51
Definition: voxelvolume.h:232
bool operator!=(const VoxelVolumeOffset &other) const
Definition: voxelvolume.tpp:888
bool operator==(const VoxelVolumeOffset &other) const
Definition: voxelvolume.tpp:879
const Offset & offset() const
Definition: voxelvolume.tpp:1021
VoxelVolume< T > operator+(const VoxelVolume< T > &other) const
Definition: voxelvolume.tpp:728
VoxelVolume(const Dimensions &nbVoxels)
Definition: voxelvolume.tpp:21
float smallestVoxelSize() const
Definition: voxelvolume.tpp:1071
static VoxelVolume< T > cylinderZ(float radius, float height, float voxelSize, const T &fillValue)
Definition: voxelvolume.tpp:270
void freeMemory()
Definition: voxelvolume.tpp:372
VoxelCoordinates coordinates(const VoxelIndex &index) const
Definition: voxelvolume.tpp:1183
bool isIsotropic() const
Definition: voxelvolume.tpp:1001
bool hasEqualSizeAs(const std::vector< T > &other) const
Definition: voxelvolume.tpp:1155
static VoxelVolume< T > fromChunk2DStack(const std::vector< Chunk2D< T >> &stack)
Definition: voxelvolume.tpp:145
VoxelCoordinates cornerVoxel() const
Definition: voxelvolume.tpp:1210
Definition: voxelvolume.h:47
VoxelVolume< T > reslicedByX(bool reverse=false) const
Definition: voxelvolume.tpp:504
VoxelSize _size
The size of individual voxels (in mm).
Definition: voxelvolume.h:208
Definition: coordinates.h:52
T * rawData()
Definition: voxelvolume.tpp:1032
std::string info() const
Definition: voxelvolume.tpp:896
Chunk2D< T > sliceZ(uint slice) const
Definition: voxelvolume.tpp:480
Offset _offset
The positional offset of the volume (in mm).
Definition: voxelvolume.h:209
unsigned int uint
Qt style alias for unsigned int.
Definition: modulelayout.h:6
static VoxelVolume< T > cylinderY(float radius, float height, float voxelSize, const T &fillValue)
Definition: voxelvolume.tpp:246
Chunk2D< ToType > convertTo(const Chunk2D< FromType > &chunk2d, ConversionFun f=[](const FromType &val) { return static_cast< ToType >(val);})
Returns a Chunk2D<ToType>, where ToType must be specified as a template parameter.
Definition: chunk2d.tpp:737
VoxelVolume< T > & operator/=(const T &divisor)
Definition: voxelvolume.tpp:705
size_t allocatedElements() const
Definition: voxelvolume.tpp:911
VoxelVolume< T > reslicedByZ(bool reverse=false) const
Definition: voxelvolume.tpp:550
VoxelVolume< T > reslicedByY(bool reverse=false) const
Definition: voxelvolume.tpp:527
VoxelVolume< T > operator *(const T &factor) const
Definition: voxelvolume.tpp:782
std::string info() const
Definition: voxelvolume.tpp:853
const std::vector< T > & data() const
Definition: voxelvolume.tpp:969
float product() const
Definition: voxelvolume.tpp:862
void setVoxelSize(const VoxelSize &size)
Definition: voxelvolume.tpp:1099
size_t totalVoxelCount() const
Definition: voxelvolume.tpp:1053
VoxelVolume< T > & operator+=(const VoxelVolume< T > &other)
Definition: voxelvolume.tpp:597
VoxelIndex index(const VoxelCoordinates &coordinates) const
Definition: voxelvolume.tpp:1226
VoxelVolume< T > operator/(const T &divisor) const
Definition: voxelvolume.tpp:793
bool isIsotropic() const
Definition: voxelvolume.tpp:871
bool operator!=(const VoxelVolumeVoxelSize &other) const
Definition: voxelvolume.tpp:845
const VoxelSize & voxelSize() const
Definition: voxelvolume.tpp:1062
bool hasData() const
Definition: voxelvolume.tpp:989
Chunk2D< T > sliceX(uint slice) const
Definition: voxelvolume.tpp:430
VoxelVolume< T > & operator *=(const T &factor)
Definition: voxelvolume.tpp:686
const std::vector< T > & constData() const
Definition: voxelvolume.tpp:960
VoxelCoordinates volumeCorner() const
Definition: voxelvolume.tpp:1260