diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index 6acd3222..33d477e7 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -26,6 +26,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Density.h" #include "PolyVoxCore/Material.h" #include "PolyVoxCore/MaterialDensityPair.h" +#include "PolyVoxCore/RawVolume.h" #include "PolyVoxCore/SimpleVolume.h" #include "PolyVoxCore/CubicSurfaceExtractor.h" @@ -56,11 +57,11 @@ public: }; // Runs the surface extractor for a given type. -template -SimpleVolume* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, VoxelType minValue, VoxelType maxValue) +template +VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename VolumeType::VoxelType minValue, typename VolumeType::VoxelType maxValue) { //Create empty volume - SimpleVolume* volData = new SimpleVolume(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)), 32); + VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1))); srand(12345); @@ -80,7 +81,7 @@ SimpleVolume* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, { // Otherwise we write random voxel values between zero and the requested maximum int voxelValue = (rand() % (maxValue - minValue + 1)) + minValue; - volData->setVoxelAt(x, y, z, static_cast(voxelValue)); + volData->setVoxelAt(x, y, z, static_cast(voxelValue)); } } } @@ -92,26 +93,26 @@ SimpleVolume* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, void TestCubicSurfaceExtractor::testBehaviour() { // Test with default mesh and contoller types. - auto uint8Vol = createAndFillVolumeWithNoise(32, 0, 2); + auto uint8Vol = createAndFillVolumeWithNoise< SimpleVolume >(32, 0, 2); auto uint8Mesh = extractCubicMesh(uint8Vol, uint8Vol->getEnclosingRegion()); QCOMPARE(uint8Mesh.getNoOfVertices(), uint32_t(57687)); QCOMPARE(uint8Mesh.getNoOfIndices(), uint32_t(216234)); // Test with default mesh type but user-provided controller. - auto int8Vol = createAndFillVolumeWithNoise(32, 0, 2); + auto int8Vol = createAndFillVolumeWithNoise< SimpleVolume >(32, 0, 2); auto int8Mesh = extractCubicMesh(int8Vol, int8Vol->getEnclosingRegion(), CustomIsQuadNeeded()); QCOMPARE(int8Mesh.getNoOfVertices(), uint32_t(29027)); QCOMPARE(int8Mesh.getNoOfIndices(), uint32_t(178356)); // Test with default controller but user-provided mesh. - auto uint32Vol = createAndFillVolumeWithNoise(32, 0, 2); + auto uint32Vol = createAndFillVolumeWithNoise< SimpleVolume >(32, 0, 2); CubicMesh< uint32_t, uint16_t > uint32Mesh; extractCubicMeshCustom(uint32Vol, uint32Vol->getEnclosingRegion(), &uint32Mesh); QCOMPARE(uint32Mesh.getNoOfVertices(), uint16_t(57687)); QCOMPARE(uint32Mesh.getNoOfIndices(), uint32_t(216234)); // Test with both mesh and controller being provided by the user. - auto int32Vol = createAndFillVolumeWithNoise(32, 0, 2); + auto int32Vol = createAndFillVolumeWithNoise< SimpleVolume >(32, 0, 2); CubicMesh< int32_t, uint16_t > int32Mesh; extractCubicMeshCustom(int32Vol, int32Vol->getEnclosingRegion(), &int32Mesh, CustomIsQuadNeeded()); QCOMPARE(int32Mesh.getNoOfVertices(), uint16_t(29027)); @@ -120,7 +121,7 @@ void TestCubicSurfaceExtractor::testBehaviour() void TestCubicSurfaceExtractor::testEmptyVolumePerformance() { - auto emptyVol = createAndFillVolumeWithNoise(32, 0, 0); + auto emptyVol = createAndFillVolumeWithNoise< RawVolume >(32, 0, 0); CubicMesh< uint32_t, uint16_t > emptyMesh; QBENCHMARK{ extractCubicMeshCustom(emptyVol, emptyVol->getEnclosingRegion(), &emptyMesh); } QCOMPARE(emptyMesh.getNoOfVertices(), uint16_t(0)); @@ -128,7 +129,7 @@ void TestCubicSurfaceExtractor::testEmptyVolumePerformance() void TestCubicSurfaceExtractor::testNoiseVolumePerformance() { - auto noiseVol = createAndFillVolumeWithNoise(32, 0, 1); + auto noiseVol = createAndFillVolumeWithNoise< RawVolume >(32, 0, 1); CubicMesh< uint32_t, uint16_t > noiseMesh; QBENCHMARK{ extractCubicMeshCustom(noiseVol, noiseVol->getEnclosingRegion(), &noiseMesh); } QCOMPARE(noiseMesh.getNoOfVertices(), uint16_t(28429));