15#ifndef BUFFEREDINTENSITYVOLUME_H_6014714286
16#define BUFFEREDINTENSITYVOLUME_H_6014714286
49template<
typename VoxelType,
typename BufferType >
94 return bufferValue /
static_cast< float >( ( 1 << ( 8 *
sizeof( VoxelType ) ) ) - 1 );
102 LIBCARNA_ASSERT_EX( 0 <= intensity && intensity <= 1,
"Intensity out of range: " << intensity );
103 const auto valueMax = ( 1 << ( 8 *
sizeof( VoxelType ) ) ) - 1;
104 float value = intensity *
valueMax + 0.5f;
106 return static_cast< VoxelType
>( value );
114 ,
unsigned int z )
const
116 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
124 return ( *
this )(
at.x(),
at.y(),
at.z() );
130 void setVoxel(
unsigned int x,
unsigned int y,
unsigned int z,
float intensity )
133 const std::size_t index = x +
size.x() * y +
size.y() *
size.x() * z;
171 const std::unique_ptr< Association< BufferType > >
myBuffer;
175 void initializeBuffer()
179 ,
"No volume data buffer supplied!" );
183 ,
"Supplied volume data buffer is of size "
185 <<
" bytes but must be at least "
Defines LibCarna::base::Composition.
Defines LibCarna::base::IntensityVolume.
Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.
#define LIBCARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define LIBCARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
Implements IntensityVolume generically for a particular VoxelType.
void setVoxel(const math::Vector3ui &at, float intensity)
BufferType & buffer()
References the underlying buffer.
VoxelType Voxel
Holds the type used to store the value of a single voxel.
static float bufferValueToIntensity(VoxelType bufferValue)
Returns the intensity value corresponding to bufferValue.
BufferedIntensityVolume(const math::Vector3ui &size, Association< BufferType > *buffer)
Instantiates with , where is size.
float operator()(const math::Vector3ui &at) const
BufferType Buffer
Holds the used buffer type.
void setVoxel(unsigned int x, unsigned int y, unsigned int z, float intensity)
Sets the intensity value of a voxel.
const std::unique_ptr< Association< BufferType > > myBuffer
Holds the underlying buffer.
float operator()(unsigned int x, unsigned int y, unsigned int z) const
Returns intensity of specified voxel.
static VoxelType intensityToBufferValue(float intensity)
Returns the buffer value corresponding to an intensity.
const BufferType & buffer() const
References the underlying buffer.
BufferedIntensityVolume(const math::Vector3ui &size)
Represents a composition, i.e. a strong reference. This basically is a std::unique_ptr that supports ...
Defines interface to volume data.
math::Vector3ui size
Holds the resolution.
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.