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

Comparing branches/new_design/OOPSE-2.0/src/brains/MoleculeCreator.cpp (file contents):
Revision 1733 by tim, Fri Nov 12 06:19:04 2004 UTC vs.
Revision 1734 by tim, Fri Nov 12 07:05:43 2004 UTC

# Line 101 | Line 101 | Molecule* MoleculeCreator::createMolecule(ForceField*
101          mol->addCutoffGroup(cutoffGroup);
102      }
103  
104 +    //every free atom is a cutoff group    
105 +    std::set<Atom*> allAtoms;
106 +    typename  Molecule::AtomIterator ai;
107 +
108 +    //add all atoms into allAtoms set
109 +    for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
110 +        allAtoms.insert(atom);
111 +    }
112 +
113 +    typename Molecule::CutoffGroupIterator ci;
114 +    CutoffGroup* cg;
115 +    std::set<Atom*> cutoffAtoms;    
116 +    
117 +    //add all of the atoms belong to cutoff groups into cutoffAtoms set
118 +    for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
119 +
120 +        for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
121 +            cutoffAtoms.insert(atom);
122 +        }
123 +
124 +    }      
125 +    
126 +    //find all free atoms (which do not belong to cutoff groups)  
127 +    //performs the "difference" operation from set theory,  the output range contains a copy of every
128 +    //element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in
129 +    //[cutoffAtoms.begin(), cutoffAtoms.end()).
130 +    std::vector<Atom*> freeAtoms;    
131 +    std::set_difference(allAtoms.begin(), allAtoms.end(), cutoffAtoms.begin(), cutoffAtoms.end(),
132 +                            std::back_inserter(freeAtoms.end()));
133 +
134 +    if (freeAtoms.size() != allAtoms.size() - cutoffAtoms.size()) {
135 +        //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
136 +        sprintf(painCave.errMsg, "Atoms in cutoff groups are not in the atom list of the same molecule");
137 +
138 +        painCave.isFatal = 1;
139 +        simError();        
140 +    }
141 +
142 +    //loop over the free atoms and then create one cutoff group for every single free atom
143 +    std::vector<Atom*>::iterator fai;
144 +
145 +    for (fai = freeAtoms.begin(); fai != freeAtoms.end(); ++fai) {
146 +        createCutoffGroup(mol, *fai);
147 +        mol->addCutoffGroup(cutoffGroup);
148 +    }
149      //create constraints
150  
151      //the construction of this molecule is finished
# Line 287 | Line 332 | CutoffGroup* MoleculeCreator::createCutoffGroup(Molecu
332      return cg;
333   }    
334  
335 + CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule * mol, Atom* atom) {
336 +    CutoffGroup* cg;
337 +    cg  = new CutoffGroup();
338 +    cg->addAtom();
339 +    return cg;
340 + }
341   //Constraint* MoleculeCreator::createConstraint() {
342  
343   //}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines