Changes in src/molecule_graph.cpp [112b09:c27778]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r112b09 rc27778 12 12 #include "bondgraph.hpp" 13 13 #include "config.hpp" 14 #include "defs.hpp" 14 15 #include "element.hpp" 15 16 #include "helpers.hpp" … … 663 664 BFS.ColorList = new enum Shading[AtomCount]; 664 665 BFS.BFSStack = new StackClass<atom *> (AtomCount); 666 BFS.TouchedStack = new StackClass<atom *> (AtomCount); 665 667 666 668 for (int i = AtomCount; i--;) { 667 669 BFS.ShortestPathList[i] = -1; 668 670 BFS.PredecessorList[i] = 0; 671 BFS.ColorList[i] = white; 669 672 } 670 673 }; … … 680 683 delete[](BFS.ColorList); 681 684 delete (BFS.BFSStack); 685 delete (BFS.TouchedStack); 682 686 BFS.AtomCount = 0; 683 687 }; … … 824 828 MinRingSize = RingSize; 825 829 } else { 826 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[ Walker->GetTrueFather()->nr] << " found." << endl);830 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[BFS.Root->GetTrueFather()->nr] << " found." << endl); 827 831 } 828 832 }; … … 1024 1028 /** Storing the bond structure of a molecule to file. 1025 1029 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 1026 * \param *path path tofile1027 * \param *filename name of file1030 * \param &filename name of file 1031 * \param path path to file, defaults to empty 1028 1032 * \return true - file written successfully, false - writing failed 1029 1033 */ 1030 bool molecule::StoreAdjacencyToFile( char *path, char *filename)1034 bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path) 1031 1035 { 1032 1036 ofstream AdjacencyFile; 1033 string streamline;1037 string line; 1034 1038 bool status = true; 1035 1039 1036 if (path != NULL)1037 line << path << "/" <<filename;1040 if (path != "") 1041 line = path + "/" + filename; 1038 1042 else 1039 line <<filename;1040 AdjacencyFile.open(line. str().c_str(), ios::out);1043 line = filename; 1044 AdjacencyFile.open(line.c_str(), ios::out); 1041 1045 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1042 if (AdjacencyFile != NULL) {1046 if (AdjacencyFile.good()) { 1043 1047 AdjacencyFile << "m\tn" << endl; 1044 1048 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); … … 1046 1050 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1047 1051 } else { 1048 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line .str()<< "." << endl);1052 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl); 1049 1053 status = false; 1050 1054 } … … 1056 1060 /** Storing the bond structure of a molecule to file. 1057 1061 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1058 * \param *path path tofile1059 * \param *filename name of file1062 * \param &filename name of file 1063 * \param path path to file, defaults to empty 1060 1064 * \return true - file written successfully, false - writing failed 1061 1065 */ 1062 bool molecule::StoreBondsToFile( char *path, char *filename)1066 bool molecule::StoreBondsToFile(std::string &filename, std::string path) 1063 1067 { 1064 1068 ofstream BondFile; 1065 string streamline;1069 string line; 1066 1070 bool status = true; 1067 1071 1068 if (path != NULL)1069 line << path << "/" <<filename;1072 if (path != "") 1073 line = path + "/" + filename; 1070 1074 else 1071 line <<filename;1072 BondFile.open(line. str().c_str(), ios::out);1075 line = filename; 1076 BondFile.open(line.c_str(), ios::out); 1073 1077 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1074 if (BondFile != NULL) {1078 if (BondFile.good()) { 1075 1079 BondFile << "m\tn" << endl; 1076 1080 ActOnAllAtoms(&atom::OutputBonds, &BondFile); … … 1078 1082 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1079 1083 } else { 1080 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line .str()<< "." << endl);1084 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl); 1081 1085 status = false; 1082 1086 } … … 1086 1090 ; 1087 1091 1088 bool CheckAdjacencyFileAgainstMolecule_Init( char *path, ifstream &File, int *&CurrentBonds)1089 { 1090 string streamfilename;1091 filename << path << "/" << FRAGMENTPREFIX <<ADJACENCYFILE;1092 File.open(filename. str().c_str(), ios::out);1092 bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds) 1093 { 1094 string filename; 1095 filename = path + ADJACENCYFILE; 1096 File.open(filename.c_str(), ios::out); 1093 1097 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 1094 if (File == NULL)1098 if (File.fail()) 1095 1099 return false; 1096 1100 … … 1146 1150 * \return true - structure is equal, false - not equivalence 1147 1151 */ 1148 bool molecule::CheckAdjacencyFileAgainstMolecule( char *path, atom **ListOfAtoms)1152 bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms) 1149 1153 { 1150 1154 ifstream File;
Note:
See TracChangeset
for help on using the changeset viewer.