From ed4bdf08c47a2e12c0ecbaaa0b66e1ebe30a00f9 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 12 Aug 2014 16:09:56 +0200 Subject: [PATCH] Added extraction test for MaterialDensityPair. --- tests/TestSurfaceExtractor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index e80f6b78..db9ac0b2 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -117,7 +117,10 @@ SimpleVolume* createAndFillVolume(void) { // Create a density field which changes throughout the volume. It's // zero in the lower corner and increasing as the coordinates increase. - volData->setVoxelAt(x, y, z, x + y + z); + VoxelType voxelValue; + writeDensityValueToVoxel(x + y + z, voxelValue); + writeMaterialValueToVoxel(z > uVolumeSideLength / 2 ? 42 : 79, voxelValue); + volData->setVoxelAt(x, y, z, voxelValue); } } } @@ -276,6 +279,13 @@ void TestSurfaceExtractor::testExecute() QCOMPARE(doubleMesh.getNoOfVertices(), uint16_t(16113)); // Verifies size of mesh and that we have 32-bit indices QCOMPARE(doubleMesh.getNoOfIndices(), uint32_t(22053)); // Verifies size of mesh QCOMPARE(doubleMesh.getIndex(100), uint16_t(26)); // Verifies that we have 32-bit indices + + auto materialVol = createAndFillVolume(); + auto materialMesh = extractMarchingCubesMesh(materialVol, materialVol->getEnclosingRegion()); + QCOMPARE(materialMesh.getNoOfVertices(), uint32_t(12096)); // Verifies size of mesh and that we have 32-bit indices + QCOMPARE(materialMesh.getNoOfIndices(), uint32_t(35157)); // Verifies size of mesh + QCOMPARE(materialMesh.getIndex(100), uint32_t(44)); // Verifies that we have 32-bit indices + QCOMPARE(materialMesh.getVertex(100).data.getMaterial(), uint16_t(79)); } QTEST_MAIN(TestSurfaceExtractor)