votca 2024.2-dev
Loading...
Searching...
No Matches
beadlist.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// VOTCA includes
20
21// Local VOTCA includes
22#include "votca/csg/beadlist.h"
23#include "votca/csg/topology.h"
24
25namespace votca {
26namespace csg {
27
28using namespace std;
29
30Index BeadList::Generate(Topology &top, const string &select) {
31 topology_ = ⊤
32 bool selectByName = false;
33 string pSelect; // parsed selection string
34
35 if (select.substr(0, 5) == "name:") {
36 // select according to bead name instead of type
37 pSelect = select.substr(5);
38 selectByName = true;
39 } else {
40 pSelect = select;
41 }
42
43 for (auto &bead : top.Beads()) {
44 if (!selectByName) {
45 if (tools::wildcmp(pSelect, bead.getType())) {
46 beads_.push_back(&bead);
47 }
48 } else {
49 if (tools::wildcmp(pSelect, bead.getName())) {
50 beads_.push_back(&bead);
51 }
52 }
53 }
54 return size();
55}
56
58 const string &select,
59 Eigen::Vector3d ref,
60 double radius) {
61 topology_ = ⊤
62 bool selectByName = false;
63 string pSelect; // parsed selection string
64
65 if (select.substr(0, 5) == "name:") {
66 // select according to bead name instead of type
67 pSelect = select.substr(5);
68 selectByName = true;
69 } else {
70 pSelect = select;
71 }
72
73 for (auto &bead : top.Beads()) {
74 if (topology_->BCShortestConnection(ref, bead.getPos()).norm() > radius) {
75 continue;
76 }
77 if (!selectByName) {
78 if (tools::wildcmp(pSelect, bead.getType())) {
79 beads_.push_back(&bead);
80 }
81 } else {
82 if (tools::wildcmp(pSelect, bead.getName())) {
83 beads_.push_back(&bead);
84 }
85 }
86 }
87 return size();
88}
89
90} // namespace csg
91} // namespace votca
Index Generate(Topology &top, const std::string &select)
Select all beads of type "select".
Definition beadlist.cc:30
std::vector< Bead * > beads_
Definition beadlist.h:66
Index size() const
Definition beadlist.h:52
Topology * topology_
Definition beadlist.h:67
Index GenerateInSphericalSubvolume(Topology &top, const std::string &select, Eigen::Vector3d ref, double radius)
Select all beads of type "select" withn a radius "radius" of reference vector "ref".
Definition beadlist.cc:57
topology of the whole system
Definition topology.h:81
BeadContainer & Beads()
Definition topology.h:169
Eigen::Vector3d BCShortestConnection(const Eigen::Vector3d &r_i, const Eigen::Vector3d &r_j) const
calculate shortest vector connecting two points
Definition topology.cc:238
STL namespace.
int wildcmp(const char *wild, const char *string)
Definition tokenizer.cc:28
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26