More work on base Volume class and sampler.

Added new test case for creating a volume subclass.
This commit is contained in:
David Williams
2011-07-30 10:12:28 +01:00
parent 84c78f6839
commit d1649c9323
10 changed files with 236 additions and 38 deletions

View File

@ -36,10 +36,8 @@ namespace PolyVox
{
template <typename VoxelType>
LargeVolume<VoxelType>::Sampler::Sampler(LargeVolume<VoxelType>* volume)
//:mVolume(volume)
:Volume<VoxelType>::Sampler< LargeVolume<VoxelType> >(volume)
{
//Dodgy doing this - need to find how to call base constructor
this->mVolume = volume;
}
template <typename VoxelType>

View File

@ -31,15 +31,13 @@ namespace PolyVox
{
template <typename VoxelType>
RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume)
//:mVolume(volume)
:mXPosInVolume(0)
:Volume<VoxelType>::Sampler< RawVolume<VoxelType> >(volume)
,mXPosInVolume(0)
,mYPosInVolume(0)
,mZPosInVolume(0)
,mCurrentVoxel(0)
,m_bIsCurrentPositionValid(false)
{
//Dodgy doing this - need to find how to call base constructor
this->mVolume = volume;
}
template <typename VoxelType>

View File

@ -41,6 +41,7 @@ namespace PolyVox
Region();
Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner);
Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ);
const Vector3DInt32& getLowerCorner(void) const;
const Vector3DInt32& getUpperCorner(void) const;

View File

@ -36,10 +36,8 @@ namespace PolyVox
{
template <typename VoxelType>
SimpleVolume<VoxelType>::Sampler::Sampler(SimpleVolume<VoxelType>* volume)
//:mVolume(volume)
:Volume<VoxelType>::Sampler< SimpleVolume<VoxelType> >(volume)
{
//Dodgy doing this - need to find how to call base constructor
this->mVolume = volume;
}
template <typename VoxelType>

View File

@ -41,6 +41,9 @@ namespace PolyVox
class Sampler
{
public:
Sampler(DerivedVolumeType* volume);
~Sampler();
int32_t getPosX(void) const;
int32_t getPosY(void) const;
int32_t getPosZ(void) const;

View File

@ -29,6 +29,22 @@ freely, subject to the following restrictions:
#include <limits>
namespace PolyVox
{
template <typename VoxelType>
template <typename DerivedVolumeType>
Volume<VoxelType>::Sampler<DerivedVolumeType>::Sampler(DerivedVolumeType* volume)
:mVolume(volume)
,mXPos(0)
,mYPos(0)
,mZPos(0)
{
}
template <typename VoxelType>
template <typename DerivedVolumeType>
Volume<VoxelType>::Sampler<DerivedVolumeType>::~Sampler()
{
}
template <typename VoxelType>
template <typename DerivedVolumeType>
int32_t Volume<VoxelType>::Sampler<DerivedVolumeType>::getPosX(void) const
@ -54,7 +70,7 @@ namespace PolyVox
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::getVoxel(void) const
{
mVolume->getVoxelAt(mXPos, mYPos, mZPos);
return mVolume->getVoxelAt(mXPos, mYPos, mZPos);
}
template <typename VoxelType>
@ -121,63 +137,63 @@ namespace PolyVox
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1ny1nz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1ny0pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos );
return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1ny1pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx0py1nz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx0py0pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos );
return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx0py1pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1py1nz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1py0pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos );
return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1nx1py1pz(void) const
{
mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1);
}
//////////////////////////////////////////////////////////////////////////
@ -186,63 +202,63 @@ namespace PolyVox
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1ny1nz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1ny0pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos );
return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1ny1pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px0py1nz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1);
return mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px0py0pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos , mZPos );
return mVolume->getVoxelAt(mXPos , mYPos , mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px0py1pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1);
return mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1py1nz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1py0pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos );
return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel0px1py1pz(void) const
{
mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1);
}
//////////////////////////////////////////////////////////////////////////
@ -251,62 +267,62 @@ namespace PolyVox
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1ny1nz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1ny0pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos );
return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1ny1pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px0py1nz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px0py0pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos );
return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px0py1pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1py1nz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1);
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1py0pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos );
return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos );
}
template <typename VoxelType>
template <typename DerivedVolumeType>
VoxelType Volume<VoxelType>::Sampler<DerivedVolumeType>::peekVoxel1px1py1pz(void) const
{
mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1);
return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1);
}
}

View File

@ -50,6 +50,16 @@ namespace PolyVox
assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ());
}
Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ)
:m_v3dLowerCorner(iLowerX, iLowerY, iLowerZ)
,m_v3dUpperCorner(iUpperX, iUpperY, iUpperZ)
{
//Check the region is valid.
assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX());
assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY());
assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ());
}
const Vector3DInt32& Region::getLowerCorner(void) const
{
return m_v3dLowerCorner;