• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PolyVoxCore/include/PolyVoxCore/BaseVolume.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 Copyright (c) 2005-2009 David Williams
00003 
00004 This software is provided 'as-is', without any express or implied
00005 warranty. In no event will the authors be held liable for any damages
00006 arising from the use of this software.
00007 
00008 Permission is granted to anyone to use this software for any purpose,
00009 including commercial applications, and to alter it and redistribute it
00010 freely, subject to the following restrictions:
00011 
00012     1. The origin of this software must not be misrepresented; you must not
00013     claim that you wrote the original software. If you use this software
00014     in a product, an acknowledgment in the product documentation would be
00015     appreciated but is not required.
00016 
00017     2. Altered source versions must be plainly marked as such, and must not be
00018     misrepresented as being the original software.
00019 
00020     3. This notice may not be removed or altered from any source
00021     distribution.   
00022 *******************************************************************************/
00023 
00024 #ifndef __PolyVox_BaseVolume_H__
00025 #define __PolyVox_BaseVolume_H__
00026 
00027 #include "PolyVoxCore/Log.h"
00028 #include "PolyVoxCore/Region.h"
00029 #include "PolyVoxCore/Vector.h"
00030 
00031 #include <cassert>
00032 #include <limits>
00033 
00034 namespace PolyVox
00035 {
00036     template <typename VoxelType>
00037     class BaseVolume
00038     {
00039     public:
00040         #ifndef SWIG
00041         template <typename DerivedVolumeType>
00042         class Sampler
00043         {
00044         public:
00045             Sampler(DerivedVolumeType* volume);
00046             ~Sampler();
00047 
00048             int32_t getPosX(void) const;
00049             int32_t getPosY(void) const;
00050             int32_t getPosZ(void) const;
00051             inline VoxelType getVoxel(void) const;  
00052 
00053             void setPosition(const Vector3DInt32& v3dNewPos);
00054             void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
00055             inline bool setVoxel(VoxelType tValue);
00056 
00057             void movePositiveX(void);
00058             void movePositiveY(void);
00059             void movePositiveZ(void);
00060 
00061             void moveNegativeX(void);
00062             void moveNegativeY(void);
00063             void moveNegativeZ(void);
00064 
00065             inline VoxelType peekVoxel1nx1ny1nz(void) const;
00066             inline VoxelType peekVoxel1nx1ny0pz(void) const;
00067             inline VoxelType peekVoxel1nx1ny1pz(void) const;
00068             inline VoxelType peekVoxel1nx0py1nz(void) const;
00069             inline VoxelType peekVoxel1nx0py0pz(void) const;
00070             inline VoxelType peekVoxel1nx0py1pz(void) const;
00071             inline VoxelType peekVoxel1nx1py1nz(void) const;
00072             inline VoxelType peekVoxel1nx1py0pz(void) const;
00073             inline VoxelType peekVoxel1nx1py1pz(void) const;
00074 
00075             inline VoxelType peekVoxel0px1ny1nz(void) const;
00076             inline VoxelType peekVoxel0px1ny0pz(void) const;
00077             inline VoxelType peekVoxel0px1ny1pz(void) const;
00078             inline VoxelType peekVoxel0px0py1nz(void) const;
00079             inline VoxelType peekVoxel0px0py0pz(void) const;
00080             inline VoxelType peekVoxel0px0py1pz(void) const;
00081             inline VoxelType peekVoxel0px1py1nz(void) const;
00082             inline VoxelType peekVoxel0px1py0pz(void) const;
00083             inline VoxelType peekVoxel0px1py1pz(void) const;
00084 
00085             inline VoxelType peekVoxel1px1ny1nz(void) const;
00086             inline VoxelType peekVoxel1px1ny0pz(void) const;
00087             inline VoxelType peekVoxel1px1ny1pz(void) const;
00088             inline VoxelType peekVoxel1px0py1nz(void) const;
00089             inline VoxelType peekVoxel1px0py0pz(void) const;
00090             inline VoxelType peekVoxel1px0py1pz(void) const;
00091             inline VoxelType peekVoxel1px1py1nz(void) const;
00092             inline VoxelType peekVoxel1px1py0pz(void) const;
00093             inline VoxelType peekVoxel1px1py1pz(void) const;
00094 
00095         protected:
00096             DerivedVolumeType* mVolume;
00097 
00098             //The current position in the volume
00099             int32_t mXPosInVolume;
00100             int32_t mYPosInVolume;
00101             int32_t mZPosInVolume;
00102         };
00103         #endif
00104 
00105     public:
00107         BaseVolume
00108         (
00109             const Region& regValid
00110         );
00112         ~BaseVolume();
00113 
00115         VoxelType getBorderValue(void) const;
00117         Region getEnclosingRegion(void) const;
00119         int32_t getWidth(void) const;
00121         int32_t getHeight(void) const;
00123         int32_t getDepth(void) const;
00125         int32_t getLongestSideLength(void) const;
00127         int32_t getShortestSideLength(void) const;
00129         float getDiagonalLength(void) const;
00131         VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
00133         VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
00134 
00136         void setBorderValue(const VoxelType& tBorder);
00138         bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
00140         bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
00141 
00143         uint32_t calculateSizeInBytes(void);
00144 
00145     protected:  
00146         //The size of the volume
00147         Region m_regValidRegion;
00148 
00149         //Some useful sizes
00150         int32_t m_uLongestSideLength;
00151         int32_t m_uShortestSideLength;
00152         float m_fDiagonalLength;
00153     };
00154 }
00155 
00156 #include "PolyVoxCore/BaseVolume.inl"
00157 #include "PolyVoxCore/BaseVolumeSampler.inl"
00158 
00159 #endif //__PolyVox_BaseVolume_H__

Generated on Sat Nov 19 2011 00:27:30 for PolyVox by  doxygen 1.7.1