OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Shear.cpp
Go to the documentation of this file.
4
5#include <boost/regex.hpp>
6
7namespace mslang {
8 void Shear::print(int indentwidth) {
9 std::string indent(indentwidth, ' ');
10 std::string indent2(indentwidth + 8, ' ');
11 std::cout << indent << "shear, " << std::endl;
12 func_m->print(indentwidth + 8);
13 if (std::abs(angleX_m) > 0.0) {
14 std::cout << ",\n"
15 << indent2 << "angle X: " << angleX_m;
16 } else {
17 std::cout << ",\n"
18 << indent2 << "angle Y: " << angleY_m;
19 }
20 }
21
22 void Shear::applyShear(std::vector<std::shared_ptr<Base> > &bfuncs) {
23 AffineTransformation shear(Vector_t(1.0, tan(angleX_m), 0.0),
24 Vector_t(-tan(angleY_m), 1.0, 0.0));
25
26 const unsigned int size = bfuncs.size();
27
28 for (unsigned int j = 0; j < size; ++ j) {
29 std::shared_ptr<Base> &obj = bfuncs[j];
30 obj->trafo_m = obj->trafo_m.mult(shear);
31
32 if (!obj->divisor_m.empty())
33 applyShear(obj->divisor_m);
34 }
35 }
36
37 void Shear::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
38 func_m->apply(bfuncs);
39 applyShear(bfuncs);
40 }
41
43 Shear *shr = static_cast<Shear*>(fun);
44 if (!parse(it, end, shr->func_m)) return false;
45
46 ArgumentExtractor arguments(std::string(++ it, end));
47 try {
48 shr->angleX_m = parseMathExpression(arguments.get(0));
49 shr->angleY_m = parseMathExpression(arguments.get(1));
50 } catch (std::runtime_error &e) {
51 std::cout << e.what() << std::endl;
52 return false;
53 }
54
55 it += (arguments.getLengthConsumed() + 1);
56
57 return true;
58 }
59}
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
Tps< T > tan(const Tps< T > &x)
Tangent.
Definition: TpsMath.h:147
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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
Function * func_m
Definition: Shear.h:8
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition: Shear.cpp:42
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Shear.cpp:37
void applyShear(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Shear.cpp:22
virtual void print(int indentwidth)
Definition: Shear.cpp:8
double angleX_m
Definition: Shear.h:9
double angleY_m
Definition: Shear.h:10
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6