| 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 | * MolecularVolumeAction.cpp | 
|---|
| 25 | * | 
|---|
| 26 | *  Created on: May 12, 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 "config.hpp" | 
|---|
| 38 | #include "CodePatterns/Log.hpp" | 
|---|
| 39 | #include "CodePatterns/Verbose.hpp" | 
|---|
| 40 | #include "LinkedCell/linkedcell.hpp" | 
|---|
| 41 | #include "LinkedCell/PointCloudAdaptor.hpp" | 
|---|
| 42 | #include "molecule.hpp" | 
|---|
| 43 | #include "Tesselation/boundary.hpp" | 
|---|
| 44 | #include "Tesselation/tesselation.hpp" | 
|---|
| 45 | #include "World.hpp" | 
|---|
| 46 |  | 
|---|
| 47 | #include <iostream> | 
|---|
| 48 | #include <string> | 
|---|
| 49 |  | 
|---|
| 50 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" | 
|---|
| 51 |  | 
|---|
| 52 | using namespace MoleCuilder; | 
|---|
| 53 |  | 
|---|
| 54 | // and construct the stuff | 
|---|
| 55 | #include "MolecularVolumeAction.def" | 
|---|
| 56 | #include "Action_impl_pre.hpp" | 
|---|
| 57 |  | 
|---|
| 58 | /** =========== define the function ====================== */ | 
|---|
| 59 | ActionState::ptr AnalysisMolecularVolumeAction::performCall() { | 
|---|
| 60 | // execute action | 
|---|
| 61 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { | 
|---|
| 62 | molecule *mol = iter->second; | 
|---|
| 63 | class Tesselation *TesselStruct = NULL; | 
|---|
| 64 | const LinkedCell_deprecated *LCList = NULL; | 
|---|
| 65 | LOG(0, "Evaluating volume of the convex envelope."); | 
|---|
| 66 | PointCloudAdaptor< molecule > cloud(mol, mol->name); | 
|---|
| 67 | LCList = new LinkedCell_deprecated(cloud, 10.); | 
|---|
| 68 | config * const configuration = World::getInstance().getConfig(); | 
|---|
| 69 | //Boundaries *BoundaryPoints = NULL; | 
|---|
| 70 | //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); | 
|---|
| 71 | FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); | 
|---|
| 72 | //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]); | 
|---|
| 73 | double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL); | 
|---|
| 74 | double clustervolume = TesselStruct->getVolumeOfConvexEnvelope(configuration->GetIsAngstroem()); | 
|---|
| 75 | LOG(0, "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3."); | 
|---|
| 76 | LOG(0, "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3."); | 
|---|
| 77 | delete(TesselStruct); | 
|---|
| 78 | delete(LCList); | 
|---|
| 79 | } | 
|---|
| 80 | return Action::success; | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | ActionState::ptr AnalysisMolecularVolumeAction::performUndo(ActionState::ptr _state) { | 
|---|
| 84 | return Action::success; | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | ActionState::ptr AnalysisMolecularVolumeAction::performRedo(ActionState::ptr _state){ | 
|---|
| 88 | return Action::success; | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | bool AnalysisMolecularVolumeAction::canUndo() { | 
|---|
| 92 | return true; | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 | bool AnalysisMolecularVolumeAction::shouldUndo() { | 
|---|
| 96 | return true; | 
|---|
| 97 | } | 
|---|
| 98 | /** =========== end of function ====================== */ | 
|---|