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.
This commit is contained in:
Matt Williams 2012-11-24 15:37:46 +00:00
parent e7daab5bbc
commit bb3d3c4b68
3 changed files with 18 additions and 2 deletions

View File

@ -8,4 +8,4 @@
%include "SimpleVolume.h"
%include "MarchingCubesSurfaceExtractor.h"
%template(SurfaceExtractorSimpleVolumeDensity8) PolyVox::MarchingCubesSurfaceExtractor<PolyVox::SimpleVolume<PolyVox::Density8> >;
EXTRACTORS(MarchingCubesSurfaceExtractor)

View File

@ -34,6 +34,22 @@ const char* __str__() {
%template(class ## MaterialDensityPair88) PolyVox::class<PolyVox::MaterialDensityPair88>;
%enddef
//Template based on voxel type
%define EXTRACTOR(class, volumetype)
%template(class ## volumetype ## Density8) PolyVox::class<PolyVox::volumetype<PolyVox::Density8> >;
//%template(class ## volumetype ## Material8) PolyVox::class<PolyVox::volumetype<PolyVox::Material8> >;
//%template(class ## volumetype ## Material16) PolyVox::class<PolyVox::volumetype<PolyVox::Material16> >;
%template(class ## volumetype ## MaterialDensityPair44) PolyVox::class<PolyVox::volumetype<PolyVox::MaterialDensityPair44> >;
%template(class ## volumetype ## MaterialDensityPair88) PolyVox::class<PolyVox::volumetype<PolyVox::MaterialDensityPair88> >;
%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

View File

@ -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):