| [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"
 | 
|---|
 | 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"
 | 
|---|
| [9d33ba] | 26 | #include "UIElements/ValueStorage.hpp"
 | 
|---|
| [97ebf8] | 27 | 
 | 
|---|
 | 28 | const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | AnalysisMolecularVolumeAction::AnalysisMolecularVolumeAction() :
 | 
|---|
 | 31 |   Action(NAME)
 | 
|---|
 | 32 | {}
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | AnalysisMolecularVolumeAction::~AnalysisMolecularVolumeAction()
 | 
|---|
 | 35 | {}
 | 
|---|
 | 36 | 
 | 
|---|
| [0c9cc3] | 37 | Dialog * AnalysisMolecularVolumeAction::createDialog() {
 | 
|---|
| [97ebf8] | 38 |   Dialog *dialog = UIFactory::getInstance().makeDialog();
 | 
|---|
| [5cb3cb] | 39 | 
 | 
|---|
 | 40 |   dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
 | 
|---|
 | 41 | 
 | 
|---|
| [0c9cc3] | 42 |   return dialog;
 | 
|---|
 | 43 | }
 | 
|---|
| [97ebf8] | 44 | 
 | 
|---|
| [0c9cc3] | 45 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
 | 
|---|
 | 46 |   int molID = -1;
 | 
|---|
 | 47 |   // obtain information
 | 
|---|
| [9d33ba] | 48 |   ValueStorage::getInstance().queryCurrentValue(NAME, molID);
 | 
|---|
| [97ebf8] | 49 | 
 | 
|---|
| [0c9cc3] | 50 |   // execute action
 | 
|---|
 | 51 |   for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
 | 
|---|
 | 52 |     molecule *mol = iter->second;
 | 
|---|
| [97ebf8] | 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();
 | 
|---|
| [bdc91e] | 58 |     Boundaries *BoundaryPoints = NULL;
 | 
|---|
 | 59 |     //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
 | 
|---|
| [97ebf8] | 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 |   }
 | 
|---|
| [0c9cc3] | 69 |   return Action::success;
 | 
|---|
| [97ebf8] | 70 | }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| [0c9cc3] | 73 |   return Action::success;
 | 
|---|
| [97ebf8] | 74 | }
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [0c9cc3] | 77 |   return Action::success;
 | 
|---|
| [97ebf8] | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | bool AnalysisMolecularVolumeAction::canUndo() {
 | 
|---|
| [0c9cc3] | 81 |   return true;
 | 
|---|
| [97ebf8] | 82 | }
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | bool AnalysisMolecularVolumeAction::shouldUndo() {
 | 
|---|
| [0c9cc3] | 85 |   return true;
 | 
|---|
| [97ebf8] | 86 | }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | const string AnalysisMolecularVolumeAction::getName() {
 | 
|---|
 | 89 |   return NAME;
 | 
|---|
 | 90 | }
 | 
|---|