diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 2e17d32a..4cd45bab 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -77,8 +77,9 @@ int main(int argc, char *argv[]) SimpleVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); createSphereInVolume(volData, 30); - // Extract the surface for the specified region of the volume. - auto mesh = extractCubicSurfaceWithNormals(&volData, volData.getEnclosingRegion()); + // Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see. + //auto mesh = extractCubicSurfaceWithNormals(&volData, volData.getEnclosingRegion()); + auto mesh = extractMarchingCubesSurface(&volData, volData.getEnclosingRegion()); //Pass the surface to the OpenGL window openGLWidget.setSurfaceMeshToRender(mesh); diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h index 31803437..2603641a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h @@ -210,6 +210,22 @@ namespace PolyVox //Our threshold value typename Controller::DensityType m_tThreshold; }; + + template< typename VolumeType, typename Controller> + SurfaceMesh extractMarchingCubesSurface(VolumeType* volData, Region region, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, Controller controller) + { + SurfaceMesh result; + MarchingCubesSurfaceExtractor extractor(volData, region, &result, eWrapMode, tBorderValue, controller); + extractor.execute(); + return result; + } + + template< typename VolumeType> + SurfaceMesh extractMarchingCubesSurface(VolumeType* volData, Region region, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType()) + { + DefaultMarchingCubesController controller; + return extractMarchingCubesSurface(volData, region, eWrapMode, tBorderValue, controller); + } } #include "PolyVoxCore/MarchingCubesSurfaceExtractor.inl"