Ignore:
Timestamp:
Dec 5, 2010, 12:20:07 AM (14 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Extended LoadXyz and SaveXyz to any format.

Testchanges:

  • copied all from Simple_configuration/2/pre to ./post.
  • changes to test.conf:

MaxPsiStep (if 0 given, then 3 is set).
MaxMinGapStopStep (if 0 given, then 1 is set).
InitMaxMinGapStopStep (if 0 given, then 1 is set).

  • changes to test.pdb:

segName is tes (from _tes_t.pdb) not non.
Obtaining molecule names from pdb file's segName is not implemented yet.

  • ParserCommonUnitTest::rewriteAnXyzTest(), we don't check for string equality but parse the output stream again and check whether first and second half of all atoms are equal with respect to position and element.
  • all regression test that diff an xyz file now use -I '.*Created by....*'
  • changed regression tests with respect to changed short forms.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/SaveAction.cpp

    r4fbca9c rcabb46  
    77
    88/*
    9  * SaveXyzAction.cpp
     9 * SaveAction.cpp
    1010 *
    1111 *  Created on: May 8, 2010
     
    2222#include "Helpers/Log.hpp"
    2323#include "Helpers/Verbose.hpp"
    24 #include "Parser/XyzParser.hpp"
     24#include "Parser/FormatParserStorage.hpp"
    2525
    2626#include <iostream>
    2727#include <string>
    2828
     29#include <boost/filesystem/fstream.hpp>
     30
    2931using namespace std;
    3032
    31 #include "Actions/ParserAction/SaveXyzAction.hpp"
     33#include "SaveAction.hpp"
    3234
    3335// and construct the stuff
    34 #include "SaveXyzAction.def"
     36#include "SaveAction.def"
    3537#include "Action_impl_pre.hpp"
    3638/** =========== define the function ====================== */
    37 Action::state_ptr ParserSaveXyzAction::performCall() {
    38   XyzParser parser;
    39 
     39Action::state_ptr MoleculeSaveAction::performCall() {
    4040  // obtain information
    4141  getParametersfromValueStorage();
    4242
    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);
    4761  if (!output.fail()) {
    48     parser.save(&output);
     62    FormatParserStorage::getInstance().put(output, FilenameSuffix);
    4963  } else {
    5064    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << params.filename << "." << endl);
    5165  }
    5266  output.close();
     67
    5368  return Action::failure;
    5469}
    5570
    56 Action::state_ptr ParserSaveXyzAction::performUndo(Action::state_ptr _state) {
     71Action::state_ptr MoleculeSaveAction::performUndo(Action::state_ptr _state) {
    5772//  ParserSaveXyzState *state = assert_cast<ParserSaveXyzState*>(_state.get());
    5873
     
    6479}
    6580
    66 Action::state_ptr ParserSaveXyzAction::performRedo(Action::state_ptr _state){
     81Action::state_ptr MoleculeSaveAction::performRedo(Action::state_ptr _state){
    6782  return Action::failure;
    6883//  // Undo and redo have to do the same for this action
     
    7085}
    7186
    72 bool ParserSaveXyzAction::canUndo() {
     87bool MoleculeSaveAction::canUndo() {
    7388  return false;
    7489}
    7590
    76 bool ParserSaveXyzAction::shouldUndo() {
     91bool MoleculeSaveAction::shouldUndo() {
    7792  return false;
    7893}
Note: See TracChangeset for help on using the changeset viewer.