12 #ifndef BUFFEREDHUVOLUME_H_6014714286 13 #define BUFFEREDHUVOLUME_H_6014714286 48 template<
typename VoxelType,
typename BufferType >
83 ,
myBuffer( new
Composition< BufferType >( new BufferType( size.x() * size.y() * size.z() ) ) )
93 return HUV::abs( ( bufferValue >> (
sizeof( VoxelType ) * 8 - 12 ) ) - 1024 );
101 return ( static_cast< VoxelType >( huValue + 1024 ) << (
sizeof( VoxelType ) * 8 - 12 ) );
109 ,
unsigned int z )
const 111 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
120 return ( *
this )( at.x(), at.y(), at.z() );
126 void setVoxel(
unsigned int x,
unsigned int y,
unsigned int z,
HUV huv )
129 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
138 this->
setVoxel( at.x(), at.y(), at.z(), huv );
168 const std::unique_ptr< Association< BufferType > >
myBuffer;
172 void initializeBuffer()
175 ( myBuffer.get() && myBuffer->get()
176 ,
"No volume data buffer supplied!" );
179 ( myBuffer->get()->size() >=
size.x() *
size.y() *
size.z()
180 ,
"Supplied volume data buffer is of size " 181 << myBuffer->get()->size()
182 <<
" bytes but must be at least " 195 #endif // BUFFEREDHUVOLUME_H_6014714286 Implements HUVolume generically for a particular VoxelType.
const BufferType & buffer() const
References the underlying buffer.
BufferType Buffer
Holds the used buffer type.
static VoxelType HUVToBufferValue(HUV huValue)
Returns the buffer value corresponding to huValue.
static HUV bufferValueToHUV(VoxelType bufferValue)
Returns the HU value corresponding to bufferValue.
#define CARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
HUV operator()(unsigned int x, unsigned int y, unsigned int z) const
Returns HUV of specified voxel.
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
HUV operator()(const math::Vector3ui &at) const
Returns HUV of specified voxel.
math::Vector3ui size
Holds the resolution.
BufferType & buffer()
References the underlying buffer.
BufferedHUVolume(const math::Vector3ui &size, Association< BufferType > *buffer)
Instantiates with , where is size.
void setVoxel(const math::Vector3ui &at, HUV huv)
Sets the HUV of a voxel.
Defines interface to volumetric data.
BufferedHUVolume(const math::Vector3ui &size)
void setVoxel(unsigned int x, unsigned int y, unsigned int z, HUV huv)
Sets the HUV of a voxel.
Defines Carna::base::HUVolume.
const std::unique_ptr< Association< BufferType > > myBuffer
Holds the underlying buffer.
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
Represents a composition, i.e. a strong reference. This basically is a std::unique_ptr that supports ...
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
VoxelType Voxel
Holds the type used to store the value of a single voxel.
Defines Carna::base::Composition.
static HUV abs(T value)
Wraps an absolute HU value.