Work on custom thresholds in SurfaceExtractionController.
This commit is contained in:
		| @@ -109,6 +109,17 @@ namespace PolyVox | ||||
| 		typedef Type DensityType; | ||||
| 		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) | ||||
| 		{ | ||||
| 			return voxel.getDensity(); | ||||
| @@ -120,10 +131,12 @@ namespace PolyVox | ||||
| 		} | ||||
|  | ||||
| 		DensityType getThreshold(void) | ||||
| 		{ | ||||
| 			// Returns a threshold value halfway between the min and max possible values. | ||||
| 			return (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2; | ||||
| 		{			 | ||||
| 			return m_tThreshold; | ||||
| 		} | ||||
|  | ||||
| 	private: | ||||
| 		DensityType m_tThreshold; | ||||
| 	}; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -121,6 +121,17 @@ namespace PolyVox | ||||
| 		typedef Type DensityType; | ||||
| 		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) | ||||
| 		{ | ||||
| 			return voxel.getDensity(); | ||||
| @@ -132,10 +143,12 @@ namespace PolyVox | ||||
| 		} | ||||
|  | ||||
| 		DensityType getThreshold(void) | ||||
| 		{ | ||||
| 			// Returns a threshold value halfway between the min and max possible values. | ||||
| 			return (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2; | ||||
| 		} | ||||
| 		{			 | ||||
| 			return m_tThreshold; | ||||
| 		}		 | ||||
|  | ||||
| 	private: | ||||
| 		DensityType m_tThreshold; | ||||
| 	}; | ||||
|  | ||||
| 	typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44; | ||||
|   | ||||
| @@ -35,6 +35,16 @@ namespace PolyVox | ||||
| 		typedef VoxelType DensityType; | ||||
| 		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) | ||||
| 		{ | ||||
| 			return voxel; | ||||
| @@ -48,8 +58,11 @@ namespace PolyVox | ||||
| 		DensityType getThreshold(void) | ||||
| 		{ | ||||
| 			// 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 | ||||
| 	{ | ||||
| 	public: | ||||
| 		SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result); | ||||
| 		SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, Controller controller = Controller()); | ||||
|  | ||||
| 		void execute(); | ||||
|  | ||||
|   | ||||
| @@ -24,7 +24,7 @@ freely, subject to the following restrictions: | ||||
| namespace PolyVox | ||||
| { | ||||
| 	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_sampVolume(volData) | ||||
| 		,m_meshCurrent(result) | ||||
| @@ -34,7 +34,7 @@ namespace PolyVox | ||||
| 		m_regSizeInCells = m_regSizeInVoxels; | ||||
| 		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(); | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user