Work on custom thresholds in SurfaceExtractionController.
This commit is contained in:
parent
949528b07a
commit
1217ea1fd8
@ -109,6 +109,17 @@ namespace PolyVox
|
|||||||
typedef Type DensityType;
|
typedef Type DensityType;
|
||||||
typedef float MaterialType;
|
typedef float MaterialType;
|
||||||
|
|
||||||
|
SurfaceExtractionController(void)
|
||||||
|
{
|
||||||
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
|
m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceExtractionController(DensityType tThreshold)
|
||||||
|
{
|
||||||
|
m_tThreshold = tThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(Density<Type> voxel)
|
DensityType convertToDensity(Density<Type> voxel)
|
||||||
{
|
{
|
||||||
return voxel.getDensity();
|
return voxel.getDensity();
|
||||||
@ -120,10 +131,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
// Returns a threshold value halfway between the min and max possible values.
|
return m_tThreshold;
|
||||||
return (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DensityType m_tThreshold;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,17 @@ namespace PolyVox
|
|||||||
typedef Type DensityType;
|
typedef Type DensityType;
|
||||||
typedef Type MaterialType;
|
typedef Type MaterialType;
|
||||||
|
|
||||||
|
SurfaceExtractionController(void)
|
||||||
|
{
|
||||||
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
|
m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceExtractionController(DensityType tThreshold)
|
||||||
|
{
|
||||||
|
m_tThreshold = tThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
||||||
{
|
{
|
||||||
return voxel.getDensity();
|
return voxel.getDensity();
|
||||||
@ -132,10 +143,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
// Returns a threshold value halfway between the min and max possible values.
|
return m_tThreshold;
|
||||||
return (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
}
|
||||||
}
|
|
||||||
|
private:
|
||||||
|
DensityType m_tThreshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||||
|
@ -35,6 +35,16 @@ namespace PolyVox
|
|||||||
typedef VoxelType DensityType;
|
typedef VoxelType DensityType;
|
||||||
typedef float MaterialType;
|
typedef float MaterialType;
|
||||||
|
|
||||||
|
SurfaceExtractionController(void)
|
||||||
|
{
|
||||||
|
m_tThreshold = ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceExtractionController(DensityType tThreshold)
|
||||||
|
{
|
||||||
|
m_tThreshold = tThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(VoxelType voxel)
|
DensityType convertToDensity(VoxelType voxel)
|
||||||
{
|
{
|
||||||
return voxel;
|
return voxel;
|
||||||
@ -48,8 +58,11 @@ namespace PolyVox
|
|||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
// Returns a threshold value halfway between the min and max possible values.
|
// Returns a threshold value halfway between the min and max possible values.
|
||||||
return ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DensityType m_tThreshold;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace PolyVox
|
|||||||
class SurfaceExtractor
|
class SurfaceExtractor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result);
|
SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, Controller controller = Controller());
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template<typename VolumeType, typename Controller>
|
template<typename VolumeType, typename Controller>
|
||||||
SurfaceExtractor<VolumeType, Controller>::SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result)
|
SurfaceExtractor<VolumeType, Controller>::SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, Controller controller = Controller())
|
||||||
:m_volData(volData)
|
:m_volData(volData)
|
||||||
,m_sampVolume(volData)
|
,m_sampVolume(volData)
|
||||||
,m_meshCurrent(result)
|
,m_meshCurrent(result)
|
||||||
@ -34,7 +34,7 @@ namespace PolyVox
|
|||||||
m_regSizeInCells = m_regSizeInVoxels;
|
m_regSizeInCells = m_regSizeInVoxels;
|
||||||
m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1));
|
m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1));
|
||||||
|
|
||||||
//FIXME - Check is m_controller is guarenteed to be valid at this point?!
|
m_controller = controller;
|
||||||
m_tThreshold = m_controller.getThreshold();
|
m_tThreshold = m_controller.getThreshold();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
using namespace PolyVox;
|
using namespace PolyVox;
|
||||||
|
|
||||||
|
|
||||||
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
||||||
// They are conceptually the inverse of the 'convertToDensity' function used by the SurfaceExtractor. They probably shouldn't be part
|
// They are conceptually the inverse of the 'convertToDensity' function used by the SurfaceExtractor. They probably shouldn't be part
|
||||||
// of PolyVox, but they might be usful to other tests so we cold move them into a 'Tests.h' or something in the future.
|
// of PolyVox, but they might be usful to other tests so we cold move them into a 'Tests.h' or something in the future.
|
||||||
@ -92,8 +91,8 @@ void testForType(SurfaceMesh<PositionMaterialNormal>& result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// THIS TEST IS BROKEN BECAUSE CUSTOM THRESHOLDS ARE TEMOPRARILY NOT WORKING.
|
SurfaceExtractionController<VoxelType> controller(50);
|
||||||
SurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result/*, 50*/);
|
SurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, controller);
|
||||||
extractor.execute();
|
extractor.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user