Wrapped MarchingCubesSurfaceExtractor with functions (part of unclassing).

This commit is contained in:
David Williams
2014-03-05 16:30:54 +01:00
parent 529e97f71e
commit acbfb184b8
2 changed files with 19 additions and 2 deletions

View File

@ -77,8 +77,9 @@ int main(int argc, char *argv[])
SimpleVolume<uint8_t> 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);

View File

@ -210,6 +210,22 @@ namespace PolyVox
//Our threshold value
typename Controller::DensityType m_tThreshold;
};
template< typename VolumeType, typename Controller>
SurfaceMesh<PositionMaterialNormal> extractMarchingCubesSurface(VolumeType* volData, Region region, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, Controller controller)
{
SurfaceMesh<PositionMaterialNormal> result;
MarchingCubesSurfaceExtractor<VolumeType, Controller> extractor(volData, region, &result, eWrapMode, tBorderValue, controller);
extractor.execute();
return result;
}
template< typename VolumeType>
SurfaceMesh<PositionMaterialNormal> extractMarchingCubesSurface(VolumeType* volData, Region region, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType())
{
DefaultMarchingCubesController<typename VolumeType::VoxelType> controller;
return extractMarchingCubesSurface(volData, region, eWrapMode, tBorderValue, controller);
}
}
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.inl"