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