[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * DepthFirstSearchAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 9, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[97ebf8] | 22 | #include "atom.hpp"
|
---|
[632508] | 23 | #include "Graph/BondGraph.hpp"
|
---|
[97ebf8] | 24 | #include "config.hpp"
|
---|
[ad011c] | 25 | #include "CodePatterns/Log.hpp"
|
---|
| 26 | #include "CodePatterns/Verbose.hpp"
|
---|
[97ebf8] | 27 | #include "molecule.hpp"
|
---|
| 28 | #include "Descriptors/MoleculeDescriptor.hpp"
|
---|
| 29 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
| 30 | #include "World.hpp"
|
---|
| 31 |
|
---|
| 32 | #include <iostream>
|
---|
| 33 | #include <string>
|
---|
| 34 |
|
---|
| 35 | using namespace std;
|
---|
| 36 |
|
---|
[1fd675] | 37 | #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
|
---|
[f394a6] | 38 |
|
---|
[1fd675] | 39 | // and construct the stuff
|
---|
| 40 | #include "DepthFirstSearchAction.def"
|
---|
| 41 | #include "Action_impl_pre.hpp"
|
---|
| 42 | /** =========== define the function ====================== */
|
---|
[f394a6] | 43 | Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
|
---|
[1fd675] | 44 | // obtain information
|
---|
| 45 | getParametersfromValueStorage();
|
---|
[f394a6] | 46 |
|
---|
| 47 | DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
|
---|
| 48 | molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
|
---|
| 49 | MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis
|
---|
| 50 | int *MinimumRingSize = new int[mol->getAtomCount()];
|
---|
| 51 | atom **ListOfAtoms = NULL;
|
---|
[a564be] | 52 | std::deque<bond *> *BackEdgeStack = NULL;
|
---|
| 53 | std::deque<bond *> *LocalBackEdgeStack = NULL;
|
---|
[f394a6] | 54 | Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
|
---|
| 55 | if (Subgraphs != NULL) {
|
---|
| 56 | int FragmentCounter = 0;
|
---|
| 57 | while (Subgraphs->next != NULL) {
|
---|
| 58 | Subgraphs = Subgraphs->next;
|
---|
| 59 | ListOfAtoms = NULL;
|
---|
| 60 | Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms
|
---|
[a564be] | 61 | LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size
|
---|
[f394a6] | 62 | Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
|
---|
| 63 | Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
|
---|
| 64 | delete(LocalBackEdgeStack);
|
---|
| 65 | delete(Subgraphs->previous);
|
---|
| 66 | delete[](ListOfAtoms); // and here we remove it
|
---|
| 67 | FragmentCounter++;
|
---|
[97ebf8] | 68 | }
|
---|
[f394a6] | 69 | delete(Subgraphs);
|
---|
[97ebf8] | 70 | }
|
---|
[f394a6] | 71 | delete(BackEdgeStack);
|
---|
| 72 | delete[](MinimumRingSize);
|
---|
| 73 | return Action::success;
|
---|
[97ebf8] | 74 | }
|
---|
| 75 |
|
---|
| 76 | Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
|
---|
[f394a6] | 77 | return Action::success;
|
---|
[97ebf8] | 78 | }
|
---|
| 79 |
|
---|
| 80 | Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
|
---|
[f394a6] | 81 | return Action::success;
|
---|
[97ebf8] | 82 | }
|
---|
| 83 |
|
---|
| 84 | bool FragmentationDepthFirstSearchAction::canUndo() {
|
---|
[f394a6] | 85 | return true;
|
---|
[97ebf8] | 86 | }
|
---|
| 87 |
|
---|
| 88 | bool FragmentationDepthFirstSearchAction::shouldUndo() {
|
---|
[f394a6] | 89 | return true;
|
---|
[97ebf8] | 90 | }
|
---|
[1fd675] | 91 | /** =========== end of function ====================== */
|
---|