| 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 | * NonConvexEnvelopeAction.cpp
|
|---|
| 25 | *
|
|---|
| 26 | * Created on: May 10, 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 "CodePatterns/Log.hpp"
|
|---|
| 38 | #include "LinkedCell/linkedcell.hpp"
|
|---|
| 39 | #include "LinkedCell/PointCloudAdaptor.hpp"
|
|---|
| 40 | #include "molecule.hpp"
|
|---|
| 41 | #include "Tesselation/boundary.hpp"
|
|---|
| 42 | #include "Tesselation/tesselation.hpp"
|
|---|
| 43 | #include "World.hpp"
|
|---|
| 44 |
|
|---|
| 45 | #include <iostream>
|
|---|
| 46 | #include <string>
|
|---|
| 47 |
|
|---|
| 48 | #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
|
|---|
| 49 |
|
|---|
| 50 | using namespace MoleCuilder;
|
|---|
| 51 |
|
|---|
| 52 | // and construct the stuff
|
|---|
| 53 | #include "NonConvexEnvelopeAction.def"
|
|---|
| 54 | #include "Action_impl_pre.hpp"
|
|---|
| 55 | /** =========== define the function ====================== */
|
|---|
| 56 | Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
|
|---|
| 57 | molecule * Boundary = NULL;
|
|---|
| 58 | bool Success = false;
|
|---|
| 59 | clock_t start,end;
|
|---|
| 60 |
|
|---|
| 61 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
|---|
| 62 | Boundary = iter->second;
|
|---|
| 63 | class Tesselation *T = NULL;
|
|---|
| 64 | const LinkedCell_deprecated *LCList = NULL;
|
|---|
| 65 | LOG(0, "Evaluating non-convex envelope of molecule." << Boundary->getId());
|
|---|
| 66 | LOG(1, "Using rolling ball of radius " << params.SphereRadius.get() << " and storing tecplot data in " << params.filename.get() << ".");
|
|---|
| 67 | LOG(1, "Specified molecule has " << Boundary->getAtomCount() << " atoms.");
|
|---|
| 68 | start = clock();
|
|---|
| 69 | PointCloudAdaptor< molecule > cloud(Boundary, Boundary->name);
|
|---|
| 70 | LCList = new LinkedCell_deprecated(cloud, params.SphereRadius.get()*2.);
|
|---|
| 71 | Success = FindNonConvexBorder(Boundary, T, LCList, params.SphereRadius.get(), params.filename.get().string().c_str());
|
|---|
| 72 | //FindDistributionOfEllipsoids(T, &LCList, N, number, params.filename.get().c_str());
|
|---|
| 73 | end = clock();
|
|---|
| 74 | LOG(0, "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s.");
|
|---|
| 75 | delete(LCList);
|
|---|
| 76 | delete(T);
|
|---|
| 77 | }
|
|---|
| 78 | if (Success)
|
|---|
| 79 | return Action::success;
|
|---|
| 80 | else
|
|---|
| 81 | return Action::failure;
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | Action::state_ptr TesselationNonConvexEnvelopeAction::performUndo(Action::state_ptr _state) {
|
|---|
| 85 | // TesselationNonConvexEnvelopeState *state = assert_cast<TesselationNonConvexEnvelopeState*>(_state.get());
|
|---|
| 86 |
|
|---|
| 87 | // string newName = state->mol->getName();
|
|---|
| 88 | // state->mol->setName(state->lastName);
|
|---|
| 89 |
|
|---|
| 90 | return Action::failure;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | Action::state_ptr TesselationNonConvexEnvelopeAction::performRedo(Action::state_ptr _state){
|
|---|
| 94 | // Undo and redo have to do the same for this action
|
|---|
| 95 | return performUndo(_state);
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | bool TesselationNonConvexEnvelopeAction::canUndo() {
|
|---|
| 99 | return false;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | bool TesselationNonConvexEnvelopeAction::shouldUndo() {
|
|---|
| 103 | return false;
|
|---|
| 104 | }
|
|---|
| 105 | /** =========== end of function ====================== */
|
|---|