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