# | Line 40 | Line 40 | |
---|---|---|
40 | */ | |
41 | #include "selection/NameFinder.hpp" | |
42 | #include "utils/wildcards.hpp" | |
43 | + | #include "utils/StringTokenizer.hpp" |
44 | + | #include "primitives/Molecule.hpp" |
45 | namespace oopse { | |
46 | ||
47 | TreeNode::~TreeNode(){ | |
# | Line 52 | Line 54 | NameFinder::NameFinder(SimInfo* info) : info_(info), r | |
54 | ||
55 | ||
56 | NameFinder::NameFinder(SimInfo* info) : info_(info), root_(NULL){ | |
57 | < | nStuntDouble_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies() |
57 | > | nStuntDouble_ = info_->getNGlobalAtoms() + info_->getNGlobalRigidBodies(); |
58 | loadNames(); | |
59 | } | |
60 | ||
# | Line 72 | Line 74 | void NameFinder::loadNames() { | |
74 | RigidBody* rb; | |
75 | ||
76 | root_ = new TreeNode; | |
77 | < | root_->bs.resize(nStuntDobule_); |
77 | > | root_->bs.resize(nStuntDouble_); |
78 | root_->bs.setAll(); // | |
79 | ||
80 | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { | |
# | Line 85 | Line 87 | void NameFinder::loadNames() { | |
87 | currentMolNode->name = molName; | |
88 | currentMolNode->bs.resize(nStuntDouble_); | |
89 | }else { | |
90 | < | currentMolNode = i->second; |
90 | > | currentMolNode = foundIter->second; |
91 | } | |
92 | ||
93 | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | |
# | Line 137 | Line 139 | void NameFinder::loadNames() { | |
139 | ||
140 | } | |
141 | ||
140 | – | std::map<std::string, TreeNode*>::iterator i; |
141 | – | for( i = root_->children.begin(); i != ; ++i){ |
142 | – | i->bs = |
143 | – | } |
142 | } | |
143 | ||
144 | bool NameFinder::match(const std::string& name, BitSet& bs){ | |
145 | ||
146 | < | bool error = true; |
146 | > | bool hasError = false; |
147 | StringTokenizer tokenizer(name, "."); | |
148 | ||
149 | std::vector<std::string> names; | |
# | Line 161 | Line 159 | bool NameFinder::match(const std::string& name, BitSet | |
159 | //if all molecules are selected, we don't need to do the matching, just set all of the bits | |
160 | bs.setAll(); | |
161 | } else{ | |
162 | < | matchMolecule(name[0]); |
163 | < | matchStuntDouble("*", names[0]); |
162 | > | matchMolecule(names[0], bs); |
163 | > | matchStuntDouble("*", names[0], bs); |
164 | } | |
165 | ||
166 | break; | |
167 | case 2: | |
168 | //could be molecule.*(include atoms and rigidbodies) or rigidbody.*(atoms belong to rigidbody) | |
169 | matchRigidAtoms("*", names[0], names[1], bs); | |
170 | < | matchStuntDouble(names[0], names[1]); |
170 | > | matchStuntDouble(names[0], names[1], bs); |
171 | ||
172 | break; | |
173 | case 3: | |
174 | //must be molecule.rigidbody.* | |
175 | < | matchRigidAtoms(names[0], names[1], names[2], bs) |
175 | > | matchRigidAtoms(names[0], names[1], names[2], bs); |
176 | break; | |
177 | < | default: |
177 | > | default: |
178 | > | hasError = true; |
179 | break; | |
180 | } | |
181 | ||
182 | < | return matched; |
182 | > | return hasError; |
183 | } | |
184 | ||
185 | void NameFinder::matchMolecule(const std::string& molName, BitSet& bs) { | |
186 | std::vector<TreeNode*> molNodes = getMatchedChildren(root_, molName); | |
187 | std::vector<TreeNode*>::iterator i; | |
188 | for( i = molNodes.begin(); i != molNodes.end(); ++i ) { | |
189 | < | bs |= i->bs; |
189 | > | bs |= (*i)->bs; |
190 | } | |
191 | } | |
192 | ||
# | Line 198 | Line 197 | void NameFinder::matchStuntDouble(const std::string& m | |
197 | std::vector<TreeNode*> sdNodes = getMatchedChildren(*i, sdName); | |
198 | std::vector<TreeNode*>::iterator j; | |
199 | for (j = sdNodes.begin(); j != sdNodes.end(); ++j) { | |
200 | < | bs |= j->bs; |
200 | > | bs |= (*j)->bs; |
201 | } | |
202 | } | |
203 | ||
# | Line 214 | Line 213 | void NameFinder::matchRigidAtoms(const std::string& mo | |
213 | std::vector<TreeNode*> rbAtomNodes = getMatchedChildren(*j, rbAtomName); | |
214 | std::vector<TreeNode*>::iterator k; | |
215 | for(k = rbAtomNodes.begin(); k != rbAtomNodes.end(); ++k){ | |
216 | < | bs |= k->bs; |
216 | > | bs |= (*k)->bs; |
217 | } | |
218 | } | |
219 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |