Changeset 08b88b
- Timestamp:
- Nov 3, 2009, 2:34:02 PM (16 years ago)
- Children:
- c1b4a4
- Parents:
- 5f9f8b
- git-author:
- Frederik Heber <heber@…> (11/03/09 14:27:15)
- git-committer:
- Frederik Heber <heber@…> (11/03/09 14:34:02)
- Location:
- molecuilder/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/bondgraph.cpp
r5f9f8b r08b88b 13 13 #include "molecule.hpp" 14 14 #include "parser.hpp" 15 #include "periodentafel.hpp" 15 16 #include "vector.hpp" 16 17 … … 18 19 * This classes contains typical bond lengths and thus may be used to construct a bond graph for a given molecule. 19 20 */ 20 BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), IsAngstroem(IsA)21 BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), max_distance(0), IsAngstroem(IsA) 21 22 { 22 23 }; … … 104 105 }; 105 106 107 /** Determines the maximum of all element::CovalentRadius. 108 * \param *out output stream for debugging 109 * \param *periode periodentafel with all elements. 110 */ 111 double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(ofstream * const out, const periodentafel * const periode) 112 { 113 max_distance = 0.; 114 115 element * Runner = periode->start; 116 while (Runner->next != periode->end) { 117 Runner = Runner->next; 118 if (Runner->CovalentRadius > max_distance) 119 max_distance = Runner->CovalentRadius; 120 } 121 max_distance *= 2.; 122 123 return max_distance; 124 }; 125 106 126 /** Returns bond criterion for given pair based on covalent radius. 107 127 * \param *Walker first BondedParticle -
molecuilder/src/bondgraph.hpp
r5f9f8b r08b88b 23 23 24 24 class molecule; 25 class periodentafel; 25 26 class MatrixContainer; 26 27 … … 37 38 bool ConstructBondGraph(ofstream * const out, molecule * const mol); 38 39 double GetBondLength(int firstelement, int secondelement); 40 double SetMaxDistanceToMaxOfCovalentRadii(ofstream * const out, const periodentafel * const periode); 39 41 40 42 void BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem); -
molecuilder/src/builder.cpp
r5f9f8b r08b88b 1250 1250 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1251 1251 int N = molecules->ListOfMolecules.size(); 1252 int *src = new int (N);1252 int *src = new int[N]; 1253 1253 N=0; 1254 1254 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { … … 1257 1257 } 1258 1258 molecules->SimpleMultiAdd(mol, src, N); 1259 delete (src);1259 delete[](src); 1260 1260 1261 1261 // ... and translate back -
molecuilder/src/config.cpp
r5f9f8b r08b88b 1051 1051 } else { 1052 1052 cout << Verbose(0) << "Bond length table loading failed." << endl; 1053 BG->SetMaxDistanceToMaxOfCovalentRadii((ofstream *)&cout, periode); 1053 1054 } 1054 1055 1055 1056 // 3. parse the molecule in 1056 1057 LoadMolecule(mol, FileBuffer, periode, FastParsing); 1057 mol->ActiveFlag = true;1058 MolList->insert(mol);1058 //mol->ActiveFlag = true; 1059 //MolList->insert(mol); 1059 1060 1060 1061 // 4. dissect the molecule into connected subgraphs 1061 1062 BG->ConstructBondGraph((ofstream *)&cout, mol); 1063 1064 // 5. scan for connected subgraphs 1065 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 1066 class StackClass<bond *> *BackEdgeStack = NULL; 1067 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack); 1068 delete(BackEdgeStack); 1069 1070 // 6. dissect 1071 atom ***ListOfLocalAtoms = NULL; 1072 int FragmentCounter = 0; 1073 MoleculeLeafClass *MolecularWalker = Subgraphs; 1074 atom *Walker = NULL; 1075 while (MolecularWalker->next != NULL) { 1076 MolecularWalker = MolecularWalker->next; 1077 // fill the bond structure of the individually stored subgraphs (goes through whole chained list by itself) 1078 MolecularWalker->FillBondStructureFromReference((ofstream *)&cout, mol, FragmentCounter, ListOfLocalAtoms, false); // we don't want to keep the created ListOfLocalAtoms 1079 FragmentCounter++; 1080 MolecularWalker->Leaf->ActiveFlag = true; 1081 Walker = MolecularWalker->Leaf->start; 1082 while (Walker->next != MolecularWalker->Leaf->end) { 1083 Walker = Walker->next; 1084 Walker->father = Walker; 1085 } 1086 MolList->insert(MolecularWalker->Leaf); 1087 MolecularWalker->Leaf = NULL; // don't remove molecule when deleting MolecularWalker 1088 delete(MolecularWalker->previous); 1089 } 1090 delete(MolecularWalker); 1091 for (int i=0;i<FragmentCounter;i++) 1092 Free(&ListOfLocalAtoms[i]); 1093 Free(&ListOfLocalAtoms); 1094 cout << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl; 1095 1096 // 6. free parsed in molecule 1097 delete(mol); 1062 1098 1063 1099 delete(FileBuffer); -
molecuilder/src/molecule_graph.cpp
r5f9f8b r08b88b 114 114 *out << Verbose(0) << "Begin of CreateAdjacencyList." << endl; 115 115 // remove every bond from the list 116 if ((first->next != last) && (last->previous != first)) { // there are bonds present 117 cleanup(first, last); 116 bond *Binder = NULL; 117 while (last->previous != first) { 118 Binder = last->previous; 119 Binder->leftatom->UnregisterBond(Binder); 120 Binder->rightatom->UnregisterBond(Binder); 121 removewithoutcheck(Binder); 118 122 } 119 123 120 124 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 121 125 CountAtoms(out); 122 *out << Verbose(1) << "AtomCount " << AtomCount << " ." << endl;126 *out << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl; 123 127 124 128 if ((AtomCount > 1) && (bonddistance > 1.)) { 129 *out << Verbose(2) << "Creating Linked Cell structure ... " << endl; 125 130 LC = new LinkedCell(this, bonddistance); 126 131 127 132 // create a list to map Tesselpoint::nr to atom * 133 *out << Verbose(2) << "Creating TesselPoint to atom map ... " << endl; 128 134 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 129 135 Walker = start; … … 134 140 135 141 // 3a. go through every cell 142 *out << Verbose(2) << "Celling ... " << endl; 136 143 for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++) 137 144 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) … … 175 182 176 183 // correct bond degree by comparing valence and bond degree 184 *out << Verbose(2) << "Correcting bond degree ... " << endl; 177 185 CorrectBondDegree(out); 178 186 -
molecuilder/src/moleculelist.cpp
r5f9f8b r08b88b 12 12 #include "helpers.hpp" 13 13 #include "linkedcell.hpp" 14 #include "lists.hpp" 14 15 #include "molecule.hpp" 15 16 #include "memoryallocator.hpp" … … 829 830 830 831 if (status) { 831 *out << Verbose(1) << "Creating adjacency list for subgraph " << this 832 << "." << endl; 832 *out << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl; 833 // remove every bond from the list 834 bond *Binder = NULL; 835 while (Leaf->last->previous != Leaf->first) { 836 Binder = Leaf->last->previous; 837 Binder->leftatom->UnregisterBond(Binder); 838 Binder->rightatom->UnregisterBond(Binder); 839 removewithoutcheck(Binder); 840 } 841 833 842 Walker = Leaf->start; 834 843 while (Walker->next != Leaf->end) { … … 847 856 } 848 857 } 849 // FragmentCounter++;850 // if (next != NULL)851 // status = next->FillBondStructureFromReference(out, reference, FragmentCounter, ListOfLocalAtoms);852 // FragmentCounter--;853 858 } 854 859 … … 916 921 bool status = true; 917 922 918 int Counter = Count();919 923 if (ListOfLocalAtoms == NULL) { // allocated initial pointer 920 924 // allocate and set each field to NULL 925 const int Counter = Count(); 921 926 ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms"); 922 if (ListOfLocalAtoms != NULL) { 923 FreeList = FreeList && true; 924 } else 927 if (ListOfLocalAtoms == NULL) { 928 FreeList = FreeList && false; 925 929 status = false; 930 } 926 931 } 927 932
Note:
See TracChangeset
for help on using the changeset viewer.