diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 47b79721..e662bc2a 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -62,7 +62,7 @@ SET(CORE_INC_FILES include/PolyVoxCore/SimpleVolume.inl include/PolyVoxCore/SimpleVolumeBlock.inl include/PolyVoxCore/SimpleVolumeSampler.inl - include/PolyVoxCore/SurfaceExtractionController.h + include/PolyVoxCore/MarchingCubesController.h include/PolyVoxCore/MarchingCubesSurfaceExtractor.h include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl include/PolyVoxCore/SurfaceMesh.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index 801bebfb..e1d92e42 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -24,7 +24,7 @@ freely, subject to the following restrictions: #ifndef __PolyVox_Density_H__ #define __PolyVox_Density_H__ -#include "PolyVoxCore/SurfaceExtractionController.h" //We'll specialise the controller contained in here +#include "PolyVoxCore/MarchingCubesController.h" //We'll specialise the controller contained in here #include "PolyVoxCore/Voxel.h" #include "PolyVoxImpl/TypeDef.h" @@ -103,19 +103,19 @@ namespace PolyVox typedef Density Density8; template - class SurfaceExtractionController< Density > + class MarchingCubesController< Density > { public: typedef Type DensityType; typedef float MaterialType; - SurfaceExtractionController(void) + MarchingCubesController(void) { // Default to a threshold value halfway between the min and max possible values. m_tThreshold = (Density::getMinDensity() + Density::getMaxDensity()) / 2; } - SurfaceExtractionController(DensityType tThreshold) + MarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractionController.h b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesController.h similarity index 88% rename from library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractionController.h rename to library/PolyVoxCore/include/PolyVoxCore/MarchingCubesController.h index 9851dc9d..68b6b090 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractionController.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesController.h @@ -21,26 +21,26 @@ freely, subject to the following restrictions: distribution. *******************************************************************************/ -#ifndef __PolyVox_SurfaceExtractionController_H__ -#define __PolyVox_SurfaceExtractionController_H__ +#ifndef __PolyVox_MarchingCubesController_H__ +#define __PolyVox_MarchingCubesController_H__ #include namespace PolyVox { template - class SurfaceExtractionController + class MarchingCubesController { public: typedef VoxelType DensityType; typedef float MaterialType; - SurfaceExtractionController(void) + MarchingCubesController(void) { m_tThreshold = ((std::numeric_limits::min)() + (std::numeric_limits::max)()) / 2; } - SurfaceExtractionController(DensityType tThreshold) + MarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index ca087161..8ce8db43 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -24,7 +24,7 @@ freely, subject to the following restrictions: #ifndef __PolyVox_MaterialDensityPair_H__ #define __PolyVox_MaterialDensityPair_H__ -#include "PolyVoxCore/SurfaceExtractionController.h" //We'll specialise the controller contained in here +#include "PolyVoxCore/MarchingCubesController.h" //We'll specialise the controller contained in here #include "PolyVoxCore/Voxel.h" #include "PolyVoxImpl/TypeDef.h" @@ -115,19 +115,19 @@ namespace PolyVox }; template - class SurfaceExtractionController< MaterialDensityPair > + class MarchingCubesController< MaterialDensityPair > { public: typedef Type DensityType; typedef Type MaterialType; - SurfaceExtractionController(void) + MarchingCubesController(void) { // Default to a threshold value halfway between the min and max possible values. m_tThreshold = (MaterialDensityPair::getMinDensity() + MaterialDensityPair::getMaxDensity()) / 2; } - SurfaceExtractionController(DensityType tThreshold) + MarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; } diff --git a/library/bindings/MarchingCubesController.i b/library/bindings/MarchingCubesController.i new file mode 100644 index 00000000..ffe2c253 --- /dev/null +++ b/library/bindings/MarchingCubesController.i @@ -0,0 +1,7 @@ +%module MarchingCubesController +%{ +#include "MarchingCubesController.h" +%} + +%include "MarchingCubesController.h" + diff --git a/library/bindings/MarchingCubesSurfaceExtractor.i b/library/bindings/MarchingCubesSurfaceExtractor.i new file mode 100644 index 00000000..490fd36c --- /dev/null +++ b/library/bindings/MarchingCubesSurfaceExtractor.i @@ -0,0 +1,11 @@ +%module MarchingCubesSurfaceExtractor +%{ +#include "SimpleVolume.h" +#include "Material.h" +#include "MarchingCubesSurfaceExtractor.h" +%} + +%include "SimpleVolume.h" +%include "MarchingCubesSurfaceExtractor.h" + +%template(SurfaceExtractorSimpleVolumeDensity8) PolyVox::MarchingCubesSurfaceExtractor >; diff --git a/library/bindings/PolyVoxCore.i b/library/bindings/PolyVoxCore.i index 75bf41fc..5b87b333 100644 --- a/library/bindings/PolyVoxCore.i +++ b/library/bindings/PolyVoxCore.i @@ -38,7 +38,7 @@ const char* __str__() { %include "VertexTypes.i" %include "SurfaceMesh.i" //%include "SimpleVolumeSampler.i" -%include "SurfaceExtractionController.i" +%include "MarchingCubesController.i" %include "MarchingCubesSurfaceExtractor.i" //%include "CubicSurfaceExtractor.i" //%include "CubicSurfaceExtractorWithNormals.i" diff --git a/library/bindings/SurfaceExtractionController.i b/library/bindings/SurfaceExtractionController.i deleted file mode 100644 index 63eed130..00000000 --- a/library/bindings/SurfaceExtractionController.i +++ /dev/null @@ -1,7 +0,0 @@ -%module SurfaceExtractionController -%{ -#include "SurfaceExtractionController.h" -%} - -%include "SurfaceExtractionController.h" - diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 6cfb08b9..a9b98034 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -34,12 +34,12 @@ using namespace PolyVox; // Test our ability to modify the behaviour of the MarchingCubesSurfaceExtractor. This simple example only modifies // the threshold (and actually this can be achieved by passing a parameter to the constructor of the -// DefaultSurfaceExtractionController) but you could implement custom behaviour in the other members +// DefaultMarchingCubesController) but you could implement custom behaviour in the other members // if you wanted too. Actually, it's not clear if this ability is really useful because I can't think // what you'd modify apart from the threshold but the ability is at least available. Also, the -// DefaultSurfaceExtractionController is templatised whereas this exmple shows that controllers don't +// DefaultMarchingCubesController is templatised whereas this exmple shows that controllers don't // have to be. -class CustomSurfaceExtractionController +class CustomMarchingCubesController { public: float convertToDensity(float voxel) @@ -117,7 +117,7 @@ void testForType(SurfaceMesh& result) } } - SurfaceExtractionController controller(50); + MarchingCubesController controller(50); MarchingCubesSurfaceExtractor< SimpleVolume > extractor(&volData, volData.getEnclosingRegion(), &result, controller); extractor.execute(); } @@ -141,8 +141,8 @@ void testCustomController(SurfaceMesh& result) } } - CustomSurfaceExtractionController controller; - MarchingCubesSurfaceExtractor< SimpleVolume, CustomSurfaceExtractionController > extractor(&volData, volData.getEnclosingRegion(), &result, controller); + CustomMarchingCubesController controller; + MarchingCubesSurfaceExtractor< SimpleVolume, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller); extractor.execute(); }