[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 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/>.
|
---|
[bcf653] | 21 | */
|
---|
| 22 |
|
---|
[97ebf8] | 23 | /*
|
---|
| 24 | * FragmentationAction.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: May 9, 2010
|
---|
| 27 | * Author: heber
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[bf3817] | 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 36 |
|
---|
[6f0841] | 37 | #include "Atom/atom.hpp"
|
---|
[ad011c] | 38 | #include "CodePatterns/Log.hpp"
|
---|
[246e13] | 39 | #include "Fragmentation/Fragmentation.hpp"
|
---|
[07a47e] | 40 | #include "Fragmentation/HydrogenSaturation_enum.hpp"
|
---|
[49c059] | 41 | #include "Graph/DepthFirstSearchAnalysis.hpp"
|
---|
[97ebf8] | 42 | #include "molecule.hpp"
|
---|
| 43 | #include "World.hpp"
|
---|
| 44 |
|
---|
| 45 | #include <iostream>
|
---|
| 46 | #include <string>
|
---|
| 47 |
|
---|
[1fd675] | 48 | #include "Actions/FragmentationAction/FragmentationAction.hpp"
|
---|
[70d9b9] | 49 |
|
---|
[ce7fdc] | 50 | using namespace MoleCuilder;
|
---|
| 51 |
|
---|
[1fd675] | 52 | // and construct the stuff
|
---|
| 53 | #include "FragmentationAction.def"
|
---|
| 54 | #include "Action_impl_pre.hpp"
|
---|
| 55 | /** =========== define the function ====================== */
|
---|
[70d9b9] | 56 | Action::state_ptr FragmentationFragmentationAction::performCall() {
|
---|
[e4b5de] | 57 | clock_t start,end;
|
---|
| 58 | molecule *mol = NULL;
|
---|
| 59 | int ExitFlag = 0;
|
---|
| 60 |
|
---|
[99b0dc] | 61 | LOG(0, "STATUS: Fragmenting molecular system with current connection matrix maximum bond distance "
|
---|
[f10b0c] | 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);
|
---|
[99b0dc] | 66 |
|
---|
[49c059] | 67 | DepthFirstSearchAnalysis DFS;
|
---|
[38f991] | 68 | for (World::MoleculeSelectionConstIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
[70d9b9] | 69 | mol = iter->second;
|
---|
[e4b5de] | 70 | ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
|
---|
[f10b0c] | 71 | LOG(2, "INFO: Fragmenting molecule with bond distance " << params.distance.get() << " angstroem, order of " << params.order.get() << ".");
|
---|
[e4b5de] | 72 | start = clock();
|
---|
| 73 | if (mol->hasBondStructure()) {
|
---|
[f10b0c] | 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);
|
---|
[e4b5de] | 77 | }
|
---|
| 78 | World::getInstance().setExitFlag(ExitFlag);
|
---|
| 79 | end = clock();
|
---|
[49c059] | 80 | LOG(0, "STATUS: Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s.");
|
---|
[97ebf8] | 81 | }
|
---|
[70d9b9] | 82 | return Action::success;
|
---|
[97ebf8] | 83 | }
|
---|
| 84 |
|
---|
| 85 | Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
|
---|
[70d9b9] | 86 | return Action::success;
|
---|
[97ebf8] | 87 | }
|
---|
| 88 |
|
---|
| 89 | Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
|
---|
[70d9b9] | 90 | return Action::success;
|
---|
[97ebf8] | 91 | }
|
---|
| 92 |
|
---|
| 93 | bool FragmentationFragmentationAction::canUndo() {
|
---|
[70d9b9] | 94 | return true;
|
---|
[97ebf8] | 95 | }
|
---|
| 96 |
|
---|
| 97 | bool FragmentationFragmentationAction::shouldUndo() {
|
---|
[70d9b9] | 98 | return true;
|
---|
[97ebf8] | 99 | }
|
---|
[1fd675] | 100 | /** =========== end of function ====================== */
|
---|