| [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 | 
 | 
|---|
| [d127c8] | 22 | #include "Tesselation/boundary.hpp"
 | 
|---|
| [97ebf8] | 23 | #include "config.hpp"
 | 
|---|
 | 24 | #include "molecule.hpp"
 | 
|---|
 | 25 | #include "linkedcell.hpp"
 | 
|---|
| [ad011c] | 26 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 27 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| [34c43a] | 28 | #include "PointCloudAdaptor.hpp"
 | 
|---|
| [d127c8] | 29 | #include "Tesselation/tesselation.hpp"
 | 
|---|
| [97ebf8] | 30 | #include "World.hpp"
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | #include <iostream>
 | 
|---|
 | 33 | #include <string>
 | 
|---|
 | 34 | 
 | 
|---|
| [0b2ce9] | 35 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
 | 
|---|
| [5cb3cb] | 36 | 
 | 
|---|
| [ce7fdc] | 37 | using namespace MoleCuilder;
 | 
|---|
 | 38 | 
 | 
|---|
| [0b2ce9] | 39 | // and construct the stuff
 | 
|---|
| [9ee38b] | 40 | #include "MolecularVolumeAction.def"
 | 
|---|
| [0b2ce9] | 41 | #include "Action_impl_pre.hpp"
 | 
|---|
| [97ebf8] | 42 | 
 | 
|---|
| [0b2ce9] | 43 | /** =========== define the function ====================== */
 | 
|---|
| [9ee38b] | 44 | Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
 | 
|---|
| [0c9cc3] | 45 |   // obtain information
 | 
|---|
| [0b2ce9] | 46 |   getParametersfromValueStorage();
 | 
|---|
| [97ebf8] | 47 | 
 | 
|---|
| [0c9cc3] | 48 |   // execute action
 | 
|---|
 | 49 |   for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
 | 
|---|
 | 50 |     molecule *mol = iter->second;
 | 
|---|
| [97ebf8] | 51 |     class Tesselation *TesselStruct = NULL;
 | 
|---|
 | 52 |     const LinkedCell *LCList = NULL;
 | 
|---|
| [47d041] | 53 |     LOG(0, "Evaluating volume of the convex envelope.");
 | 
|---|
| [caa06ef] | 54 |     PointCloudAdaptor< molecule > cloud(mol, mol->name);
 | 
|---|
| [34c43a] | 55 |     LCList = new LinkedCell(cloud, 10.);
 | 
|---|
| [97ebf8] | 56 |     config * const configuration = World::getInstance().getConfig();
 | 
|---|
| [25b9d2] | 57 |     //Boundaries *BoundaryPoints = NULL;
 | 
|---|
| [bdc91e] | 58 |     //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
 | 
|---|
| [97ebf8] | 59 |     FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
 | 
|---|
 | 60 |     //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
 | 
|---|
 | 61 |     double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, NULL);
 | 
|---|
 | 62 |     double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
 | 
|---|
| [47d041] | 63 |     LOG(0, "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3.");
 | 
|---|
 | 64 |     LOG(0, "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3.");
 | 
|---|
| [97ebf8] | 65 |     delete(TesselStruct);
 | 
|---|
 | 66 |     delete(LCList);
 | 
|---|
 | 67 |   }
 | 
|---|
| [0c9cc3] | 68 |   return Action::success;
 | 
|---|
| [97ebf8] | 69 | }
 | 
|---|
 | 70 | 
 | 
|---|
| [9ee38b] | 71 | Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| [0c9cc3] | 72 |   return Action::success;
 | 
|---|
| [97ebf8] | 73 | }
 | 
|---|
 | 74 | 
 | 
|---|
| [9ee38b] | 75 | Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [0c9cc3] | 76 |   return Action::success;
 | 
|---|
| [97ebf8] | 77 | }
 | 
|---|
 | 78 | 
 | 
|---|
| [9ee38b] | 79 | bool AnalysisMolecularVolumeAction::canUndo() {
 | 
|---|
| [0c9cc3] | 80 |   return true;
 | 
|---|
| [97ebf8] | 81 | }
 | 
|---|
 | 82 | 
 | 
|---|
| [9ee38b] | 83 | bool AnalysisMolecularVolumeAction::shouldUndo() {
 | 
|---|
| [0c9cc3] | 84 |   return true;
 | 
|---|
| [97ebf8] | 85 | }
 | 
|---|
| [0b2ce9] | 86 | /** =========== end of function ====================== */
 | 
|---|