Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    r97b825 r61951b  
    193193      }
    194194      // Center and size
    195       (*out) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
     195      Vector *Center = (*ListRunner)->DetermineCenterOfAll();
     196      (*out) << "\t" << *Center << "\t" << sqrt(size) << endl;
     197      delete(Center);
    196198    }
    197199  }
     
    210212};
    211213
    212 /** Simple merge of two molecules into one.
    213  * \param *mol destination molecule
    214  * \param *srcmol source molecule
    215  * \return true - merge successful, false - merge failed (probably due to non-existant indices
    216  */
    217 bool MoleculeListClass::SimpleMerge(molecule *mol, molecule *srcmol)
    218 {
    219   if (srcmol == NULL)
    220     return false;
    221 
    222   // put all molecules of src into mol
    223   for (molecule::iterator iter = srcmol->begin(); !srcmol->empty(); iter=srcmol->begin()) {
    224     atom * const Walker = *iter;
    225     srcmol->UnlinkAtom(Walker);
    226     mol->AddAtom(Walker);
    227   }
    228 
    229   // remove src
    230   ListOfMolecules.remove(srcmol);
    231   World::getInstance().destroyMolecule(srcmol);
    232   return true;
    233 };
    234 
    235 /** Simple add of one molecules into another.
    236  * \param *mol destination molecule
    237  * \param *srcmol source molecule
    238  * \return true - merge successful, false - merge failed (probably due to non-existant indices
    239  */
    240 bool MoleculeListClass::SimpleAdd(molecule *mol, molecule *srcmol)
    241 {
    242   if (srcmol == NULL)
    243     return false;
    244 
    245   // put all molecules of src into mol
    246   atom *Walker = NULL;
    247   for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
    248     Walker = mol->AddCopyAtom((*iter));
    249     Walker->father = Walker;
    250   }
    251 
    252   return true;
    253 };
    254 
    255 /** Simple merge of a given set of molecules into one.
    256  * \param *mol destination molecule
    257  * \param *src index of set of source molecule
    258  * \param N number of source molecules
    259  * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
    260  */
    261 bool MoleculeListClass::SimpleMultiMerge(molecule *mol, int *src, int N)
    262 {
    263   bool status = true;
    264   // check presence of all source molecules
    265   for (int i=0;i<N;i++) {
    266     molecule *srcmol = ReturnIndex(src[i]);
    267     status = status && SimpleMerge(mol, srcmol);
    268   }
    269   insert(mol);
    270   return status;
    271 };
    272 
    273 /** Simple add of a given set of molecules into one.
    274  * \param *mol destination molecule
    275  * \param *src index of set of source molecule
    276  * \param N number of source molecules
    277  * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
    278  */
    279 bool MoleculeListClass::SimpleMultiAdd(molecule *mol, int *src, int N)
    280 {
    281   bool status = true;
    282   // check presence of all source molecules
    283   for (int i=0;i<N;i++) {
    284     molecule *srcmol = ReturnIndex(src[i]);
    285     status = status && SimpleAdd(mol, srcmol);
    286   }
    287   return status;
    288 };
    289 
    290 /** Scatter merge of a given set of molecules into one.
    291  * Scatter merge distributes the molecules in such a manner that they don't overlap.
    292  * \param *mol destination molecule
    293  * \param *src index of set of source molecule
    294  * \param N number of source molecules
    295  * \return true - merge successful, false - merge failed (probably due to non-existant indices
    296  * \TODO find scatter center for each src molecule
    297  */
    298 bool MoleculeListClass::ScatterMerge(molecule *mol, int *src, int N)
    299 {
    300   // check presence of all source molecules
    301   for (int i=0;i<N;i++) {
    302     // get pointer to src molecule
    303     molecule *srcmol = ReturnIndex(src[i]);
    304     if (srcmol == NULL)
    305       return false;
    306   }
    307   // adapt each Center
    308   for (int i=0;i<N;i++) {
    309     // get pointer to src molecule
    310     molecule *srcmol = ReturnIndex(src[i]);
    311     //srcmol->Center.Zero();
    312     srcmol->Translate(&srcmol->Center);
    313   }
    314   // perform a simple multi merge
    315   SimpleMultiMerge(mol, src, N);
    316   return true;
    317 };
    318 
    319 /** Embedding merge of a given set of molecules into one.
    320  * Embedding merge inserts one molecule into the other.
    321  * \param *mol destination molecule (fixed one)
    322  * \param *srcmol source molecule (variable one, where atoms are taken from)
    323  * \return true - merge successful, false - merge failed (probably due to non-existant indices)
    324  * \TODO linked cell dimensions for boundary points has to be as big as inner diameter!
    325  */
    326 bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol)
    327 {
    328   LinkedCell *LCList = NULL;
    329   Tesselation *TesselStruct = NULL;
    330   if ((srcmol == NULL) || (mol == NULL)) {
    331     DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl);
    332     return false;
    333   }
    334 
    335   // calculate envelope for *mol
    336   LCList = new LinkedCell(mol, 8.);
    337   FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL);
    338   if (TesselStruct == NULL) {
    339     DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl);
    340     return false;
    341   }
    342   delete(LCList);
    343   LCList = new LinkedCell(TesselStruct, 8.);  // re-create with boundary points only!
    344 
    345   // prepare index list for bonds
    346   atom ** CopyAtoms = new atom*[srcmol->getAtomCount()];
    347   for(int i=0;i<srcmol->getAtomCount();i++)
    348     CopyAtoms[i] = NULL;
    349 
    350   // for each of the source atoms check whether we are in- or outside and add copy atom
    351   int nr=0;
    352   for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
    353     DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl);
    354     if (!TesselStruct->IsInnerPoint((*iter)->getPosition(), LCList)) {
    355       CopyAtoms[(*iter)->nr] = (*iter)->clone();
    356       mol->AddAtom(CopyAtoms[(*iter)->nr]);
    357       nr++;
    358     } else {
    359       // do nothing
    360     }
    361   }
    362   DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged.");
    363 
    364   // go through all bonds and add as well
    365   for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner)
    366     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
    367       if ((*BondRunner)->leftatom == *AtomRunner) {
    368         DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl);
    369         mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree);
    370       }
    371   delete(LCList);
    372   return true;
    373 };
    374214
    375215/** Simple output of the pointers in ListOfMolecules.
Note: See TracChangeset for help on using the changeset viewer.