File: MeshIterator.h

package info (click to toggle)
siril 1.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 47,656 kB
  • sloc: ansic: 175,395; cpp: 28,654; python: 8,476; makefile: 974; xml: 879; sh: 280
file content (46 lines) | stat: -rw-r--r-- 1,202 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
    SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com>
    SPDX-License-Identifier: BSD-3-Clause AND GPL-2.0-or-later
*/

#pragma once

#include "typedef.h"

class HTMesh;

/**
 * @class MeshIterator
 * MeshIterator is a very lightweight class used to iterate over the
 * result set of an HTMesh intersection.  If you want to iterate over the same
 * result set multiple times in the same block of code, you don't need to create
 * a new MeshIterator, just call the reset() method and then re-use the iterator.
 */

class MeshIterator
{
  public:
    MeshIterator(HTMesh *mesh, BufNum bufNum = 0);

    /** @short true if there are more trixel to iterate over.
         */
    bool hasNext() const { return cnt < m_size; }

    /** @short returns the next trixel
         */
    Trixel next() const { return index[cnt++]; }

    /** @short returns the number of trixels stored
         */
    int size() const { return m_size; }

    /** @short sets the count back to zero so you can use this iterator
         * to iterate again over the same result set.
         */
    void reset() const { cnt = 0; }

  private:
    const Trixel *index;
    int m_size;
    mutable int cnt;
};