15#ifndef VOLUMEGRIDHELPERDETAILS_H_6014714286
16#define VOLUMEGRIDHELPERDETAILS_H_6014714286
61template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
83template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
102template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
125template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
145template<
typename TextureFactory >
153 <
typename TextureFactory::SegmentIntensityVolume
154 ,
typename TextureFactory::SegmentNormalsVolume >*
179 <
typename TextureFactory::SegmentIntensityVolume
180 ,
typename TextureFactory::SegmentNormalsVolume >& segment )
const;
186 <
typename TextureFactory::SegmentIntensityVolume
187 ,
typename TextureFactory::SegmentNormalsVolume >& segment )
const;
192template<
typename TextureFactory >
195 releaseGeometryFeatures();
199template<
typename TextureFactory >
202 for(
auto itr = textures.begin(); itr != textures.end(); ++itr )
211template<
typename TextureFactory >
216 <
typename TextureFactory::SegmentIntensityVolume
217 ,
typename TextureFactory::SegmentNormalsVolume >& segment )
const
224template<
typename TextureFactory >
227 <
typename TextureFactory::SegmentIntensityVolume
228 ,
typename TextureFactory::SegmentNormalsVolume >& segment )
const
230 auto textureItr = textures.find( &segment );
231 if( textureItr == textures.end() )
236 textures[ &segment ] = &texture;
243 return *textureItr->second;
259template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
313template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
315 : role( DEFAULT_ROLE_INTENSITIES )
320template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
327template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
334template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
340 ::attachTexture( geometry, role, segment );
344template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
349 SegmentIntensityVolumeType*
const intensities =
new SegmentIntensityVolumeType( size );
396template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
398 :
public TextureManager< NormalsTextureFactory< SegmentIntensityVolumeType, SegmentNormalsVolumeType > >
464template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
466 : role( DEFAULT_ROLE_NORMALS )
471template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
478template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
485template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
496 const Vector3ui resolution = gridResolution();
501 for(
unsigned int dim0 = 0; dim0 < 3; ++dim0 )
503 for(
signed int sign = -1; sign <= +1; sign += 2 )
507 Vector3f normal( 0, 0, 0 );
508 normal( dim0 ) = sign;
512 const unsigned int dim1 = ( dim0 + 1 ) % 3;
513 const unsigned int dim2 = ( dim0 + 2 ) % 3;
516 coord( dim0 ) = sign < 0 ? 0 : resolution( dim0 ) - 1;
518 for( coord( dim1 ) = 0; coord( dim1 ) < resolution( dim1 ); ++coord( dim1 ) )
519 for( coord( dim2 ) = 0; coord( dim2 ) < resolution( dim2 ); ++coord( dim2 ) )
521 grid->template setVoxel< NormalSelector >( coord, normal );
528 const Vector3ui coordLowerBound = Vector3ui( 1, 1, 1 );
529 const Vector3ui coordUpperBound = ( resolution.cast<
int >() - Vector3i( 1, 1, 1 ) ).cast< unsigned int >();
535 [
this, &coord](
unsigned int dx,
unsigned int dy,
unsigned int dz )
537 return grid->template getVoxel< IntensitySelector >( Vector3ui( coord.x() + dx, coord.y() + dy, coord.z() + dz ) );
544 Vector3f normal = -gradient;
545 if( normal.squaredNorm() > 1e-12 )
551 normal = Vector3f( 0, 0, 0 );
553 grid->template setVoxel< NormalSelector >( coord, normal );
560 ,
"VolumeGridHelper finished normals computation in "
561 + base::text::lexical_cast< std::string >( seconds )
566template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
574template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
580 ::attachTexture( geometry, role, segment );
584template<
typename SegmentIntensityVolumeType,
typename SegmentNormalsVolumeType >
589 SegmentNormalsVolumeType*
const normals =
new SegmentNormalsVolumeType( size );
604template<
typename SegmentIntensityVolumeType >
644template<
typename SegmentIntensityVolumeType >
650template<
typename SegmentIntensityVolumeType >
656template<
typename SegmentIntensityVolumeType >
663template<
typename SegmentIntensityVolumeType >
671template<
typename SegmentIntensityVolumeType >
Defines LibCarna::base::BufferedNormalMap3D.
Defines LibCarna::base::BufferedVectorFieldTexture.
Defines LibCarna::base::Geometry.
#define LIBCARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Contains forward-declarations.
Defines LibCarna::base::Log.
Defines LibCarna::base::Stopwatch.
Defines LibCarna::base::VolumeGrid.
Defines LibCarna::base::VolumeSegment.
Represents an association.
static BufferedVectorFieldTexture< BufferedVectorFieldType > & create(const BufferedVectorFieldType &field)
Instantiates. Invoke release when it isn't needed any longer.
void release()
Denotes that this object is no longer required and may be deleted as soon as it is valid to delete it...
Defines scene graph leafs. Instances of this class represent visible geometry that can be rendered....
void putFeature(unsigned int role, GeometryFeature &feature)
Adds the feature to this geometry node using role in . The concept of geometry features and roles is ...
@ verbose
Indicates statistics and suchlike.
Represents 3D OpenGL texture object whose lifetime is managed by instances of this class.
static Log & instance()
Returns the only instance from class InstanceType.
Implements stopwatch using the robust wallclock time from OMP that most compilers support.
double result() const
Tells result in seconds from current time measurement.
Represents a single volumetric data partition.
Computes the partitioning of volumetric data and the corresponding normal map. Also creates scene nod...
Defines the helpers::VolumeGridHelper component that maintains intensity volume data.
static const unsigned int DEFAULT_ROLE_INTENSITIES
Holds the default role to use for attaching textures to base::Geometry nodes.
void initializeSegment(base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment, const base::math::Vector3ui &size) const
Initializes intensity volume of segment.
void attachTexture(base::Geometry &geometry, const base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment) const
Attaches the texture that represents the base::VolumeSegment::intensities of segment to geometry usin...
void setIntensitiesRole(unsigned int role)
Sets the role to use for attaching textures to base::Geometry nodes.
unsigned int intensitiesRole() const
Tels the role used for attaching textures to base::Geometry nodes.
IntensityComponent()
Sets the role to use for attaching textures to base::Geometry nodes to DEFAULT_ROLE_INTENSITIES.
Defines the NormalsComponent base class that is independent of type arguments.
virtual base::math::Vector3ui gridResolution() const =0
Tells the effective grid resolution.
virtual ~NormalsComponentBase()
Deletes.
Defines the helpers::VolumeGridHelper component that computes and maintains normal maps.
void setGrid(base::VolumeGrid< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &grid)
Sets the grid that computeNormals operates on.
void setNormalsRole(unsigned int role)
Sets the role to use for attaching textures to base::Geometry nodes.
static const unsigned int DEFAULT_ROLE_NORMALS
Holds the default role to use for attaching textures to base::Geometry nodes.
unsigned int normalsRole() const
Tels the role used for attaching textures to base::Geometry nodes.
void initializeSegment(base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment, const base::math::Vector3ui &size) const
Initializes normal map of segment.
void attachTexture(base::Geometry &geometry, const base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment) const
Attaches the texture that represents the base::VolumeSegmentNormalsComponent::normals of segment to g...
NormalsComponent()
Sets the role to use for attaching textures to base::Geometry nodes to DEFAULT_ROLE_NORMALS.
void computeNormals()
Computes the normal map on the previously set grid.
Provides mapping base::VolumeSegment to base::ManagedTexture3D objects in a caching manner....
void attachTexture(base::Geometry &geometry, unsigned int role, const base::VolumeSegment< typename TextureFactory::SegmentIntensityVolume, typename TextureFactory::SegmentNormalsVolume > &segment) const
Attaches the texture that TextureFactory creates from segment to geometry using role.
void releaseGeometryFeatures()
Releases all textures.
virtual ~TextureManager()
Releases all textures and deletes.
#define LIBCARNA_FOR_VECTOR3UI_EX(vecName, vecLimit, vecStart)
Loops vecName over all where is vecLimit and is vecStart.
base::math::Vector3f computeFastGradient3f(Sampler func)
Computes fast approximation of the gradient at the origin of the scalar field func.
Eigen::Matrix< signed int, 3, 1 > Vector3i
Defines vector.
Eigen::Matrix< float, 3, 1 > Vector3f
Defines vector.
unsigned int round_ui(ScalarType x)
Rounds x to the closest . Either the data type of must be unsigned or .
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
#define NON_COPYABLE
Marks the class that it is placed in as non-copyable.
References the intensity volume of a given partition.
Creates textures that represents base::VolumeSegment::intensities in video memory.
SegmentNormalsVolumeType SegmentNormalsVolume
Reflects the type to use for storing the normal map of a single partition.
SegmentIntensityVolumeType SegmentIntensityVolume
Reflects the type to use for storing the intensity volume of a single partition.
static base::ManagedTexture3D & createTexture(const base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment)
Creates texture that represents the base::VolumeSegment::intensities of segment in video memory.
Creates textures that represents base::VolumeSegmentNormalsComponent::normals in video memory.
SegmentIntensityVolumeType SegmentIntensityVolume
Reflects the type to use for storing the intensity volume of a single partition.
static base::ManagedTexture3D & createTexture(const base::VolumeSegment< SegmentIntensityVolumeType, SegmentNormalsVolumeType > &segment)
Creates texture that represents the base::VolumeSegmentNormalsComponent::normals of segment in video ...
SegmentNormalsVolumeType SegmentNormalsVolume
Reflects the type to use for storing the normal map of a single partition.
Computes the partitioning that VolumeGridHelper uses along one dimension.
std::size_t partitionsCount() const
Tells the total partitions number.
std::size_t tailSize
Holds the resolution of the last partition that may also be 0.
std::size_t totalSize() const
Computes the effective total resolution.
std::size_t regularPartitionSize
Holds the always odd, effective resolution of a single regular partition.
Partionining(std::size_t nativeSize, std::size_t regularPartitionSize)
Computes the partitioning.
std::size_t regularPartitionsCount
Holds the number of regular partitions, i.e. such of the size held by regularPartitionSize.
Defines LibCarna::base::text.