[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 |
|
---|
[112b09] | 20 | #include "Helpers/MemDebug.hpp"
|
---|
| 21 |
|
---|
[97ebf8] | 22 | #include "atom.hpp"
|
---|
[a3fded] | 23 | #include "bondgraph.hpp"
|
---|
[97ebf8] | 24 | #include "config.hpp"
|
---|
[952f38] | 25 | #include "Helpers/Log.hpp"
|
---|
[97ebf8] | 26 | #include "molecule.hpp"
|
---|
| 27 | #include "Descriptors/MoleculeDescriptor.hpp"
|
---|
| 28 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
| 29 | #include "stackclass.hpp"
|
---|
[952f38] | 30 | #include "Helpers/Verbose.hpp"
|
---|
[97ebf8] | 31 | #include "World.hpp"
|
---|
| 32 |
|
---|
| 33 | #include <iostream>
|
---|
| 34 | #include <string>
|
---|
| 35 |
|
---|
| 36 | using namespace std;
|
---|
| 37 |
|
---|
[1fd675] | 38 | #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
|
---|
[f394a6] | 39 |
|
---|
[1fd675] | 40 | // and construct the stuff
|
---|
| 41 | #include "DepthFirstSearchAction.def"
|
---|
| 42 | #include "Action_impl_pre.hpp"
|
---|
| 43 | /** =========== define the function ====================== */
|
---|
[f394a6] | 44 | Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
|
---|
[1fd675] | 45 | // obtain information
|
---|
| 46 | getParametersfromValueStorage();
|
---|
[f394a6] | 47 |
|
---|
| 48 | DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
|
---|
| 49 | molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
|
---|
| 50 | MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis
|
---|
| 51 | int *MinimumRingSize = new int[mol->getAtomCount()];
|
---|
| 52 | atom **ListOfAtoms = NULL;
|
---|
| 53 | class StackClass<bond *> *BackEdgeStack = NULL;
|
---|
| 54 | class StackClass<bond *> *LocalBackEdgeStack = NULL;
|
---|
[1fd675] | 55 | mol->CreateAdjacencyList(params.distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
[f394a6] | 56 | Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
|
---|
| 57 | if (Subgraphs != NULL) {
|
---|
| 58 | int FragmentCounter = 0;
|
---|
| 59 | while (Subgraphs->next != NULL) {
|
---|
| 60 | Subgraphs = Subgraphs->next;
|
---|
| 61 | ListOfAtoms = NULL;
|
---|
| 62 | Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms
|
---|
| 63 | LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
|
---|
| 64 | Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
|
---|
| 65 | Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
|
---|
| 66 | delete(LocalBackEdgeStack);
|
---|
| 67 | delete(Subgraphs->previous);
|
---|
| 68 | delete[](ListOfAtoms); // and here we remove it
|
---|
| 69 | FragmentCounter++;
|
---|
[97ebf8] | 70 | }
|
---|
[f394a6] | 71 | delete(Subgraphs);
|
---|
[97ebf8] | 72 | }
|
---|
[f394a6] | 73 | delete(BackEdgeStack);
|
---|
| 74 | delete[](MinimumRingSize);
|
---|
| 75 | return Action::success;
|
---|
[97ebf8] | 76 | }
|
---|
| 77 |
|
---|
| 78 | Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
|
---|
[f394a6] | 79 | return Action::success;
|
---|
[97ebf8] | 80 | }
|
---|
| 81 |
|
---|
| 82 | Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
|
---|
[f394a6] | 83 | return Action::success;
|
---|
[97ebf8] | 84 | }
|
---|
| 85 |
|
---|
| 86 | bool FragmentationDepthFirstSearchAction::canUndo() {
|
---|
[f394a6] | 87 | return true;
|
---|
[97ebf8] | 88 | }
|
---|
| 89 |
|
---|
| 90 | bool FragmentationDepthFirstSearchAction::shouldUndo() {
|
---|
[f394a6] | 91 | return true;
|
---|
[97ebf8] | 92 | }
|
---|
| 93 |
|
---|
| 94 | const string FragmentationDepthFirstSearchAction::getName() {
|
---|
| 95 | return NAME;
|
---|
| 96 | }
|
---|
[1fd675] | 97 | /** =========== end of function ====================== */
|
---|