OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Polygon.cpp
Go to the documentation of this file.
4 #include "Utilities/Mesher.h"
5 #include "Physics/Physics.h"
6 
7 #include <boost/regex.hpp>
8 
9 namespace mslang {
10  void Polygon::triangulize(std::vector<Vector_t> &nodes) {
11  Mesher mesher(nodes);
12  triangles_m = mesher.getTriangles();
13  }
14 
15  bool Polygon::parse_detail(iterator &it, const iterator &end, Function* &fun) {
16  Polygon *poly = static_cast<Polygon*>(fun);
17 
18  ArgumentExtractor arguments(std::string(it, end));
19  std::vector<Vector_t> nodes;
20 
21  for (unsigned int i = 0; i + 1 < arguments.getNumArguments(); i += 2) {
22  try {
23  double x = parseMathExpression(arguments.get(i));
24  double y = parseMathExpression(arguments.get(i + 1));
25  nodes.push_back(Vector_t(x, y, 1.0));
26  } catch (std::runtime_error &e) {
27  std::cout << e.what() << std::endl;
28  return false;
29  }
30  }
31 
32  if (nodes.size() < 3) return false;
33 
34  poly->triangulize(nodes);
35 
36  it += (arguments.getLengthConsumed() + 1);
37  return true;
38  }
39 
40  void Polygon::print(int ident) {
41  // for (auto pix: pixels_m) pix.print(ident);
42  }
43 
44  void Polygon::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
45  for (Triangle &tri: triangles_m)
46  bfuncs.push_back(std::shared_ptr<Base>(tri.clone()));
47  }
48 }
unsigned int getNumArguments() const
unsigned int getLengthConsumed() const
constexpr double e
The value of .
Definition: Physics.h:40
Definition: Mesher.h:7
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition: Polygon.cpp:15
void triangulize(std::vector< Vector_t > &nodes)
Definition: Polygon.cpp:10
std::vector< mslang::Triangle > getTriangles() const
Definition: Mesher.cpp:9
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
std::vector< Triangle > triangles_m
Definition: Polygon.h:9
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Polygon.cpp:44
virtual void print(int ident)
Definition: Polygon.cpp:40
std::string get(unsigned int i) const
std::string::iterator iterator
Definition: MSLang.h:16
double parseMathExpression(const std::string &str)
Definition: matheval.cpp:4
Inform & endl(Inform &inf)
Definition: Inform.cpp:42