Moved VolumeSampler into Volume class.

This commit is contained in:
David Williams 2011-04-28 20:30:16 +01:00
parent 7d76a1bb69
commit 6f1ddb7d5f
23 changed files with 164 additions and 201 deletions

View File

@ -31,6 +31,7 @@ SET(CORE_INC_FILES
include/Density.h
include/Filters.h
include/Filters.inl
include/GradientEstimators.h
include/GradientEstimators.inl
include/Log.h
include/Material.h
@ -52,7 +53,6 @@ SET(CORE_INC_FILES
include/VertexTypes.h
include/Volume.h
include/Volume.inl
include/VolumeSampler.h
include/VolumeSampler.inl
include/VoxelFilters.h
)

View File

@ -28,7 +28,6 @@ freely, subject to the following restrictions:
#include "PolyVoxImpl/AStarPathfinderImpl.h"
#include "PolyVoxForwardDeclarations.h"
#include "Volume.h"
#include "VolumeSampler.h"
#include "PolyVoxImpl/TypeDef.h"

View File

@ -39,7 +39,7 @@ namespace PolyVox
private:
Region m_region;
VolumeSampler<VoxelType> m_sampVolume;
Volume<VoxelType>::VolumeSampler m_sampVolume;
Volume<VoxelType>* m_volInput;
Array<3, uint8_t>* m_arrayResult;
float m_fRayLength;

View File

@ -24,7 +24,6 @@ freely, subject to the following restrictions:
#include "Array.h"
#include "Raycast.h"
#include "Volume.h"
#include "VolumeSampler.h"
#include "PolyVoxImpl/RandomUnitVectors.h"
#include "PolyVoxImpl/RandomVectors.h"

View File

@ -26,7 +26,6 @@ freely, subject to the following restrictions:
#include "Array.h"
#include "PolyVoxForwardDeclarations.h"
#include "VolumeSampler.h"
#include "PolyVoxImpl/TypeDef.h"
@ -51,7 +50,7 @@ namespace PolyVox
private:
//The volume data and a sampler to access it.
Volume<VoxelType>* m_volData;
VolumeSampler<VoxelType> m_sampVolume;
Volume<VoxelType>::VolumeSampler m_sampVolume;
//Information about the region we are currently processing
Region m_regSizeInVoxels;

View File

@ -25,7 +25,7 @@ freely, subject to the following restrictions:
#define __PolyVox_CubicSurfaceExtractorWithNormals_H__
#include "PolyVoxForwardDeclarations.h"
#include "VolumeSampler.h"
#include "Volume.h"
#include "PolyVoxImpl/TypeDef.h"
@ -42,7 +42,7 @@ namespace PolyVox
private:
//The volume data and a sampler to access it.
Volume<VoxelType>* m_volData;
VolumeSampler<VoxelType> m_sampVolume;
typename Volume<VoxelType>::VolumeSampler m_sampVolume;
//The surface patch we are currently filling.
SurfaceMesh<PositionMaterialNormal>* m_meshCurrent;

View File

@ -26,7 +26,7 @@ freely, subject to the following restrictions:
#ifndef __PolyVox_GradientEstimators_H__
#define __PolyVox_GradientEstimators_H__
#include "VolumeSampler.h"
#include "Volume.h"
#include <vector>
@ -42,18 +42,18 @@ namespace PolyVox
};
template <typename VoxelType>
Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeCentralDifferenceGradient(const typename Volume<VoxelType>::VolumeSampler& volIter);
template <typename VoxelType>
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeSmoothCentralDifferenceGradient(typename Volume<VoxelType>::VolumeSampler& volIter);
template <typename VoxelType>
Vector3DFloat computeDecimatedCentralDifferenceGradient(VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeDecimatedCentralDifferenceGradient(typename Volume<VoxelType>::VolumeSampler& volIter);
template <typename VoxelType>
Vector3DFloat computeSobelGradient(const VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeSobelGradient(const typename Volume<VoxelType>::VolumeSampler& volIter);
template <typename VoxelType>
Vector3DFloat computeSmoothSobelGradient(VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeSmoothSobelGradient(typename Volume<VoxelType>::VolumeSampler& volIter);
POLYVOX_API void computeNormalsForVertices(Volume<uint8_t>* volumeData, SurfaceMesh<PositionMaterialNormal>& mesh, NormalGenerationMethod normalGenerationMethod);
POLYVOX_API Vector3DFloat computeNormal(Volume<uint8_t>* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod);

View File

@ -23,10 +23,12 @@ freely, subject to the following restrictions:
#include "VoxelFilters.h"
#include "Volume.h"
namespace PolyVox
{
template <typename VoxelType>
Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler<VoxelType>& volIter)
Vector3DFloat computeCentralDifferenceGradient(const typename Volume<VoxelType>::VolumeSampler& volIter)
{
//FIXME - bitwise way of doing this?
VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0;
@ -47,7 +49,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat computeDecimatedCentralDifferenceGradient(const VolumeSampler<VoxelType>& volIter)
Vector3DFloat computeDecimatedCentralDifferenceGradient(const typename Volume<VoxelType>::VolumeSampler& volIter)
{
const int32_t x = volIter.getPosX();
const int32_t y = volIter.getPosY();
@ -72,7 +74,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeSampler<VoxelType>& volIter)
Vector3DFloat computeSmoothCentralDifferenceGradient(typename Volume<VoxelType>::VolumeSampler& volIter)
{
int32_t initialX = volIter.getPosX();
int32_t initialY = volIter.getPosY();
@ -103,7 +105,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat computeSobelGradient(const VolumeSampler<VoxelType>& volIter)
Vector3DFloat computeSobelGradient(const typename Volume<VoxelType>::VolumeSampler& volIter)
{
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
@ -186,7 +188,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat computeSmoothSobelGradient(VolumeSampler<VoxelType>& volIter)
Vector3DFloat computeSmoothSobelGradient(typename Volume<VoxelType>::VolumeSampler& volIter)
{
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };

View File

@ -99,7 +99,7 @@ namespace PolyVox
typedef Vector<3,uint32_t> Vector3DUint32;
//----------------------------
template <typename VoxelType> class VolumeSampler;
//template <typename VoxelType> class VolumeSampler;
}
#endif

View File

@ -45,7 +45,7 @@ namespace PolyVox
};
//Make VolumeSampler a friend
friend class VolumeSampler<VoxelType>;
friend class Volume<VoxelType>::VolumeSampler;
public:
Block(uint16_t uSideLength = 0);

View File

@ -101,7 +101,7 @@ namespace PolyVox
void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2);
Volume<VoxelType>* m_volData;
VolumeSampler<VoxelType> m_sampVolume;
Volume<VoxelType>::VolumeSampler m_sampVolume;
Vector3DFloat m_v3dStart;
Vector3DFloat m_v3dDirection;

View File

@ -47,7 +47,7 @@ namespace PolyVox
void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2);
Volume<VoxelType>* m_volData;
VolumeSampler<VoxelType> m_sampVolume;
Volume<VoxelType>::VolumeSampler m_sampVolume;
Vector3DFloat m_v3dStart;
Vector3DFloat m_v3dDirection;

View File

@ -25,7 +25,7 @@ freely, subject to the following restrictions:
#define __PolyVox_SurfaceExtractor_H__
#include "PolyVoxForwardDeclarations.h"
#include "VolumeSampler.h"
#include "Volume.h"
#include "PolyVoxImpl/TypeDef.h"
@ -54,8 +54,8 @@ namespace PolyVox
Array2DInt32& m_pCurrentVertexIndicesY,
Array2DInt32& m_pCurrentVertexIndicesZ);
Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeSobelGradient(const VolumeSampler<VoxelType>& volIter);
Vector3DFloat computeCentralDifferenceGradient(const typename Volume<VoxelType>::VolumeSampler& volIter);
Vector3DFloat computeSobelGradient(const typename Volume<VoxelType>::VolumeSampler& volIter);
//Use the cell bitmasks to generate all the indices needed for that slice
void generateIndicesForSlice(const Array2DUint8& pPreviousBitmask,
@ -68,7 +68,7 @@ namespace PolyVox
//The volume data and a sampler to access it.
Volume<VoxelType>* m_volData;
VolumeSampler<VoxelType> m_sampVolume;
typename Volume<VoxelType>::VolumeSampler m_sampVolume;
//Holds a position in volume space.
int32_t iXVolSpace;

View File

@ -507,7 +507,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat SurfaceExtractor<VoxelType>::computeCentralDifferenceGradient(const VolumeSampler<VoxelType>& volIter)
Vector3DFloat SurfaceExtractor<VoxelType>::computeCentralDifferenceGradient(const typename Volume<VoxelType>::VolumeSampler& volIter)
{
uint8_t voxel1nx = volIter.peekVoxel1nx0py0pz().getDensity();
uint8_t voxel1px = volIter.peekVoxel1px0py0pz().getDensity();
@ -527,7 +527,7 @@ namespace PolyVox
}
template <typename VoxelType>
Vector3DFloat SurfaceExtractor<VoxelType>::computeSobelGradient(const VolumeSampler<VoxelType>& volIter)
Vector3DFloat SurfaceExtractor<VoxelType>::computeSobelGradient(const typename Volume<VoxelType>::VolumeSampler& volIter)
{
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };

View File

@ -143,8 +143,77 @@ namespace PolyVox
template <typename VoxelType>
class Volume
{
// Make VolumeSampler a friend
friend class VolumeSampler<VoxelType>;
public:
class VolumeSampler
{
public:
VolumeSampler(Volume<VoxelType>* volume);
~VolumeSampler();
typename VolumeSampler& operator=(const typename VolumeSampler& rhs) throw();
int32_t getPosX(void) const;
int32_t getPosY(void) const;
int32_t getPosZ(void) const;
VoxelType getSubSampledVoxel(uint8_t uLevel) const;
const Volume<VoxelType>* getVolume(void) const;
inline VoxelType getVoxel(void) const;
void setPosition(const Vector3DInt32& v3dNewPos);
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
void movePositiveX(void);
void movePositiveY(void);
void movePositiveZ(void);
void moveNegativeX(void);
void moveNegativeY(void);
void moveNegativeZ(void);
inline VoxelType peekVoxel1nx1ny1nz(void) const;
inline VoxelType peekVoxel1nx1ny0pz(void) const;
inline VoxelType peekVoxel1nx1ny1pz(void) const;
inline VoxelType peekVoxel1nx0py1nz(void) const;
inline VoxelType peekVoxel1nx0py0pz(void) const;
inline VoxelType peekVoxel1nx0py1pz(void) const;
inline VoxelType peekVoxel1nx1py1nz(void) const;
inline VoxelType peekVoxel1nx1py0pz(void) const;
inline VoxelType peekVoxel1nx1py1pz(void) const;
inline VoxelType peekVoxel0px1ny1nz(void) const;
inline VoxelType peekVoxel0px1ny0pz(void) const;
inline VoxelType peekVoxel0px1ny1pz(void) const;
inline VoxelType peekVoxel0px0py1nz(void) const;
inline VoxelType peekVoxel0px0py0pz(void) const;
inline VoxelType peekVoxel0px0py1pz(void) const;
inline VoxelType peekVoxel0px1py1nz(void) const;
inline VoxelType peekVoxel0px1py0pz(void) const;
inline VoxelType peekVoxel0px1py1pz(void) const;
inline VoxelType peekVoxel1px1ny1nz(void) const;
inline VoxelType peekVoxel1px1ny0pz(void) const;
inline VoxelType peekVoxel1px1ny1pz(void) const;
inline VoxelType peekVoxel1px0py1nz(void) const;
inline VoxelType peekVoxel1px0py0pz(void) const;
inline VoxelType peekVoxel1px0py1pz(void) const;
inline VoxelType peekVoxel1px1py1nz(void) const;
inline VoxelType peekVoxel1px1py0pz(void) const;
inline VoxelType peekVoxel1px1py1pz(void) const;
private:
//The current volume
Volume<VoxelType>* mVolume;
//The current position in the volume
int32_t mXPosInVolume;
int32_t mYPosInVolume;
int32_t mZPosInVolume;
//Other current position information
VoxelType* mCurrentVoxel;
};
// Make the ConstVolumeProxy a friend
friend class ConstVolumeProxy<VoxelType>;
@ -162,7 +231,7 @@ namespace PolyVox
};
public:
/// Constructor for creting a very large paging volume.
/// Constructor for creating a very large paging volume.
Volume
(
polyvox_function<void(const ConstVolumeProxy<VoxelType>&, const Region&)> dataRequiredHandler,
@ -291,5 +360,6 @@ private:
}
#include "Volume.inl"
#include "VolumeSampler.inl"
#endif

View File

@ -24,7 +24,6 @@ freely, subject to the following restrictions:
#include "ConstVolumeProxy.h"
#include "PolyVoxImpl/Block.h"
#include "Log.h"
#include "VolumeSampler.h"
#include "Region.h"
#include "Vector.h"

View File

@ -1,105 +0,0 @@
/*******************************************************************************
Copyright (c) 2005-2009 David Williams
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*******************************************************************************/
#ifndef __VolumeSampler_H__
#define __VolumeSampler_H__
#include "PolyVoxForwardDeclarations.h"
namespace PolyVox
{
template <typename VoxelType>
class VolumeSampler
{
public:
VolumeSampler(Volume<VoxelType>* volume);
~VolumeSampler();
VolumeSampler<VoxelType>& operator=(const VolumeSampler<VoxelType>& rhs) throw();
int32_t getPosX(void) const;
int32_t getPosY(void) const;
int32_t getPosZ(void) const;
VoxelType getSubSampledVoxel(uint8_t uLevel) const;
const Volume<VoxelType>* getVolume(void) const;
inline VoxelType getVoxel(void) const;
void setPosition(const Vector3DInt32& v3dNewPos);
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
void movePositiveX(void);
void movePositiveY(void);
void movePositiveZ(void);
void moveNegativeX(void);
void moveNegativeY(void);
void moveNegativeZ(void);
inline VoxelType peekVoxel1nx1ny1nz(void) const;
inline VoxelType peekVoxel1nx1ny0pz(void) const;
inline VoxelType peekVoxel1nx1ny1pz(void) const;
inline VoxelType peekVoxel1nx0py1nz(void) const;
inline VoxelType peekVoxel1nx0py0pz(void) const;
inline VoxelType peekVoxel1nx0py1pz(void) const;
inline VoxelType peekVoxel1nx1py1nz(void) const;
inline VoxelType peekVoxel1nx1py0pz(void) const;
inline VoxelType peekVoxel1nx1py1pz(void) const;
inline VoxelType peekVoxel0px1ny1nz(void) const;
inline VoxelType peekVoxel0px1ny0pz(void) const;
inline VoxelType peekVoxel0px1ny1pz(void) const;
inline VoxelType peekVoxel0px0py1nz(void) const;
inline VoxelType peekVoxel0px0py0pz(void) const;
inline VoxelType peekVoxel0px0py1pz(void) const;
inline VoxelType peekVoxel0px1py1nz(void) const;
inline VoxelType peekVoxel0px1py0pz(void) const;
inline VoxelType peekVoxel0px1py1pz(void) const;
inline VoxelType peekVoxel1px1ny1nz(void) const;
inline VoxelType peekVoxel1px1ny0pz(void) const;
inline VoxelType peekVoxel1px1ny1pz(void) const;
inline VoxelType peekVoxel1px0py1nz(void) const;
inline VoxelType peekVoxel1px0py0pz(void) const;
inline VoxelType peekVoxel1px0py1pz(void) const;
inline VoxelType peekVoxel1px1py1nz(void) const;
inline VoxelType peekVoxel1px1py0pz(void) const;
inline VoxelType peekVoxel1px1py1pz(void) const;
private:
//The current volume
Volume<VoxelType>* mVolume;
//The current position in the volume
int32_t mXPosInVolume;
int32_t mYPosInVolume;
int32_t mZPosInVolume;
//Other current position information
VoxelType* mCurrentVoxel;
};
}
#include "VolumeSampler.inl"
#endif

View File

@ -35,18 +35,18 @@ freely, subject to the following restrictions:
namespace PolyVox
{
template <typename VoxelType>
VolumeSampler<VoxelType>::VolumeSampler(Volume<VoxelType>* volume)
Volume<VoxelType>::VolumeSampler::VolumeSampler(Volume<VoxelType>* volume)
:mVolume(volume)
{
}
template <typename VoxelType>
VolumeSampler<VoxelType>::~VolumeSampler()
Volume<VoxelType>::VolumeSampler::~VolumeSampler()
{
}
template <typename VoxelType>
VolumeSampler<VoxelType>& VolumeSampler<VoxelType>::operator=(const VolumeSampler<VoxelType>& rhs) throw()
typename Volume<VoxelType>::VolumeSampler& Volume<VoxelType>::VolumeSampler::operator=(const typename Volume<VoxelType>::VolumeSampler& rhs) throw()
{
if(this == &rhs)
{
@ -61,25 +61,25 @@ namespace PolyVox
}
template <typename VoxelType>
int32_t VolumeSampler<VoxelType>::getPosX(void) const
int32_t Volume<VoxelType>::VolumeSampler::getPosX(void) const
{
return mXPosInVolume;
}
template <typename VoxelType>
int32_t VolumeSampler<VoxelType>::getPosY(void) const
int32_t Volume<VoxelType>::VolumeSampler::getPosY(void) const
{
return mYPosInVolume;
}
template <typename VoxelType>
int32_t VolumeSampler<VoxelType>::getPosZ(void) const
int32_t Volume<VoxelType>::VolumeSampler::getPosZ(void) const
{
return mZPosInVolume;
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::getSubSampledVoxel(uint8_t uLevel) const
VoxelType Volume<VoxelType>::VolumeSampler::getSubSampledVoxel(uint8_t uLevel) const
{
if(uLevel == 0)
{
@ -117,25 +117,25 @@ namespace PolyVox
}
template <typename VoxelType>
const Volume<VoxelType>* VolumeSampler<VoxelType>::getVolume(void) const
const Volume<VoxelType>* Volume<VoxelType>::VolumeSampler::getVolume(void) const
{
return mVolume;
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::getVoxel(void) const
VoxelType Volume<VoxelType>::VolumeSampler::getVoxel(void) const
{
return *mCurrentVoxel;
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::setPosition(const Vector3DInt32& v3dNewPos)
void Volume<VoxelType>::VolumeSampler::setPosition(const Vector3DInt32& v3dNewPos)
{
setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ());
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::setPosition(int32_t xPos, int32_t yPos, int32_t zPos)
void Volume<VoxelType>::VolumeSampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos)
{
mXPosInVolume = xPos;
mYPosInVolume = yPos;
@ -166,7 +166,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::movePositiveX(void)
void Volume<VoxelType>::VolumeSampler::movePositiveX(void)
{
//Note the *pre* increament here
if((++mXPosInVolume) % mVolume->m_uBlockSideLength != 0)
@ -182,7 +182,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::movePositiveY(void)
void Volume<VoxelType>::VolumeSampler::movePositiveY(void)
{
//Note the *pre* increament here
if((++mYPosInVolume) % mVolume->m_uBlockSideLength != 0)
@ -198,7 +198,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::movePositiveZ(void)
void Volume<VoxelType>::VolumeSampler::movePositiveZ(void)
{
//Note the *pre* increament here
if((++mZPosInVolume) % mVolume->m_uBlockSideLength != 0)
@ -214,7 +214,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::moveNegativeX(void)
void Volume<VoxelType>::VolumeSampler::moveNegativeX(void)
{
//Note the *post* decreament here
if((mXPosInVolume--) % mVolume->m_uBlockSideLength != 0)
@ -230,7 +230,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::moveNegativeY(void)
void Volume<VoxelType>::VolumeSampler::moveNegativeY(void)
{
//Note the *post* decreament here
if((mYPosInVolume--) % mVolume->m_uBlockSideLength != 0)
@ -246,7 +246,7 @@ namespace PolyVox
}
template <typename VoxelType>
void VolumeSampler<VoxelType>::moveNegativeZ(void)
void Volume<VoxelType>::VolumeSampler::moveNegativeZ(void)
{
//Note the *post* decreament here
if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0)
@ -262,7 +262,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1ny1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1ny1nz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -272,7 +272,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1ny0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1ny0pz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) )
{
@ -282,7 +282,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1ny1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1ny1pz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -292,7 +292,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx0py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx0py1nz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -302,7 +302,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx0py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx0py0pz(void) const
{
if( BORDER_LOW(mXPosInVolume) )
{
@ -312,7 +312,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx0py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx0py1pz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -322,7 +322,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1py1nz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) )
{
@ -332,7 +332,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1py0pz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) )
{
@ -342,7 +342,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1nx1py1pz(void) const
{
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -354,7 +354,7 @@ namespace PolyVox
//////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1ny1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1ny1nz(void) const
{
if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -364,7 +364,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1ny0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1ny0pz(void) const
{
if( BORDER_LOW(mYPosInVolume) )
{
@ -374,7 +374,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1ny1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1ny1pz(void) const
{
if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -384,7 +384,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px0py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px0py1nz(void) const
{
if( BORDER_LOW(mZPosInVolume) )
{
@ -394,13 +394,13 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px0py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px0py0pz(void) const
{
return *mCurrentVoxel;
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px0py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px0py1pz(void) const
{
if( BORDER_HIGH(mZPosInVolume) )
{
@ -410,7 +410,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1py1nz(void) const
{
if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -420,7 +420,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1py0pz(void) const
{
if( BORDER_HIGH(mYPosInVolume) )
{
@ -430,7 +430,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel0px1py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel0px1py1pz(void) const
{
if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -442,7 +442,7 @@ namespace PolyVox
//////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1ny1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1ny1nz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -452,7 +452,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1ny0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1ny0pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) )
{
@ -462,7 +462,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1ny1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1ny1pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -472,7 +472,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px0py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px0py1nz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -482,7 +482,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px0py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px0py0pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) )
{
@ -492,7 +492,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px0py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px0py1pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{
@ -502,7 +502,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1py1nz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1py1nz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
{
@ -512,7 +512,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1py0pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1py0pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) )
{
@ -522,7 +522,7 @@ namespace PolyVox
}
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1px1py1pz(void) const
VoxelType Volume<VoxelType>::VolumeSampler::peekVoxel1px1py1pz(void) const
{
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
{

View File

@ -27,9 +27,11 @@ freely, subject to the following restrictions:
#include "PolyVoxForwardDeclarations.h"
#include "PolyVoxImpl/TypeDef.h"
#include "Volume.h"
namespace PolyVox
{
float computeSmoothedVoxel(VolumeSampler<uint8_t>& volIter);
float computeSmoothedVoxel(Volume<uint8_t>::VolumeSampler& volIter);
}
#endif

View File

@ -26,6 +26,8 @@ freely, subject to the following restrictions:
#include "VertexTypes.h"
#include "PolyVoxImpl/TypeDef.h"
#include "Volume.h"
using namespace std;
namespace PolyVox
@ -39,7 +41,7 @@ namespace PolyVox
const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(mesh.m_Region.getLowerCorner());
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
VolumeSampler<uint8_t> volIter(volumeData);
Volume<uint8_t>::VolumeSampler volIter(volumeData);
//Check all corners are within the volume, allowing a boundary for gradient estimation
bool lowerCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor,2);
@ -65,7 +67,7 @@ namespace PolyVox
{
Vector3DFloat v3dGradient; //To store the result
VolumeSampler<uint8_t> volIter(volumeData);
Volume<uint8_t>::VolumeSampler volIter(volumeData);
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
@ -74,16 +76,16 @@ namespace PolyVox
switch(normalGenerationMethod)
{
case SOBEL_SMOOTHED:
gradFloor = computeSmoothSobelGradient(volIter);
gradFloor = computeSmoothSobelGradient<uint8_t>(volIter);
break;
case CENTRAL_DIFFERENCE_SMOOTHED:
gradFloor = computeSmoothCentralDifferenceGradient(volIter);
gradFloor = computeSmoothCentralDifferenceGradient<uint8_t>(volIter);
break;
case SOBEL:
gradFloor = computeSobelGradient(volIter);
gradFloor = computeSobelGradient<uint8_t>(volIter);
break;
case CENTRAL_DIFFERENCE:
gradFloor = computeCentralDifferenceGradient(volIter);
gradFloor = computeCentralDifferenceGradient<uint8_t>(volIter);
break;
}
@ -104,16 +106,16 @@ namespace PolyVox
switch(normalGenerationMethod)
{
case SOBEL_SMOOTHED:
gradCeil = computeSmoothSobelGradient(volIter);
gradCeil = computeSmoothSobelGradient<uint8_t>(volIter);
break;
case CENTRAL_DIFFERENCE_SMOOTHED:
gradCeil = computeSmoothCentralDifferenceGradient(volIter);
gradCeil = computeSmoothCentralDifferenceGradient<uint8_t>(volIter);
break;
case SOBEL:
gradCeil = computeSobelGradient(volIter);
gradCeil = computeSobelGradient<uint8_t>(volIter);
break;
case CENTRAL_DIFFERENCE:
gradCeil = computeCentralDifferenceGradient(volIter);
gradCeil = computeCentralDifferenceGradient<uint8_t>(volIter);
break;
}

View File

@ -23,11 +23,9 @@ freely, subject to the following restrictions:
#include "VoxelFilters.h"
#include "VolumeSampler.h"
namespace PolyVox
{
float computeSmoothedVoxel(VolumeSampler<uint8_t>& volIter)
float computeSmoothedVoxel(Volume<uint8_t>::VolumeSampler& volIter)
{
assert(volIter.getPosX() >= 1);
assert(volIter.getPosY() >= 1);

View File

@ -22,7 +22,6 @@ freely, subject to the following restrictions:
*******************************************************************************/
#include "Volume.h"
#include "VolumeSampler.h"
#include "PolyVoxImpl/Utility.h"
namespace PolyVox
@ -99,7 +98,7 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
//Write data
VolumeSampler<VoxelType> volIter(&volume);
Volume<VoxelType>::VolumeSampler volIter(&volume);
for(uint16_t z = 0; z < volumeDepth; ++z)
{
//Update progress once per slice.
@ -213,7 +212,7 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
//Write data
VolumeSampler<VoxelType> volIter(&volume);
Volume<VoxelType>::VolumeSampler volIter(&volume);
VoxelType current;
uint32_t runLength = 0;
bool firstTime = true;
@ -381,7 +380,7 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepth), sizeof(volumeDepth));
//Write data
VolumeSampler<VoxelType> volIter(&volume);
Volume<VoxelType>::VolumeSampler volIter(&volume);
VoxelType current;
uint32_t runLength = 0;
bool firstTime = true;

View File

@ -30,7 +30,6 @@ freely, subject to the following restrictions:
#include "PolyVoxImpl/Utility.h"
#include "Vector.h"
#include "Volume.h"
#include "VolumeSampler.h"
namespace PolyVox
{