Changeset ce5f05


Ignore:
Timestamp:
Mar 1, 2011, 10:16:46 AM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
3738f0
Parents:
4092c5
git-author:
Frederik Heber <heber@…> (02/18/11 16:24:28)
git-committer:
Frederik Heber <heber@…> (03/01/11 10:16:46)
Message:

Moved Shading and EdgeType from defs.hpp to bond.hpp, getColor from molecule to class bond.

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Helpers/defs.hpp

    r4092c5 rce5f05  
    3434
    3535//enum BondOrderScheme { NoScheme, BottomUp, TopDown, ANOVA, Combined }; //!< Fragmentation scheme used in BOSS
    36 
    37 enum EdgeType { Undetermined, TreeEdge, BackEdge }; //!< edge type in a graph after Depth-First-Search analysis.
    38 
    39 enum Shading { white, lightgray, darkgray, black };  //!< color in Breadth-First-Search analysis
    4036
    4137
  • src/bond.cpp

    r4092c5 rce5f05  
    100100 * \return bond::Used
    101101 */
    102 enum Shading bond::IsUsed()
     102enum bond::Shading bond::IsUsed()
    103103{
    104104  return Used;
     
    158158  return (leftatom->DistanceSquared(*rightatom));
    159159};
     160
     161/** Returns Shading as a char string.
     162 * \param color the Shading
     163 * \return string of the flag
     164 */
     165string bond::GetColor(enum Shading color) const
     166{
     167  switch (color) {
     168    case white:
     169      return "white";
     170      break;
     171    case lightgray:
     172      return "lightgray";
     173      break;
     174    case darkgray:
     175      return "darkgray";
     176      break;
     177    case black:
     178      return "black";
     179      break;
     180    default:
     181      return "uncolored";
     182      break;
     183  };
     184}
  • src/bond.hpp

    r4092c5 rce5f05  
    3434class bond {
    3535  public:
    36     atom *leftatom;    //!< first bond partner
    37     atom *rightatom;  //!< second bond partner
    38     int HydrogenBond;  //!< Number of hydrogen atoms in the bond
    39     int BondDegree;    //!< single, double, triple, ... bond
    40     int nr;           //!< unique number in a molecule, updated by molecule::CreateAdjacencyList()
    41     bool Cyclic;      //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
    42     enum EdgeType Type;//!< whether this is a tree or back edge
     36  enum EdgeType { Undetermined, TreeEdge, BackEdge }; //!< edge type in a graph after Depth-First-Search analysis.
     37
     38  enum Shading { white, lightgray, darkgray, black };  //!< color in Breadth-First-Search analysis
     39
     40  atom *leftatom;    //!< first bond partner
     41  atom *rightatom;  //!< second bond partner
     42  int HydrogenBond;  //!< Number of hydrogen atoms in the bond
     43  int BondDegree;    //!< single, double, triple, ... bond
     44  int nr;           //!< unique number in a molecule, updated by BondGraph::CreateAdjacencyForList()
     45  bool Cyclic;      //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
     46  enum EdgeType Type;//!< whether this is a tree or back edge
    4347
    4448  atom * GetOtherAtom(const ParticleInfo * const Atom) const;
     
    5660  ~bond();
    5761
     62  string GetColor(enum Shading color) const;
     63
    5864  private:
    5965    enum Shading Used;        //!< marker in depth-first search, DepthFirstSearchAnalysis()
  • src/molecule.cpp

    r4092c5 rce5f05  
    397397      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    398398      Binder->Cyclic = false;
    399       Binder->Type = TreeEdge;
     399      Binder->Type = bond::TreeEdge;
    400400      break;
    401401    case 2:
     
    493493      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    494494      Binder->Cyclic = false;
    495       Binder->Type = TreeEdge;
     495      Binder->Type = bond::TreeEdge;
    496496      Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
    497497      Binder->Cyclic = false;
    498       Binder->Type = TreeEdge;
     498      Binder->Type = bond::TreeEdge;
    499499      break;
    500500    case 3:
     
    576576      Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
    577577      Binder->Cyclic = false;
    578       Binder->Type = TreeEdge;
     578      Binder->Type = bond::TreeEdge;
    579579      Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
    580580      Binder->Cyclic = false;
    581       Binder->Type = TreeEdge;
     581      Binder->Type = bond::TreeEdge;
    582582      Binder = AddBond(BottomOrigin, ThirdOtherAtom, 1);
    583583      Binder->Cyclic = false;
    584       Binder->Type = TreeEdge;
     584      Binder->Type = bond::TreeEdge;
    585585      break;
    586586    default:
  • src/molecule.hpp

    r4092c5 rce5f05  
    224224  int CountCyclicBonds();
    225225  bool CheckForConnectedSubgraph(KeySet *Fragment);
    226   string GetColor(enum Shading color) const;
    227226  bond * CopyBond(atom *left, atom *right, bond *CopyBond);
    228227
  • src/molecule_fragmentation.cpp

    r4092c5 rce5f05  
    17941794  atom *OtherWalker = NULL;
    17951795  RealSpaceMatrix matrix = World::getInstance().getDomain().getM();
    1796   enum Shading *ColorList = NULL;
     1796  enum bond::Shading *ColorList = NULL;
    17971797  double tmp;
    17981798  //bool LastBond = true; // only needed to due list construct
     
    18051805  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    18061806
    1807   ColorList = new enum Shading[getAtomCount()];
     1807  ColorList = new enum bond::Shading[getAtomCount()];
    18081808  for (int i=0;i<getAtomCount();i++)
    1809     ColorList[i] = (enum Shading)0;
     1809    ColorList[i] = (enum bond::Shading)0;
    18101810  if (flag) {
    18111811    // remove bonds that are beyond bonddistance
     
    18491849      // apply to all atoms of first component via BFS
    18501850      for (int i=getAtomCount();i--;)
    1851         ColorList[i] = white;
     1851        ColorList[i] = bond::white;
    18521852      AtomStack->push_front(Binder->leftatom);
    18531853      while (!AtomStack->empty()) {
     
    18551855        AtomStack->pop_front();
    18561856        //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl;
    1857         ColorList[Walker->getNr()] = black;    // mark as explored
     1857        ColorList[Walker->getNr()] = bond::black;    // mark as explored
    18581858        *Walker += Translationvector; // translate
    18591859        const BondList& ListOfBonds = Walker->getListOfBonds();
     
    18631863          if ((*Runner) != Binder) {
    18641864            OtherWalker = (*Runner)->GetOtherAtom(Walker);
    1865             if (ColorList[OtherWalker->getNr()] == white) {
     1865            if (ColorList[OtherWalker->getNr()] == bond::white) {
    18661866              AtomStack->push_front(OtherWalker); // push if yet unexplored
    18671867            }
  • src/molecule_graph.cpp

    r4092c5 rce5f05  
    4848  atom **PredecessorList;
    4949  int *ShortestPathList;
    50   enum Shading *ColorList;
     50  enum bond::Shading *ColorList;
    5151  std::deque<atom *> *BFSStack;
    5252  std::deque<atom *> *TouchedStack;
     
    308308  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    309309    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    310     if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == Undetermined)) {
     310    if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == bond::Undetermined)) {
    311311      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    312312      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
     
    334334;
    335335
    336 /** Returns Shading as a char string.
    337  * \param color the Shading
    338  * \return string of the flag
    339  */
    340 string molecule::GetColor(enum Shading color) const
    341 {
    342   switch (color) {
    343     case white:
    344       return "white";
    345       break;
    346     case lightgray:
    347       return "lightgray";
    348       break;
    349     case darkgray:
    350       return "darkgray";
    351       break;
    352     case black:
    353       return "black";
    354       break;
    355     default:
    356       return "uncolored";
    357       break;
    358   };
    359 }
    360 ;
    361336
    362337/** Sets atom::GraphNr and atom::LowpointNr to BFSAccounting::CurrentGraphNr.
     
    397372    DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
    398373    // (4) Mark Binder used, ...
    399     Binder->MarkUsed(black);
     374    Binder->MarkUsed(bond::black);
    400375    OtherAtom = Binder->GetOtherAtom(Walker);
    401376    DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl);
    402377    if (OtherAtom->GraphNr != -1) {
    403378      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
    404       Binder->Type = BackEdge;
     379      Binder->Type = bond::BackEdge;
    405380      DFS.BackEdgeStack->push_front(Binder);
    406381      Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
     
    408383    } else {
    409384      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
    410       Binder->Type = TreeEdge;
     385      Binder->Type = bond::TreeEdge;
    411386      OtherAtom->Ancestor = Walker;
    412387      Walker = OtherAtom;
     
    664639        if (DoLog(2)) {
    665640          ostream &out = (Log() << Verbose(2));
    666           out << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
     641          out << ((Binder->Type == bond::TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
    667642          out << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";
    668643          Binder->leftatom->OutputComponentNumber(&out);
     
    688663  BFS.PredecessorList = new atom*[AtomCount];
    689664  BFS.ShortestPathList = new int[AtomCount];
    690   BFS.ColorList = new enum Shading[AtomCount];
     665  BFS.ColorList = new enum bond::Shading[AtomCount];
    691666  BFS.BFSStack = new std::deque<atom *> (AtomCount);
    692667  BFS.TouchedStack = new std::deque<atom *> (AtomCount);
     
    695670    BFS.ShortestPathList[i] = -1;
    696671    BFS.PredecessorList[i] = 0;
    697     BFS.ColorList[i] = white;
     672    BFS.ColorList[i] = bond::white;
    698673  }
    699674};
     
    723698    BFS.PredecessorList[Walker->getNr()] = NULL;
    724699    BFS.ShortestPathList[Walker->getNr()] = -1;
    725     BFS.ColorList[Walker->getNr()] = white;
     700    BFS.ColorList[Walker->getNr()] = bond::white;
    726701  }
    727702};
     
    762737#endif
    763738        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
    764         if (BFS.ColorList[OtherAtom->getNr()] == white) {
     739        if (BFS.ColorList[OtherAtom->getNr()] == bond::white) {
    765740          BFS.TouchedStack->push_front(OtherAtom);
    766           BFS.ColorList[OtherAtom->getNr()] = lightgray;
     741          BFS.ColorList[OtherAtom->getNr()] = bond::lightgray;
    767742          BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
    768743          BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1;
     
    780755      } else {
    781756        DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl);
    782         BFS.ColorList[OtherAtom->getNr()] = black;
     757        BFS.ColorList[OtherAtom->getNr()] = bond::black;
    783758      }
    784759#endif
     
    787762      }
    788763    }
    789     BFS.ColorList[Walker->getNr()] = black;
     764    BFS.ColorList[Walker->getNr()] = bond::black;
    790765    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
    791766    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
     
    807782            BFS.PredecessorList[OtherAtom->getNr()] = NULL;
    808783            BFS.ShortestPathList[OtherAtom->getNr()] = -1;
    809             BFS.ColorList[OtherAtom->getNr()] = white;
     784            BFS.ColorList[OtherAtom->getNr()] = bond::white;
    810785            // rats ... deque has no find()
    811786            std::deque<atom *>::iterator iter = find(
     
    894869        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    895870        //Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl;
    896         if (BFS.ColorList[OtherAtom->getNr()] == white) {
     871        if (BFS.ColorList[OtherAtom->getNr()] == bond::white) {
    897872          BFS.TouchedStack->push_front(OtherAtom);
    898           BFS.ColorList[OtherAtom->getNr()] = lightgray;
     873          BFS.ColorList[OtherAtom->getNr()] = bond::lightgray;
    899874          BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
    900875          BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1;
     
    913888      }
    914889    }
    915     BFS.ColorList[Walker->getNr()] = black;
     890    BFS.ColorList[Walker->getNr()] = bond::black;
    916891    //Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
    917892  }
     
    10411016      Runner != ListOfBonds.end();
    10421017      ++Runner)
    1043     if ((*Runner)->IsUsed() == white)
     1018    if ((*Runner)->IsUsed() == bond::white)
    10441019      return ((*Runner));
    10451020  return NULL;
     
    13041279  BFS.PredecessorList = new atom*[AtomCount];
    13051280  BFS.ShortestPathList = new int[AtomCount];
    1306   BFS.ColorList = new enum Shading[AtomCount];
     1281  BFS.ColorList = new enum bond::Shading[AtomCount];
    13071282  BFS.BFSStack = new std::deque<atom *> (AtomCount);
    13081283
     
    13161291    BFS.ShortestPathList[i] = -1;
    13171292    if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited
    1318       BFS.ColorList[i] = lightgray;
     1293      BFS.ColorList[i] = bond::lightgray;
    13191294    else
    1320       BFS.ColorList[i] = white;
     1295      BFS.ColorList[i] = bond::white;
    13211296  }
    13221297  //BFS.ShortestPathList[Root->getNr()] = 0; // done by Calloc
     
    13371312{
    13381313  if (Binder != Bond) // let other atom white if it's via Root bond. In case it's cyclic it has to be reached again (yet Root is from OtherAtom already black, thus no problem)
    1339     BFS.ColorList[OtherAtom->getNr()] = lightgray;
     1314    BFS.ColorList[OtherAtom->getNr()] = bond::lightgray;
    13401315  BFS.PredecessorList[OtherAtom->getNr()] = Walker; // Walker is the predecessor
    13411316  BFS.ShortestPathList[OtherAtom->getNr()] = BFS.ShortestPathList[Walker->getNr()] + 1;
    1342   DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->getNr()] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl);
     1317  DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->getNr()] == bond::white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->getNr()] << " egde(s) long." << endl);
    13431318  if ((((BFS.ShortestPathList[OtherAtom->getNr()] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
    13441319    DoLog(3) && (Log() << Verbose(3));
     
    13601335  } else { // out of bond order, then replace
    13611336    if ((AddedAtomList[OtherAtom->getNr()] == NULL) && (Binder->Cyclic))
    1362       BFS.ColorList[OtherAtom->getNr()] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
     1337      BFS.ColorList[OtherAtom->getNr()] = bond::white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
    13631338    if (Binder == Bond)
    13641339      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");
     
    14381413        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    14391414        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl);
    1440         if (BFS.ColorList[OtherAtom->getNr()] == white) {
     1415        if (BFS.ColorList[OtherAtom->getNr()] == bond::white) {
    14411416          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
    14421417        } else {
     
    14451420      }
    14461421    }
    1447     BFS.ColorList[Walker->getNr()] = black;
     1422    BFS.ColorList[Walker->getNr()] = bond::black;
    14481423    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl);
    14491424  }
Note: See TracChangeset for help on using the changeset viewer.