source: src/Actions/TesselationAction/NonConvexEnvelopeAction.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@…>, 15 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.1 KB
Line 
1/*
2 * NonConvexEnvelopeAction.cpp
3 *
4 * Created on: May 10, 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/NonConvexEnvelopeAction.hpp"
16#include "Actions/ActionRegistry.hpp"
17#include "boundary.hpp"
18#include "linkedcell.hpp"
19#include "Helpers/Log.hpp"
20#include "molecule.hpp"
21#include "tesselation.hpp"
22#include "Helpers/Verbose.hpp"
23#include "World.hpp"
24
25#include <iostream>
26#include <string>
27
28using namespace std;
29
30#include "UIElements/UIFactory.hpp"
31#include "UIElements/Dialog.hpp"
32#include "Actions/ValueStorage.hpp"
33
34/****** TesselationNonConvexEnvelopeAction *****/
35
36// memento to remember the state when undoing
37
38//class TesselationNonConvexEnvelopeState : public ActionState {
39//public:
40// TesselationNonConvexEnvelopeState(molecule* _mol,std::string _lastName) :
41// mol(_mol),
42// lastName(_lastName)
43// {}
44// molecule* mol;
45// std::string lastName;
46//};
47
48const char TesselationNonConvexEnvelopeAction::NAME[] = "nonconvex-envelope";
49
50TesselationNonConvexEnvelopeAction::TesselationNonConvexEnvelopeAction() :
51 Action(NAME)
52{}
53
54TesselationNonConvexEnvelopeAction::~TesselationNonConvexEnvelopeAction()
55{}
56
57void TesselationNonConvexEnvelope(double radius, std::string &filename) {
58 ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius);
59 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename);
60 ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
61};
62
63Dialog* TesselationNonConvexEnvelopeAction::fillDialog(Dialog *dialog) {
64 ASSERT(dialog,"No Dialog given when filling action dialog");
65
66 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
67 dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
68
69 return dialog;
70}
71
72Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
73 string filename;
74 molecule * Boundary = NULL;
75 double SphereRadius = 0;
76 bool Success = false;
77 clock_t start,end;
78
79 ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius);
80 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename);
81
82 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
83 Boundary = iter->second;
84 class Tesselation *T = NULL;
85 const LinkedCell *LCList = NULL;
86 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of molecule." << Boundary->getId() << endl);
87 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << SphereRadius << " and storing tecplot data in " << filename << "." << endl);
88 DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary->getAtomCount() << " atoms." << endl);
89 start = clock();
90 LCList = new LinkedCell(Boundary, SphereRadius*2.);
91 Success = FindNonConvexBorder(Boundary, T, LCList, SphereRadius, filename.c_str());
92 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
93 end = clock();
94 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
95 delete(LCList);
96 delete(T);
97 }
98 if (Success)
99 return Action::success;
100 else
101 return Action::failure;
102}
103
104Action::state_ptr TesselationNonConvexEnvelopeAction::performUndo(Action::state_ptr _state) {
105// TesselationNonConvexEnvelopeState *state = assert_cast<TesselationNonConvexEnvelopeState*>(_state.get());
106
107// string newName = state->mol->getName();
108// state->mol->setName(state->lastName);
109
110 return Action::failure;
111}
112
113Action::state_ptr TesselationNonConvexEnvelopeAction::performRedo(Action::state_ptr _state){
114 // Undo and redo have to do the same for this action
115 return performUndo(_state);
116}
117
118bool TesselationNonConvexEnvelopeAction::canUndo() {
119 return false;
120}
121
122bool TesselationNonConvexEnvelopeAction::shouldUndo() {
123 return false;
124}
125
126const string TesselationNonConvexEnvelopeAction::getName() {
127 return NAME;
128}
Note: See TracBrowser for help on using the repository browser.