Ignore:
Timestamp:
May 7, 2008, 1:38:13 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
a01955
Parents:
417bb5
Message:

AtomStackClass -> template <typename T> StackClass<T> change in new file stackclass.hpp, other templates to helpers.hpp

StackClass was changed to a template and as template code may only be present in header file was moved to a new
header file stackclass.hpp. New file was added to Makefile.am
Other templates (list management et al) were moved to helpers.hpp as they are more sensibly placed there.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified molecuilder/src/molecules.cpp

    r417bb5 rd50d2a  
    14191419MoleculeLeafClass * molecule::DepthFirstSearchAnalysis(ofstream *out, bool ReturnStack, int &MinimumRingSize)
    14201420{
    1421   AtomStackClass *AtomStack = new AtomStackClass(AtomCount);
     1421  class StackClass<atom *> *AtomStack;
     1422  AtomStack = new StackClass<atom *>(AtomCount);
     1423  class StackClass<bond *> *BackEdgeStack = new StackClass<bond *> (BondCount);
    14221424  MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL);
    14231425  MoleculeLeafClass *LeafWalker = SubGraphs;
    14241426  int CurrentGraphNr = 0, OldGraphNr;
    1425   int CyclicBonds;
    14261427  int ComponentNumber = 0;
    14271428  atom *Walker = NULL, *OtherAtom = NULL, *Root = start->next;
     
    14341435  ResetAllAtomNumbers();
    14351436  InitComponentNumbers();
     1437  BackEdgeStack->ClearStack();
    14361438  while (Root != end) { // if there any atoms at all
    14371439    // (1) mark all edges unused, empty stack, set atom->GraphNr = 0 for all
     
    14681470            // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
    14691471            Binder->Type = BackEdge;
     1472            BackEdgeStack->Push(Binder);
    14701473            Walker->LowpointNr = ( Walker->LowpointNr < OtherAtom->GraphNr ) ? Walker->LowpointNr : OtherAtom->GraphNr;
    14711474            *out << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;
     
    15681571  }
    15691572
    1570   // correct cyclic bonds that are not included in "same LP" argument
    1571   Binder = first;
    1572   while (Binder->next != last) {
    1573     Binder = Binder->next;
    1574     Walker = Binder->leftatom;
    1575     OtherAtom = Binder->rightatom;
    1576     // now check whether both have a cyclic bond in their list
    1577     CyclicBonds = 0;   // counts cyclic bonds;
    1578     for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++)
    1579       if ((CyclicBonds == 0) && (ListOfBondsPerAtom[Walker->nr][i]->Cyclic))
    1580         CyclicBonds = 1; 
    1581     for(int i=0;i<NumberOfBondsPerAtom[OtherAtom->nr];i++)
    1582       if ((CyclicBonds == 1) && (ListOfBondsPerAtom[OtherAtom->nr][i]->Cyclic))
    1583         CyclicBonds = 2; 
    1584     Binder->Cyclic = (Binder->Cyclic) || (CyclicBonds == 2); // set the Cyclic criterium either or ...
    1585   }
    1586  
    1587   // further analysis of the found cycles (print rings, get minimum cycle length)
     1573  // analysis of the cycles (print rings, get minimum cycle length)
    15881574  CyclicStructureAnalysis(out, MinimumRingSize);
     1575
    15891576  *out << Verbose(1) << "Final graph info for each atom is:" << endl;
    15901577  Walker = start;
     
    16241611void molecule::CyclicStructureAnalysis(ofstream *out, int &MinimumRingSize)
    16251612{
    1626   AtomStackClass *AtomStack = new AtomStackClass(AtomCount);
     1613  class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
    16271614  int LP;
    16281615  atom *Walker = NULL, *OtherAtom = NULL, *Root = NULL, *Runner = NULL;
     
    16301617  int RingSize, NumCycles;
    16311618
    1632   // go through every atom
     1619  // count number of cyclic bonds per atom and push all with 3 cyclic bonds onto stack
    16331620  AtomStack->ClearStack();
    16341621  int *NoCyclicBondsPerAtom = (int *) Malloc(sizeof(int)*AtomCount, "molecule::CyclicStructureAnalysis: *NoCyclicBondsPerAtom");
     
    20652052  line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    20662053  File.open(line.str().c_str(), ios::out);
    2067   *out << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl;
     2054  *out << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";
    20682055  if (File != NULL) {
    20692056    // allocate storage structure
     
    21192106    status = false;
    21202107  }
     2108  *out << endl;
    21212109  Free((void **)&buffer, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");
    21222110 
     
    26202608
    26212609/** Adds atoms up to \a BondCount distance from \a *Root and notes them down in \a **AddedAtomList.
    2622  * Gray vertices are always enqueued in an AtomStackClass FIFO queue, the rest is usual BFS with adding vertices found was
     2610 * Gray vertices are always enqueued in an StackClass<atom *> FIFO queue, the rest is usual BFS with adding vertices found was
    26232611 * white and putting into queue.
    26242612 * \param *out output stream for debugging
     
    26362624  int *ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::BreadthFirstSearchAdd: *ShortestPathList");
    26372625  enum Shading *ColorList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::BreadthFirstSearchAdd: *ColorList");
    2638   AtomStackClass *AtomStack = new AtomStackClass(AtomCount);
     2626  class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
    26392627  atom *Walker = NULL, *OtherAtom = NULL;
    26402628  bond *Binder = NULL;
     
    28022790
    28032791
    2804 /** Looks through a AtomStackClass and returns the likeliest removal candiate.
     2792/** Looks through a StackClass<atom *> and returns the likeliest removal candiate.
    28052793 * \param *out output stream for debugging messages
    28062794 * \param *&Leaf KeySet to look through
     
    29222910  enum Shading *ColorVertexList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorList");
    29232911  enum Shading *ColorEdgeList = (enum Shading *) Malloc(sizeof(enum Shading)*BondCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorBondList");
    2924   AtomStackClass *RootStack = new AtomStackClass(AtomCount);
    2925   AtomStackClass *TouchedStack = new AtomStackClass((int)pow(4,Order)+2); // number of atoms reached from one with maximal 4 bonds plus Root itself
    2926   AtomStackClass *SnakeStack = new AtomStackClass(Order+1); // equal to Order is not possible, as then the AtomStackClass cannot discern between full and empty stack!
     2912  StackClass<atom *> *RootStack = new StackClass<atom *>(AtomCount);
     2913  StackClass<atom *> *TouchedStack = new StackClass<atom *>((int)pow(4,Order)+2); // number of atoms reached from one with maximal 4 bonds plus Root itself
     2914  StackClass<atom *> *SnakeStack = new StackClass<atom *>(Order+1); // equal to Order is not possible, as then the StackClass<atom *> cannot discern between full and empty stack!
    29272915  MoleculeLeafClass *Leaflet = NULL, *TempLeaf = NULL;
    29282916  MoleculeListClass *FragmentList = NULL;
     
    34893477  double tmp;
    34903478  vector TranslationVector;
    3491   //AtomStackClass *CompStack = NULL;
    3492   AtomStackClass *AtomStack = new AtomStackClass(AtomCount);
     3479  //class StackClass<atom *> *CompStack = NULL;
     3480  class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
    34933481  bool flag = true;
    34943482
Note: See TracChangeset for help on using the changeset viewer.