Added Region class.
This commit is contained in:
		| @@ -4,6 +4,7 @@ PROJECT(PolyVox) | ||||
| SET(SRC_FILES | ||||
| 	source/IndexedSurfacePatch.cpp | ||||
| 	source/MarchingCubesTables.cpp | ||||
| 	source/Region.cpp | ||||
| 	source/RegionGeometry.cpp  | ||||
| 	source/SurfaceExtractors.cpp  | ||||
| 	source/SurfaceVertex.cpp | ||||
| @@ -26,6 +27,7 @@ SET(INC_FILES | ||||
| 	include/IndexedSurfacePatch.h | ||||
| 	include/MarchingCubesTables.h | ||||
| 	include/PolyVoxForwardDeclarations.h | ||||
| 	include/Region.h | ||||
| 	include/RegionGeometry.h | ||||
| 	include/SurfaceExtractors.h | ||||
| 	include/SurfaceVertex.h | ||||
|   | ||||
| @@ -49,8 +49,8 @@ namespace PolyVox | ||||
| 		VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const; | ||||
| 		VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const; | ||||
|  | ||||
| 		bool containsPoint(Vector3DFloat pos, float boundary) const; | ||||
| 		bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const; | ||||
| 		bool containsPoint(const Vector3DFloat& pos, float boundary) const; | ||||
| 		bool containsPoint(const Vector3DInt32& pos, boost::uint16_t boundary) const; | ||||
| 		VolumeIterator<VoxelType> firstVoxel(void); | ||||
| 		void idle(boost::uint32_t uAmount); | ||||
| 		VolumeIterator<VoxelType> lastVoxel(void); | ||||
|   | ||||
| @@ -163,7 +163,7 @@ namespace PolyVox | ||||
|  | ||||
| 	#pragma region Other | ||||
| 	template <typename VoxelType> | ||||
| 	bool BlockVolume<VoxelType>::containsPoint(Vector3DFloat pos, float boundary) const | ||||
| 	bool BlockVolume<VoxelType>::containsPoint(const Vector3DFloat& pos, float boundary) const | ||||
| 	{ | ||||
| 		return (pos.x() <= m_uSideLength - 1 - boundary) | ||||
| 			&& (pos.y() <= m_uSideLength - 1 - boundary)  | ||||
| @@ -174,7 +174,7 @@ namespace PolyVox | ||||
| 	} | ||||
|  | ||||
| 	template <typename VoxelType> | ||||
| 	bool BlockVolume<VoxelType>::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const | ||||
| 	bool BlockVolume<VoxelType>::containsPoint(const Vector3DInt32& pos, boost::uint16_t boundary) const | ||||
| 	{ | ||||
| 		return (pos.x() <= m_uSideLength - 1 - boundary) | ||||
| 			&& (pos.y() <= m_uSideLength - 1 - boundary)  | ||||
|   | ||||
| @@ -29,17 +29,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | ||||
| namespace PolyVox | ||||
| { | ||||
| 	template <typename VoxelType> class Block; | ||||
|  | ||||
| 	//---------- BlockVolume ---------- | ||||
| 	template <typename VoxelType> class BlockVolume; | ||||
| 	//Some handy typedefs | ||||
| 	typedef BlockVolume<float> FloatBlockVolume; | ||||
| 	typedef BlockVolume<boost::uint8_t> UInt8BlockVolume; | ||||
| 	typedef BlockVolume<boost::uint16_t> UInt16BlockVolume; | ||||
| 	//--------------------------------- | ||||
|  | ||||
| 	class IndexedSurfacePatch; | ||||
| 	class IntegrealVector3; | ||||
| 	template <typename VoxelType> class LinearVolume; | ||||
| 	class VolumeChangeTracker; | ||||
| 	class Region; | ||||
| 	class RegionGeometry; | ||||
| 	class SurfaceVertex; | ||||
|  | ||||
| 	//---------- Vector ---------- | ||||
| 	template <boost::uint32_t Size, typename Type> class Vector; | ||||
| 	typedef Vector<3,float> Vector3DFloat; | ||||
|     typedef Vector<3,double> Vector3DDouble; | ||||
| @@ -48,7 +53,10 @@ namespace PolyVox | ||||
| 	typedef Vector<3,boost::int16_t> Vector3DInt16; | ||||
| 	typedef Vector<3,boost::uint16_t> Vector3DUint16; | ||||
| 	typedef Vector<3,boost::int32_t> Vector3DInt32; | ||||
| 	typedef Vector<3,boost::uint32_t> Vector3DUint32;		 | ||||
| 	typedef Vector<3,boost::uint32_t> Vector3DUint32; | ||||
| 	//---------------------------- | ||||
|  | ||||
| 	class VolumeChangeTracker; | ||||
| 	template <typename VoxelType> class VolumeIterator; | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										52
									
								
								include/Region.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								include/Region.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| #pragma region License | ||||
| /****************************************************************************** | ||||
| This file is part of the PolyVox library | ||||
| Copyright (C) 2006  David Williams | ||||
|  | ||||
| This program is free software; you can redistribute it and/or | ||||
| modify it under the terms of the GNU General Public License | ||||
| as published by the Free Software Foundation; either version 2 | ||||
| of the License, or (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License | ||||
| along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | ||||
| ******************************************************************************/ | ||||
| #pragma endregion | ||||
|  | ||||
| #ifndef __PolyVox_Region_H__ | ||||
| #define __PolyVox_Region_H__ | ||||
|  | ||||
| #pragma region Headers | ||||
| #include "Vector.h" | ||||
| #pragma endregion | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	class Region | ||||
| 	{ | ||||
| 	public: | ||||
| 		Region(); | ||||
| 		Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner); | ||||
|  | ||||
| 		const Vector3DInt32& getLowerCorner(void) const; | ||||
| 		const Vector3DInt32& getUpperCorner(void) const; | ||||
|  | ||||
| 		void setLowerCorner(const Vector3DInt32& v3dLowerCorner); | ||||
| 		void setUpperCorner(const Vector3DInt32& v3dUpperCorner); | ||||
|  | ||||
| 		bool containsPoint(const Vector3DFloat& pos, float boundary) const; | ||||
| 		bool containsPoint(const Vector3DInt32& pos, boost::uint8_t boundary) const; | ||||
|  | ||||
| 	private: | ||||
| 		Vector3DInt32 m_v3dLowerCorner; | ||||
| 		Vector3DInt32 m_v3dUpperCorner; | ||||
| 	}; | ||||
| } | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										56
									
								
								source/Region.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								source/Region.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| #include "Region.h" | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	Region::Region() | ||||
| 		:m_v3dLowerCorner(0,0,0) | ||||
| 		,m_v3dUpperCorner(0,0,0) | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner) | ||||
| 		:m_v3dLowerCorner(v3dLowerCorner) | ||||
| 		,m_v3dUpperCorner(v3dUpperCorner) | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	const Vector3DInt32& Region::getLowerCorner(void) const | ||||
| 	{ | ||||
| 		return m_v3dLowerCorner; | ||||
| 	} | ||||
|  | ||||
| 	const Vector3DInt32& Region::getUpperCorner(void) const | ||||
| 	{ | ||||
| 		return m_v3dUpperCorner; | ||||
| 	}	 | ||||
|  | ||||
| 	void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner) | ||||
| 	{ | ||||
| 		m_v3dLowerCorner = v3dLowerCorner; | ||||
| 	} | ||||
|  | ||||
| 	void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner) | ||||
| 	{ | ||||
| 		m_v3dUpperCorner = v3dUpperCorner; | ||||
| 	} | ||||
|  | ||||
| 	bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const | ||||
| 	{ | ||||
| 		return (pos.x() <= m_v3dUpperCorner.x() - boundary) | ||||
| 			&& (pos.y() <= m_v3dUpperCorner.y() - boundary)  | ||||
| 			&& (pos.z() <= m_v3dUpperCorner.z() - boundary) | ||||
| 			&& (pos.x() >= m_v3dLowerCorner.x() + boundary) | ||||
| 			&& (pos.y() >= m_v3dLowerCorner.y() + boundary) | ||||
| 			&& (pos.z() >= m_v3dLowerCorner.z() + boundary); | ||||
| 	} | ||||
|  | ||||
| 	bool Region::containsPoint(const Vector3DInt32& pos, boost::uint8_t boundary) const | ||||
| 	{ | ||||
| 		return (pos.x() <= m_v3dUpperCorner.x() - boundary) | ||||
| 			&& (pos.y() <= m_v3dUpperCorner.y() - boundary)  | ||||
| 			&& (pos.z() <= m_v3dUpperCorner.z() - boundary) | ||||
| 			&& (pos.x() >= m_v3dLowerCorner.x() + boundary) | ||||
| 			&& (pos.y() >= m_v3dLowerCorner.y() + boundary) | ||||
| 			&& (pos.z() >= m_v3dLowerCorner.z() + boundary); | ||||
| 	} | ||||
| } | ||||
| @@ -250,24 +250,6 @@ namespace PolyVox | ||||
| 		m_normalGenerationMethod = method; | ||||
| 	} | ||||
|  | ||||
| 	/*bool VolumeChangeTracker::containsPoint(Vector3DFloat pos, float boundary) | ||||
| 	{ | ||||
| 		return volumeData->containsPoint(pos, boundary); | ||||
| 	} | ||||
|  | ||||
| 	bool VolumeChangeTracker::containsPoint(Vector3DInt32 pos, uint16_t boundary) | ||||
| 	{ | ||||
| 		return volumeData->containsPoint(pos, boundary); | ||||
| 	}*/ | ||||
|  | ||||
| 	/* | ||||
|  | ||||
| 	void VolumeChangeTracker::setAxisVisible(bool visible) | ||||
| 	{ | ||||
| 		if(m_axisNode) | ||||
| 			m_axisNode->setVisible(visible); | ||||
| 	}*/ | ||||
|  | ||||
| 	const BlockVolume<boost::uint8_t>* VolumeChangeTracker::getVolumeData(void) const | ||||
| 	{ | ||||
| 		return volumeData; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user