source: src/Actions/TesselationAction/ConvexEnvelopeAction.cpp@ 88b400

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 88b400 was 88b400, checked in by Frederik Heber <heber@…>, 14 years ago

converted #define's to enums, consts and typedefs [Meyers, "Effective C++", item 1].

basic changes:

  • #define bla 1.3 -> const double bla = 1.3
  • #define bla "test" -> const char * const bla = "test
  • use class specific constants! (HULLEPSILON)

const int Class::bla = 1.3; (in .cpp)
static const int bla; (in .hpp inside class private section)

  • "enum hack": #define bla 5 -> enum { bla = 5 };
    • if const int bla=5; impossible
    • e.g. necessary if constant is used in array declaration (int blabla[bla];)

details:

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