From ca45d49e0c63bfc46410bcbb6c1af17f408e65e0 Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Fri, 14 Dec 2012 15:25:21 +0100 Subject: [PATCH] More work on exposing wrap modes to marching cubes. --- .../DefaultMarchingCubesController.h | 22 ++++++++++++++----- .../PolyVoxCore/include/PolyVoxCore/Density.h | 5 +++++ .../include/PolyVoxCore/MaterialDensityPair.h | 5 +++++ tests/TestSurfaceExtractor.cpp | 3 ++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h index 81d382e1..59ca4345 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h +++ b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h @@ -77,10 +77,10 @@ namespace PolyVox /// if the voxel type is 'float' then the representable range is -FLT_MAX to FLT_MAX and the threshold will be set to zero. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DefaultMarchingCubesController(void) - { - m_tThreshold = ((std::numeric_limits::min)() + (std::numeric_limits::max)()) / 2; - m_eWrapMode = WrapModes::Border; - m_tBorder = 0; + :m_tThreshold(((std::numeric_limits::min)() + (std::numeric_limits::max)()) / 2) + ,m_eWrapMode(WrapModes::Border) + ,m_tBorder(VoxelType(0)) + { } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -89,12 +89,12 @@ namespace PolyVox /// This version of the constructor allows you to set some custom parameters /// \param tThreshold The threshold to use. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - DefaultMarchingCubesController(DensityType tThreshold) + /*DefaultMarchingCubesController(DensityType tThreshold) { m_tThreshold = tThreshold; m_eWrapMode = WrapModes::Border; m_tBorder = 0; - } + }*/ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Converts the underlying voxel type into a density value. @@ -135,6 +135,16 @@ namespace PolyVox return m_eWrapMode; } + VoxelType getBorderValue(void) + { + return m_tBorder; + } + + void setThreshold(DensityType tThreshold) + { + m_tThreshold = tThreshold; + } + void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType(0)) { m_eWrapMode = eWrapMode; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index a08481d3..1621a81e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -184,6 +184,11 @@ namespace PolyVox return m_eWrapMode; } + void setThreshold(DensityType tThreshold) + { + m_tThreshold = tThreshold; + } + void setWrapMode(WrapMode eWrapMode) { m_eWrapMode = eWrapMode; diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 2b85c7e8..3e40654c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -148,6 +148,11 @@ namespace PolyVox return m_eWrapMode; } + void setThreshold(DensityType tThreshold) + { + m_tThreshold = tThreshold; + } + void setWrapMode(WrapMode eWrapMode) { m_eWrapMode = eWrapMode; diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 116894a9..d1b88ebc 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -127,7 +127,8 @@ void testForType(SurfaceMesh& result) } } - DefaultMarchingCubesController controller(50); + DefaultMarchingCubesController controller; + controller.setThreshold(50); MarchingCubesSurfaceExtractor< SimpleVolume > extractor(&volData, volData.getEnclosingRegion(), &result, controller); extractor.execute(); }