Changeset 677e13 for src/Actions/FragmentationAction
- Timestamp:
- Jul 28, 2010, 9:21:14 AM (15 years ago)
- Branches:
- 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, Candidate_v1.7.0, 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
- Children:
- 400170, a7b777c
- Parents:
- 7067bd6 (diff), 0430e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Actions/FragmentationAction
- Files:
-
- 6 edited
-
DepthFirstSearchAction.cpp (modified) (3 diffs)
-
DepthFirstSearchAction.hpp (modified) (2 diffs)
-
FragmentationAction.cpp (modified) (5 diffs)
-
FragmentationAction.hpp (modified) (2 diffs)
-
SubgraphDissectionAction.cpp (modified) (3 diffs)
-
SubgraphDissectionAction.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "bondgraph.hpp" … … 27 28 #include "UIElements/UIFactory.hpp" 28 29 #include "UIElements/Dialog.hpp" 29 #include " Actions/MapOfActions.hpp"30 #include "UIElements/ValueStorage.hpp" 30 31 31 32 const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search"; … … 38 39 {} 39 40 41 void FragmentationDepthFirstSearch(double distance) { 42 ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance); 43 ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationDepthFirstSearchAction::createDialog() { 47 Dialog *dialog = UIFactory::getInstance().makeDialog(); 48 49 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 51 return dialog; 52 } 53 40 54 Action::state_ptr FragmentationDepthFirstSearchAction::performCall() { 41 Dialog *dialog = UIFactory::getInstance().makeDialog();42 55 double distance; 43 56 44 dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));57 ValueStorage::getInstance().queryCurrentValue(NAME, distance); 45 58 46 if(dialog->display()) { 47 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 48 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 49 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 50 int *MinimumRingSize = new int[mol->getAtomCount()]; 51 atom **ListOfAtoms = NULL; 52 class StackClass<bond *> *BackEdgeStack = NULL; 53 class StackClass<bond *> *LocalBackEdgeStack = NULL; 54 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 55 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 56 if (Subgraphs != NULL) { 57 int FragmentCounter = 0; 58 while (Subgraphs->next != NULL) { 59 Subgraphs = Subgraphs->next; 60 ListOfAtoms = NULL; 61 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 62 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 63 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 64 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 65 delete(LocalBackEdgeStack); 66 delete(Subgraphs->previous); 67 delete[](ListOfAtoms); // and here we remove it 68 FragmentCounter++; 69 } 70 delete(Subgraphs); 59 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 60 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 61 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 62 int *MinimumRingSize = new int[mol->getAtomCount()]; 63 atom **ListOfAtoms = NULL; 64 class StackClass<bond *> *BackEdgeStack = NULL; 65 class StackClass<bond *> *LocalBackEdgeStack = NULL; 66 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 67 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 68 if (Subgraphs != NULL) { 69 int FragmentCounter = 0; 70 while (Subgraphs->next != NULL) { 71 Subgraphs = Subgraphs->next; 72 ListOfAtoms = NULL; 73 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 74 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 75 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 76 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 77 delete(LocalBackEdgeStack); 78 delete(Subgraphs->previous); 79 delete[](ListOfAtoms); // and here we remove it 80 FragmentCounter++; 71 81 } 72 delete(BackEdgeStack); 73 delete[](MinimumRingSize); 74 delete dialog; 75 return Action::success; 76 } else { 77 delete dialog; 78 return Action::failure; 82 delete(Subgraphs); 79 83 } 84 delete(BackEdgeStack); 85 delete[](MinimumRingSize); 86 return Action::success; 80 87 } 81 88 82 89 Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) { 83 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 84 85 return Action::failure; 86 // string newName = state->mol->getName(); 87 // state->mol->setName(state->lastName); 88 // 89 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 90 return Action::success; 90 91 } 91 92 92 93 Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){ 93 return Action:: failure;94 return Action::success; 94 95 } 95 96 96 97 bool FragmentationDepthFirstSearchAction::canUndo() { 97 return false;98 return true; 98 99 } 99 100 100 101 bool FragmentationDepthFirstSearchAction::shouldUndo() { 101 return false;102 return true; 102 103 } 103 104 -
src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationDepthFirstSearch(double distance); 14 13 15 class FragmentationDepthFirstSearchAction : public Action { 16 friend void FragmentationDepthFirstSearch(double distance); 17 14 18 public: 15 19 FragmentationDepthFirstSearchAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/FragmentationAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "bondgraph.hpp" … … 25 26 #include "UIElements/UIFactory.hpp" 26 27 #include "UIElements/Dialog.hpp" 27 #include " Actions/MapOfActions.hpp"28 #include "UIElements/ValueStorage.hpp" 28 29 29 30 const char FragmentationFragmentationAction::NAME[] = "fragment-mol"; … … 36 37 {} 37 38 39 void FragmentationFragmentation(std::string &path, double distance, int order) { 40 ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path); 41 ValueStorage::getInstance().setCurrentValue("distance", distance); 42 ValueStorage::getInstance().setCurrentValue("order", order); 43 ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationFragmentationAction::createDialog() { 47 Dialog *dialog = UIFactory::getInstance().makeDialog(); 48 49 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance")); 51 dialog->queryInt("order", ValueStorage::getInstance().getDescription("order")); 52 53 return dialog; 54 } 55 38 56 Action::state_ptr FragmentationFragmentationAction::performCall() { 39 Dialog *dialog = UIFactory::getInstance().makeDialog();40 57 clock_t start,end; 41 58 molecule *mol = NULL; … … 46 63 int ExitFlag = 0; 47 64 48 cout << "pre-dialog"<< endl; 49 dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME)); 50 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 51 dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance")); 52 dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order")); 65 ValueStorage::getInstance().queryCurrentValue(NAME, path); 66 ValueStorage::getInstance().queryCurrentValue("distance", distance); 67 ValueStorage::getInstance().queryCurrentValue("order", order); 53 68 54 if(dialog->display()) {55 cout << "POST-dialog"<< endl;69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 56 71 ASSERT(mol != NULL, "No molecule has been picked for fragmentation."); 57 72 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl); … … 66 81 end = clock(); 67 82 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 68 delete dialog;69 return Action::success;70 } else {71 delete dialog;72 return Action::failure;73 83 } 84 return Action::success; 74 85 } 75 86 76 87 Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) { 77 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 78 79 return Action::failure; 80 // string newName = state->mol->getName(); 81 // state->mol->setName(state->lastName); 82 // 83 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 88 return Action::success; 84 89 } 85 90 86 91 Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){ 87 return Action:: failure;92 return Action::success; 88 93 } 89 94 90 95 bool FragmentationFragmentationAction::canUndo() { 91 return false;96 return true; 92 97 } 93 98 94 99 bool FragmentationFragmentationAction::shouldUndo() { 95 return false;100 return true; 96 101 } 97 102 -
src/Actions/FragmentationAction/FragmentationAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationFragmentation(std::string &path, double distance, int order); 14 13 15 class FragmentationFragmentationAction : public Action { 16 friend void FragmentationFragmentation(std::string &path, double distance, int order); 17 14 18 public: 15 19 FragmentationFragmentationAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "config.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect"; … … 35 36 {} 36 37 37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 38 void FragmentationSubgraphDissection() { 39 ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* FragmentationSubgraphDissectionAction::createDialog() { 38 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 44 40 45 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 41 46 42 if(dialog->display()) { 43 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 44 // @TODO rather do the dissection afterwards 45 MoleculeListClass *molecules = World::getInstance().getMolecules(); 46 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 47 delete dialog; 48 return Action::success; 49 } else { 50 delete dialog; 51 return Action::failure; 52 } 47 return dialog; 48 } 49 50 51 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 52 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 53 // @TODO rather do the dissection afterwards 54 MoleculeListClass *molecules = World::getInstance().getMolecules(); 55 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 56 return Action::success; 53 57 } 54 58 -
src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationSubgraphDissection(); 14 13 15 class FragmentationSubgraphDissectionAction : public Action { 16 friend void FragmentationSubgraphDissection(); 17 14 18 public: 15 19 FragmentationSubgraphDissectionAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.
