- Timestamp:
- Dec 5, 2010, 12:20:07 AM (14 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, 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:
- 001f8a, ca03c7
- Parents:
- 4fbca9c
- git-author:
- Frederik Heber <heber@…> (12/04/10 21:23:07)
- git-committer:
- Frederik Heber <heber@…> (12/05/10 00:20:07)
- Location:
- src
- Files:
-
- 1 added
- 1 deleted
- 7 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Makefile.am
r4fbca9c rcabb46 96 96 MoleculeAction/FillVoidWithMoleculeAction.cpp \ 97 97 MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \ 98 MoleculeAction/LoadAction.cpp \ 98 99 MoleculeAction/RotateAroundSelfByAngleAction.cpp \ 99 100 MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \ 101 MoleculeAction/SaveAction.cpp \ 100 102 MoleculeAction/SaveAdjacencyAction.cpp \ 101 103 MoleculeAction/SaveBondsAction.cpp \ … … 110 112 MoleculeAction/FillVoidWithMoleculeAction.hpp \ 111 113 MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \ 114 MoleculeAction/LoadAction.cpp \ 112 115 MoleculeAction/RotateAroundSelfByAngleAction.hpp \ 113 116 MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \ 117 MoleculeAction/SaveAction.hpp \ 114 118 MoleculeAction/SaveAdjacencyAction.hpp \ 115 119 MoleculeAction/SaveBondsAction.hpp \ … … 118 122 MoleculeAction/VerletIntegrationAction.hpp 119 123 120 PARSERACTIONSOURCE = \121 ParserAction/LoadXyzAction.cpp \122 ParserAction/SaveXyzAction.cpp123 PARSERACTIONHEADER = \124 ParserAction/LoadXyzAction.hpp \125 ParserAction/SaveXyzAction.hpp126 127 124 SELECTIONACTIONSOURCE = \ 128 125 SelectionAction/AllAtomsAction.cpp \ -
src/Actions/MoleculeAction/LoadAction.def
r4fbca9c rcabb46 1 1 /* 2 * Load XyzAction.def2 * LoadAction.def 3 3 * 4 4 * Created on: Aug 26, 2010 … … 13 13 // "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value 14 14 #define paramtypes (boost::filesystem::path) 15 #define paramtokens (" parse-xyz")16 #define paramdescriptions ("name of xyzfile")15 #define paramtokens ("load") 16 #define paramdescriptions ("name of molecule file") 17 17 #undef paramdefaults 18 18 #define paramreferences (filename) … … 22 22 23 23 // some defines for all the names, you may use ACTION, STATE and PARAMS 24 #define CATEGORY Parser25 #define MENUNAME " parser"24 #define CATEGORY Molecule 25 #define MENUNAME "molecule" 26 26 #define MENUPOSITION 1 27 #define ACTIONNAME Load Xyz28 #define TOKEN " parse-xyz"27 #define ACTIONNAME Load 28 #define TOKEN "load" 29 29 30 30 31 31 // finally the information stored in the ActionTrait specialization 32 #define DESCRIPTION "parse xyz file into World"33 #define SHORTFORM " p"32 #define DESCRIPTION "parse file with molecule into World" 33 #define SHORTFORM "l" -
src/Actions/MoleculeAction/LoadAction.hpp
r4fbca9c rcabb46 11 11 #include "Actions/Action.hpp" 12 12 13 #include "Load XyzAction.def"13 #include "LoadAction.def" 14 14 #include "Action_impl_header.hpp" 15 15 -
src/Actions/MoleculeAction/SaveAction.cpp
r4fbca9c rcabb46 7 7 8 8 /* 9 * Save XyzAction.cpp9 * SaveAction.cpp 10 10 * 11 11 * Created on: May 8, 2010 … … 22 22 #include "Helpers/Log.hpp" 23 23 #include "Helpers/Verbose.hpp" 24 #include "Parser/ XyzParser.hpp"24 #include "Parser/FormatParserStorage.hpp" 25 25 26 26 #include <iostream> 27 27 #include <string> 28 28 29 #include <boost/filesystem/fstream.hpp> 30 29 31 using namespace std; 30 32 31 #include " Actions/ParserAction/SaveXyzAction.hpp"33 #include "SaveAction.hpp" 32 34 33 35 // and construct the stuff 34 #include "Save XyzAction.def"36 #include "SaveAction.def" 35 37 #include "Action_impl_pre.hpp" 36 38 /** =========== define the function ====================== */ 37 Action::state_ptr ParserSaveXyzAction::performCall() { 38 XyzParser parser; 39 39 Action::state_ptr MoleculeSaveAction::performCall() { 40 40 // obtain information 41 41 getParametersfromValueStorage(); 42 42 43 DoLog(1) && (Log() << Verbose(1) << "Storing xyz file " << params.filename << "." << endl); 44 // store xyz file 45 ofstream output; 46 output.open(params.filename.string().c_str()); 43 DoLog(1) && (Log() << Verbose(1) << "Storing world to file " << params.filename << "." << endl); 44 45 // extract suffix 46 std::string FilenameSuffix; 47 std::string FilenamePrefix; 48 if (params.filename.has_filename()) { 49 // get suffix 50 FilenameSuffix = params.filename.extension().substr(1); // remove the prefixed "." 51 FilenamePrefix = params.filename.stem(); 52 } else { 53 DoeLog(1) && (eLog() << Verbose(1) << "Output file does not have a suffix, cannot recognize format." << endl); 54 return Action::failure; 55 } 56 57 // store file 58 // parse the file 59 boost::filesystem::ofstream output; 60 output.open(params.filename); 47 61 if (!output.fail()) { 48 parser.save(&output);62 FormatParserStorage::getInstance().put(output, FilenameSuffix); 49 63 } else { 50 64 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << params.filename << "." << endl); 51 65 } 52 66 output.close(); 67 53 68 return Action::failure; 54 69 } 55 70 56 Action::state_ptr ParserSaveXyzAction::performUndo(Action::state_ptr _state) {71 Action::state_ptr MoleculeSaveAction::performUndo(Action::state_ptr _state) { 57 72 // ParserSaveXyzState *state = assert_cast<ParserSaveXyzState*>(_state.get()); 58 73 … … 64 79 } 65 80 66 Action::state_ptr ParserSaveXyzAction::performRedo(Action::state_ptr _state){81 Action::state_ptr MoleculeSaveAction::performRedo(Action::state_ptr _state){ 67 82 return Action::failure; 68 83 // // Undo and redo have to do the same for this action … … 70 85 } 71 86 72 bool ParserSaveXyzAction::canUndo() {87 bool MoleculeSaveAction::canUndo() { 73 88 return false; 74 89 } 75 90 76 bool ParserSaveXyzAction::shouldUndo() {91 bool MoleculeSaveAction::shouldUndo() { 77 92 return false; 78 93 } -
src/Actions/MoleculeAction/SaveAction.def
r4fbca9c rcabb46 1 1 /* 2 * Save XyzAction.def2 * SaveAction.def 3 3 * 4 4 * Created on: Aug 26, 2010 … … 13 13 // "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value 14 14 #define paramtypes (boost::filesystem::path) 15 #define paramtokens ("s tore-xyz")16 #define paramdescriptions ("file name of xyzfile")15 #define paramtokens ("save") 16 #define paramdescriptions ("file name of file") 17 17 #undef paramdefaults 18 18 #define paramreferences (filename) … … 22 22 23 23 // some defines for all the names, you may use ACTION, STATE and PARAMS 24 #define CATEGORY Parser25 #define MENUNAME " parser"24 #define CATEGORY Molecule 25 #define MENUNAME "molecule" 26 26 #define MENUPOSITION 2 27 #define ACTIONNAME Save Xyz28 #define TOKEN "s tore-xyz"27 #define ACTIONNAME Save 28 #define TOKEN "save" 29 29 30 30 31 31 // finally the information stored in the ActionTrait specialization 32 #define DESCRIPTION "save world as xyz file"33 # undef SHORTFORM32 #define DESCRIPTION "save world as file of certain type" 33 #define SHORTFORM "s" -
src/Actions/MoleculeAction/SaveAction.hpp
r4fbca9c rcabb46 11 11 #include "Actions/Action.hpp" 12 12 13 #include "Save XyzAction.def"13 #include "SaveAction.def" 14 14 #include "Action_impl_header.hpp" 15 15 -
src/Actions/WorldAction/InputAction.cpp
r4fbca9c rcabb46 23 23 #include "molecule.hpp" 24 24 #include "Parser/FormatParserStorage.hpp" 25 #include "Parser/PcpParser.hpp"26 25 #include "Helpers/Verbose.hpp" 27 26 #include "World.hpp" -
src/Actions/WorldAction/ScaleBoxAction.def
r4fbca9c rcabb46 32 32 // finally the information stored in the ActionTrait specialization 33 33 #define DESCRIPTION "scale box and atomic positions inside" 34 # define SHORTFORM "s"34 #undef SHORTFORM -
src/Parser/FormatParserStorage.cpp
r4fbca9c rcabb46 243 243 } 244 244 245 246 /** Stores world in an ostream depending on its suffix 247 * \param &output output stream 248 * \param suffix 249 * \return true - storing ok, false - suffix unknown 250 */ 251 bool FormatParserStorage::put(std::ostream &output, std::string suffix) 252 { 253 if (suffix == ParserSuffixes[mpqc]) { 254 getMpqc().save(&output); 255 } else if (suffix == ParserSuffixes[pcp]) { 256 getPcp().save(&output); 257 } else if (suffix == ParserSuffixes[pdb]) { 258 getPdb().save(&output); 259 } else if (suffix == ParserSuffixes[tremolo]) { 260 getTremolo().save(&output); 261 } else if (suffix == ParserSuffixes[xyz]) { 262 getXyz().save(&output); 263 } else { 264 DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::put()." << endl); 265 return false; 266 } 267 return true; 268 } 269 245 270 /** Returns reference to the output MpqcParser, adds if not present. 246 271 * \return reference to the output MpqcParser -
src/Parser/FormatParserStorage.hpp
r4fbca9c rcabb46 46 46 47 47 bool get(std::istream &input, std::string suffix); 48 bool put(std::ostream &output, std::string suffix); 48 49 MpqcParser &getMpqc(); 49 50 PcpParser &getPcp(); -
src/Parser/XyzParser.cpp
r4fbca9c rcabb46 84 84 void XyzParser::save(ostream* file) { 85 85 DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl); 86 if (comment == "") {86 //if (comment == "") { 87 87 time_t now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 88 88 comment = "Created by molecuilder on "; … … 94 94 else 95 95 comment += time; 96 }96 //} 97 97 *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl; 98 98 -
src/unittests/ParserCommonUnitTest.cpp
r4fbca9c rcabb46 187 187 input << waterXyz; 188 188 testParser->load(&input); 189 input.clear(); 189 190 190 191 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 191 192 192 string newWaterXyz = ""; 193 stringstream output; 194 testParser->save(&output); 195 newWaterXyz = output.str(); 196 197 CPPUNIT_ASSERT(waterXyz == newWaterXyz); 193 // store and parse in again 194 stringstream output; 195 testParser->save(&output); 196 input << output.str(); 197 testParser->load(&input); 198 199 // now twice as many 200 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); 201 202 // check every atom 203 World::AtomComposite atoms = World::getInstance().getAllAtoms(); 204 World::AtomComposite::const_iterator firstiter = atoms.begin(); 205 World::AtomComposite::const_iterator seconditer = atoms.begin(); 206 for (size_t i=0;i<3;i++) 207 ++seconditer; 208 for (; 209 seconditer != atoms.end(); 210 ++firstiter,++seconditer) { 211 // check position and type (only stuff xyz stores) 212 CPPUNIT_ASSERT_EQUAL((*firstiter)->getPosition(),(*seconditer)->getPosition()); 213 CPPUNIT_ASSERT_EQUAL((*firstiter)->getType(),(*seconditer)->getType()); 214 } 198 215 } 199 216
Note:
See TracChangeset
for help on using the changeset viewer.