/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * DepthFirstSearchAction.cpp * * Created on: May 9, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Atom/atom.hpp" #include "CodePatterns/Log.hpp" #include "Fragmentation/HydrogenSaturation_enum.hpp" #include "Graph/CyclicStructureAnalysis.hpp" #include "Graph/DepthFirstSearchAnalysis.hpp" #include "molecule.hpp" #include "MoleculeLeafClass.hpp" #include #include #include "Actions/GraphAction/DepthFirstSearchAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "DepthFirstSearchAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr GraphDepthFirstSearchAction::performCall() { LOG(1, "Depth-First-Search Analysis."); atom **ListOfAtoms = NULL; std::deque *LocalBackEdgeStack = NULL; DepthFirstSearchAnalysis DFS; DFS(); DFS.UpdateMoleculeStructure(); MoleculeLeafClass *Subgraphs = DFS.getMoleculeStructure(); if (Subgraphs != NULL) { int FragmentCounter = 0; while (Subgraphs->next != NULL) { Subgraphs = Subgraphs->next; ListOfAtoms = NULL; Subgraphs->Leaf->FillListOfLocalAtoms(ListOfAtoms, Subgraphs->Leaf->getAtomCount()); LocalBackEdgeStack = new std::deque; // no need to have it Subgraphs->Leaf->BondCount size DFS.PickLocalBackEdges(ListOfAtoms, LocalBackEdgeStack); CyclicStructureAnalysis CycleAnalysis(params.DoSaturation ? DoSaturate : DontSaturate); CycleAnalysis(LocalBackEdgeStack); delete(LocalBackEdgeStack); Subgraphs->Leaf = NULL; delete(Subgraphs->previous); delete[](ListOfAtoms); // allocated by FillListOfLocalAtoms FragmentCounter++; } Subgraphs->Leaf = NULL; delete(Subgraphs); } return Action::success; } Action::state_ptr GraphDepthFirstSearchAction::performUndo(Action::state_ptr _state) { return Action::success; } Action::state_ptr GraphDepthFirstSearchAction::performRedo(Action::state_ptr _state){ return Action::success; } bool GraphDepthFirstSearchAction::canUndo() { return true; } bool GraphDepthFirstSearchAction::shouldUndo() { return true; } /** =========== end of function ====================== */