Debian Codegraph @

avogadro/core/layer.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_CORE_LAYER_H
7 #define AVOGADRO_CORE_LAYER_H
8
9 #include "avogadrocoreexport.h"
10
11 #include "avogadrocore.h"
12
13 #include <avogadro/core/array.h>
14
15 namespace Avogadro::Core {
16
17 /**
18 * @class Layer layer.h <avogadro/core/layer.h>
19 * @brief The Layer class represents a relation one to one between atoms ID
20 * and layer ID, and stores the unique active layer.
21 * Layer's ID are consecutively and there can't be a ID bigger than @p
22 * m_maxLayer.
23 */
24 class AVOGADROCORE_EXPORT Layer
25 {
26 public:
27 Layer() = default;
28 ~Layer() = default;
29
30 // att atom to param layer
31 void addAtom(size_t layer);
32 void addAtom(size_t layer, Index atom);
33 void addAtomToActiveLayer(Index atom);
34 void removeAtom(Index atom);
35 void removeLayer(size_t layer);
36
37 /** @return the layer ID from the @p atom. */
38 size_t getLayerID(Index atom) const;
39 /** @return the active Layer. */
40 size_t activeLayer() const;
41
42 /** @return the maximum layer allowed. */
43 size_t maxLayer() const;
44
45 /** @return the number of layers. */
46 size_t layerCount() const;
47
48 /** @return The number of atoms. */
49 size_t atomCount() const;
50
51 /** remove all IDs. */
52 void clear();
53
54 /** resize the atom-layer array to @p count atoms, removing any excess. */
55 void resize(size_t count);
56
57 /** increase the maximum layer allowed .*/
58 void addLayer();
59
60 /** insert a layer at @p layer, equal or bigger previous layers will be
61 * shifted. */
62 void addLayer(size_t layer);
63
64 /** change @p m_activeLayer. */
65 void setActiveLayer(size_t layer);
66
67 /** swap the layer ID from @p a and @p b. */
68 void swapLayer(Index a, Index b);
69
70 private:
71 Core::Array<size_t> m_atomAndLayers;
72 size_t m_activeLayer = 0;
73 size_t m_maxLayer = 0;
74 };
75
76 } // namespace Avogadro::Core
77
78 #endif