Changes in / [8d6d31:1bab08]
- Files:
-
- 1 added
- 18 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/RotateAroundOriginByAngleAction.cpp
r8d6d31 r1bab08 52 52 {} 53 53 54 void MoleculeRotateAroundOriginByAngle( const Vector &Axis,double angle) {54 void MoleculeRotateAroundOriginByAngle(double angle) { 55 55 ValueStorage::getInstance().setCurrentValue(MoleculeRotateAroundOriginByAngleAction::NAME, angle); 56 ValueStorage::getInstance().setCurrentValue("position", Axis);57 56 ActionRegistry::getInstance().getActionByName(MoleculeRotateAroundOriginByAngleAction::NAME)->call(Action::NonInteractive); 58 57 }; … … 83 82 alpha *= M_PI/180.; 84 83 85 // Creation Line that is the rotation axis86 Line RotationAxis(Vector(0.,0.,0.), Axis);87 88 84 DoLog(0) && (Log() << Verbose(0) << "Rotate around origin by " << alpha << " radian, axis from origin to " << Axis << "." << endl); 89 85 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 90 86 mol = iter->second; 91 87 88 // Creation Line that is the rotation axis 89 Line RotationAxis(Vector(0.,0.,0.), Axis); 90 92 91 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 93 92 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), alpha); 94 93 } 94 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 95 95 } 96 DoLog(0) && (Log() << Verbose(0) << "done." << endl);97 96 return Action::state_ptr(new MoleculeRotateAroundOriginByAngleState(World::getInstance().getSelectedMolecules(), Axis, alpha)); 98 97 } -
src/Actions/MoleculeAction/RotateAroundOriginByAngleAction.hpp
r8d6d31 r1bab08 17 17 18 18 class MoleculeRotateAroundOriginByAngleAction : public Action { 19 friend void MoleculeRotateAroundOriginByAngle( const Vector &Axis,double angle);19 friend void MoleculeRotateAroundOriginByAngle(double angle); 20 20 21 21 public: -
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
r8d6d31 r1bab08 34 34 class MoleculeRotateAroundSelfByAngleState : public ActionState { 35 35 public: 36 MoleculeRotateAroundSelfByAngleState(molecule * const _mol, const Vector &_Axis, constdouble _alpha) :36 MoleculeRotateAroundSelfByAngleState(molecule * const _mol, const double _alpha) : 37 37 mol(_mol), 38 Axis(_Axis),39 38 alpha(_alpha) 40 39 {} 41 40 molecule* const mol; 42 Vector Axis;43 41 double alpha; 44 42 }; … … 53 51 {} 54 52 55 void MoleculeRotateAroundSelfByAngle( const Vector &Axis, constdouble angle) {53 void MoleculeRotateAroundSelfByAngle(double angle) { 56 54 ValueStorage::getInstance().setCurrentValue(MoleculeRotateAroundSelfByAngleAction::NAME, angle); 57 ValueStorage::getInstance().setCurrentValue("position", Axis);58 55 ActionRegistry::getInstance().getActionByName(MoleculeRotateAroundSelfByAngleAction::NAME)->call(Action::NonInteractive); 59 56 }; … … 63 60 64 61 dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME)); 65 dialog->queryVector("position", false, MapOfActions::getInstance().getDescription(NAME));66 62 67 63 return dialog; … … 71 67 molecule *mol = NULL; 72 68 double alpha = 0.; 73 Vector Axis;74 69 75 // obtain angle a nd axis around which rotate70 // obtain angle around which rotate 76 71 ValueStorage::getInstance().queryCurrentValue(NAME, alpha); 77 ValueStorage::getInstance().queryCurrentValue("position", Axis);78 72 79 73 // check whether a single atom and molecule is selected 80 if (World::getInstance().getSelectedMolecules().size() != 1) 81 return Action::failure; 82 mol = World::getInstance().beginMoleculeSelection()->second; 83 84 // check whether Axis is valid 85 if (Axis.IsZero()) 74 if ((World::getInstance().getSelectedAtoms().size() != 1) || (World::getInstance().getSelectedMolecules().size() != 1)) 86 75 return Action::failure; 87 76 88 // convert from degrees to radian89 alpha *= M_PI/180.;77 DoLog(0) && (Log() << Verbose(0) << "Rotate around self by " << alpha << "." << endl); 78 mol = World::getInstance().beginMoleculeSelection()->second; 90 79 91 80 // Creation Line that is the rotation axis 92 81 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 93 Line RotationAxis(*CenterOfGravity, Axis);82 Line RotationAxis(*CenterOfGravity, (World::getInstance().beginAtomSelection()->second)->x); 94 83 delete(CenterOfGravity); 95 DoLog(0) && (Log() << Verbose(0) << "Rotate around self by " << alpha << " along " << RotationAxis << "." << endl);96 84 97 85 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { … … 100 88 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 101 89 102 return Action::state_ptr(new MoleculeRotateAroundSelfByAngleState(mol, Axis,alpha));90 return Action::state_ptr(new MoleculeRotateAroundSelfByAngleState(mol, alpha)); 103 91 } 104 92 … … 107 95 108 96 Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity(); 109 Line RotationAxis(*CenterOfGravity, state->Axis);97 Line RotationAxis(*CenterOfGravity, (World::getInstance().beginAtomSelection()->second)->x); 110 98 delete(CenterOfGravity); 111 99 … … 121 109 122 110 Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity(); 123 Line RotationAxis(*CenterOfGravity, state->Axis);111 Line RotationAxis(*CenterOfGravity, (World::getInstance().beginAtomSelection()->second)->x); 124 112 delete(CenterOfGravity); 125 113 -
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp
r8d6d31 r1bab08 17 17 18 18 class MoleculeRotateAroundSelfByAngleAction : public Action { 19 friend void MoleculeRotateAroundSelfByAngle( const Vector &Axis, constdouble angle);19 friend void MoleculeRotateAroundSelfByAngle(double angle); 20 20 21 21 public: -
src/LinearAlgebra/Line.cpp
r8d6d31 r1bab08 241 241 return Line(x1,x1-x2); 242 242 } 243 244 ostream& operator<<(ostream& ost, const Line& m)245 {246 const Vector origin = m.getOrigin();247 const Vector direction = m.getDirection();248 ost << "(";249 for (int i=0;i<NDIM;i++) {250 ost << origin[i];251 if (i != 2)252 ost << ",";253 }254 ost << ") -> (";255 for (int i=0;i<NDIM;i++) {256 ost << direction[i];257 if (i != 2)258 ost << ",";259 }260 ost << ")";261 return ost;262 };263 -
src/LinearAlgebra/Line.hpp
r8d6d31 r1bab08 11 11 #include "LinearAlgebra/Space.hpp" 12 12 13 #include <iosfwd>14 13 #include <memory> 15 14 #include <vector> … … 46 45 }; 47 46 48 std::ostream & operator << (std::ostream& ost, const Line &m);49 50 47 /** 51 48 * Named constructor to make a line through two points -
tests/regression/testsuite-molecules.at
r8d6d31 r1bab08 61 61 62 62 # 8. Rotate to PAS 63 AT_SETUP([Molecules - Rotate to PAS])63 AT_SETUP([Molecules - BROKEN: Rotate to PAS]) 64 64 AT_KEYWORDS([Molecules]) 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test-*.xyz .], 0) 66 AT_CHECK([../../molecuilder -i test-rotated-z90.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 67 AT_CHECK([file="test-rotated-z90.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 68 AT_CHECK([../../molecuilder -i test-rotated-z180.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 69 AT_CHECK([file="test-rotated-z180.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 70 AT_CHECK([../../molecuilder -i test-rotated-z360.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 71 AT_CHECK([file="test-rotated-z360.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 72 AT_CHECK([../../molecuilder -i test-rotated-xYz20.xyz -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 73 AT_CHECK([file="test-rotated-xYz20.xyz"; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0) 66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m "0,0,1"], 0, [stdout], [stderr]) 67 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 74 68 AT_CLEANUP 75 69 76 # 9. Rotate around origin77 AT_SETUP([Molecules - Rotate around origin])78 AT_KEYWORDS([Molecules])79 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)80 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 90. --position "0,0,1"], 0, [stdout], [stderr])81 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z90.xyz], 0, [ignore], [ignore])82 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)83 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 180. --position "0,0,1"], 0, [stdout], [stderr])84 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z180.xyz], 0, [ignore], [ignore])85 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)86 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 360. --position "0,0,1"], 0, [stdout], [stderr])87 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-z360.xyz], 0, [ignore], [ignore])88 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz], 0, [ignore], [ignore])89 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/pre/test.xyz .], 0)90 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-origin 20. --position "1,2,1"], 0, [stdout], [stderr])91 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/9/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore])92 AT_CLEANUP93 94 # 9. Rotate around self95 AT_SETUP([Molecules - Rotate around self])96 AT_KEYWORDS([Molecules])97 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)98 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 90. --position "0,0,1"], 0, [stdout], [stderr])99 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z90.xyz], 0, [ignore], [ignore])100 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)101 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 180. --position "0,0,1"], 0, [stdout], [stderr])102 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z180.xyz], 0, [ignore], [ignore])103 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)104 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 360. --position "0,0,1"], 0, [stdout], [stderr])105 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-z360.xyz], 0, [ignore], [ignore])106 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz], 0, [ignore], [ignore])107 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/pre/test.xyz .], 0)108 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-all-molecules --rotate-self 20. --position "1,2,1"], 0, [stdout], [stderr])109 AT_CHECK([diff test.xyz ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/10/post/test-rotated-xYz20.xyz], 0, [ignore], [ignore])110 AT_CLEANUP111
Note:
See TracChangeset
for help on using the changeset viewer.