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