Removed remaining uses of template template parameters.

This commit is contained in:
unknown 2012-06-12 16:38:51 +02:00
parent fcefe27192
commit 71b884e97b
5 changed files with 53 additions and 53 deletions

View File

@ -28,8 +28,8 @@ freely, subject to the following restrictions:
namespace PolyVox namespace PolyVox
{ {
template< template<typename> class VolumeType> template< typename VolumeType >
float computeSmoothedVoxel(typename VolumeType<uint8_t>::Sampler& volIter); float computeSmoothedVoxel(typename VolumeType::Sampler& volIter);
} }
#endif #endif

View File

@ -25,8 +25,8 @@ freely, subject to the following restrictions:
namespace PolyVox namespace PolyVox
{ {
template< template<typename> class VolumeType> template< typename VolumeType >
float computeSmoothedVoxel(typename VolumeType<uint8_t>::Sampler& volIter) float computeSmoothedVoxel(typename VolumeType::Sampler& volIter)
{ {
float sum = 0.0; float sum = 0.0;

View File

@ -42,29 +42,29 @@ namespace PolyVox
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// THESE FUNCTIONS ARE DEPRECATED. USE VERSIONED 'loadVolume' AND 'saveVolume' INSTEAD. // THESE FUNCTIONS ARE DEPRECATED. USE VERSIONED 'loadVolume' AND 'saveVolume' INSTEAD.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
polyvox_shared_ptr< VolumeType<VoxelType> > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); polyvox_shared_ptr< VolumeType > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
void saveVolumeRaw(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); void saveVolumeRaw(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
polyvox_shared_ptr< VolumeType<VoxelType> > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); polyvox_shared_ptr< VolumeType > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
void saveVolumeRle(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); void saveVolumeRle(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// END OF DEPRECATED FUNCTIONS // END OF DEPRECATED FUNCTIONS
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool loadVolume(std::istream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); bool loadVolume(std::istream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool saveVolume(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); bool saveVolume(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool loadVersion0(std::istream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); bool loadVersion0(std::istream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool saveVersion0(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener = 0); bool saveVersion0(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener = 0);
} }
#include "PolyVoxUtil/Serialization.inl" #include "PolyVoxUtil/Serialization.inl"

View File

@ -25,8 +25,8 @@ namespace PolyVox
{ {
//Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller.
//FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
polyvox_shared_ptr< VolumeType<VoxelType> > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener) polyvox_shared_ptr< VolumeType > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener)
{ {
assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'loadVolume()' ASAP. assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'loadVolume()' ASAP.
@ -43,7 +43,7 @@ namespace PolyVox
uint16_t volumeDepth = 0x0001 << volumeDepthPower; uint16_t volumeDepth = 0x0001 << volumeDepthPower;
//FIXME - need to support non cubic volumes //FIXME - need to support non cubic volumes
polyvox_shared_ptr< VolumeType<VoxelType> > volume(new LargeVolume<VoxelType>(volumeWidth, volumeHeight, volumeDepth)); polyvox_shared_ptr< VolumeType > volume(new LargeVolume<VolumeType::VoxelType>(volumeWidth, volumeHeight, volumeDepth));
//Read data //Read data
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
@ -59,7 +59,7 @@ namespace PolyVox
{ {
for(uint16_t x = 0; x < volumeWidth; ++x) for(uint16_t x = 0; x < volumeWidth; ++x)
{ {
VoxelType value; VolumeType::VoxelType value;
stream.read(reinterpret_cast<char*>(&value), sizeof(value)); stream.read(reinterpret_cast<char*>(&value), sizeof(value));
volume->setVoxelAt(x,y,z,value); volume->setVoxelAt(x,y,z,value);
@ -76,8 +76,8 @@ namespace PolyVox
return volume; return volume;
} }
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
void saveVolumeRaw(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) void saveVolumeRaw(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'saveVolume()' ASAP. assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'saveVolume()' ASAP.
@ -95,7 +95,7 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower)); stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
//Write data //Write data
VolumeType<VoxelType>::Sampler volIter(&volume); VolumeType::Sampler volIter(&volume);
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
{ {
//Update progress once per slice. //Update progress once per slice.
@ -110,7 +110,7 @@ namespace PolyVox
for(uint16_t x = 0; x < volumeWidth; ++x) for(uint16_t x = 0; x < volumeWidth; ++x)
{ {
volIter.setPosition(x,y,z); volIter.setPosition(x,y,z);
VoxelType value = volIter.getVoxel(); VolumeType::VoxelType value = volIter.getVoxel();
stream.write(reinterpret_cast<char*>(&value), sizeof(value)); stream.write(reinterpret_cast<char*>(&value), sizeof(value));
} }
} }
@ -125,8 +125,8 @@ namespace PolyVox
//Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller.
//FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
polyvox_shared_ptr< VolumeType<VoxelType> > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener) polyvox_shared_ptr< VolumeType > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener)
{ {
assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'loadVolume()' ASAP. assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'loadVolume()' ASAP.
@ -143,12 +143,12 @@ namespace PolyVox
uint16_t volumeDepth = 0x0001 << volumeDepthPower; uint16_t volumeDepth = 0x0001 << volumeDepthPower;
//FIXME - need to support non cubic volumes //FIXME - need to support non cubic volumes
polyvox_shared_ptr< VolumeType<VoxelType> > volume(new LargeVolume<VoxelType>(volumeWidth, volumeHeight, volumeDepth)); polyvox_shared_ptr< VolumeType > volume(new LargeVolume<VolumeType::VoxelType>(volumeWidth, volumeHeight, volumeDepth));
//Read data //Read data
bool firstTime = true; bool firstTime = true;
uint32_t runLength = 0; uint32_t runLength = 0;
VoxelType value; VolumeType::VoxelType value;
stream.read(reinterpret_cast<char*>(&value), sizeof(value)); stream.read(reinterpret_cast<char*>(&value), sizeof(value));
stream.read(reinterpret_cast<char*>(&runLength), sizeof(runLength)); stream.read(reinterpret_cast<char*>(&runLength), sizeof(runLength));
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
@ -190,8 +190,8 @@ namespace PolyVox
return volume; return volume;
} }
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
void saveVolumeRle(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) void saveVolumeRle(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'saveVolume()' ASAP. assert(false); //THIS FUNCTION IS DEPRECATED. REMOVE THIS ASSERT TO CONTINUE, BUT SWITCH TO 'saveVolume()' ASAP.
@ -209,8 +209,8 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower)); stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
//Write data //Write data
VolumeType<VoxelType>::Sampler volIter(&volume); VolumeType::Sampler volIter(&volume);
VoxelType current; VolumeType::VoxelType current;
uint32_t runLength = 0; uint32_t runLength = 0;
bool firstTime = true; bool firstTime = true;
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
@ -227,7 +227,7 @@ namespace PolyVox
for(uint16_t x = 0; x < volumeWidth; ++x) for(uint16_t x = 0; x < volumeWidth; ++x)
{ {
volIter.setPosition(x,y,z); volIter.setPosition(x,y,z);
VoxelType value = volIter.getVoxel(); VolumeType::VoxelType value = volIter.getVoxel();
if(firstTime) if(firstTime)
{ {
current = value; current = value;
@ -265,8 +265,8 @@ namespace PolyVox
// New version of load/save code with versioning // New version of load/save code with versioning
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool loadVolume(std::istream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) bool loadVolume(std::istream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
char pIdentifier[8]; char pIdentifier[8];
stream.read(pIdentifier, 7); stream.read(pIdentifier, 7);
@ -290,8 +290,8 @@ namespace PolyVox
} }
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool saveVolume(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) bool saveVolume(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
char pIdentifier[] = "PolyVox"; char pIdentifier[] = "PolyVox";
stream.write(pIdentifier, 7); stream.write(pIdentifier, 7);
@ -304,8 +304,8 @@ namespace PolyVox
//Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller.
//FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool loadVersion0(std::istream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) bool loadVersion0(std::istream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
//Read volume dimensions //Read volume dimensions
uint16_t volumeWidth = 0; uint16_t volumeWidth = 0;
@ -322,7 +322,7 @@ namespace PolyVox
//Read data //Read data
bool firstTime = true; bool firstTime = true;
uint32_t runLength = 0; uint32_t runLength = 0;
VoxelType value; VolumeType::VoxelType value;
stream.read(reinterpret_cast<char*>(&value), sizeof(value)); stream.read(reinterpret_cast<char*>(&value), sizeof(value));
stream.read(reinterpret_cast<char*>(&runLength), sizeof(runLength)); stream.read(reinterpret_cast<char*>(&runLength), sizeof(runLength));
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
@ -364,8 +364,8 @@ namespace PolyVox
return true; return true;
} }
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType >
bool saveVersion0(std::ostream& stream, VolumeType<VoxelType>& volume, VolumeSerializationProgressListener* progressListener) bool saveVersion0(std::ostream& stream, VolumeType& volume, VolumeSerializationProgressListener* progressListener)
{ {
//Write volume dimensions //Write volume dimensions
uint16_t volumeWidth = volume.getWidth(); uint16_t volumeWidth = volume.getWidth();
@ -377,8 +377,8 @@ namespace PolyVox
stream.write(reinterpret_cast<char*>(&volumeDepth), sizeof(volumeDepth)); stream.write(reinterpret_cast<char*>(&volumeDepth), sizeof(volumeDepth));
//Write data //Write data
VolumeType<VoxelType>::Sampler volIter(&volume); VolumeType::Sampler volIter(&volume);
VoxelType current; VolumeType::VoxelType current;
uint32_t runLength = 0; uint32_t runLength = 0;
bool firstTime = true; bool firstTime = true;
for(uint16_t z = 0; z < volumeDepth; ++z) for(uint16_t z = 0; z < volumeDepth; ++z)
@ -395,7 +395,7 @@ namespace PolyVox
for(uint16_t x = 0; x < volumeWidth; ++x) for(uint16_t x = 0; x < volumeWidth; ++x)
{ {
volIter.setPosition(x,y,z); volIter.setPosition(x,y,z);
VoxelType value = volIter.getVoxel(); VolumeType::VoxelType value = volIter.getVoxel();
if(firstTime) if(firstTime)
{ {
current = value; current = value;

View File

@ -31,8 +31,8 @@ freely, subject to the following restrictions:
using namespace PolyVox; using namespace PolyVox;
template< template<typename> class VolumeType, typename VoxelType> template< typename VolumeType>
bool testVoxelValidator(const VolumeType<VoxelType>* volData, const Vector3DInt32& v3dPos) bool testVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos)
{ {
//Voxels are considered valid candidates for the path if they are inside the volume... //Voxels are considered valid candidates for the path if they are inside the volume...
if(volData->getEnclosingRegion().containsPoint(v3dPos) == false) if(volData->getEnclosingRegion().containsPoint(v3dPos) == false)
@ -40,7 +40,7 @@ bool testVoxelValidator(const VolumeType<VoxelType>* volData, const Vector3DInt3
return false; return false;
} }
VoxelType voxel = volData->getVoxelAt(v3dPos); VolumeType::VoxelType voxel = volData->getVoxelAt(v3dPos);
if(voxel != 0) if(voxel != 0)
{ {
return false; return false;
@ -150,7 +150,7 @@ void TestAStarPathfinder::testExecute()
std::list<Vector3DInt32> result; std::list<Vector3DInt32> result;
//Create an AStarPathfinder //Create an AStarPathfinder
AStarPathfinderParams< RawVolume<uint8_t> > params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(15,15,15), &result, 1.0f, 10000, TwentySixConnected, &testVoxelValidator<RawVolume, uint8_t>); AStarPathfinderParams< RawVolume<uint8_t> > params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(15,15,15), &result, 1.0f, 10000, TwentySixConnected, &testVoxelValidator<RawVolume<uint8_t> >);
AStarPathfinder< RawVolume<uint8_t> > pathfinder(params); AStarPathfinder< RawVolume<uint8_t> > pathfinder(params);
//Execute the pathfinder. //Execute the pathfinder.