source: src/Actions/TesselationAction/ConvexEnvelopeAction.cpp@ bf3817

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since bf3817 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 * ConvexEnvelopeAction.cpp
3 *
4 * Created on: May 12, 2010
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
16#include "Actions/ActionRegistry.hpp"
17#include "boundary.hpp"
18#include "config.hpp"
19#include "linkedcell.hpp"
20#include "Helpers/Log.hpp"
21#include "molecule.hpp"
22#include "tesselation.hpp"
23#include "Helpers/Verbose.hpp"
24#include "World.hpp"
25
26#include <iostream>
27#include <string>
28
29using namespace std;
30
31#include "UIElements/UIFactory.hpp"
32#include "UIElements/Dialog.hpp"
33#include "Actions/ValueStorage.hpp"
34
35/****** TesselationConvexEnvelopeAction *****/
36
37// memento to remember the state when undoing
38
39//class TesselationConvexEnvelopeState : public ActionState {
40//public:
41// TesselationConvexEnvelopeState(molecule* _mol,std::string _lastName) :
42// mol(_mol),
43// lastName(_lastName)
44// {}
45// molecule* mol;
46// std::string lastName;
47//};
48
49const char TesselationConvexEnvelopeAction::NAME[] = "convex-envelope";
50
51TesselationConvexEnvelopeAction::TesselationConvexEnvelopeAction() :
52 Action(NAME)
53{}
54
55TesselationConvexEnvelopeAction::~TesselationConvexEnvelopeAction()
56{}
57
58void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) {
59 ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex);
60 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex);
61 ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
62};
63
64Dialog* TesselationConvexEnvelopeAction::fillDialog(Dialog *dialog) {
65 ASSERT(dialog,"No Dialog given when filling action dialog");
66
67 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
68 dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file"));
69 dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
70
71 return dialog;
72}
73
74Action::state_ptr TesselationConvexEnvelopeAction::performCall() {
75 string filenameConvex;
76 string filenameNonConvex;
77 molecule * mol = NULL;
78 bool Success = true;
79 config *configuration = World::getInstance().getConfig();
80
81 ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex);
82 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex);
83
84 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
85 mol = iter->second;
86 class Tesselation *TesselStruct = NULL;
87 const LinkedCell *LCList = NULL;
88 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
89 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << filenameConvex << "." << endl);
90 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl);
91 LCList = new LinkedCell(mol, 100.);
92 //Boundaries *BoundaryPoints = NULL;
93 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
94 // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests
95 FindNonConvexBorder(mol, TesselStruct, LCList, 50., filenameNonConvex.c_str());
96 //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
97 const double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, filenameConvex.c_str());
98 const double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
99 DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
100 DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration->GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
101 delete(TesselStruct);
102 delete(LCList);
103 }
104 if (Success)
105 return Action::success;
106 else
107 return Action::failure;
108}
109
110Action::state_ptr TesselationConvexEnvelopeAction::performUndo(Action::state_ptr _state) {
111// TesselationConvexEnvelopeState *state = assert_cast<TesselationConvexEnvelopeState*>(_state.get());
112
113// string newName = state->mol->getName();
114// state->mol->setName(state->lastName);
115
116 return Action::failure;
117}
118
119Action::state_ptr TesselationConvexEnvelopeAction::performRedo(Action::state_ptr _state){
120 // Undo and redo have to do the same for this action
121 return performUndo(_state);
122}
123
124bool TesselationConvexEnvelopeAction::canUndo() {
125 return false;
126}
127
128bool TesselationConvexEnvelopeAction::shouldUndo() {
129 return false;
130}
131
132const string TesselationConvexEnvelopeAction::getName() {
133 return NAME;
134}
Note: See TracBrowser for help on using the repository browser.