Carna  Version 3.0.1
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType > Class Template Reference

Computes the partitioning of volumetric data and the corresponding normal map. Also creates scene nodes that insert the volumetric data into a scene. More...

#include <VolumeGridHelper.h>

+ Inheritance diagram for Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >:
+ Collaboration diagram for Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >:

Public Member Functions

 VolumeGridHelper (const base::math::Vector3ui &nativeResolution, std::size_t maxSegmentBytesize=DEFAULT_MAX_SEGMENT_BYTESIZE)
 Creates new base::VolumeGrid object. Initializes its' segments s.t. the totally covered resolution is resolution at least. It may be chosen larger if the buffers' resolution need to be rounded to even numbers. More...
 
template<typename UnaryVector3uiToHUVFunction >
void loadData (const UnaryVector3uiToHUVFunction &data)
 Alters the volume data. More...
 
virtual void loadData (const std::function< base::HUV(const base::math::Vector3ui &) > &data) override
 
virtual void releaseGeometryFeatures () override
 Releases all previously acquired textures. Invoke this method when the volume data changes, loadData already does takes care of that. More...
 
base::VolumeGrid< SegmentHUVolumeType, SegmentNormalsVolumeType > & grid () const
 References the underlying grid.
 
virtual base::NodecreateNode (unsigned int geometryType, const Spacing &spacing) const override
 Creates renderable representation of the underlying grid, that can be put anywhere in the scene graph. The volume is centered in the node. More...
 
virtual base::NodecreateNode (unsigned int geometryType, const Dimensions &dimensions) const override
 Creates renderable representation of the underlying grid, that can be put anywhere in the scene graph. The volume is centered in the node. More...
 
- Public Member Functions inherited from Carna::helpers::VolumeGridHelperBase
 VolumeGridHelperBase (const base::math::Vector3ui &nativeResolution)
 Instantiates. More...
 
virtual ~VolumeGridHelperBase ()
 Does nothing.
 
- Public Member Functions inherited from Carna::helpers::details::VolumeGridHelper::HUComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
 HUComponent ()
 Sets the role to use for attaching textures to base::Geometry nodes to DEFAULT_ROLE_HU_VOLUME.
 
void setHUVolumeRole (unsigned int role)
 Sets the role to use for attaching textures to base::Geometry nodes.
 
unsigned int huVolumeRole () const
 Tels the role used for attaching textures to base::Geometry nodes.
 
- Public Member Functions inherited from Carna::helpers::details::VolumeGridHelper::TextureManager< HUTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType > >
virtual ~TextureManager ()
 Releases all textures and deletes.
 
void releaseGeometryFeatures ()
 Releases all textures.
 
- Public Member Functions inherited from Carna::helpers::details::VolumeGridHelper::NormalsComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
 NormalsComponent ()
 Sets the role to use for attaching textures to base::Geometry nodes to DEFAULT_ROLE_NORMALS.
 
void setNormalsRole (unsigned int role)
 Sets the 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 computeNormals ()
 Computes the normal map on the previously set grid.
 
- Public Member Functions inherited from Carna::helpers::details::VolumeGridHelper::TextureManager< NormalsTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType > >
virtual ~TextureManager ()
 Releases all textures and deletes.
 
void releaseGeometryFeatures ()
 Releases all textures.
 
- Public Member Functions inherited from Carna::helpers::details::VolumeGridHelper::NormalsComponentBase
virtual ~NormalsComponentBase ()
 Deletes.
 

Public Attributes

const std::size_t maxSegmentBytesize
 Maximum memory size of a single segment volume.
 
const base::math::Vector3ui maxSegmentSize
 The maximum effective resolution of a single grid segment.
 
const details::VolumeGridHelper::Partionining partitioningX
 Describes the partitioning along the x-axis.
 
const details::VolumeGridHelper::Partionining partitioningY
 Describes the partitioning along the y-axis.
 
const details::VolumeGridHelper::Partionining partitioningZ
 Describes the partitioning along the z-axis.
 
const base::math::Vector3ui resolution
 Holds the effective resolution, i.e. the resolution covered by the grid.
 
- Public Attributes inherited from Carna::helpers::VolumeGridHelperBase
const base::math::Vector3ui nativeResolution
 Holds the original resolution of the loaded data.
 

Protected Member Functions

virtual base::math::Vector3ui gridResolution () const override
 Tells the effective grid resolution.
 
- Protected Member Functions inherited from Carna::helpers::details::VolumeGridHelper::HUComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
void attachTexture (base::Geometry &geometry, const base::VolumeSegment< SegmentHUVolumeType, SegmentNormalsVolumeType > &segment) const
 Attaches the texture that represents the base::VolumeSegment::huVolume of segment to geometry using the previously configured role.
 
void initializeSegment (base::VolumeSegment< SegmentHUVolumeType, SegmentNormalsVolumeType > &segment, const base::math::Vector3ui &size) const
 Initializes HU volume of segment.
 
- Protected Member Functions inherited from Carna::helpers::details::VolumeGridHelper::TextureManager< HUTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType > >
void attachTexture (base::Geometry &geometry, unsigned int role, const base::VolumeSegment< typename HUTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType >::SegmentHUVolume, typename HUTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType >::SegmentNormalsVolume > &segment) const
 Attaches the texture that TextureFactory creates from segment to geometry using role.
 
- Protected Member Functions inherited from Carna::helpers::details::VolumeGridHelper::NormalsComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
void setGrid (base::VolumeGrid< SegmentHUVolumeType, SegmentNormalsVolumeType > &grid)
 Sets the grid that computeNormals operates on.
 
void attachTexture (base::Geometry &geometry, const base::VolumeSegment< SegmentHUVolumeType, SegmentNormalsVolumeType > &segment) const
 Attaches the texture that represents the base::VolumeSegmentNormalsComponent::normals of segment to geometry using the previously configured role.
 
void initializeSegment (base::VolumeSegment< SegmentHUVolumeType, SegmentNormalsVolumeType > &segment, const base::math::Vector3ui &size) const
 Initializes normal map of segment.
 
- Protected Member Functions inherited from Carna::helpers::details::VolumeGridHelper::TextureManager< NormalsTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType > >
void attachTexture (base::Geometry &geometry, unsigned int role, const base::VolumeSegment< typename NormalsTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType >::SegmentHUVolume, typename NormalsTextureFactory< SegmentHUVolumeType, SegmentNormalsVolumeType >::SegmentNormalsVolume > &segment) const
 Attaches the texture that TextureFactory creates from segment to geometry using role.
 

Additional Inherited Members

- Static Public Attributes inherited from Carna::helpers::VolumeGridHelperBase
static const std::size_t DEFAULT_MAX_SEGMENT_BYTESIZE = 2 * 300 * 300 * 300
 Default maximum memory size of a single segment volume, 50 megabytes approximately. This determines the segments partitioning. More...
 
- Static Public Attributes inherited from Carna::helpers::details::VolumeGridHelper::HUComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
static const unsigned int DEFAULT_ROLE_HU_VOLUME = 0
 Holds the default role to use for attaching textures to base::Geometry nodes.
 
- Static Public Attributes inherited from Carna::helpers::details::VolumeGridHelper::NormalsComponent< SegmentHUVolumeType, SegmentNormalsVolumeType >
static const unsigned int DEFAULT_ROLE_NORMALS = 1
 Holds the default role to use for attaching textures to base::Geometry nodes.
 

Detailed Description

template<typename SegmentHUVolumeType, typename SegmentNormalsVolumeType>
class Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >

Computes the partitioning of volumetric data and the corresponding normal map. Also creates scene nodes that insert the volumetric data into a scene.

Parameters
SegmentHUVolumeTypeis the base::BufferedHUVolume compatible type to use for storing the HU volume of a single partition.
SegmentNormalsVolumeTypeis the base::BufferedNormalMap3D compatible type to use for storing the normal map of a single partition. Set to void if the normal map is not required.

Normal Map Computation

The loadData kicks off the computation of the normals automatically. If you alter the volume data differently, it is within your responsibility to do this by calling computeNormals on this object. Note that the computeNormals method is only available if SegmentNormalsVolumeType is not void.

Resolutions

This class needs to distinguish between three kinds of resolutions. The grid's volume textures are not disjoint, but must maintain redundant voxels along common segment faces. Hence, the resolution of the data uploaded to GPU from all segments, that we will call the total resolution therefore, will usually be greater than the resolution of the actually loaded data. We will refer to the latter as the native resolution.

Furthermore, the effective resolution, that is the one covered by the grid and available for payload, might still be greater than the native resolution, namely because the segments' resolution is rounded to even numbers. The additional voxels arising from this are not queried from the data source, but automatically padded with \(-1024\), s.t. the data source doesn't have to pay attention to this circumstance.

Author
Leonid Kostrykin
Date
8.3.15 - 29.3.15

Definition at line 199 of file Carna.h.

Constructor & Destructor Documentation

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::VolumeGridHelper ( const base::math::Vector3ui nativeResolution,
std::size_t  maxSegmentBytesize = DEFAULT_MAX_SEGMENT_BYTESIZE 
)

Creates new base::VolumeGrid object. Initializes its' segments s.t. the totally covered resolution is resolution at least. It may be chosen larger if the buffers' resolution need to be rounded to even numbers.

Parameters
nativeResolutionThe resolution the grid is to be prepared for. This is the resolution that will be expected from the data source.
maxSegmentBytesizeMaximum memory size of a single segment volume. The segments partitioning is chosen according to this value.

Definition at line 342 of file VolumeGridHelper.h.

Member Function Documentation

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
base::Node * Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::createNode ( unsigned int  geometryType,
const Spacing spacing 
) const
overridevirtual

Creates renderable representation of the underlying grid, that can be put anywhere in the scene graph. The volume is centered in the node.

Warning
Only change the returned node's localTransform attribute when you know what you're doing! Put it into another node otherwise.
Parameters
geometryTypeWill be used for base::Geometry instantiation.
spacingSpecifies the spacing between two succeeding voxel centers in millimeters.

Implements Carna::helpers::VolumeGridHelperBase.

Definition at line 476 of file VolumeGridHelper.h.

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
base::Node * Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::createNode ( unsigned int  geometryType,
const Dimensions dimensions 
) const
overridevirtual

Creates renderable representation of the underlying grid, that can be put anywhere in the scene graph. The volume is centered in the node.

Warning
Only change the returned node's localTransform attribute when you know what you're doing! Put it into another node otherwise.
Parameters
geometryTypeWill be used for base::Geometry instantiation.
dimensionsSpecifies the dimensions of the whole dataset in millimeters.

Implements Carna::helpers::VolumeGridHelperBase.

Definition at line 486 of file VolumeGridHelper.h.

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
template<typename UnaryVector3uiToHUVFunction >
void Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::loadData ( const UnaryVector3uiToHUVFunction &  data)

Alters the volume data.

Parameters
dataUnary function that maps base::math::Vector3ui to base::HUV. It will be queried for all values up to nativeResolution.

The normal map is re-computed if SegmentNormalsVolumeType is not void.

Definition at line 385 of file VolumeGridHelper.h.

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
void Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::loadData ( const std::function< base::HUV(const base::math::Vector3ui &) > &  data)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements Carna::helpers::VolumeGridHelperBase.

Definition at line 403 of file VolumeGridHelper.h.

template<typename SegmentHUVolumeType , typename SegmentNormalsVolumeType >
void Carna::helpers::VolumeGridHelper< SegmentHUVolumeType, SegmentNormalsVolumeType >::releaseGeometryFeatures ( )
overridevirtual

Releases all previously acquired textures. Invoke this method when the volume data changes, loadData already does takes care of that.

If this method is not invoked after an update of the volume data, succeeding calls to createNode will not reflect the new data. Note however, that if you call this method between two invocations of createNode without the volume data been altered, same textures will get uploaded twice to video memory, i.e. video resources will be wasted.

Implements Carna::helpers::VolumeGridHelperBase.

Definition at line 375 of file VolumeGridHelper.h.


The documentation for this class was generated from the following files: