1 | /*
|
---|
2 | * BondVectors_impl.hpp
|
---|
3 | *
|
---|
4 | * Created on: Jun 13, 2017
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 |
|
---|
9 | #ifndef DYNAMICS_BONDVECTORS_IMPL_HPP_
|
---|
10 | #define DYNAMICS_BONDVECTORS_IMPL_HPP_
|
---|
11 |
|
---|
12 | // include config.h
|
---|
13 | #ifdef HAVE_CONFIG_H
|
---|
14 | #include <config.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "BondVectors.hpp"
|
---|
18 |
|
---|
19 | #include <algorithm>
|
---|
20 |
|
---|
21 | #include "Atom/atom.hpp"
|
---|
22 |
|
---|
23 | BondVectors::BondVectors() :
|
---|
24 | map_is_dirty(false),
|
---|
25 | current_step_for_map((size_t)-1)
|
---|
26 | {}
|
---|
27 |
|
---|
28 | template <class T>
|
---|
29 | void BondVectors::setFromAtomRange(
|
---|
30 | typename T::iterator _start,
|
---|
31 | typename T::iterator _end,
|
---|
32 | const size_t &_step)
|
---|
33 | {
|
---|
34 | container.clear();
|
---|
35 | for (typename T::iterator iter = _start; iter != _end; ++iter) {
|
---|
36 | const atom &walker = **iter;
|
---|
37 | const BondList &ListOfBonds = walker.getListOfBondsAtStep(_step);
|
---|
38 | container.insert(container.end(), ListOfBonds.begin(), ListOfBonds.end());
|
---|
39 | }
|
---|
40 | // sort and make unique
|
---|
41 | std::sort(container.begin(), container.end());
|
---|
42 | container.erase(std::unique(container.begin(), container.end()), container.end());
|
---|
43 | map_is_dirty = true;
|
---|
44 | }
|
---|
45 |
|
---|
46 | const BondVectors::mapped_t&
|
---|
47 | BondVectors::getBondVectorsAtStep(const size_t &_step) const
|
---|
48 | {
|
---|
49 | if (map_is_dirty || (current_step_for_map != _step))
|
---|
50 | recalculateBondVectorsAtStep(_step);
|
---|
51 | return current_mapped_vectors;
|
---|
52 | }
|
---|
53 |
|
---|
54 | const BondVectors::container_t&
|
---|
55 | BondVectors::getSorted() const
|
---|
56 | {
|
---|
57 | ASSERT( !container.empty(),
|
---|
58 | "BondVectors::getSorted() - empty internal container, not set properly?");
|
---|
59 | return container;
|
---|
60 | }
|
---|
61 |
|
---|
62 | #endif /* DYNAMICS_BONDVECTORS_IMPL_HPP_ */
|
---|