Commit b980b0e5 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX ##173] this fixes an issue with 2d datasets. As the Colormapper virtually...

[FIX ##173] this fixes an issue with 2d datasets. As the Colormapper virtually works in voxel-space, the bounding box of each dataset should also be in voxel space.
parent 88645758
......@@ -33,7 +33,7 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr< WValueSetBase > valueSet, boo
WGETexture3D( static_cast< float >( valueSet->getMaximumValue() - valueSet->getMinimumValue() ),
static_cast< float >( valueSet->getMinimumValue() ) ),
m_valueSet( valueSet ),
m_boundingBox( grid->getBoundingBox() )
m_boundingBox( grid->getBoundingBoxIncludingBorder() )
{
// initialize members
setTextureSize( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
......
......@@ -205,6 +205,21 @@ public:
*/
WBoundingBox getBoundingBox() const;
/**
* Calculates the bounding box but includes the border voxel associated cell too.
*
* \return the bounding box
*/
WBoundingBox getBoundingBoxIncludingBorder() const;
/**
* Calculate the bounding box in voxel space. In contrast to the cell bounding box, this includes the space of the last voxel in each
* direction.
*
* \return the voxel space bounding box.
*/
WBoundingBox getVoxelBoundingBox() const;
/**
* Returns the i-th position on the grid.
* \param i id of position to be obtained
......@@ -641,6 +656,36 @@ inline WBoundingBox WGridRegular3DTemplate< T >::getBoundingBox() const
return result;
}
template< typename T >
inline WBoundingBox WGridRegular3DTemplate< T >::getBoundingBoxIncludingBorder() const
{
WBoundingBox result;
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, 0.0 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), 0.0, 0.0 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY(), 0.0 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), getNbCoordsY(), 0.0 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, getNbCoordsZ() ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), 0.0, getNbCoordsZ() ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY(), getNbCoordsZ() ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), getNbCoordsY(), getNbCoordsZ() ) ) );
return result;
}
template< typename T >
inline WBoundingBox WGridRegular3DTemplate< T >::getVoxelBoundingBox() const
{
WBoundingBox result;
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, -0.5, -0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, -0.5, -0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
result.expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
return result;
}
template< typename T >
inline typename WGridRegular3DTemplate< T >::Vector3Type WGridRegular3DTemplate< T >::getPosition( unsigned int i ) const
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment