Avogadro::Core::Layer#
-
class Layer#
The Layer class represents a relation one to one between atoms ID and layer ID, and stores the unique active layer. Layer’s ID are consecutively and there can’t be a ID bigger than
m_maxLayer.Public Functions
-
Layer() = default#
-
~Layer() = default#
-
void addAtom(size_t layer)#
-
void addAtom(size_t layer, Index atom)#
-
void addAtomToActiveLayer(Index atom)#
-
void removeAtom(Index atom)#
-
void removeLayer(size_t layer)#
Remove
layer, renumbering higher layers down by one. Atoms that were inlayerare NOT removed from the per-atom array: they move into whichever layer is active once the active layer itself has been updated (see setActiveLayer’s effect below), so atomCount() never changes. Iflayeris the active layer, the layer below becomes active (layer 0 iflayeris 0); if the active layer is abovelayer, its id is decremented to keep naming the same layer. A no-op iflayeris greater than maxLayer(), or if maxLayer() is 0 (the only layer cannot be removed).
-
size_t getLayerID(Index atom) const#
- Returns:
the layer ID from the
atom.
-
size_t maxLayer() const#
- Returns:
the maximum layer allowed.
-
size_t layerCount() const#
- Returns:
the number of layers.
-
size_t atomCount() const#
- Returns:
The number of atoms.
-
void clear()#
remove all IDs.
-
void resize(size_t count)#
resize the atom-layer array to
countatoms, removing any excess.
-
void addLayer()#
increase the maximum layer allowed .
-
void addLayer(size_t layer)#
insert a layer at
layer, equal or bigger previous layers will be shifted up by one, and the active layer shifts up with them if it was at or abovelayer, so it keeps naming the same layer. A no-op iflayeris greater than maxLayer() + 1.
-
void setActiveLayer(size_t layer)#
change
m_activeLayertolayer. A layer id one past maxLayer() is accepted: it lets a caller point the active layer at a layer that does not exist yet, which is then created lazily the first time an atom is actually added to it (see addAtomToActiveLayer() / addAtom()). Anything further out of range is ignored, leaving the active layer unchanged.
-
void swapLayer(Index a, Index b)#
swap the layer ID from
aandb. A no-op if either index is out of range (>= atomCount()).
-
Layer() = default#