Remove Density and Material tyes from bindings

We now only have the bindings for (u)int{8,16,32}_t and float. This will
hopefully simplify things.
This commit is contained in:
Matt Williams 2012-11-26 13:58:51 +00:00
parent 6e296b010f
commit 79cc521666
11 changed files with 23 additions and 67 deletions

View File

@ -1,12 +1,8 @@
%module SimpleVolume %module SimpleVolume
%{ %{
#include "Material.h"
#include "Density.h"
#include "BaseVolume.h" #include "BaseVolume.h"
%} %}
%include "Material.h"
%include "Density.h"
%include "BaseVolume.h" %include "BaseVolume.h"
VOLUMETYPES(BaseVolume) VOLUMETYPES(BaseVolume)

View File

@ -1,9 +0,0 @@
%module Density
%{
#include "Density.h"
%}
%include "MarchingCubesSurfaceExtractor.h"
%include "Density.h"
%template(Density8) PolyVox::Density<uint8_t>;

View File

@ -1,12 +1,8 @@
%module LargeVolume %module LargeVolume
%{ %{
#include "Material.h"
#include "Density.h"
#include "LargeVolume.h" #include "LargeVolume.h"
%} %}
%include "Material.h"
%include "Density.h"
%include "LargeVolume.h" %include "LargeVolume.h"
VOLUMETYPES(LargeVolume) VOLUMETYPES(LargeVolume)

View File

@ -1,10 +0,0 @@
%module Material
%{
#include "Material.h"
%}
%include "DefaultIsQuadNeeded.h"
%include "Material.h"
%template(Material8) PolyVox::Material<uint8_t>;
%template(Material16) PolyVox::Material<uint16_t>;

View File

@ -1,9 +0,0 @@
%module MaterialDensityPair
%{
#include "MaterialDensityPair.h"
%}
%include "MaterialDensityPair.h"
%template(MaterialDensityPair44) PolyVox::MaterialDensityPair<uint8_t, 4, 4>;
%template(MaterialDensityPair88) PolyVox::MaterialDensityPair<uint16_t, 8, 8>;

View File

@ -27,20 +27,24 @@ const char* __str__() {
//Centralise this to avoid repeating ourselves //Centralise this to avoid repeating ourselves
//This macro will be called in the volume interface files to define the various volume types. //This macro will be called in the volume interface files to define the various volume types.
%define VOLUMETYPES(class) %define VOLUMETYPES(class)
%template(class ## Density8) PolyVox::class<PolyVox::Density8>; %template(class ## int8) PolyVox::class<int8_t>;
%template(class ## Material8) PolyVox::class<PolyVox::Material8>; %template(class ## int16) PolyVox::class<int16_t>;
%template(class ## Material16) PolyVox::class<PolyVox::Material16>; %template(class ## int32) PolyVox::class<int32_t>;
%template(class ## MaterialDensityPair44) PolyVox::class<PolyVox::MaterialDensityPair44>; %template(class ## uint8) PolyVox::class<uint8_t>;
%template(class ## MaterialDensityPair88) PolyVox::class<PolyVox::MaterialDensityPair88>; %template(class ## uint16) PolyVox::class<uint16_t>;
%template(class ## uint32) PolyVox::class<uint32_t>;
%template(class ## float) PolyVox::class<float>;
%enddef %enddef
//Template based on voxel type //Template based on voxel type
%define EXTRACTOR(class, volumetype) %define EXTRACTOR(class, volumetype)
%template(class ## volumetype ## Density8) PolyVox::class<PolyVox::volumetype<PolyVox::Density8> >; %template(class ## volumetype ## int8) PolyVox::class<PolyVox::volumetype<int8_t> >;
//%template(class ## volumetype ## Material8) PolyVox::class<PolyVox::volumetype<PolyVox::Material8> >; %template(class ## volumetype ## int16) PolyVox::class<PolyVox::volumetype<int16_t> >;
//%template(class ## volumetype ## Material16) PolyVox::class<PolyVox::volumetype<PolyVox::Material16> >; %template(class ## volumetype ## int32) PolyVox::class<PolyVox::volumetype<int32_t> >;
%template(class ## volumetype ## MaterialDensityPair44) PolyVox::class<PolyVox::volumetype<PolyVox::MaterialDensityPair44> >; %template(class ## volumetype ## uint8) PolyVox::class<PolyVox::volumetype<uint8_t> >;
%template(class ## volumetype ## MaterialDensityPair88) PolyVox::class<PolyVox::volumetype<PolyVox::MaterialDensityPair88> >; %template(class ## volumetype ## uint16) PolyVox::class<PolyVox::volumetype<uint16_t> >;
%template(class ## volumetype ## uint32) PolyVox::class<PolyVox::volumetype<uint32_t> >;
%template(class ## volumetype ## float) PolyVox::class<PolyVox::volumetype<float> >;
%enddef %enddef
//Template based on volume type //Template based on volume type
@ -61,9 +65,6 @@ EXTRACTOR(shortname, LargeVolume)
%include "std_vector.i" %include "std_vector.i"
%include "Vector.i" %include "Vector.i"
%include "DefaultMarchingCubesController.i" %include "DefaultMarchingCubesController.i"
%include "Density.i"
%include "Material.i"
%include "MaterialDensityPair.i"
%include "Region.i" %include "Region.i"
%include "BaseVolume.i" %include "BaseVolume.i"
%include "SimpleVolume.i" %include "SimpleVolume.i"

View File

@ -1,12 +1,8 @@
%module RawVolume %module RawVolume
%{ %{
#include "Material.h"
#include "Density.h"
#include "RawVolume.h" #include "RawVolume.h"
%} %}
%include "Material.h"
%include "Density.h"
%include "RawVolume.h" %include "RawVolume.h"
VOLUMETYPES(RawVolume) VOLUMETYPES(RawVolume)

View File

@ -28,7 +28,7 @@ public:
{ {
return false; //Make this raise a Python exception return false; //Make this raise a Python exception
} }
PyObject *args = Py_BuildValue("(l)", sampler.getVoxel().getDensity()); //TODO pass the sampler object itself in PyObject *args = Py_BuildValue("(l)", sampler.getVoxel()); //TODO pass the sampler object itself in
PyObject *result = PyObject_Call(func,args,0); PyObject *result = PyObject_Call(func,args,0);
Py_DECREF(args); Py_DECREF(args);
Py_XDECREF(result); Py_XDECREF(result);
@ -50,5 +50,4 @@ PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const Pol
template<typename VolumeType, typename Callback> template<typename VolumeType, typename Callback>
PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback); PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback);
%template(raycastWithEndpointsSimpleVolumeDensity8) raycastWithEndpointsPython<PolyVox::SimpleVolume<PolyVox::Density8>, PyCallback<PolyVox::SimpleVolume<PolyVox::Density8> > >; %template(raycastWithEndpointsSimpleVolumeuint8) raycastWithEndpointsPython<PolyVox::SimpleVolume<uint8_t>, PyCallback<PolyVox::SimpleVolume<uint8_t> > >;
//%template(raycastWithEndpointsSimpleVolumeMaterial8) raycastWithEndpointsPython<PolyVox::SimpleVolume<PolyVox::Material8>, PyCallback<PolyVox::SimpleVolume<PolyVox::Material8> > >;

View File

@ -1,12 +1,8 @@
%module SimpleVolume %module SimpleVolume
%{ %{
#include "Material.h"
#include "Density.h"
#include "SimpleVolume.h" #include "SimpleVolume.h"
%} %}
%include "Material.h"
%include "Density.h"
%include "SimpleVolume.h" %include "SimpleVolume.h"
VOLUMETYPES(SimpleVolume) VOLUMETYPES(SimpleVolume)

View File

@ -14,15 +14,15 @@ class TestSurfaceExtractor(unittest.TestCase):
#Create a small volume #Create a small volume
r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31)) r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31))
self.vol = PolyVoxCore.SimpleVolumeDensity8(r) self.vol = PolyVoxCore.SimpleVolumeuint8(r)
#Set one single voxel to have a reasonably high density #Set one single voxel to have a reasonably high density
self.vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), PolyVoxCore.Density8(200)) self.vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), 200)
def test_hit_voxel(self): def test_hit_voxel(self):
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeDensity8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(31,31,31), test_functor), 1) self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(31,31,31), test_functor), 1)
def test_miss_voxel(self): def test_miss_voxel(self):
self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeDensity8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(0,31,31), test_functor), 0) self.assertEqual(PolyVoxCore.raycastWithEndpointsSimpleVolumeuint8(self.vol, PolyVoxCore.Vector3DFloat(0,0,0), PolyVoxCore.Vector3DFloat(0,31,31), test_functor), 0)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -11,11 +11,11 @@ class TestSurfaceExtractor(unittest.TestCase):
#Create a small volume #Create a small volume
r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31)) r = PolyVoxCore.Region(PolyVoxCore.Vector3DInt32(0,0,0), PolyVoxCore.Vector3DInt32(31,31,31))
vol = PolyVoxCore.SimpleVolumeDensity8(r) vol = PolyVoxCore.SimpleVolumeuint8(r)
#Set one single voxel to have a reasonably high density #Set one single voxel to have a reasonably high density
vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), PolyVoxCore.Density8(200)) vol.setVoxelAt(PolyVoxCore.Vector3DInt32(5, 5, 5), 200)
self.mesh = PolyVoxCore.SurfaceMeshPositionMaterialNormal() self.mesh = PolyVoxCore.SurfaceMeshPositionMaterialNormal()
extractor = PolyVoxCore.MarchingCubesSurfaceExtractorSimpleVolumeDensity8(vol, r, self.mesh) extractor = PolyVoxCore.MarchingCubesSurfaceExtractorSimpleVolumeuint8(vol, r, self.mesh)
extractor.execute() extractor.execute()
def test_num_vertices(self): def test_num_vertices(self):