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