Restructuring code...
This commit is contained in:
parent
1d51ee8d0a
commit
d353685ce9
@ -153,13 +153,11 @@ namespace PolyVox
|
||||
class MarchingCubesSurfaceExtractor
|
||||
{
|
||||
public:
|
||||
MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller);
|
||||
MarchingCubesSurfaceExtractor();
|
||||
|
||||
void execute();
|
||||
void execute(VolumeType* volData, Region region, MeshType* result, ControllerType controller);
|
||||
|
||||
private:
|
||||
//Compute the cell bitmask for a particular slice in z.
|
||||
void computeBitmaskForSlice();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010.
|
||||
@ -307,8 +305,8 @@ namespace PolyVox
|
||||
template< typename VolumeType, typename MeshType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
||||
void extractMarchingCubesMeshCustom(VolumeType* volData, Region region, MeshType* result, ControllerType controller = ControllerType())
|
||||
{
|
||||
MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType> extractor(volData, region, result, controller);
|
||||
extractor.execute();
|
||||
MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType> extractor;
|
||||
extractor.execute(volData, region, result, controller);
|
||||
}
|
||||
|
||||
template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
||||
|
@ -26,34 +26,24 @@ freely, subject to the following restrictions:
|
||||
namespace PolyVox
|
||||
{
|
||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||
MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller)
|
||||
:m_volData(volData)
|
||||
,m_meshCurrent(result)
|
||||
,m_regSizeInVoxels(region)
|
||||
,m_controller(controller)
|
||||
,m_tThreshold(m_controller.getThreshold())
|
||||
{
|
||||
POLYVOX_THROW_IF(m_meshCurrent == nullptr, std::invalid_argument, "Provided mesh cannot be null");
|
||||
MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::MarchingCubesSurfaceExtractor()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::execute()
|
||||
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::execute(VolumeType* volData, Region region, MeshType* result, ControllerType controller)
|
||||
{
|
||||
POLYVOX_THROW_IF(result == nullptr, std::invalid_argument, "Provided mesh cannot be null");
|
||||
|
||||
m_volData = volData;
|
||||
m_meshCurrent = result;
|
||||
m_regSizeInVoxels = region;
|
||||
m_controller = controller;
|
||||
m_tThreshold = m_controller.getThreshold();
|
||||
|
||||
Timer timer;
|
||||
m_meshCurrent->clear();
|
||||
|
||||
computeBitmaskForSlice();
|
||||
|
||||
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
||||
|
||||
POLYVOX_LOG_TRACE("Marching cubes surface extraction took ", timer.elapsedTimeInMilliSeconds(),
|
||||
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
|
||||
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
|
||||
}
|
||||
|
||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::computeBitmaskForSlice()
|
||||
{
|
||||
const uint32_t uArrayWidth = m_regSizeInVoxels.getUpperX() - m_regSizeInVoxels.getLowerX() + 2;
|
||||
const uint32_t uArrayHeight = m_regSizeInVoxels.getUpperY() - m_regSizeInVoxels.getLowerY() + 2;
|
||||
const uint32_t uArrayDepth = m_regSizeInVoxels.getUpperZ() - m_regSizeInVoxels.getLowerZ() + 2;
|
||||
@ -321,5 +311,11 @@ namespace PolyVox
|
||||
} // For Y
|
||||
startOfSlice.movePositiveZ();
|
||||
} // For Z
|
||||
}
|
||||
|
||||
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
||||
|
||||
POLYVOX_LOG_TRACE("Marching cubes surface extraction took ", timer.elapsedTimeInMilliSeconds(),
|
||||
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
|
||||
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user