OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
MSLang.h
Go to the documentation of this file.
1#ifndef MSLANG_H
2#define MSLANG_H
3
6#include "Algorithms/Vektor.h"
7
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace mslang {
13 typedef std::string::iterator iterator;
14
15 inline
17 v[2] = 0.0;
18 return euclidean_norm(v);
19 }
20
21 struct Base;
22
23 struct Function {
24 virtual ~Function() {};
25
26 virtual void print(int indent) = 0;
27 virtual void apply(std::vector<std::shared_ptr<Base>> &bfuncs) = 0;
28
29 static bool parse(iterator &it, const iterator &end, Function* &fun);
30
31 static const std::string UDouble;
32 static const std::string Double;
33 static const std::string UInt;
34 static const std::string FCall;
35 };
36
37 struct Base: public Function {
40 std::vector<std::shared_ptr<Base> > divisor_m;
41
43 trafo_m()
44 { }
45
46 Base(const Base &right):
47 trafo_m(right.trafo_m),
48 bb_m(right.bb_m)
49 { }
50
51 virtual ~Base() {
52 // for (auto item: divisor_m) {
53 // item.reset();
54 // }
55 divisor_m.clear();
56 }
57
58 virtual std::shared_ptr<Base> clone() const = 0;
59 virtual void writeGnuplot(std::ofstream &out) const = 0;
60 virtual void computeBoundingBox() = 0;
61 virtual bool isInside(const Vector_t &R) const = 0;
62 virtual void divideBy(std::vector<std::shared_ptr<Base> > &divisors) {
63 for (auto item: divisors) {
64 if (bb_m.doesIntersect(item->bb_m)) {
65 divisor_m.emplace_back(item->clone());
66 }
67 }
68 }
69 };
70
71 bool parse(std::string str, Function* &fun);
72}
73
74#endif
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Definition Vector.h:243
std::string::iterator iterator
Definition MSLang.h:13
bool parse(std::string str, Function *&fun)
Definition MSLang.cpp:35
double euclidean_norm2D(Vector_t v)
Definition MSLang.h:16
static const std::string FCall
Definition MSLang.h:34
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)=0
virtual ~Function()
Definition MSLang.h:24
static const std::string Double
Definition MSLang.h:32
static const std::string UDouble
Definition MSLang.h:31
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition MSLang.cpp:46
virtual void print(int indent)=0
static const std::string UInt
Definition MSLang.h:33
std::vector< std::shared_ptr< Base > > divisor_m
Definition MSLang.h:40
virtual ~Base()
Definition MSLang.h:51
virtual void computeBoundingBox()=0
Base(const Base &right)
Definition MSLang.h:46
AffineTransformation trafo_m
Definition MSLang.h:38
BoundingBox2D bb_m
Definition MSLang.h:39
virtual void divideBy(std::vector< std::shared_ptr< Base > > &divisors)
Definition MSLang.h:62
virtual bool isInside(const Vector_t &R) const =0
virtual std::shared_ptr< Base > clone() const =0
virtual void writeGnuplot(std::ofstream &out) const =0
bool doesIntersect(const BoundingBox2D &bb) const