File indexing completed on 2024-04-21 03:44:00
0001 /* 0002 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com> 0003 SPDX-License-Identifier: BSD-3-Clause AND GPL-2.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include "typedef.h" 0009 0010 class HTMesh; 0011 0012 /** 0013 * @class MeshIterator 0014 * MeshIterator is a very lightweight class used to iterate over the 0015 * result set of an HTMesh intersection. If you want to iterate over the same 0016 * result set multiple times in the same block of code, you don't need to create 0017 * a new MeshIterator, just call the reset() method and then re-use the iterator. 0018 */ 0019 0020 class MeshIterator 0021 { 0022 public: 0023 MeshIterator(HTMesh *mesh, BufNum bufNum = 0); 0024 0025 /** @short true if there are more trixel to iterate over. 0026 */ 0027 bool hasNext() const { return cnt < m_size; } 0028 0029 /** @short returns the next trixel 0030 */ 0031 Trixel next() const { return index[cnt++]; } 0032 0033 /** @short returns the number of trixels stored 0034 */ 0035 int size() const { return m_size; } 0036 0037 /** @short sets the count back to zero so you can use this iterator 0038 * to iterate again over the same result set. 0039 */ 0040 void reset() const { cnt = 0; } 0041 0042 private: 0043 const Trixel *index; 0044 int m_size; 0045 mutable int cnt; 0046 };