Changes in src/moleculelist.cpp [244a84:482373]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/moleculelist.cpp
r244a84 r482373 4 4 * 5 5 */ 6 7 #include <cstring>8 6 9 7 #include "atom.hpp" … … 741 739 /** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this. 742 740 * \param *out output stream for debugging 743 * \param * periode periodentafel741 * \param *mol molecule with atoms to dissect 744 742 * \param *configuration config with BondGraph 745 743 */ 746 void 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 744 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(molecule * const mol, config * const configuration) 745 { 777 746 // 1. dissect the molecule into connected subgraphs 778 747 configuration->BG->ConstructBondGraph(mol); … … 790 759 // 4a. create array of molecules to fill 791 760 const int MolCount = Subgraphs->next->Count(); 792 char number[MAXSTRINGSIZE];793 761 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 794 762 for (int i=0;i<MolCount;i++) { 795 763 molecules[i] = (molecule*) new molecule(mol->elemente); 796 764 molecules[i]->ActiveFlag = true; 797 strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);798 if (MolCount > 1) {799 sprintf(number, "-%d", i+1);800 strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);801 }802 cout << "MolName is " << molecules[i]->name << endl;803 765 insert(molecules[i]); 804 766 } … … 808 770 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 809 771 MoleculeLeafClass *MolecularWalker = Subgraphs; 810 Walker = NULL;772 atom *Walker = NULL; 811 773 while (MolecularWalker->next != NULL) { 812 774 MolecularWalker = MolecularWalker->next; … … 837 799 } 838 800 } 839 // 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 list840 Binder = mol->first;801 // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintained their ListOfBonds, but we have to remove them from first..last list 802 bond *Binder = mol->first; 841 803 while (mol->first->next != mol->last) { 842 804 Binder = mol->first->next;
Note:
See TracChangeset
for help on using the changeset viewer.