From bb3d3c4b68b242f4f7b9c89dd63bc53a61919e8c Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Sat, 24 Nov 2012 15:37:46 +0000 Subject: [PATCH] Add a EXTRACTORS macro to automate the generation of the extractors Like with VOLUMETYPES it is centralising the definitions of the volume and voxel types. --- library/bindings/MarchingCubesSurfaceExtractor.i | 2 +- library/bindings/PolyVoxCore.i | 16 ++++++++++++++++ tests/TestSurfaceExtractor.py | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/library/bindings/MarchingCubesSurfaceExtractor.i b/library/bindings/MarchingCubesSurfaceExtractor.i index 490fd36c..cf97b0e6 100644 --- a/library/bindings/MarchingCubesSurfaceExtractor.i +++ b/library/bindings/MarchingCubesSurfaceExtractor.i @@ -8,4 +8,4 @@ %include "SimpleVolume.h" %include "MarchingCubesSurfaceExtractor.h" -%template(SurfaceExtractorSimpleVolumeDensity8) PolyVox::MarchingCubesSurfaceExtractor >; +EXTRACTORS(MarchingCubesSurfaceExtractor) diff --git a/library/bindings/PolyVoxCore.i b/library/bindings/PolyVoxCore.i index 72bdbbef..2207b191 100644 --- a/library/bindings/PolyVoxCore.i +++ b/library/bindings/PolyVoxCore.i @@ -34,6 +34,22 @@ const char* __str__() { %template(class ## MaterialDensityPair88) PolyVox::class; %enddef +//Template based on voxel type +%define EXTRACTOR(class, volumetype) +%template(class ## volumetype ## Density8) PolyVox::class >; +//%template(class ## volumetype ## Material8) PolyVox::class >; +//%template(class ## volumetype ## Material16) PolyVox::class >; +%template(class ## volumetype ## MaterialDensityPair44) PolyVox::class >; +%template(class ## volumetype ## MaterialDensityPair88) PolyVox::class >; +%enddef + +//Template based on volume type +%define EXTRACTORS(shortname) +EXTRACTOR(shortname, SimpleVolume) +EXTRACTOR(shortname, RawVolume) +EXTRACTOR(shortname, LargeVolume) +%enddef + %feature("autodoc", "1"); //This will rename "operator=" to "assign" since Python doesn't have assignment diff --git a/tests/TestSurfaceExtractor.py b/tests/TestSurfaceExtractor.py index 7e966584..1d8465ad 100644 --- a/tests/TestSurfaceExtractor.py +++ b/tests/TestSurfaceExtractor.py @@ -15,7 +15,7 @@ class TestSurfaceExtractor(unittest.TestCase): #Set one single voxel to have a reasonably high density vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), PolyVoxCore.Density8(200)) self.mesh = PolyVoxCore.SurfaceMeshPositionMaterialNormal() - extractor = PolyVoxCore.SurfaceExtractorSimpleVolumeDensity8(vol, r, self.mesh) + extractor = PolyVoxCore.MarchingCubesSurfaceExtractorSimpleVolumeDensity8(vol, r, self.mesh) extractor.execute() def test_num_vertices(self):