From 67ec0d2db81b426e3511242fbe62041d34aed3af Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 5 Mar 2014 15:41:16 +0100 Subject: [PATCH] Initial function wrapper around CubicSurfaceExtractorWithNormals. --- examples/Basic/main.cpp | 7 +++++-- .../PolyVoxCore/CubicSurfaceExtractorWithNormals.h | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 64097731..65814645 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -81,11 +81,14 @@ int main(int argc, char *argv[]) SurfaceMesh mesh; //Create a surface extractor. Comment out one of the following two lines to decide which type gets created. - CubicSurfaceExtractorWithNormals< SimpleVolume > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); + //CubicSurfaceExtractorWithNormals< SimpleVolume > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); //MarchingCubesSurfaceExtractor< SimpleVolume > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); //Execute the surface extractor. - surfaceExtractor.execute(); + //surfaceExtractor.execute(); + + DefaultIsQuadNeeded< uint8_t > isQuadNeeded; + mesh = extractCubicSurfaceWithNormals< SimpleVolume, DefaultIsQuadNeeded< uint8_t > >(&volData, volData.getEnclosingRegion(), WrapModes::Border, 0, isQuadNeeded); //Pass the surface to the OpenGL window openGLWidget.setSurfaceMeshToRender(mesh); diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h index 211734f0..9fc44d7c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h @@ -63,6 +63,15 @@ namespace PolyVox WrapMode m_eWrapMode; typename VolumeType::VoxelType m_tBorderValue; }; + + template + SurfaceMesh extractCubicSurfaceWithNormals(VolumeType* volData, Region region, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, IsQuadNeeded isQuadNeeded) + { + SurfaceMesh result; + CubicSurfaceExtractorWithNormals extractor(volData, region, &result, eWrapMode, tBorderValue, isQuadNeeded); + extractor.execute(); + return result; + } } #include "PolyVoxCore/CubicSurfaceExtractorWithNormals.inl"