diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h
index a76ff391..5d56ac03 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h
+++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h
@@ -149,9 +149,17 @@ namespace PolyVox
/// Gets the length of the diagonal in voxels
float getDiagonalLength(void) const;
/// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxel(const Vector3DInt32& v3dPos) const;
+ /// Gets a voxel at the position given by x,y,z coordinates
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
/// Gets a voxel at the position given by a 3D vector
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
/// Sets the value used for voxels which are outside the volume
void setBorderValue(const VoxelType& tBorder);
diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl
index d50c0838..7d5d48fa 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl
+++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl
@@ -153,6 +153,30 @@ namespace PolyVox
return m_fDiagonalLength;
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/) const
+ {
+ assert(false);
+ return VoxelType();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/) const
+ {
+ assert(false);
+ return VoxelType();
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos The \c x position of the voxel
/// \param uYPos The \c y position of the voxel
@@ -177,6 +201,30 @@ namespace PolyVox
return VoxelType();
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType BaseVolume::getVoxelWithWrapping(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const
+ {
+ assert(false);
+ return VoxelType();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType BaseVolume::getVoxelWithWrapping(const Vector3DInt32& /*v3dPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const
+ {
+ assert(false);
+ return VoxelType();
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param tBorder The value to use for voxels outside the volume.
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h
index 3755dae0..371bb66e 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h
+++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h
@@ -267,10 +267,18 @@ namespace PolyVox
/// Destructor
~LargeVolume();
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxel(const Vector3DInt32& v3dPos) const;
/// Gets a voxel at the position given by x,y,z coordinates
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
/// Gets a voxel at the position given by a 3D vector
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
//Sets whether or not blocks are compressed in memory
void setCompressionEnabled(bool bCompressionEnabled);
diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl
index 45465445..2966b9c1 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl
+++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl
@@ -110,6 +110,40 @@ namespace PolyVox
assert(false); // See function comment above.
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType LargeVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
+ {
+ assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)));
+
+ const int32_t blockX = uXPos >> m_uBlockSideLengthPower;
+ const int32_t blockY = uYPos >> m_uBlockSideLengthPower;
+ const int32_t blockZ = uZPos >> m_uBlockSideLengthPower;
+
+ const uint16_t xOffset = static_cast(uXPos - (blockX << m_uBlockSideLengthPower));
+ const uint16_t yOffset = static_cast(uYPos - (blockY << m_uBlockSideLengthPower));
+ const uint16_t zOffset = static_cast(uZPos - (blockZ << m_uBlockSideLengthPower));
+
+ Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
+
+ return pUncompressedBlock->getVoxelAt(xOffset,yOffset,zOffset);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType LargeVolume::getVoxel(const Vector3DInt32& v3dPos) const
+ {
+ return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos The \c x position of the voxel
/// \param uYPos The \c y position of the voxel
@@ -149,6 +183,62 @@ namespace PolyVox
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType LargeVolume::getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ switch(eWrapMode)
+ {
+ case WrapModes::Clamp:
+ {
+ //Perform clamping
+ uXPos = (std::max)(uXPos, m_regValidRegion.getLowerX());
+ uYPos = (std::max)(uYPos, m_regValidRegion.getLowerY());
+ uZPos = (std::max)(uZPos, m_regValidRegion.getLowerZ());
+ uXPos = (std::min)(uXPos, m_regValidRegion.getUpperX());
+ uYPos = (std::min)(uYPos, m_regValidRegion.getUpperY());
+ uZPos = (std::min)(uZPos, m_regValidRegion.getUpperZ());
+
+ //Get the voxel value
+ return getVoxel(uXPos, uYPos, uZPos);
+ //No need to break as we've returned
+ }
+ case WrapModes::Border:
+ {
+ if(m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
+ {
+ return getVoxel(uXPos, uYPos, uZPos);
+ }
+ else
+ {
+ return tBorder;
+ }
+ //No need to break as we've returned
+ }
+ default:
+ {
+ //Should never happen
+ assert(false);
+ return VoxelType(0);
+ }
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType LargeVolume::getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ return getVoxelWithWrapping(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// Enabling compression allows significantly more data to be stored in memory.
/// \param bCompressionEnabled Specifies whether compression is enabled.
diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h
index 189ac286..f0ef1c6e 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h
+++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h
@@ -117,10 +117,18 @@ namespace PolyVox
/// Destructor
~RawVolume();
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxel(const Vector3DInt32& v3dPos) const;
/// Gets a voxel at the position given by x,y,z coordinates
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
/// Gets a voxel at the position given by a 3D vector
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
/// Sets the voxel at the position given by x,y,z coordinates
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl
index 61acfdd8..e1188738 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl
+++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl
@@ -73,6 +73,40 @@ namespace PolyVox
assert(false); // See function comment above.
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType RawVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
+ {
+ assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)));
+
+ const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
+ int32_t iLocalXPos = uXPos - v3dLowerCorner.getX();
+ int32_t iLocalYPos = uYPos - v3dLowerCorner.getY();
+ int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ();
+
+ return m_pData
+ [
+ iLocalXPos +
+ iLocalYPos * this->getWidth() +
+ iLocalZPos * this->getWidth() * this->getHeight()
+ ];
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType RawVolume::getVoxel(const Vector3DInt32& v3dPos) const
+ {
+ return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos The \c x position of the voxel
/// \param uYPos The \c y position of the voxel
@@ -112,6 +146,62 @@ namespace PolyVox
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType RawVolume::getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ switch(eWrapMode)
+ {
+ case WrapModes::Clamp:
+ {
+ //Perform clamping
+ uXPos = (std::max)(uXPos, m_regValidRegion.getLowerX());
+ uYPos = (std::max)(uYPos, m_regValidRegion.getLowerY());
+ uZPos = (std::max)(uZPos, m_regValidRegion.getLowerZ());
+ uXPos = (std::min)(uXPos, m_regValidRegion.getUpperX());
+ uYPos = (std::min)(uYPos, m_regValidRegion.getUpperY());
+ uZPos = (std::min)(uZPos, m_regValidRegion.getUpperZ());
+
+ //Get the voxel value
+ return getVoxel(uXPos, uYPos, uZPos);
+ //No need to break as we've returned
+ }
+ case WrapModes::Border:
+ {
+ if(m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
+ {
+ return getVoxel(uXPos, uYPos, uZPos);
+ }
+ else
+ {
+ return tBorder;
+ }
+ //No need to break as we've returned
+ }
+ default:
+ {
+ //Should never happen
+ assert(false);
+ return VoxelType(0);
+ }
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType RawVolume::getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ return getVoxelWithWrapping(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos the \c x position of the voxel
/// \param uYPos the \c y position of the voxel
diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h
index 4e9d180c..3ddafdbf 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h
+++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h
@@ -158,10 +158,18 @@ namespace PolyVox
/// Destructor
~SimpleVolume();
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxel(const Vector3DInt32& v3dPos) const;
/// Gets a voxel at the position given by x,y,z coordinates
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
/// Gets a voxel at the position given by a 3D vector
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
+ /// Gets a voxel at the position given by x,y,z coordinates
+ VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
+ /// Gets a voxel at the position given by a 3D vector
+ VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
/// Sets the voxel at the position given by x,y,z coordinates
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl
index 4fd15d8e..35a7c99c 100644
--- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl
+++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl
@@ -71,6 +71,40 @@ namespace PolyVox
assert(false); // See function comment above.
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType SimpleVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
+ {
+ assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)));
+
+ const int32_t blockX = uXPos >> m_uBlockSideLengthPower;
+ const int32_t blockY = uYPos >> m_uBlockSideLengthPower;
+ const int32_t blockZ = uZPos >> m_uBlockSideLengthPower;
+
+ const uint16_t xOffset = static_cast(uXPos - (blockX << m_uBlockSideLengthPower));
+ const uint16_t yOffset = static_cast(uYPos - (blockY << m_uBlockSideLengthPower));
+ const uint16_t zOffset = static_cast(uZPos - (blockZ << m_uBlockSideLengthPower));
+
+ typename SimpleVolume::Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
+
+ return pUncompressedBlock->getVoxelAt(xOffset,yOffset,zOffset);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType SimpleVolume::getVoxel(const Vector3DInt32& v3dPos) const
+ {
+ return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos The \c x position of the voxel
/// \param uYPos The \c y position of the voxel
@@ -110,6 +144,62 @@ namespace PolyVox
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
}
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param uXPos The \c x position of the voxel
+ /// \param uYPos The \c y position of the voxel
+ /// \param uZPos The \c z position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType SimpleVolume::getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ switch(eWrapMode)
+ {
+ case WrapModes::Clamp:
+ {
+ //Perform clamping
+ uXPos = (std::max)(uXPos, m_regValidRegion.getLowerX());
+ uYPos = (std::max)(uYPos, m_regValidRegion.getLowerY());
+ uZPos = (std::max)(uZPos, m_regValidRegion.getLowerZ());
+ uXPos = (std::min)(uXPos, m_regValidRegion.getUpperX());
+ uYPos = (std::min)(uYPos, m_regValidRegion.getUpperY());
+ uZPos = (std::min)(uZPos, m_regValidRegion.getUpperZ());
+
+ //Get the voxel value
+ return getVoxel(uXPos, uYPos, uZPos);
+ //No need to break as we've returned
+ }
+ case WrapModes::Border:
+ {
+ if(m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
+ {
+ return getVoxel(uXPos, uYPos, uZPos);
+ }
+ else
+ {
+ return tBorder;
+ }
+ //No need to break as we've returned
+ }
+ default:
+ {
+ //Should never happen
+ assert(false);
+ return VoxelType(0);
+ }
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \param v3dPos The 3D position of the voxel
+ /// \return The voxel value
+ ////////////////////////////////////////////////////////////////////////////////
+ template
+ VoxelType SimpleVolume::getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder) const
+ {
+ return getVoxelWithWrapping(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
+ }
+
////////////////////////////////////////////////////////////////////////////////
/// \param uXPos the \c x position of the voxel
/// \param uYPos the \c y position of the voxel
diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp
index d40c55fe..251e90b9 100644
--- a/tests/testvolume.cpp
+++ b/tests/testvolume.cpp
@@ -34,7 +34,10 @@ using namespace PolyVox;
template
int32_t complexVolumeTest(void)
{
+ //Create the volume
VolumeType testVolume(Region(-57, -31, 12, 64, 96, 131)); // Deliberatly awkward size
+
+ //Fill the volume with some data
for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
{
for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
@@ -46,38 +49,65 @@ int32_t complexVolumeTest(void)
}
}
- int32_t sum = 0;
+ int32_t result = 0;
+ //Test the getVoxel function
for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
{
for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
{
for(int x = testVolume.getEnclosingRegion().getLowerX(); x <= testVolume.getEnclosingRegion().getUpperX(); x++)
{
- sum += testVolume.getVoxelAt(x, y, z);
+ result += testVolume.getVoxel(x, y, z);
}
}
}
- return sum;
+ //Test border wrap mode
+ for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
+ {
+ //Just a few slices from y
+ for(int y = testVolume.getEnclosingRegion().getLowerY() - 3; y <= testVolume.getEnclosingRegion().getUpperY() + 5; y++)
+ {
+ for(int x = testVolume.getEnclosingRegion().getLowerX(); x <= testVolume.getEnclosingRegion().getUpperX(); x++)
+ {
+ result += testVolume.getVoxelWithWrapping(x, y, z, WrapModes::Border, 3);
+ }
+ }
+ }
+
+ //Test clamp wrap mode
+ for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
+ {
+ for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
+ {
+ //Just a few slices from y
+ for(int x = testVolume.getEnclosingRegion().getLowerX() - 2; x <= testVolume.getEnclosingRegion().getUpperX() + 4; x++)
+ {
+ result += testVolume.getVoxelWithWrapping(x, y, z, WrapModes::Clamp);
+ }
+ }
+ }
+
+ return result;
}
void TestVolume::testLargeVolume()
{
int32_t result = complexVolumeTest< LargeVolume >();
- QCOMPARE(result, static_cast(201446400));
+ QCOMPARE(result, static_cast(616456320));
}
void TestVolume::testRawVolume()
{
int32_t result = complexVolumeTest< RawVolume >();
- QCOMPARE(result, static_cast(201446400));
+ QCOMPARE(result, static_cast(616456320));
}
void TestVolume::testSimpleVolume()
{
int32_t result = complexVolumeTest< SimpleVolume >();
- QCOMPARE(result, static_cast(201446400));
+ QCOMPARE(result, static_cast(616456320));
}
QTEST_MAIN(TestVolume)