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 namespace PolyVox 00025 { 00026 template <typename IteratorType> 00027 void IteratorController<IteratorType>::reset(void) 00028 { 00029 m_Iter->setPosition(m_regValid.getLowerCorner()); 00030 } 00031 00032 template <typename IteratorType> 00033 bool IteratorController<IteratorType>::moveForward(void) 00034 { 00035 Vector3DInt32 v3dInitialPosition(m_Iter->getPosX(), m_Iter->getPosY(), m_Iter->getPosZ()); 00036 00037 if(v3dInitialPosition.getX() < m_regValid.getUpperCorner().getX()) 00038 { 00039 m_Iter->movePositiveX(); 00040 return true; 00041 } 00042 00043 v3dInitialPosition.setX(m_regValid.getLowerCorner().getX()); 00044 00045 if(v3dInitialPosition.getY() < m_regValid.getUpperCorner().getY()) 00046 { 00047 v3dInitialPosition.setY(v3dInitialPosition.getY() + 1); 00048 m_Iter->setPosition(v3dInitialPosition); 00049 return true; 00050 } 00051 00052 v3dInitialPosition.setY(m_regValid.getLowerCorner().getY()); 00053 00054 if(v3dInitialPosition.getZ() < m_regValid.getUpperCorner().getZ()) 00055 { 00056 v3dInitialPosition.setZ(v3dInitialPosition.getZ() + 1); 00057 m_Iter->setPosition(v3dInitialPosition); 00058 return true; 00059 } 00060 00061 return false; 00062 } 00063 }