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