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

PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl

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 #define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x)
00025 #define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1))
00026 //#define BORDER_LOW(x) (( x % this->mVolume->m_uBlockSideLength) != 0)
00027 //#define BORDER_HIGH(x) (( x % this->mVolume->m_uBlockSideLength) != this->mVolume->m_uBlockSideLength - 1)
00028 
00029 namespace PolyVox
00030 {
00031     template <typename VoxelType>
00032     SimpleVolume<VoxelType>::Sampler::Sampler(SimpleVolume<VoxelType>* volume)
00033         :BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >(volume)
00034     {
00035     }
00036 
00037     template <typename VoxelType>
00038     SimpleVolume<VoxelType>::Sampler::~Sampler()
00039     {
00040     }
00041 
00042     template <typename VoxelType>
00043     typename SimpleVolume<VoxelType>::Sampler& SimpleVolume<VoxelType>::Sampler::operator=(const typename SimpleVolume<VoxelType>::Sampler& rhs) throw()
00044     {
00045         if(this == &rhs)
00046         {
00047             return *this;
00048         }
00049         this->mVolume = rhs.mVolume;
00050         this->mXPosInVolume = rhs.mXPosInVolume;
00051         this->mYPosInVolume = rhs.mYPosInVolume;
00052         this->mZPosInVolume = rhs.mZPosInVolume;
00053         mCurrentVoxel = rhs.mCurrentVoxel;
00054         return *this;
00055     }
00056 
00057     template <typename VoxelType>
00058     int32_t SimpleVolume<VoxelType>::Sampler::getPosX(void) const
00059     {
00060         return this->mXPosInVolume;
00061     }
00062 
00063     template <typename VoxelType>
00064     int32_t SimpleVolume<VoxelType>::Sampler::getPosY(void) const
00065     {
00066         return this->mYPosInVolume;
00067     }
00068 
00069     template <typename VoxelType>
00070     int32_t SimpleVolume<VoxelType>::Sampler::getPosZ(void) const
00071     {
00072         return this->mZPosInVolume;
00073     }
00074 
00075     template <typename VoxelType>
00076     VoxelType SimpleVolume<VoxelType>::Sampler::getSubSampledVoxel(uint8_t uLevel) const
00077     {       
00078         if(uLevel == 0)
00079         {
00080             return getVoxel();
00081         }
00082         else if(uLevel == 1)
00083         {
00084             VoxelType tValue = getVoxel();
00085             tValue = (std::min)(tValue, peekVoxel1px0py0pz());
00086             tValue = (std::min)(tValue, peekVoxel0px1py0pz());
00087             tValue = (std::min)(tValue, peekVoxel1px1py0pz());
00088             tValue = (std::min)(tValue, peekVoxel0px0py1pz());
00089             tValue = (std::min)(tValue, peekVoxel1px0py1pz());
00090             tValue = (std::min)(tValue, peekVoxel0px1py1pz());
00091             tValue = (std::min)(tValue, peekVoxel1px1py1pz());
00092             return tValue;
00093         }
00094         else
00095         {
00096             const uint8_t uSize = 1 << uLevel;
00097 
00098             VoxelType tValue = (std::numeric_limits<VoxelType>::max)();
00099             for(uint8_t z = 0; z < uSize; ++z)
00100             {
00101                 for(uint8_t y = 0; y < uSize; ++y)
00102                 {
00103                     for(uint8_t x = 0; x < uSize; ++x)
00104                     {
00105                         tValue = (std::min)(tValue, this->mVolume->getVoxelAt(this->mXPosInVolume + x, this->mYPosInVolume + y, this->mZPosInVolume + z));
00106                     }
00107                 }
00108             }
00109             return tValue;
00110         }
00111     }
00112 
00113     template <typename VoxelType>
00114     VoxelType SimpleVolume<VoxelType>::Sampler::getVoxel(void) const
00115     {
00116         return *mCurrentVoxel;
00117     }
00118 
00119     template <typename VoxelType>
00120     void SimpleVolume<VoxelType>::Sampler::setPosition(const Vector3DInt32& v3dNewPos)
00121     {
00122         setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ());
00123     }
00124 
00125     template <typename VoxelType>
00126     void SimpleVolume<VoxelType>::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos)
00127     {
00128         this->mXPosInVolume = xPos;
00129         this->mYPosInVolume = yPos;
00130         this->mZPosInVolume = zPos;
00131 
00132         const int32_t uXBlock = this->mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower;
00133         const int32_t uYBlock = this->mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower;
00134         const int32_t uZBlock = this->mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower;
00135 
00136         const uint16_t uXPosInBlock = this->mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower);
00137         const uint16_t uYPosInBlock = this->mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower);
00138         const uint16_t uZPosInBlock = this->mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower);
00139 
00140         const uint32_t uVoxelIndexInBlock = uXPosInBlock + 
00141                 uYPosInBlock * this->mVolume->m_uBlockSideLength + 
00142                 uZPosInBlock * this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;
00143 
00144         if(this->mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock)))
00145         {
00146             Block* pUncompressedCurrentBlock = this->mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock);
00147 
00148             mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock;
00149         }
00150         else
00151         {
00152             mCurrentVoxel = this->mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock;
00153         }
00154     }
00155 
00156     template <typename VoxelType>
00157     bool SimpleVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
00158     {
00159         VoxelType* pBorderDataEndPlusOne = this->mVolume->m_pUncompressedBorderData + this->mVolume->m_uNoOfVoxelsPerBlock;
00160 
00161         //Make sure we're not trying to write to the border data
00162         if((mCurrentVoxel < this->mVolume->m_pUncompressedBorderData) || (mCurrentVoxel >= pBorderDataEndPlusOne))
00163         {
00164             *mCurrentVoxel = tValue;
00165             return true;
00166         }
00167         else
00168         {
00169             return false;
00170         }
00171     }
00172 
00173     template <typename VoxelType>
00174     void SimpleVolume<VoxelType>::Sampler::movePositiveX(void)
00175     {
00176         //Note the *pre* increament here
00177         if((++this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0)
00178         {
00179             //No need to compute new block.
00180             ++mCurrentVoxel;            
00181         }
00182         else
00183         {
00184             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00185             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00186         }
00187     }
00188 
00189     template <typename VoxelType>
00190     void SimpleVolume<VoxelType>::Sampler::movePositiveY(void)
00191     {
00192         //Note the *pre* increament here
00193         if((++this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0)
00194         {
00195             //No need to compute new block.
00196             mCurrentVoxel += this->mVolume->m_uBlockSideLength;
00197         }
00198         else
00199         {
00200             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00201             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00202         }
00203     }
00204 
00205     template <typename VoxelType>
00206     void SimpleVolume<VoxelType>::Sampler::movePositiveZ(void)
00207     {
00208         //Note the *pre* increament here
00209         if((++this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0)
00210         {
00211             //No need to compute new block.
00212             mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;
00213         }
00214         else
00215         {
00216             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00217             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00218         }
00219     }
00220 
00221     template <typename VoxelType>
00222     void SimpleVolume<VoxelType>::Sampler::moveNegativeX(void)
00223     {
00224         //Note the *post* decreament here
00225         if((this->mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0)
00226         {
00227             //No need to compute new block.
00228             --mCurrentVoxel;            
00229         }
00230         else
00231         {
00232             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00233             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00234         }
00235     }
00236 
00237     template <typename VoxelType>
00238     void SimpleVolume<VoxelType>::Sampler::moveNegativeY(void)
00239     {
00240         //Note the *post* decreament here
00241         if((this->mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0)
00242         {
00243             //No need to compute new block.
00244             mCurrentVoxel -= this->mVolume->m_uBlockSideLength;
00245         }
00246         else
00247         {
00248             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00249             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00250         }
00251     }
00252 
00253     template <typename VoxelType>
00254     void SimpleVolume<VoxelType>::Sampler::moveNegativeZ(void)
00255     {
00256         //Note the *post* decreament here
00257         if((this->mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0)
00258         {
00259             //No need to compute new block.
00260             mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;
00261         }
00262         else
00263         {
00264             //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
00265             setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
00266         }
00267     }
00268 
00269     template <typename VoxelType>
00270     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
00271     {
00272         if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00273         {
00274             return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00275         }
00276         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1);
00277     }
00278 
00279     template <typename VoxelType>
00280     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
00281     {
00282         if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
00283         {
00284             return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength);
00285         }
00286         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume);
00287     }
00288 
00289     template <typename VoxelType>
00290     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
00291     {
00292         if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00293         {
00294             return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00295         }
00296         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1);
00297     }
00298 
00299     template <typename VoxelType>
00300     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
00301     {
00302         if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00303         {
00304             return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00305         }
00306         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1);
00307     }
00308 
00309     template <typename VoxelType>
00310     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
00311     {
00312         if( BORDER_LOW(this->mXPosInVolume) )
00313         {
00314             return *(mCurrentVoxel - 1);
00315         }
00316         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume);
00317     }
00318 
00319     template <typename VoxelType>
00320     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
00321     {
00322         if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00323         {
00324             return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00325         }
00326         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1);
00327     }
00328 
00329     template <typename VoxelType>
00330     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
00331     {
00332         if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
00333         {
00334             return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00335         }
00336         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1);
00337     }
00338 
00339     template <typename VoxelType>
00340     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
00341     {
00342         if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
00343         {
00344             return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength);
00345         }
00346         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume);
00347     }
00348 
00349     template <typename VoxelType>
00350     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
00351     {
00352         if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00353         {
00354             return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00355         }
00356         return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1);
00357     }
00358 
00360 
00361     template <typename VoxelType>
00362     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
00363     {
00364         if( BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00365         {
00366             return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00367         }
00368         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1);
00369     }
00370 
00371     template <typename VoxelType>
00372     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
00373     {
00374         if( BORDER_LOW(this->mYPosInVolume) )
00375         {
00376             return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength);
00377         }
00378         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume);
00379     }
00380 
00381     template <typename VoxelType>
00382     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
00383     {
00384         if( BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00385         {
00386             return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00387         }
00388         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1);
00389     }
00390 
00391     template <typename VoxelType>
00392     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
00393     {
00394         if( BORDER_LOW(this->mZPosInVolume) )
00395         {
00396             return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00397         }
00398         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1);
00399     }
00400 
00401     template <typename VoxelType>
00402     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const
00403     {
00404             return *mCurrentVoxel;
00405     }
00406 
00407     template <typename VoxelType>
00408     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
00409     {
00410         if( BORDER_HIGH(this->mZPosInVolume) )
00411         {
00412             return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00413         }
00414         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1);
00415     }
00416 
00417     template <typename VoxelType>
00418     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
00419     {
00420         if( BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00421         {
00422             return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00423         }
00424         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1);
00425     }
00426 
00427     template <typename VoxelType>
00428     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
00429     {
00430         if( BORDER_HIGH(this->mYPosInVolume) )
00431         {
00432             return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength);
00433         }
00434         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume);
00435     }
00436 
00437     template <typename VoxelType>
00438     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
00439     {
00440         if( BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00441         {
00442             return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00443         }
00444         return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1);
00445     }
00446 
00448 
00449     template <typename VoxelType>
00450     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
00451     {
00452         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00453         {
00454             return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00455         }
00456         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1);
00457     }
00458 
00459     template <typename VoxelType>
00460     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
00461     {
00462         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) )
00463         {
00464             return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength);
00465         }
00466         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume);
00467     }
00468 
00469     template <typename VoxelType>
00470     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
00471     {
00472         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00473         {
00474             return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00475         }
00476         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1);
00477     }
00478 
00479     template <typename VoxelType>
00480     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
00481     {
00482         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00483         {
00484             return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00485         }
00486         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1);
00487     }
00488 
00489     template <typename VoxelType>
00490     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
00491     {
00492         if( BORDER_HIGH(this->mXPosInVolume) )
00493         {
00494             return *(mCurrentVoxel + 1);
00495         }
00496         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume);
00497     }
00498 
00499     template <typename VoxelType>
00500     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
00501     {
00502         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00503         {
00504             return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00505         }
00506         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1);
00507     }
00508 
00509     template <typename VoxelType>
00510     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
00511     {
00512         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) )
00513         {
00514             return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00515         }
00516         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1);
00517     }
00518 
00519     template <typename VoxelType>
00520     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
00521     {
00522         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) )
00523         {
00524             return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength);
00525         }
00526         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume);
00527     }
00528 
00529     template <typename VoxelType>
00530     VoxelType SimpleVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
00531     {
00532         if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) )
00533         {
00534             return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength);
00535         }
00536         return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
00537     }
00538 }
00539 
00540 #undef BORDER_LOW
00541 #undef BORDER_HIGH

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