Ignore:
Timestamp:
Jan 26, 2010, 12:52:31 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
8d0b25, d34341
Parents:
551a58
Message:

GetDistanceToSurface() separated, filling now with water instead of boron, DissectMoleculeIntoConnectedSubgraphs() now working on list of molecules instead of single one.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/moleculelist.cpp

    r551a58 r478683  
    741741/** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
    742742 * \param *out output stream for debugging
    743  * \param *mol molecule with atoms to dissect
     743 * \param *periode periodentafel
    744744 * \param *configuration config with BondGraph
    745745 */
    746 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(molecule * const mol, config * const configuration)
    747 {
     746void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
     747{
     748  molecule *mol = new molecule(periode);
     749  atom *Walker = NULL;
     750  atom *Advancer = NULL;
     751  bond *Binder = NULL;
     752  bond *Stepper = NULL;
     753  // 0. gather all atoms into single molecule
     754  for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
     755    // shift all atoms to new molecule
     756    Advancer = (*MolRunner)->start->next;
     757    while (Advancer != (*MolRunner)->end) {
     758      Walker = Advancer;
     759      Advancer = Advancer->next;
     760      Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     761      unlink(Walker);
     762      Walker->father = Walker;
     763      mol->AddAtom(Walker);    // counting starts at 1
     764    }
     765    // remove all bonds
     766    Stepper = (*MolRunner)->first->next;
     767    while (Stepper != (*MolRunner)->last) {
     768      Binder = Stepper;
     769      Stepper = Stepper->next;
     770      delete(Binder);
     771    }
     772    // remove the molecule
     773    delete(*MolRunner);
     774    ListOfMolecules.erase(MolRunner);
     775  }
     776
    748777  // 1. dissect the molecule into connected subgraphs
    749778  configuration->BG->ConstructBondGraph(mol);
     
    779808  int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    780809  MoleculeLeafClass *MolecularWalker = Subgraphs;
    781   atom *Walker = NULL;
     810  Walker = NULL;
    782811  while (MolecularWalker->next != NULL) {
    783812    MolecularWalker = MolecularWalker->next;
     
    809838  }
    810839  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    811   bond *Binder = mol->first;
     840  Binder = mol->first;
    812841  while (mol->first->next != mol->last) {
    813842    Binder = mol->first->next;
Note: See TracChangeset for help on using the changeset viewer.