ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/brains/MoleculeCreator.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/brains/MoleculeCreator.cpp (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2346 by tim, Wed Oct 5 19:34:01 2005 UTC

# Line 59 | Line 59 | namespace oopse {
59   #include "utils/StringUtils.hpp"
60  
61   namespace oopse {
62 <
62 >  
63    Molecule* MoleculeCreator::createMolecule(ForceField* ff, MoleculeStamp *molStamp,
64                                              int stampId, int globalIndex, LocalIndexManager* localIndexMan) {
65  
# Line 128 | Line 128 | namespace oopse {
128      }
129  
130      //every free atom is a cutoff group    
131 <    std::set<Atom*> allAtoms;
132 <    Molecule::AtomIterator ai;
131 >    std::vector<Atom*> freeAtoms;
132 >    std::vector<Atom*>::iterator ai;
133 >    std::vector<Atom*>::iterator fai;
134  
135      //add all atoms into allAtoms set
136 <    for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
137 <      allAtoms.insert(atom);
136 >    for(atom = mol->beginAtom(fai); atom != NULL; atom = mol->nextAtom(fai)) {
137 >      freeAtoms.push_back(atom);
138      }
139  
140      Molecule::CutoffGroupIterator ci;
141      CutoffGroup* cg;
141    std::set<Atom*> cutoffAtoms;    
142      
143    //add all of the atoms belong to cutoff groups into cutoffAtoms set
143      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
144  
145        for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
146 <        cutoffAtoms.insert(atom);
146 >           //erase the atoms belong to cutoff groups from freeAtoms vector
147 >           freeAtoms.erase(std::remove(freeAtoms.begin(), freeAtoms.end(), atom), freeAtoms.end());
148        }
149  
150      }      
151      
152 <    //find all free atoms (which do not belong to cutoff groups)  
153 <    //performs the "difference" operation from set theory,  the output range contains a copy of every
154 <    //element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in
155 <    //[cutoffAtoms.begin(), cutoffAtoms.end()).
156 <    std::vector<Atom*> freeAtoms;    
157 <    std::set_difference(allAtoms.begin(), allAtoms.end(), cutoffAtoms.begin(), cutoffAtoms.end(),
158 <                        std::back_inserter(freeAtoms));
159 <
160 <    if (freeAtoms.size() != allAtoms.size() - cutoffAtoms.size()) {
161 <      //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
162 <      sprintf(painCave.errMsg, "Atoms in cutoff groups are not in the atom list of the same molecule");
163 <
164 <      painCave.isFatal = 1;
165 <      simError();        
166 <    }
167 <
168 <    //loop over the free atoms and then create one cutoff group for every single free atom
169 <    std::vector<Atom*>::iterator fai;
170 <
152 >    //loop over the free atoms and then create one cutoff group for every single free atom
153 >    
154      for (fai = freeAtoms.begin(); fai != freeAtoms.end(); ++fai) {
155        cutoffGroup = createCutoffGroup(mol, *fai);
156        mol->addCutoffGroup(cutoffGroup);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines