File indexing completed on 2024-04-28 07:31:40
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 #ifndef MESH_BUFFER_H 0007 #define MESH_BUFFER_H 0008 0009 #include "typedef.h" 0010 0011 class HTMesh; 0012 0013 /** @class MeshBuffer 0014 * The sole purpose of a MeshBuffer is to hold storage space 0015 * for the results of an HTM inetersection and then allow multiple 0016 * MeshIterator's to walk through the result set. The buffer space is allocated 0017 * when the MeshBuffer is created. Mesh buffers will usually hang around for 0018 * the life of an HTMesh. Each mesh buffer is re-usable. Simply reset() it and 0019 * then fill it by append()'ing trixels. A MeshIterator grabs the size() and 0020 * the buffer() so it can iterate over the results. 0021 */ 0022 0023 class MeshBuffer 0024 { 0025 public: 0026 MeshBuffer(HTMesh *mesh); 0027 0028 ~MeshBuffer(); 0029 0030 /** @short prepare the buffer for a new result set 0031 */ 0032 void reset() { m_size = m_error = 0; } 0033 0034 /** @short add trixels to the buffer 0035 */ 0036 int append(Trixel trixel); 0037 0038 /** @short the location of the buffer for reading 0039 */ 0040 const Trixel *buffer() const { return m_buffer; } 0041 0042 /** @short the number of trixels in the result set 0043 */ 0044 int size() const { return m_size; } 0045 0046 /** @short returns the number of trixels that would have overflowed the 0047 * buffer. 0048 */ 0049 int error() const { return m_error; } 0050 0051 /** @short fills the buffer with consecutive integers 0052 */ 0053 void fill(); 0054 0055 private: 0056 Trixel *m_buffer; 0057 int m_size; 0058 int maxSize; 0059 int m_error; 0060 }; 0061 0062 #endif