Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    r112b09 rc27778  
    1212#include "bondgraph.hpp"
    1313#include "config.hpp"
     14#include "defs.hpp"
    1415#include "element.hpp"
    1516#include "helpers.hpp"
     
    663664  BFS.ColorList = new enum Shading[AtomCount];
    664665  BFS.BFSStack = new StackClass<atom *> (AtomCount);
     666  BFS.TouchedStack = new StackClass<atom *> (AtomCount);
    665667
    666668  for (int i = AtomCount; i--;) {
    667669    BFS.ShortestPathList[i] = -1;
    668670    BFS.PredecessorList[i] = 0;
     671    BFS.ColorList[i] = white;
    669672  }
    670673};
     
    680683  delete[](BFS.ColorList);
    681684  delete (BFS.BFSStack);
     685  delete (BFS.TouchedStack);
    682686  BFS.AtomCount = 0;
    683687};
     
    824828      MinRingSize = RingSize;
    825829  } 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);
    827831  }
    828832};
     
    10241028/** Storing the bond structure of a molecule to file.
    10251029 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    1026  * \param *path path to file
    1027  * \param *filename name of file
     1030 * \param &filename name of file
     1031 * \param path path to file, defaults to empty
    10281032 * \return true - file written successfully, false - writing failed
    10291033 */
    1030 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     1034bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
    10311035{
    10321036  ofstream AdjacencyFile;
    1033   stringstream line;
     1037  string line;
    10341038  bool status = true;
    10351039
    1036   if (path != NULL)
    1037     line << path << "/" << filename;
     1040  if (path != "")
     1041    line = path + "/" + filename;
    10381042  else
    1039     line << filename;
    1040   AdjacencyFile.open(line.str().c_str(), ios::out);
     1043    line = filename;
     1044  AdjacencyFile.open(line.c_str(), ios::out);
    10411045  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1042   if (AdjacencyFile != NULL) {
     1046  if (AdjacencyFile.good()) {
    10431047    AdjacencyFile << "m\tn" << endl;
    10441048    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
     
    10461050    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10471051  } 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);
    10491053    status = false;
    10501054  }
     
    10561060/** Storing the bond structure of a molecule to file.
    10571061 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1058  * \param *path path to file
    1059  * \param *filename name of file
     1062 * \param &filename name of file
     1063 * \param path path to file, defaults to empty
    10601064 * \return true - file written successfully, false - writing failed
    10611065 */
    1062 bool molecule::StoreBondsToFile(char *path, char *filename)
     1066bool molecule::StoreBondsToFile(std::string &filename, std::string path)
    10631067{
    10641068  ofstream BondFile;
    1065   stringstream line;
     1069  string line;
    10661070  bool status = true;
    10671071
    1068   if (path != NULL)
    1069     line << path << "/" << filename;
     1072  if (path != "")
     1073    line = path + "/" + filename;
    10701074  else
    1071     line << filename;
    1072   BondFile.open(line.str().c_str(), ios::out);
     1075    line = filename;
     1076  BondFile.open(line.c_str(), ios::out);
    10731077  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1074   if (BondFile != NULL) {
     1078  if (BondFile.good()) {
    10751079    BondFile << "m\tn" << endl;
    10761080    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
     
    10781082    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10791083  } 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);
    10811085    status = false;
    10821086  }
     
    10861090;
    10871091
    1088 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds)
    1089 {
    1090   stringstream filename;
    1091   filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1092   File.open(filename.str().c_str(), ios::out);
     1092bool 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);
    10931097  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())
    10951099    return false;
    10961100
     
    11461150 * \return true - structure is equal, false - not equivalence
    11471151 */
    1148 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms)
     1152bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
    11491153{
    11501154  ifstream File;
Note: See TracChangeset for help on using the changeset viewer.