Start updating the library bindings

Nothing works at the moment and the bindings are likely going to have to
change significantly.

In the meantime just disable them by default to avoid confusion.
This commit is contained in:
Matt Williams 2014-12-10 15:47:54 +00:00
parent 436e8d479c
commit 2e98414fd3
7 changed files with 103 additions and 49 deletions

View File

@ -19,7 +19,7 @@
# 3. This notice may not be removed or altered from any source # 3. This notice may not be removed or altered from any source
# distribution. # distribution.
option(ENABLE_BINDINGS "Build bindings" ON) option(ENABLE_BINDINGS "Build bindings" OFF) #Off by default
if(ENABLE_BINDINGS) if(ENABLE_BINDINGS)
find_package(SWIG) find_package(SWIG)
mark_as_advanced(SWIG_DIR SWIG_VERSION) mark_as_advanced(SWIG_DIR SWIG_VERSION)

9
library/bindings/Chunk.i Normal file
View File

@ -0,0 +1,9 @@
%module Chunk
%{
#include "Chunk.h"
%}
%include "Chunk.h"
VOLUMETYPES(Chunk)

View File

@ -5,5 +5,5 @@
%include "CubicSurfaceExtractor.h" %include "CubicSurfaceExtractor.h"
%template(CubicSurfaceExtractorSimpleVolumeuint8) PolyVox::CubicSurfaceExtractor<PolyVox::SimpleVolume<uint8_t>, PolyVox::DefaultIsQuadNeeded<uint8_t> >; %template(extractCubicMeshSimpleVolumeuint8) extractCubicMesh<PolyVox::PagedVolume<uint8_t> >;
//EXTRACTORS(CubicSurfaceExtractor) //EXTRACTORS(CubicSurfaceExtractor)

View File

@ -0,0 +1,50 @@
%module PagedVolume
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
namespace PolyVox
{
class PolyVox::PagedVolume_Chunk {
public:
PagedVolume_Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, PolyVox::PagedVolume_Pager* pPager = nullptr);
~PagedVolume_Chunk();
VoxelType* getData(void) const;
uint32_t getDataSizeInBytes(void) const;
VoxelType getVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
VoxelType getVoxel(const Vector3DUint16& v3dPos) const;
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
};
class PolyVox::PagedVolume_Pager {
public:
/// Constructor
PagedVolume_Pager() {};
/// Destructor
virtual ~PagedVolume_Pager() {};
virtual void pageIn(const Region& region, PagedVolume_Chunk* pChunk) = 0;
virtual void pageOut(const Region& region, PagedVolume_Chunk* pChunk) = 0;
};
}
%{
#include "PagedVolume.h"
%}
%include "PagedVolume.h"
%{
namespace PolyVox
{
// SWIG thinks that Inner is a global class, so we need to trick the C++
// compiler into understanding this so called global type.
typedef PagedVolume<int8_t>::Pager PagedVolume_Pager;
typedef PagedVolume<int8_t>::Chunk PagedVolume_Chunk;
}
%}
VOLUMETYPES(PagedVolume)

View File

@ -28,30 +28,29 @@ const char* __str__() {
//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 ## int8) PolyVox::class<int8_t>; %template(class ## int8) PolyVox::class<int8_t>;
%template(class ## int16) PolyVox::class<int16_t>; //%template(class ## int16) PolyVox::class<int16_t>;
%template(class ## int32) PolyVox::class<int32_t>; //%template(class ## int32) PolyVox::class<int32_t>;
%template(class ## uint8) PolyVox::class<uint8_t>; //%template(class ## uint8) PolyVox::class<uint8_t>;
%template(class ## uint16) PolyVox::class<uint16_t>; //%template(class ## uint16) PolyVox::class<uint16_t>;
%template(class ## uint32) PolyVox::class<uint32_t>; //%template(class ## uint32) PolyVox::class<uint32_t>;
%template(class ## float) PolyVox::class<float>; //%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 ## int8) PolyVox::class<PolyVox::volumetype<int8_t> >; %template(class ## volumetype ## int8) PolyVox::class<PolyVox::volumetype<int8_t> >;
%template(class ## volumetype ## int16) PolyVox::class<PolyVox::volumetype<int16_t> >; //%template(class ## volumetype ## int16) PolyVox::class<PolyVox::volumetype<int16_t> >;
%template(class ## volumetype ## int32) PolyVox::class<PolyVox::volumetype<int32_t> >; //%template(class ## volumetype ## int32) PolyVox::class<PolyVox::volumetype<int32_t> >;
%template(class ## volumetype ## uint8) PolyVox::class<PolyVox::volumetype<uint8_t> >; //%template(class ## volumetype ## uint8) PolyVox::class<PolyVox::volumetype<uint8_t> >;
%template(class ## volumetype ## uint16) PolyVox::class<PolyVox::volumetype<uint16_t> >; //%template(class ## volumetype ## uint16) PolyVox::class<PolyVox::volumetype<uint16_t> >;
%template(class ## volumetype ## uint32) PolyVox::class<PolyVox::volumetype<uint32_t> >; //%template(class ## volumetype ## uint32) PolyVox::class<PolyVox::volumetype<uint32_t> >;
%template(class ## volumetype ## float) PolyVox::class<PolyVox::volumetype<float> >; //%template(class ## volumetype ## float) PolyVox::class<PolyVox::volumetype<float> >;
%enddef %enddef
//Template based on volume type //Template based on volume type
%define EXTRACTORS(shortname) %define EXTRACTORS(shortname)
EXTRACTOR(shortname, SimpleVolume) EXTRACTOR(shortname, PagedVolume)
EXTRACTOR(shortname, RawVolume) EXTRACTOR(shortname, RawVolume)
EXTRACTOR(shortname, LargeVolume)
%enddef %enddef
%feature("autodoc", "1"); %feature("autodoc", "1");
@ -75,24 +74,20 @@ EXTRACTOR(shortname, LargeVolume)
%include "Vector.i" %include "Vector.i"
%include "DefaultMarchingCubesController.i" %include "DefaultMarchingCubesController.i"
%include "Region.i" %include "Region.i"
%include "Block.i" //%include "Chunk.i"
%include "CompressedBlock.i" //%include "CompressedBlock.i"
%include "UncompressedBlock.i" //%include "UncompressedBlock.i"
%include "BlockCompressor.i" //%include "BlockCompressor.i"
%include "Pager.i" //%include "Pager.i"
%include "FilePager.i" //%include "FilePager.i"
%include "MinizBlockCompressor.i" //%include "MinizBlockCompressor.i"
%include "RLEBlockCompressor.i" //%include "RLEBlockCompressor.i"
%include "BaseVolume.i" %include "BaseVolume.i"
%include "SimpleVolume.i" //%include "RawVolume.i"
%include "RawVolume.i" %include "PagedVolume.i"
%include "LargeVolume.i" //%include "VertexTypes.i"
//%include "SubArray.i" //%include "SurfaceMesh.i"
//%include "Array.i" ////%include "MarchingCubesSurfaceExtractor.i"
%include "VertexTypes.i" ////%include "CubicSurfaceExtractor.i"
%include "SurfaceMesh.i" //%include "Raycast.i"
%include "MarchingCubesSurfaceExtractor.i" //%include "Picking.i"
%include "CubicSurfaceExtractor.i"
%include "CubicSurfaceExtractorWithNormals.i"
%include "Raycast.i"
%include "Picking.i"

View File

@ -1,20 +1,20 @@
%module SurfaceMesh %module SurfaceMesh
%{ %{
#include "Region.h" #include "Region.h"
#include "VertexTypes.h" #include "Vertex.h"
#include "SurfaceMesh.h" #include "Mesh.h"
%} %}
%include "Region.h" %include "Region.h"
%include "VertexTypes.h" %include "Vertex.h"
%include "SurfaceMesh.h" %include "Mesh.h"
//%template(VertexTypeVector) std::vector<PolyVox::VertexType>; //%template(VertexTypeVector) std::vector<PolyVox::VertexType>;
%template(PositionMaterialVector) std::vector<PolyVox::PositionMaterial>; //%template(PositionMaterialVector) std::vector<PolyVox::PositionMaterial>;
%template(PositionMaterialNormalVector) std::vector<PolyVox::PositionMaterialNormal>; //%template(PositionMaterialNormalVector) std::vector<PolyVox::PositionMaterialNormal>;
%template(LodRecordVector) std::vector<PolyVox::LodRecord>; //%template(LodRecordVector) std::vector<PolyVox::LodRecord>;
%template(uint8Vector) std::vector<uint8_t>; //%template(uint8Vector) std::vector<uint8_t>;
%template(uint32Vector) std::vector<uint32_t>; //%template(uint32Vector) std::vector<uint32_t>;
%template(SurfaceMeshPositionMaterial) PolyVox::SurfaceMesh<PolyVox::PositionMaterial>; %template(MeshPositionMaterial) PolyVox::Mesh<PolyVox::CubicVertex<uint8_t>, uint16_t >;
%template(SurfaceMeshPositionMaterialNormal) PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>; %template(MeshPositionMaterialNormal) PolyVox::Mesh<PolyVox::MarchingCubesVertex<uint8_t>, uint16_t >;

View File

@ -2,12 +2,12 @@
%{ %{
#include "Impl/TypeDef.h" #include "Impl/TypeDef.h"
#include "Vector.h" #include "Vector.h"
#include "VertexTypes.h" #include "Vertex.h"
%} %}
%include "Impl/TypeDef.h" %include "Impl/TypeDef.h"
%include "Vector.h" %include "Vector.h"
%include "VertexTypes.h" %include "Vertex.h"
//%template (PositionMaterial) PolyVox::PositionMaterial; //%template (PositionMaterial) PolyVox::PositionMaterial;
//%template (PositionMaterialNormal) PolyVox::PositionMaterialNormal; //%template (PositionMaterialNormal) PolyVox::PositionMaterialNormal;