6 #ifndef BUFFEREDINTENSITYVOLUME_H_6014714286 7 #define BUFFEREDINTENSITYVOLUME_H_6014714286 41 template<
typename VoxelType,
typename BufferType >
76 ,
myBuffer( new
Composition< BufferType >( new BufferType( size.x() * size.y() * size.z() ) ) )
86 return bufferValue /
static_cast< float >( ( 1 << ( 8 *
sizeof( VoxelType ) ) ) - 1 );
94 CARNA_ASSERT_EX( 0 <= intensity && intensity <= 1,
"Intensity out of range: " << intensity );
95 const auto valueMax = ( 1 << ( 8 *
sizeof( VoxelType ) ) ) - 1;
96 float value = intensity * valueMax + 0.5f;
97 if( value > valueMax ) value = valueMax;
98 return static_cast< VoxelType
>( value );
106 ,
unsigned int z )
const 108 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
116 return ( *
this )( at.x(), at.y(), at.z() );
122 void setVoxel(
unsigned int x,
unsigned int y,
unsigned int z,
float intensity )
125 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
133 this->
setVoxel( at.x(), at.y(), at.z(), intensity );
163 const std::unique_ptr< Association< BufferType > >
myBuffer;
167 void initializeBuffer()
170 ( myBuffer.get() && myBuffer->get()
171 ,
"No volume data buffer supplied!" );
174 ( myBuffer->get()->size() >=
size.x() *
size.y() *
size.z()
175 ,
"Supplied volume data buffer is of size " 176 << myBuffer->get()->size()
177 <<
" bytes but must be at least " 190 #endif // BUFFEREDINTENSITYVOLUME_H_6014714286 void setVoxel(unsigned int x, unsigned int y, unsigned int z, float intensity)
Sets the HUV of a voxel.
void setVoxel(const math::Vector3ui &at, float intensity)
const std::unique_ptr< Association< BufferType > > myBuffer
Holds the underlying buffer.
Defines interface to volume data.
BufferedIntensityVolume(const math::Vector3ui &size)
Implements IntensityVolume generically for a particular VoxelType.
static float bufferValueToIntensity(VoxelType bufferValue)
Returns the intensity 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...
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
Defines Carna::base::IntensityVolume.
VoxelType Voxel
Holds the type used to store the value of a single voxel.
float operator()(const math::Vector3ui &at) const
math::Vector3ui size
Holds the resolution.
float operator()(unsigned int x, unsigned int y, unsigned int z) const
Returns intensity of specified voxel.
BufferType & buffer()
References the underlying buffer.
static VoxelType intensityToBufferValue(float intensity)
Returns the buffer value corresponding to an intensity.
BufferedIntensityVolume(const math::Vector3ui &size, Association< BufferType > *buffer)
Instantiates with , where is size.
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
Represents a composition, i.e. a strong reference. This basically is a std::unique_ptr that supports ...
const BufferType & buffer() const
References the underlying buffer.
BufferType Buffer
Holds the used buffer type.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Defines Carna::base::Composition.