| 1 | /* | 
|---|
| 2 | * MolecularVolumeAction.cpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: May 12, 2010 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #include "Helpers/MemDebug.hpp" | 
|---|
| 9 |  | 
|---|
| 10 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" | 
|---|
| 11 | #include "boundary.hpp" | 
|---|
| 12 | #include "config.hpp" | 
|---|
| 13 | #include "molecule.hpp" | 
|---|
| 14 | #include "linkedcell.hpp" | 
|---|
| 15 | #include "log.hpp" | 
|---|
| 16 | #include "verbose.hpp" | 
|---|
| 17 | #include "World.hpp" | 
|---|
| 18 |  | 
|---|
| 19 | #include <iostream> | 
|---|
| 20 | #include <string> | 
|---|
| 21 |  | 
|---|
| 22 | using namespace std; | 
|---|
| 23 |  | 
|---|
| 24 | #include "UIElements/UIFactory.hpp" | 
|---|
| 25 | #include "UIElements/Dialog.hpp" | 
|---|
| 26 | #include "UIElements/ValueStorage.hpp" | 
|---|
| 27 |  | 
|---|
| 28 | const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume"; | 
|---|
| 29 |  | 
|---|
| 30 | AnalysisMolecularVolumeAction::AnalysisMolecularVolumeAction() : | 
|---|
| 31 | Action(NAME) | 
|---|
| 32 | {} | 
|---|
| 33 |  | 
|---|
| 34 | AnalysisMolecularVolumeAction::~AnalysisMolecularVolumeAction() | 
|---|
| 35 | {} | 
|---|
| 36 |  | 
|---|
| 37 | Dialog * AnalysisMolecularVolumeAction::createDialog() { | 
|---|
| 38 | Dialog *dialog = UIFactory::getInstance().makeDialog(); | 
|---|
| 39 |  | 
|---|
| 40 | dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); | 
|---|
| 41 |  | 
|---|
| 42 | return dialog; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() { | 
|---|
| 46 | int molID = -1; | 
|---|
| 47 | // obtain information | 
|---|
| 48 | ValueStorage::getInstance().queryCurrentValue(NAME, molID); | 
|---|
| 49 |  | 
|---|
| 50 | // execute action | 
|---|
| 51 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { | 
|---|
| 52 | molecule *mol = iter->second; | 
|---|
| 53 | class Tesselation *TesselStruct = NULL; | 
|---|
| 54 | const LinkedCell *LCList = NULL; | 
|---|
| 55 | DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); | 
|---|
| 56 | LCList = new LinkedCell(mol, 10.); | 
|---|
| 57 | config * const configuration = World::getInstance().getConfig(); | 
|---|
| 58 | Boundaries *BoundaryPoints = NULL; | 
|---|
| 59 | //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); | 
|---|
| 60 | FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); | 
|---|
| 61 | //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]); | 
|---|
| 62 | double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL); | 
|---|
| 63 | double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); | 
|---|
| 64 | DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); | 
|---|
| 65 | DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); | 
|---|
| 66 | delete(TesselStruct); | 
|---|
| 67 | delete(LCList); | 
|---|
| 68 | } | 
|---|
| 69 | return Action::success; | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) { | 
|---|
| 73 | return Action::success; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){ | 
|---|
| 77 | return Action::success; | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | bool AnalysisMolecularVolumeAction::canUndo() { | 
|---|
| 81 | return true; | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | bool AnalysisMolecularVolumeAction::shouldUndo() { | 
|---|
| 85 | return true; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | const string AnalysisMolecularVolumeAction::getName() { | 
|---|
| 89 | return NAME; | 
|---|
| 90 | } | 
|---|