| [bcf653] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
 | 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
 | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
| [97ebf8] | 8 | /*
 | 
|---|
 | 9 |  * MolecularVolumeAction.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: May 12, 2010
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
| [bf3817] | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [112b09] | 21 | 
 | 
|---|
| [97ebf8] | 22 | #include "boundary.hpp"
 | 
|---|
 | 23 | #include "config.hpp"
 | 
|---|
 | 24 | #include "molecule.hpp"
 | 
|---|
 | 25 | #include "linkedcell.hpp"
 | 
|---|
| [ad011c] | 26 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 27 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| [88b400] | 28 | #include "tesselation.hpp"
 | 
|---|
| [97ebf8] | 29 | #include "World.hpp"
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | #include <iostream>
 | 
|---|
 | 32 | #include <string>
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | using namespace std;
 | 
|---|
 | 35 | 
 | 
|---|
| [0b2ce9] | 36 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
 | 
|---|
| [5cb3cb] | 37 | 
 | 
|---|
| [0b2ce9] | 38 | // and construct the stuff
 | 
|---|
| [9ee38b] | 39 | #include "MolecularVolumeAction.def"
 | 
|---|
| [0b2ce9] | 40 | #include "Action_impl_pre.hpp"
 | 
|---|
| [97ebf8] | 41 | 
 | 
|---|
| [0b2ce9] | 42 | /** =========== define the function ====================== */
 | 
|---|
| [9ee38b] | 43 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
 | 
|---|
| [0c9cc3] | 44 |   // obtain information
 | 
|---|
| [0b2ce9] | 45 |   getParametersfromValueStorage();
 | 
|---|
| [97ebf8] | 46 | 
 | 
|---|
| [0c9cc3] | 47 |   // execute action
 | 
|---|
 | 48 |   for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
 | 
|---|
 | 49 |     molecule *mol = iter->second;
 | 
|---|
| [97ebf8] | 50 |     class Tesselation *TesselStruct = NULL;
 | 
|---|
 | 51 |     const LinkedCell *LCList = NULL;
 | 
|---|
 | 52 |     DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
 | 
|---|
| [af2c424] | 53 |     LCList = new LinkedCell(*mol, 10.);
 | 
|---|
| [97ebf8] | 54 |     config * const configuration = World::getInstance().getConfig();
 | 
|---|
| [25b9d2] | 55 |     //Boundaries *BoundaryPoints = NULL;
 | 
|---|
| [bdc91e] | 56 |     //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
 | 
|---|
| [97ebf8] | 57 |     FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
 | 
|---|
 | 58 |     //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
 | 
|---|
 | 59 |     double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL);
 | 
|---|
 | 60 |     double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
 | 
|---|
 | 61 |     DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
 | 
|---|
 | 62 |     DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
 | 
|---|
 | 63 |     delete(TesselStruct);
 | 
|---|
 | 64 |     delete(LCList);
 | 
|---|
 | 65 |   }
 | 
|---|
| [0c9cc3] | 66 |   return Action::success;
 | 
|---|
| [97ebf8] | 67 | }
 | 
|---|
 | 68 | 
 | 
|---|
| [9ee38b] | 69 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| [0c9cc3] | 70 |   return Action::success;
 | 
|---|
| [97ebf8] | 71 | }
 | 
|---|
 | 72 | 
 | 
|---|
| [9ee38b] | 73 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [0c9cc3] | 74 |   return Action::success;
 | 
|---|
| [97ebf8] | 75 | }
 | 
|---|
 | 76 | 
 | 
|---|
| [9ee38b] | 77 | bool AnalysisMolecularVolumeAction::canUndo() {
 | 
|---|
| [0c9cc3] | 78 |   return true;
 | 
|---|
| [97ebf8] | 79 | }
 | 
|---|
 | 80 | 
 | 
|---|
| [9ee38b] | 81 | bool AnalysisMolecularVolumeAction::shouldUndo() {
 | 
|---|
| [0c9cc3] | 82 |   return true;
 | 
|---|
| [97ebf8] | 83 | }
 | 
|---|
| [0b2ce9] | 84 | /** =========== end of function ====================== */
 | 
|---|