| [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"
 | 
|---|
 | 26 | #include "Actions/MapOfActions.hpp"
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | AnalysisMolecularVolumeAction::AnalysisMolecularVolumeAction() :
 | 
|---|
 | 31 |   Action(NAME)
 | 
|---|
 | 32 | {}
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | AnalysisMolecularVolumeAction::~AnalysisMolecularVolumeAction()
 | 
|---|
 | 35 | {}
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
 | 
|---|
 | 38 |   Dialog *dialog = UIFactory::getInstance().makeDialog();
 | 
|---|
 | 39 |   molecule *mol = NULL;
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 |   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 |   if(dialog->display()) {
 | 
|---|
 | 44 |     class Tesselation *TesselStruct = NULL;
 | 
|---|
 | 45 |     const LinkedCell *LCList = NULL;
 | 
|---|
 | 46 |     DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
 | 
|---|
 | 47 |     LCList = new LinkedCell(mol, 10.);
 | 
|---|
 | 48 |     config * const configuration = World::getInstance().getConfig();
 | 
|---|
 | 49 |     //FindConvexBorder(mol, LCList, argv[argptr]);
 | 
|---|
 | 50 |     FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
 | 
|---|
 | 51 |     //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
 | 
|---|
 | 52 |     double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL);
 | 
|---|
 | 53 |     double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
 | 
|---|
 | 54 |     DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
 | 
|---|
 | 55 |     DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
 | 
|---|
 | 56 |     delete(TesselStruct);
 | 
|---|
 | 57 |     delete(LCList);
 | 
|---|
 | 58 |     delete dialog;
 | 
|---|
 | 59 |     return Action::success;
 | 
|---|
 | 60 |   } else {
 | 
|---|
 | 61 |     delete dialog;
 | 
|---|
 | 62 |     return Action::failure;
 | 
|---|
 | 63 |   }
 | 
|---|
 | 64 | }
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 67 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 |   return Action::failure;
 | 
|---|
 | 70 | //  string newName = state->mol->getName();
 | 
|---|
 | 71 | //  state->mol->setName(state->lastName);
 | 
|---|
 | 72 | //
 | 
|---|
 | 73 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
 | 
|---|
 | 74 | }
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
 | 
|---|
 | 77 |   return Action::failure;
 | 
|---|
 | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | bool AnalysisMolecularVolumeAction::canUndo() {
 | 
|---|
 | 81 |   return false;
 | 
|---|
 | 82 | }
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | bool AnalysisMolecularVolumeAction::shouldUndo() {
 | 
|---|
 | 85 |   return false;
 | 
|---|
 | 86 | }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | const string AnalysisMolecularVolumeAction::getName() {
 | 
|---|
 | 89 |   return NAME;
 | 
|---|
 | 90 | }
 | 
|---|