1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | *
|
---|
6 | *
|
---|
7 | * This file is part of MoleCuilder.
|
---|
8 | *
|
---|
9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
10 | * it under the terms of the GNU General Public License as published by
|
---|
11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
12 | * (at your option) any later version.
|
---|
13 | *
|
---|
14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * FragmentationAction.cpp
|
---|
25 | *
|
---|
26 | * Created on: May 9, 2010
|
---|
27 | * Author: heber
|
---|
28 | */
|
---|
29 |
|
---|
30 | // include config.h
|
---|
31 | #ifdef HAVE_CONFIG_H
|
---|
32 | #include <config.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include "CodePatterns/MemDebug.hpp"
|
---|
36 |
|
---|
37 | #include "Atom/atom.hpp"
|
---|
38 | #include "CodePatterns/Log.hpp"
|
---|
39 | #include "Fragmentation/Fragmentation.hpp"
|
---|
40 | #include "Fragmentation/HydrogenSaturation_enum.hpp"
|
---|
41 | #include "Graph/DepthFirstSearchAnalysis.hpp"
|
---|
42 | #include "molecule.hpp"
|
---|
43 | #include "World.hpp"
|
---|
44 |
|
---|
45 | #include <iostream>
|
---|
46 | #include <string>
|
---|
47 |
|
---|
48 | #include "Actions/FragmentationAction/FragmentationAction.hpp"
|
---|
49 |
|
---|
50 | using namespace MoleCuilder;
|
---|
51 |
|
---|
52 | // and construct the stuff
|
---|
53 | #include "FragmentationAction.def"
|
---|
54 | #include "Action_impl_pre.hpp"
|
---|
55 | /** =========== define the function ====================== */
|
---|
56 | Action::state_ptr FragmentationFragmentationAction::performCall() {
|
---|
57 | clock_t start,end;
|
---|
58 | molecule *mol = NULL;
|
---|
59 | int ExitFlag = 0;
|
---|
60 |
|
---|
61 | LOG(0, "STATUS: Fragmenting molecular system with current connection matrix maximum bond distance "
|
---|
62 | << params.distance.get() << " up to "
|
---|
63 | << params.order.get() << " order. Fragment files begin with "
|
---|
64 | << params.prefix.get() << " and are stored as: "
|
---|
65 | << params.types.get() << "." << std::endl);
|
---|
66 |
|
---|
67 | DepthFirstSearchAnalysis DFS;
|
---|
68 | for (World::MoleculeSelectionConstIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
69 | mol = iter->second;
|
---|
70 | ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
|
---|
71 | LOG(2, "INFO: Fragmenting molecule with bond distance " << params.distance.get() << " angstroem, order of " << params.order.get() << ".");
|
---|
72 | start = clock();
|
---|
73 | if (mol->hasBondStructure()) {
|
---|
74 | Fragmentation Fragmenter(mol, params.DoSaturation.get() ? DoSaturate : DontSaturate);
|
---|
75 | Fragmenter.setOutputTypes(params.types.get());
|
---|
76 | ExitFlag = Fragmenter.FragmentMolecule(params.order.get(), params.prefix.get(), DFS);
|
---|
77 | }
|
---|
78 | World::getInstance().setExitFlag(ExitFlag);
|
---|
79 | end = clock();
|
---|
80 | LOG(0, "STATUS: Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s.");
|
---|
81 | }
|
---|
82 | return Action::success;
|
---|
83 | }
|
---|
84 |
|
---|
85 | Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
|
---|
86 | return Action::success;
|
---|
87 | }
|
---|
88 |
|
---|
89 | Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
|
---|
90 | return Action::success;
|
---|
91 | }
|
---|
92 |
|
---|
93 | bool FragmentationFragmentationAction::canUndo() {
|
---|
94 | return true;
|
---|
95 | }
|
---|
96 |
|
---|
97 | bool FragmentationFragmentationAction::shouldUndo() {
|
---|
98 | return true;
|
---|
99 | }
|
---|
100 | /** =========== end of function ====================== */
|
---|