| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2010 University of Bonn. All rights reserved. | 
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | /* | 
|---|
| 9 | * MolecularVolumeAction.cpp | 
|---|
| 10 | * | 
|---|
| 11 | *  Created on: May 12, 2010 | 
|---|
| 12 | *      Author: heber | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | // include config.h | 
|---|
| 16 | #ifdef HAVE_CONFIG_H | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | #include "Helpers/MemDebug.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | #include "boundary.hpp" | 
|---|
| 23 | #include "config.hpp" | 
|---|
| 24 | #include "molecule.hpp" | 
|---|
| 25 | #include "linkedcell.hpp" | 
|---|
| 26 | #include "Helpers/Log.hpp" | 
|---|
| 27 | #include "Helpers/Verbose.hpp" | 
|---|
| 28 | #include "tesselation.hpp" | 
|---|
| 29 | #include "World.hpp" | 
|---|
| 30 |  | 
|---|
| 31 | #include <iostream> | 
|---|
| 32 | #include <string> | 
|---|
| 33 |  | 
|---|
| 34 | using namespace std; | 
|---|
| 35 |  | 
|---|
| 36 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" | 
|---|
| 37 |  | 
|---|
| 38 | // and construct the stuff | 
|---|
| 39 | #include "MolecularVolumeAction.def" | 
|---|
| 40 | #include "Action_impl_pre.hpp" | 
|---|
| 41 |  | 
|---|
| 42 | /** =========== define the function ====================== */ | 
|---|
| 43 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() { | 
|---|
| 44 | // obtain information | 
|---|
| 45 | getParametersfromValueStorage(); | 
|---|
| 46 |  | 
|---|
| 47 | // execute action | 
|---|
| 48 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { | 
|---|
| 49 | molecule *mol = iter->second; | 
|---|
| 50 | class Tesselation *TesselStruct = NULL; | 
|---|
| 51 | const LinkedCell *LCList = NULL; | 
|---|
| 52 | DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); | 
|---|
| 53 | LCList = new LinkedCell(*mol, 10.); | 
|---|
| 54 | config * const configuration = World::getInstance().getConfig(); | 
|---|
| 55 | //Boundaries *BoundaryPoints = NULL; | 
|---|
| 56 | //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); | 
|---|
| 57 | FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); | 
|---|
| 58 | //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]); | 
|---|
| 59 | double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL); | 
|---|
| 60 | double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); | 
|---|
| 61 | DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); | 
|---|
| 62 | DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); | 
|---|
| 63 | delete(TesselStruct); | 
|---|
| 64 | delete(LCList); | 
|---|
| 65 | } | 
|---|
| 66 | return Action::success; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) { | 
|---|
| 70 | return Action::success; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){ | 
|---|
| 74 | return Action::success; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | bool AnalysisMolecularVolumeAction::canUndo() { | 
|---|
| 78 | return true; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | bool AnalysisMolecularVolumeAction::shouldUndo() { | 
|---|
| 82 | return true; | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 | const string AnalysisMolecularVolumeAction::getName() { | 
|---|
| 86 | return NAME; | 
|---|
| 87 | } | 
|---|
| 88 | /** =========== end of function ====================== */ | 
|---|