Renamed MarchingCubesController to DefaultMarchingCubesController.
This commit is contained in:
		| @@ -32,6 +32,7 @@ SET(CORE_INC_FILES | |||||||
| 	include/PolyVoxCore/CubicSurfaceExtractor.inl | 	include/PolyVoxCore/CubicSurfaceExtractor.inl | ||||||
| 	include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h | 	include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h | ||||||
| 	include/PolyVoxCore/CubicSurfaceExtractorWithNormals.inl | 	include/PolyVoxCore/CubicSurfaceExtractorWithNormals.inl | ||||||
|  | 	include/PolyVoxCore/DefaultMarchingCubesController.h | ||||||
| 	include/PolyVoxCore/Density.h | 	include/PolyVoxCore/Density.h | ||||||
| 	include/PolyVoxCore/GradientEstimators.h | 	include/PolyVoxCore/GradientEstimators.h | ||||||
| 	include/PolyVoxCore/GradientEstimators.inl | 	include/PolyVoxCore/GradientEstimators.inl | ||||||
| @@ -43,7 +44,6 @@ SET(CORE_INC_FILES | |||||||
| 	include/PolyVoxCore/Log.h | 	include/PolyVoxCore/Log.h | ||||||
| 	include/PolyVoxCore/LowPassFilter.h | 	include/PolyVoxCore/LowPassFilter.h | ||||||
| 	include/PolyVoxCore/LowPassFilter.inl | 	include/PolyVoxCore/LowPassFilter.inl | ||||||
| 	include/PolyVoxCore/MarchingCubesController.h |  | ||||||
| 	include/PolyVoxCore/MarchingCubesSurfaceExtractor.h | 	include/PolyVoxCore/MarchingCubesSurfaceExtractor.h | ||||||
| 	include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl | 	include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl | ||||||
| 	include/PolyVoxCore/Material.h | 	include/PolyVoxCore/Material.h | ||||||
|   | |||||||
| @@ -29,18 +29,18 @@ freely, subject to the following restrictions: | |||||||
| namespace PolyVox | namespace PolyVox | ||||||
| { | { | ||||||
| 	template<typename VoxelType> | 	template<typename VoxelType> | ||||||
| 	class MarchingCubesController | 	class DefaultMarchingCubesController | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		typedef VoxelType DensityType; | 		typedef VoxelType DensityType; | ||||||
| 		typedef float MaterialType; | 		typedef float MaterialType; | ||||||
| 
 | 
 | ||||||
| 		MarchingCubesController(void) | 		DefaultMarchingCubesController(void) | ||||||
| 		{ | 		{ | ||||||
| 			m_tThreshold = ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2; | 			m_tThreshold = ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		MarchingCubesController(DensityType tThreshold) | 		DefaultMarchingCubesController(DensityType tThreshold) | ||||||
| 		{ | 		{ | ||||||
| 			m_tThreshold = tThreshold; | 			m_tThreshold = tThreshold; | ||||||
| 		} | 		} | ||||||
| @@ -24,7 +24,7 @@ freely, subject to the following restrictions: | |||||||
| #ifndef __PolyVox_Density_H__ | #ifndef __PolyVox_Density_H__ | ||||||
| #define __PolyVox_Density_H__ | #define __PolyVox_Density_H__ | ||||||
|  |  | ||||||
| #include "PolyVoxCore/MarchingCubesController.h" //We'll specialise the controller contained in here | #include "PolyVoxCore/DefaultMarchingCubesController.h" //We'll specialise the controller contained in here | ||||||
| #include "PolyVoxCore/Voxel.h" | #include "PolyVoxCore/Voxel.h" | ||||||
|  |  | ||||||
| #include "PolyVoxImpl/TypeDef.h" | #include "PolyVoxImpl/TypeDef.h" | ||||||
| @@ -103,19 +103,19 @@ namespace PolyVox | |||||||
| 	typedef Density<uint8_t> Density8; | 	typedef Density<uint8_t> Density8; | ||||||
|  |  | ||||||
| 	template <typename Type> | 	template <typename Type> | ||||||
| 	class MarchingCubesController< Density<Type> > | 	class DefaultMarchingCubesController< Density<Type> > | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		typedef Type DensityType; | 		typedef Type DensityType; | ||||||
| 		typedef float MaterialType; | 		typedef float MaterialType; | ||||||
|  |  | ||||||
| 		MarchingCubesController(void) | 		DefaultMarchingCubesController(void) | ||||||
| 		{ | 		{ | ||||||
| 			// Default to a threshold value halfway between the min and max possible values. | 			// Default to a threshold value halfway between the min and max possible values. | ||||||
| 			m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2; | 			m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		MarchingCubesController(DensityType tThreshold) | 		DefaultMarchingCubesController(DensityType tThreshold) | ||||||
| 		{ | 		{ | ||||||
| 			m_tThreshold = tThreshold; | 			m_tThreshold = tThreshold; | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -29,11 +29,11 @@ freely, subject to the following restrictions: | |||||||
|  |  | ||||||
| #include "PolyVoxCore/Array.h" | #include "PolyVoxCore/Array.h" | ||||||
| #include "PolyVoxCore/SurfaceMesh.h" | #include "PolyVoxCore/SurfaceMesh.h" | ||||||
| #include "PolyVoxCore/MarchingCubesController.h" | #include "PolyVoxCore/DefaultMarchingCubesController.h" | ||||||
|  |  | ||||||
| namespace PolyVox | namespace PolyVox | ||||||
| { | { | ||||||
| 	template< typename VolumeType, typename Controller = MarchingCubesController<typename VolumeType::VoxelType> > | 	template< typename VolumeType, typename Controller = DefaultMarchingCubesController<typename VolumeType::VoxelType> > | ||||||
| 	class MarchingCubesSurfaceExtractor | 	class MarchingCubesSurfaceExtractor | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| @@ -209,10 +209,10 @@ namespace PolyVox | |||||||
|  |  | ||||||
| 		//Our threshold value | 		//Our threshold value | ||||||
| 		//typename VoxelTypeTraits<typename VolumeType::VoxelType>::DensityType m_tThreshold; | 		//typename VoxelTypeTraits<typename VolumeType::VoxelType>::DensityType m_tThreshold; | ||||||
| 		typename MarchingCubesController<typename VolumeType::VoxelType>::DensityType m_tThreshold; | 		typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::DensityType m_tThreshold; | ||||||
|  |  | ||||||
| 		//Used to convert arbitrary voxel types in densities and materials. | 		//Used to convert arbitrary voxel types in densities and materials. | ||||||
| 		//MarchingCubesController<typename VolumeType::VoxelType> m_controller; | 		//DefaultMarchingCubesController<typename VolumeType::VoxelType> m_controller; | ||||||
| 		Controller m_controller; | 		Controller m_controller; | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -444,9 +444,9 @@ namespace PolyVox | |||||||
| 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | ||||||
| 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | ||||||
| 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial100 = m_controller.convertToMaterial(v100); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial100 = m_controller.convertToMaterial(v100); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial100); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial100); | ||||||
|  |  | ||||||
| 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | ||||||
| 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||||
| @@ -470,9 +470,9 @@ namespace PolyVox | |||||||
| 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | ||||||
| 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | ||||||
| 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial010 = m_controller.convertToMaterial(v010); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial010 = m_controller.convertToMaterial(v010); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial010); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial010); | ||||||
|  |  | ||||||
| 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | ||||||
| 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||||
| @@ -496,9 +496,9 @@ namespace PolyVox | |||||||
| 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | 					//Choose one of the two materials to use for the vertex (we don't interpolate as interpolation of | ||||||
| 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | 					//material IDs does not make sense). We take the largest, so that if we are working on a material-only | ||||||
| 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | 					//volume we get the one which is non-zero. Both materials can be non-zero if our volume has a density component. | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial000 = m_controller.convertToMaterial(v000); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial001 = m_controller.convertToMaterial(v001); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial001 = m_controller.convertToMaterial(v001); | ||||||
| 					typename MarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial001); | 					typename DefaultMarchingCubesController<typename VolumeType::VoxelType>::MaterialType uMaterial = (std::max)(uMaterial000, uMaterial001); | ||||||
|  |  | ||||||
| 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | 					PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast<float>(uMaterial)); | ||||||
| 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ freely, subject to the following restrictions: | |||||||
| #ifndef __PolyVox_MaterialDensityPair_H__ | #ifndef __PolyVox_MaterialDensityPair_H__ | ||||||
| #define __PolyVox_MaterialDensityPair_H__ | #define __PolyVox_MaterialDensityPair_H__ | ||||||
|  |  | ||||||
| #include "PolyVoxCore/MarchingCubesController.h" //We'll specialise the controller contained in here | #include "PolyVoxCore/DefaultMarchingCubesController.h" //We'll specialise the controller contained in here | ||||||
| #include "PolyVoxCore/Voxel.h" | #include "PolyVoxCore/Voxel.h" | ||||||
|  |  | ||||||
| #include "PolyVoxImpl/TypeDef.h" | #include "PolyVoxImpl/TypeDef.h" | ||||||
| @@ -115,19 +115,19 @@ namespace PolyVox | |||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	template <typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits> | 	template <typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits> | ||||||
| 	class MarchingCubesController< MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> > | 	class DefaultMarchingCubesController< MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> > | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		typedef Type DensityType; | 		typedef Type DensityType; | ||||||
| 		typedef Type MaterialType; | 		typedef Type MaterialType; | ||||||
|  |  | ||||||
| 		MarchingCubesController(void) | 		DefaultMarchingCubesController(void) | ||||||
| 		{ | 		{ | ||||||
| 			// Default to a threshold value halfway between the min and max possible values. | 			// 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; | 			m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		MarchingCubesController(DensityType tThreshold) | 		DefaultMarchingCubesController(DensityType tThreshold) | ||||||
| 		{ | 		{ | ||||||
| 			m_tThreshold = tThreshold; | 			m_tThreshold = tThreshold; | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								library/bindings/DefaultMarchingCubesController.i
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								library/bindings/DefaultMarchingCubesController.i
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | %module DefaultMarchingCubesController | ||||||
|  | %{ | ||||||
|  | #include "DefaultMarchingCubesController.h" | ||||||
|  | %} | ||||||
|  |  | ||||||
|  | %include "DefaultMarchingCubesController.h" | ||||||
|  |  | ||||||
| @@ -1,7 +0,0 @@ | |||||||
| %module MarchingCubesController |  | ||||||
| %{ |  | ||||||
| #include "MarchingCubesController.h" |  | ||||||
| %} |  | ||||||
|  |  | ||||||
| %include "MarchingCubesController.h" |  | ||||||
|  |  | ||||||
| @@ -27,6 +27,7 @@ const char* __str__() { | |||||||
| %include "stdint.i" | %include "stdint.i" | ||||||
| %include "std_vector.i" | %include "std_vector.i" | ||||||
| %include "Vector.i" | %include "Vector.i" | ||||||
|  | %include "DefaultMarchingCubesController.i" | ||||||
| %include "Density.i" | %include "Density.i" | ||||||
| %include "Material.i" | %include "Material.i" | ||||||
| %include "MaterialDensityPair.i" | %include "MaterialDensityPair.i" | ||||||
| @@ -38,7 +39,6 @@ const char* __str__() { | |||||||
| %include "VertexTypes.i" | %include "VertexTypes.i" | ||||||
| %include "SurfaceMesh.i" | %include "SurfaceMesh.i" | ||||||
| //%include "SimpleVolumeSampler.i" | //%include "SimpleVolumeSampler.i" | ||||||
| %include "MarchingCubesController.i" |  | ||||||
| %include "MarchingCubesSurfaceExtractor.i" | %include "MarchingCubesSurfaceExtractor.i" | ||||||
| //%include "CubicSurfaceExtractor.i" | //%include "CubicSurfaceExtractor.i" | ||||||
| //%include "CubicSurfaceExtractorWithNormals.i" | //%include "CubicSurfaceExtractorWithNormals.i" | ||||||
|   | |||||||
| @@ -117,7 +117,7 @@ void testForType(SurfaceMesh<PositionMaterialNormal>& result) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	MarchingCubesController<VoxelType> controller(50); | 	DefaultMarchingCubesController<VoxelType> controller(50); | ||||||
| 	MarchingCubesSurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, controller); | 	MarchingCubesSurfaceExtractor< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, controller); | ||||||
| 	extractor.execute(); | 	extractor.execute(); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user