source: src/Actions/FragmentationAction/DepthFirstSearchAction.cpp@ 6d6b54

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
Last change on this file since 6d6b54 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * DepthFirstSearchAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
11#include "CommandLineParser.hpp"
12#include "atom.hpp"
13#include "config.hpp"
14#include "log.hpp"
15#include "molecule.hpp"
16#include "Descriptors/MoleculeDescriptor.hpp"
17#include "Descriptors/MoleculeIdDescriptor.hpp"
18#include "stackclass.hpp"
19#include "verbose.hpp"
20#include "World.hpp"
21
22#include <iostream>
23#include <string>
24
25using namespace std;
26
27#include "UIElements/UIFactory.hpp"
28#include "UIElements/Dialog.hpp"
29#include "Actions/MapOfActions.hpp"
30
31const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
32
33FragmentationDepthFirstSearchAction::FragmentationDepthFirstSearchAction() :
34 Action(NAME)
35{}
36
37FragmentationDepthFirstSearchAction::~FragmentationDepthFirstSearchAction()
38{}
39
40Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
41 Dialog *dialog = UIFactory::getInstance().makeDialog();
42 double distance;
43
44 dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
45
46 if(dialog->display()) {
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 ***ListOfLocalAtoms = NULL;
52 class StackClass<bond *> *BackEdgeStack = NULL;
53 class StackClass<bond *> *LocalBackEdgeStack = NULL;
54 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
55 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
56 if (Subgraphs != NULL) {
57 int FragmentCounter = 0;
58 while (Subgraphs->next != NULL) {
59 Subgraphs = Subgraphs->next;
60 Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms
61 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
62 Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
63 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
64 delete(LocalBackEdgeStack);
65 delete(Subgraphs->previous);
66 FragmentCounter++;
67 }
68 delete(Subgraphs);
69 for (int i=0;i<FragmentCounter;i++)
70 delete[](ListOfLocalAtoms[i]);
71 delete[](ListOfLocalAtoms);
72 }
73 delete(BackEdgeStack);
74 delete[](MinimumRingSize);
75 delete dialog;
76 return Action::success;
77 } else {
78 delete dialog;
79 return Action::failure;
80 }
81}
82
83Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
84// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
85
86 return Action::failure;
87// string newName = state->mol->getName();
88// state->mol->setName(state->lastName);
89//
90// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
91}
92
93Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
94 return Action::failure;
95}
96
97bool FragmentationDepthFirstSearchAction::canUndo() {
98 return false;
99}
100
101bool FragmentationDepthFirstSearchAction::shouldUndo() {
102 return false;
103}
104
105const string FragmentationDepthFirstSearchAction::getName() {
106 return NAME;
107}
Note: See TracBrowser for help on using the repository browser.