OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Rotation.cpp
Go to the documentation of this file.
4
5#include <boost/regex.hpp>
6
7namespace mslang {
8 void Rotation::print(int indentwidth) {
9 std::string indent(indentwidth, ' ');
10 std::string indent2(indentwidth + 8, ' ');
11 std::cout << indent << "rotate, " << std::endl;
12 func_m->print(indentwidth + 8);
13 std::cout << ",\n"
14 << indent2 << "angle: " << angle_m;
15 }
16
17 void Rotation::applyRotation(std::vector<std::shared_ptr<Base> > &bfuncs) {
18
20 Vector_t<double, 3>(-sin(angle_m), cos(angle_m), 0.0));
21
22 const unsigned int size = bfuncs.size();
23
24 for (unsigned int j = 0; j < size; ++ j) {
25 std::shared_ptr<Base> &obj = bfuncs[j];
26 obj->trafo_m = obj->trafo_m.mult(rotation);
27
28 if (!obj->divisor_m.empty())
29 applyRotation(obj->divisor_m);
30 }
31 }
32
33 void Rotation::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
34 func_m->apply(bfuncs);
35 applyRotation(bfuncs);
36 }
37
39 Rotation *rot = static_cast<Rotation*>(fun);
40 if (!parse(it, end, rot->func_m)) return false;
41
42 ArgumentExtractor arguments(std::string(++ it, end));
43 try {
44 rot->angle_m = parseMathExpression(arguments.get(0));
45 } catch (std::runtime_error &e) {
46 std::cout << e.what() << std::endl;
47 return false;
48 }
49
50 it += (arguments.getLengthConsumed() + 1);
51
52 return true;
53 }
54}
ippl::Vector< T, Dim > Vector_t
PartBunch< T, Dim >::ConstIterator end(PartBunch< T, Dim > const &bunch)
double parseMathExpression(const std::string &str)
Definition matheval.cpp:4
std::string::iterator iterator
Definition MSLang.h:15
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition MSLang.cpp:47
std::string get(unsigned int i) const
unsigned int getLengthConsumed() const
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition Rotation.cpp:38
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition Rotation.cpp:33
void applyRotation(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition Rotation.cpp:17
virtual void print(int indentwidth)
Definition Rotation.cpp:8
double angle_m
Definition Rotation.h:9
Function * func_m
Definition Rotation.h:8